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

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

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


Revision 1.1 - (hide annotations) (download)
Wed Feb 10 14:52:05 2010 UTC (15 years, 5 months ago) by gforget
Branch: MAIN
matlab_class: example of data processing (to make llc model input using
		matlab_class/@gcmfaces)

1 gforget 1.1
2     %%%%%%%%%%%%%%%%%
3     %load parameters:
4     %%%%%%%%%%%%%%%%%
5     choiceV3orV4='v4'
6    
7     if strcmp(choiceV3orV4,'v3')&isempty(whos('mygrid'));
8     gcmfaces_path;
9     global mygrid; mygrid=[]; clear all;
10     dirGrid='/net/altix3700/raid4/gforget/mysetups/ecco_v3/RUNS/fwd3y_fg_as_v4_ncep/';
11     nF=1; grid_load(dirGrid,nF); global mygrid;
12     dirIn='/net/altix3700/raid4/gforget/mysetups/ecco_v3/RUNS/fwd3y_fg_as_v4_ncep/DIAGfiles/';
13     elseif strcmp(choiceV3orV4,'v4')&isempty(whos('mygrid'));
14     gcmfaces_path;
15     global mygrid; mygrid=[]; clear all;
16     dirGrid='/net/altix3700/raid5/gforget/mysetups/ecco_v4/RUNS/GRIDev4/';
17     nF=5; grid_load(dirGrid,nF); global mygrid;
18     dirIn='/net/altix3700/raid4/gforget/mysetups/ecco_v4/RUNS/runs3yVISC/fwd3y_ncep_evolution4/DIAGfiles/';
19     end;
20    
21    
22    
23     %%%%%%%%%%%%%%%%%%%%%%%
24     %generate delaunay triangulation
25    
26     XC=convert2array(mygrid.XC);
27     YC=convert2array(mygrid.YC);
28    
29     %needed so that we do not loose data
30     XC(isnan(XC))=270;
31     YC(isnan(YC))=180;
32    
33     TRI=delaunay(XC,YC);
34     nxy = prod(size(XC));
35     Stri=sparse(TRI(:,[1 1 2 2 3 3]),TRI(:,[2 3 1 3 1 2]),1,nxy,nxy);
36    
37     %%%%%%%%%%%%%%%%%%%%%%%
38     %generate random data
39    
40     nobs=1e6;
41     lat=(rand(nobs,1)-0.5)*2*90;
42     lon=(rand(nobs,1)-0.5)*2*180; xx=find(lon>180);lon(xx)=lon(xx)-360;
43     obs=(rand(nobs,1)-0.5)*2;
44    
45     %%%%%%%%%%%%%%%%%%%%%%%%
46     %bin average random data
47    
48     OBS=0*XC; NOBS=OBS;
49     ik=dsearch(XC,YC,TRI,lon,lat,Stri);
50     for k=1:length(ik)
51     NOBS(ik(k))=NOBS(ik(k))+1;
52     OBS(ik(k))=OBS(ik(k))+obs(k);
53     end % k=1:length(ik)
54    
55     in=find(NOBS); OBS(in)=OBS(in)./NOBS(in);
56     in=find(~NOBS); OBS(in)=NaN; NOBS(in)=NaN;
57    
58     obsmap=convert2array(OBS,mygrid.XC); %put in gcmfaces format
59     obsmapcompact=convert2gcmfaces(obsmap); %put in gcm input format
60    
61     whos obs* OBS
62    
63     figure; set(gcf,'Units','Normalized','Position',[0.1 0.3 0.4 0.6]);
64     imagescnan(OBS','nancolor',[1 1 1]*0.8); axis xy; caxis([-1 1]/2); colorbar;
65     figure; set(gcf,'Units','Normalized','Position',[0.5 0.3 0.4 0.6]);
66     imagescnan(NOBS','nancolor',[1 1 1]*0.8); axis xy; caxis([0 25]); colorbar;
67    
68     %..... now illustrate the smoothing filter
69     test=input('illustrate smoothing filter? \n type 1 for yes or 0 for no\n');
70     if test; example_smooth; end;
71    
72    

  ViewVC Help
Powered by ViewVC 1.1.22