/[MITgcm]/MITgcm_contrib/gael/profilesMatlabProcessing/netcdf_ecco_mask.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/profilesMatlabProcessing/netcdf_ecco_mask.m

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


Revision 1.1 - (hide annotations) (download)
Mon Aug 13 23:15:20 2007 UTC (17 years, 11 months ago) by gforget
Branch: MAIN
script to limit the set of profiles for the model to use

1 gforget 1.1 function []=netcdf_ecco_mask(rep_data,file_data,x00,y00);
2     %
3     %object: reads a pkg/profiles netcdf file and masks all profiles that are out of a given region
4     %
5     %input:
6     % rep_data, file_data
7     % x00 and y00 (vectors) broken line that defines the region of interest.
8     %For example: x00=[300 340 340 300 300]; y00=[60 60 70 70 60];
9     %
10     %result: [rep_data 'masked_' file_data]
11    
12    
13     %rep_data='./'; file_data='fileCur.nc';
14     %x00=[300 340 340 300 300]; y00=[60 60 70 70 60];
15    
16    
17     %flag valid profiles:
18     %--------------------
19    
20     eval(['ncload ' rep_data file_data ' prof_lon prof_lat;']);
21     prof_lonALL=prof_lon; prof_latALL= prof_lat;
22    
23     flag_profiles=zeros(size(prof_lonALL));
24     length_div=1e3;
25     num_div=ceil(length(prof_lonALL)/length_div);
26     for cur_div=1:num_div
27     list_profiles0=[(cur_div-1)*length_div+1:min(cur_div*length_div,length(prof_lonALL))];
28     [tmp1]=netcdf_ecco_GenericgridLocateCell(x00,y00,prof_lonALL(list_profiles0),prof_latALL(list_profiles0));
29     flag_profiles(list_profiles0(find(tmp1>0)))=1;
30     end
31    
32     flagged_profiles=find(flag_profiles==0);
33    
34    
35     %create final netcdf file:
36     %-------------------------
37    
38     [depth,myvars,prof_descr,mystruct,mystruct1D]=netcdf_ecco_read(rep_data,file_data);
39    
40     for vcur=1:size(myvars);
41     eval(['mystruct.prof_' deblank(myvars(vcur,:)) 'weight(flagged_profiles,:)=0;']);
42     end
43    
44     file_characteristics=[length(mystruct1D.prof_lon) 0 size(prof_descr,2) -9999];
45    
46     eval(['ncload ' rep_data file_data ' prof_interp_XC11 prof_interp_YC11 prof_interp_i prof_interp_j prof_interp_lon prof_interp_lat prof_interp_weights;']);
47     if ~isempty(prof_interp_XC11)
48     prof_interp_XC11(flagged_profiles)=-9999; prof_interp_XCNINJ(flagged_profiles)=-9999;
49     prof_interp_YC11(flagged_profiles)=-9999; prof_interp_YCNINJ(flagged_profiles)=-9999;
50     prof_interp_i(flagged_profiles,:)=-9999; prof_interp_j(flagged_profiles,:)=-9999;
51     prof_interp_lon(flagged_profiles,:)=-9999; prof_interp_lat(flagged_profiles,:)=-9999;
52     prof_interp_weights(flagged_profiles,:)=-9999;
53    
54     mystruct1D=struct('prof_YYYYMMDD',mystruct1D.prof_YYYYMMDD,'prof_HHMMSS',mystruct1D.prof_HHMMSS,...
55     'prof_lon',mystruct1D.prof_lon,'prof_lat',mystruct1D.prof_lat,...
56     'prof_interp_XC11',prof_interp_XC11,'prof_interp_YC11',prof_interp_YC11,...
57     'prof_interp_XCNINJ',prof_interp_XCNINJ,'prof_interp_YCNINJ',prof_interp_YCNINJ...
58     );
59    
60     mystruct4mygrid=struct('prof_interp_i',prof_interp_i,...
61     'prof_interp_j',prof_interp_j,...
62     'prof_interp_lon',prof_interp_lon,...
63     'prof_interp_lat',prof_interp_lat,...
64     'prof_interp_weights',prof_interp_weights);
65    
66     netcdf_ecco_create([rep_data 'masked_' file_data], file_characteristics, depth, ...
67     prof_descr, mystruct, mystruct1D,mystruct4mygrid);
68    
69     else
70    
71     netcdf_ecco_create([rep_data 'masked_' file_data], file_characteristics, depth, ...
72     prof_descr, mystruct, mystruct1D);
73    
74     end
75    
76     fprintf([rep_data 'masked_' file_data ' written \n']);
77    
78    
79    
80    

  ViewVC Help
Powered by ViewVC 1.1.22