/[MITgcm]/MITgcm_contrib/mlosch/interp_llc/extract_levitus_clim.m
ViewVC logotype

Annotation of /MITgcm_contrib/mlosch/interp_llc/extract_levitus_clim.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Thu May 3 21:07:20 2007 UTC (18 years, 2 months ago) by mlosch
Branch: MAIN
CVS Tags: HEAD
initial checkin of topography and hydrography interpolation scripts for
the llc-grid, based on old matlab scripts by Alistair Adcroft
Let's hope, they are useful.

1 mlosch 1.1 function [T,x,y,z]=extract_levitus_clim(suff,lon_lo,lon_hi,lat_lo,lat_hi)
2     %
3     % Extract Levitus data from netcdf files
4     %
5     % e.g.
6     % [T,x,y,z]=extract_levitus_clim('temp',-180,180,-90,90);
7     % [S,x,y,z]=extract_levitus_clim('salt',0,360,-90,90);
8    
9     % change a name convention:
10     if strcmp(suff,'temp'); suff = 'theta'; end
11    
12     ncquiet;
13     load DATAPATH
14    
15     fname = fullfile(datapath,['levitus_ann_' suff '.cdf']);
16     theResult=ncload(fname);
17     if isempty(theResult);
18     error([fname ' not found'])
19     end
20    
21     if size(X,1) > 1; X = X'; end
22     if size(Y,1) > 1; Y = Y'; end
23     if size(Z,1) > 1; Z = Z'; end
24    
25     i0=round( lon_lo )+1;
26     i1=round( lon_hi );
27     j0=round( (lat_lo+90) )+1;
28     j1=round( (lat_hi+90) );
29    
30     if i1>i0
31     ii=i0:i1;
32     else
33     ii=[i0:360 1:i1];
34     end
35     ii=mod(ii+360-1,360)+1;
36     jj=j0:j1;
37    
38     nx=prod(size(ii));
39     ny=prod(size(jj));
40    
41     if strcmp(suff,'theta');
42     T=permute(theta(:,jj,ii),[3 2 1]);
43     elseif strcmp(suff,'salt');
44     T=permute(sal(:,jj,ii),[3 2 1]);
45     else
46     error(['unknown variable ' suff])
47     end
48    
49     kk = find(isnan(T));
50     T(kk) = 0;
51    
52     x=X(ii);
53     ih = find(x>lon_hi); x(ih)=x(ih)-360;
54     il = find(x<lon_lo); x(il)=x(il)+360;
55     y=Y(jj);
56     z=-Z;
57    
58     return

  ViewVC Help
Powered by ViewVC 1.1.22