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

Contents of /MITgcm_contrib/mlosch/interp_llc/extract_levitus_monthly.m

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


Revision 1.1 - (show annotations) (download)
Thu May 3 21:07:20 2007 UTC (17 years 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 function [ts,x,y,z]=extract_levitus_monthly(suff,months,lon_lo,lon_hi,lat_lo,lat_hi)
2 %
3 % Extract monthly Levitus data from netcdf files
4 %
5 % e.g.
6 % [T,x,y,z]=extract_levitus_monthly('temp',1,-180,180,-90,90);
7 % [S,x,y,z]=extract_levitus_monthly('salt',1:12,0,360,-90,90);
8
9 % change a name convention:
10 if strcmp(suff,'temp'); suff = 'theta'; end
11
12
13 ncquiet;
14 load DATAPATH datapath
15 fname = fullfile(datapath,['levitus_month_' 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 if size(T,1) > 1; T = T'; end
25
26 i0=round( lon_lo )+1;
27 i1=round( lon_hi );
28 j0=round( (lat_lo+90) )+1;
29 j1=round( (lat_hi+90) );
30
31 if i1>i0
32 ii=i0:i1;
33 else
34 ii=[i0:360 1:i1];
35 end
36 ii=mod(ii+360-1,360)+1;
37 jj=j0:j1;
38
39 nx=prod(size(ii));
40 ny=prod(size(jj));
41
42 if strcmp(suff,'theta');
43 ts=permute(theta(months,:,jj,ii),[4 3 2 1]);
44 elseif strcmp(suff,'salt');
45 ts=permute(sal(months,:,jj,ii),[4 3 2 1]);
46 else
47 error(['unknown variable ' suff])
48 end
49
50 kk = find(isnan(ts));
51 ts(kk) = 0;
52
53 x=X(ii);
54 ih = find(x>lon_hi); x(ih)=x(ih)-360;
55 il = find(x<lon_lo); x(il)=x(il)+360;
56 y=Y(jj);
57 z=-Z;
58
59 return

  ViewVC Help
Powered by ViewVC 1.1.22