/[MITgcm]/MITgcm_contrib/gael/matlab_class/sample_processing/example_griddata.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/matlab_class/sample_processing/example_griddata.m

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


Revision 1.4 - (hide annotations) (download)
Thu Apr 15 15:18:51 2010 UTC (16 years, 6 months ago) by gforget
Branch: MAIN
Changes since 1.3: +5 -5 lines
adding / in pathes

1 gforget 1.1
2     %%%%%%%%%%%%%%%%%
3     %load parameters:
4     %%%%%%%%%%%%%%%%%
5     choiceV3orV4='v4'
6    
7 gforget 1.2 if ~isempty(choiceV3orV4)&isempty(whos('mygrid'));
8 gforget 1.1 gcmfaces_path;
9 gforget 1.4 dir0=[mydir '/matlab_class_material/'];
10     dirGrid=[dir0 '/GRID' choiceV3orV4 '/'];
11     dirIn=[dir0 '/SAMPLE' choiceV3orV4 '/'];
12 gforget 1.2 if strcmp(choiceV3orV4,'v4'); nF=5; else; nF=1; end;
13     global mygrid; mygrid=[]; grid_load(dirGrid,nF);
14 gforget 1.1 end;
15    
16     %%%%%%%%%%%%%%%%%%%%%%%
17 gforget 1.2 %get sample data: V3 SSH
18 gforget 1.4 dirV3=[mydir '/matlab_class_material/SAMPLEv3/'];
19 gforget 1.2 etan=rdmds([dirV3 'DDetan'],0); etan(etan==0)=NaN;
20 gforget 1.4 dirV3=[mydir '/matlab_class_material/GRIDv3/'];
21 gforget 1.2 lon=rdmds([dirV3 'XC']); lat=rdmds([dirV3 'YC']);
22 gforget 1.1
23     %%%%%%%%%%%%%%%%%%%%%%%
24     %do the interpolation:
25     x=[lon-360;lon]; y=[lat;lat]; z=[etan;etan];
26     jj=find(~isnan(z)); x=x(jj); y=y(jj); z=z(jj);
27    
28     z_interp=gcmfaces(5);
29     for ii=1:5;
30     xi=mygrid.XC{ii}; yi=mygrid.YC{ii};
31     zi = griddata(x',y',z',xi,yi);
32     z_interp{ii}=zi;
33     end;
34    
35     fprintf('note that griddata puts values in remote places ... \n');
36     fprintf('so one should obviously be cautious when using this routine\n');
37     %msk=mygrid.hFacC(:,:,1); z_interp(find(msk==0))=NaN;
38    
39     %%%%%%%%%%%%%%%%%%%%%%%
40     %illustrate the result:
41    
42     figure; set(gcf,'Units','Normalized','Position',[0.1 0.1 0.4 0.6]);
43     x=[lon-360;lon]; y=[lat;lat]; z=[etan;etan];
44     pcolor(x,y,z); axis([-180 180 -90 90]); shading flat; caxis([-2 1]); colorbar;
45    
46     figure; set(gcf,'Units','Normalized','Position',[0.5 0.1 0.4 0.6]);
47     [X,Y,FLD]=convert2pcol(mygrid.XC,mygrid.YC,z_interp);
48     pcolor(X,Y,FLD); axis([-180 180 -90 90]); shading flat; caxis([-2 1]); colorbar;
49    
50     pause;
51    

  ViewVC Help
Powered by ViewVC 1.1.22