Skip to content

Commit 444d1ae

Browse files
CHG: now use NSIDC dataset for Helheim
1 parent 309a249 commit 444d1ae

File tree

3 files changed

+41
-67
lines changed

3 files changed

+41
-67
lines changed

examples/Helheim/runme.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
[velx vely]=interpJoughinCompositeGreenland(md.mesh.x,md.mesh.y);
2323
vel = sqrt(velx.^2+vely.^2);
24+
vel(isnan(vel)) = 0;
2425

2526
% Refine mesh based on surface velocities
2627
md=bamg(md,'hmin',100,'hmax',1500,'field',vel,'err',5);
@@ -83,4 +84,4 @@
8384
md.initialization.vy=md.results.StressbalanceSolution.Vy;
8485

8586
savemodel(org,md);
86-
end%}}}
87+
end%}}}
Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,44 @@
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;
1022
end
1123

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
3236

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);
3540

36-
if nargout==1,
41+
%return vel if nargount ==1
42+
if nargout==1
3743
vxout = sqrt(vxout.^2+vyout.^2);
3844
end
Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,3 @@
11
function [vxout vyout] = interpJoughinMosaic(X,Y),
22

3-
switch oshostname(),
4-
case {'ronne'}
5-
filename = '/home/ModelData/Greenland/VelJoughin/IanGreenVel.mat';
6-
case {'totten'}
7-
filename = '/totten_1/ModelData/Greenland/VelJoughin/IanGreenVel.mat';
8-
otherwise
9-
error('machine not supported yet');
10-
end
11-
verbose = 1;
12-
13-
%Figure out what subset of the matrix should be read
14-
load(filename,'x_m','y_m');
15-
velfile = matfile(filename);
16-
17-
offset=2;
18-
19-
xmin=min(X(:)); xmax=max(X(:));
20-
posx=find(x_m<=xmax);
21-
id1x=max(1,find(x_m>=xmin,1)-offset);
22-
id2x=min(numel(x_m),posx(end)+offset);
23-
24-
ymin=min(Y(:)); ymax=max(Y(:));
25-
posy=find(y_m>=ymin);
26-
id1y=max(1,find(y_m<=ymax,1)-offset);
27-
id2y=min(numel(y_m),posy(end)+offset);
28-
29-
vx = velfile.vx(id1y:id2y,id1x:id2x);
30-
vy = velfile.vy(id1y:id2y,id1x:id2x);
31-
x_m = x_m(id1x:id2x);
32-
y_m = y_m(id1y:id2y);
33-
34-
%load(filename);
35-
vxout = InterpFromGrid(x_m,y_m,vx,X,Y);
36-
vyout = InterpFromGrid(x_m,y_m,vy,X,Y);
3+
error('Function deprecated, use interpJoughinCompositeGreenland');

0 commit comments

Comments
 (0)