source: issm/trunk-jpl/src/m/contrib/morlighem/ronne/interpRTopo2.m@ 23873

Last change on this file since 23873 was 23873, checked in by Mathieu Morlighem, 6 years ago

NEW: added interpolation routines'

File size: 1.6 KB
Line 
1function [output] = interpRTopo2(X,Y,varargin),
2%INTERPRTOPO2 - interp from RTOPO-2 onto X and Y
3%
4% Usage:
5% bed = interpRTopo2(X,Y,varargin),
6%
7% varargin = 1 (Greenland), default
8% -1 (Antarctica)
9
10switch oshostname(),
11 case {'ronne'}
12 rootname='/home/ModelData/Global/RTopo-2/RTopo-2.0.1_30sec_bedrock_topography.nc';
13 otherwise
14 error('machine not supported yet');
15end
16verbose = 1;
17
18if nargin==3,
19 hemisphere = varargin{1};
20else
21 hemisphere = +1;
22end
23if abs(hemisphere)~=1,
24 error('hemisphere should be +/-1');
25end
26
27if hemisphere==+1,
28 if verbose, disp(' -- RTopo-2: convert to lat/lon using Greenland projection'); end
29 [LAT, LON ] = xy2ll(double(X(:)),double(Y(:)),+1,45,70);
30else
31 if verbose, disp(' -- RTopo-2: convert to lat/lon using Antarctica projection'); end
32 [LAT, LON ] = xy2ll(double(X(:)),double(Y(:)),-1,0,71);
33end
34
35Y=reshape(LAT,size(X)); X=reshape(LON,size(X));
36
37xdata = double(ncread(rootname,'lon'));
38ydata = double(ncread(rootname,'lat'));
39
40offset=2;
41
42xmin=min(X(:)); xmax=max(X(:));
43posx=find(xdata<=xmax);
44id1x=max(1,find(xdata>=xmin,1)-offset);
45id2x=min(numel(xdata),posx(end)+offset);
46
47ymin=min(Y(:)); ymax=max(Y(:));
48posy=find(ydata<=ymax);
49id1y=max(1,find(ydata>=ymin,1)-offset);
50id2y=min(numel(ydata),posy(end)+offset);
51
52if verbose, disp(' -- RTopo-2: reading bed topography'); end
53data = double(ncread(rootname,'bedrock_topography',[id1x id1y],[id2x-id1x+1 id2y-id1y+1],[1 1]))';
54xdata=xdata(id1x:id2x);
55ydata=ydata(id1y:id2y);
56data(find(data==-9999))=NaN;
57
58if verbose, disp(' -- RTopo-2: interpolating'); end
59output = InterpFromGrid(xdata,ydata,data,double(X),double(Y));
Note: See TracBrowser for help on using the repository browser.