|
1 | | -function [vxout vyout] = interpJoughinCompositeGreenland(X,Y,ncpath), |
2 | | - |
3 | | -% - optional input argument: path to dataset IanGreenVel.mat |
4 | | - |
5 | | -if nargin<3 |
6 | | - %data=load(['/u/astrid-r1b/morlighe/issmjpl/proj-morlighem/DatasetGreenland/Data/VelJoughin/IanGreenVel.mat']); |
7 | | - filename = '/totten_1/ModelData/Greenland/VelJoughin/IanGreenVel.mat'; |
8 | | -else |
9 | | - filename = [ncpath '/IanGreenVel.mat']; |
| 1 | +function [vxout vyout] = interpJoughinCompositeGreenland(X,Y,path) |
| 2 | +% INTERPJOUGHINCOMPOSITEGREENLAND - interpolate Joughin's mosaic nsidc-0670 |
| 3 | +% |
| 4 | +% Usage: |
| 5 | +% [vx vy] = interpJoughinCompositeGreenland(X,Y) |
| 6 | +% [vx vy] = interpJoughinCompositeGreenland(X,Y,path) |
| 7 | +% vel = interpJoughinCompositeGreenland(X,Y) |
| 8 | +% |
| 9 | +% Example: |
| 10 | +% [vx vy] = interpJoughinCompositeGreenland(md.mesh.x, md.mesh.y) |
| 11 | +% [vx vy] = interpJoughinCompositeGreenland(md.mesh.x, md.mesh.y, '../Data') |
| 12 | + |
| 13 | +%possible paths of dataset |
| 14 | +paths = {... |
| 15 | + ['/totten_1/ModelData/Greenland/VelMEaSUREs/Greenland_1995_2015_decadal_average_mosaic_v1/',],... |
| 16 | + ['/home/ModelData/Antarctica/VelMEaSUREs/Greenland_1995_2015_decadal_average_mosaic_v1/',],... |
| 17 | + [issmdir() 'examples/Data/'],... |
| 18 | + ['./',],... |
| 19 | + }; |
| 20 | +if nargin>2 |
| 21 | + paths{end+1} = path; |
10 | 22 | end |
11 | 23 |
|
12 | | -%Figure out what subset of the matrix should be read |
13 | | -load(filename,'x_m','y_m'); |
14 | | -velfile = matfile(filename); |
15 | | - |
16 | | -offset=2; |
17 | | - |
18 | | -xmin=min(X(:)); xmax=max(X(:)); |
19 | | -posx=find(x_m<=xmax); |
20 | | -id1x=max(1,find(x_m>=xmin,1)-offset); |
21 | | -id2x=min(numel(x_m),posx(end)+offset); |
22 | | - |
23 | | -ymin=min(Y(:)); ymax=max(Y(:)); |
24 | | -posy=find(y_m>=ymin); |
25 | | -id1y=max(1,find(y_m<=ymax,1)-offset); |
26 | | -id2y=min(numel(y_m),posy(end)+offset); |
27 | | - |
28 | | -vx = velfile.vx(id1y:id2y,id1x:id2x); |
29 | | -vy = velfile.vy(id1y:id2y,id1x:id2x); |
30 | | -x = x_m(id1x:id2x); |
31 | | -y = y_m(id1y:id2y); |
| 24 | +%Check if we can find it |
| 25 | +found = 0; |
| 26 | +for i=1:numel(paths) |
| 27 | + if exist([paths{i} '/greenland_vel_mosaic250_vx_v1.tif'],'file') |
| 28 | + datadir = paths{i}; |
| 29 | + found = 1; |
| 30 | + break; |
| 31 | + end |
| 32 | +end |
| 33 | +if ~found |
| 34 | + error(['Could not find greenland_vel_mosaic250_vx_v1.tif, you can add the path to the list or provide its path as a 3rd argument']); |
| 35 | +end |
32 | 36 |
|
33 | | -vxout = InterpFromGrid(x,y,double(vx),X,Y); |
34 | | -vyout = InterpFromGrid(x,y,double(vy),X,Y); |
| 37 | +%Now go ahead and interpolate |
| 38 | +vxout = interpFromGeotiff([datadir '/greenland_vel_mosaic250_vx_v1.tif'], X, Y,-2e9); |
| 39 | +vyout = interpFromGeotiff([datadir '/greenland_vel_mosaic250_vy_v1.tif'], X, Y,-2e9); |
35 | 40 |
|
36 | | -if nargout==1, |
| 41 | +%return vel if nargount ==1 |
| 42 | +if nargout==1 |
37 | 43 | vxout = sqrt(vxout.^2+vyout.^2); |
38 | 44 | end |
0 commit comments