/[MITgcm]/MITgcm_contrib/gael/profilesMatlabProcessing/profiles_IO_v2/MITprof_gcm2nc.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/profilesMatlabProcessing/profiles_IO_v2/MITprof_gcm2nc.m

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


Revision 1.1 - (hide annotations) (download)
Wed Jan 5 21:38:54 2011 UTC (14 years, 6 months ago) by gforget
Branch: MAIN
- add MITprof_gcm2nc.m that replaces netcdf_ecco_recompose.m
  recomposing MITprof netcdf files from binary model outputs.
- remove old netcdf_ecco_* routines.

1 gforget 1.1 function []=MITprof_gcm2nc(dir_model,list_model);
2     %[]=MITprof_gcm2nc(dir_model,list_model);
3     %function:
4     % takes binary output of MITgcm/pkg/profiles
5     % and recomposes a MITprof netcdf file.
6     %example:
7     % dir_model='./';
8     % list_model={'seals*','XBT*','argo_at*','argo_pa*','argo_in*'};
9     % MITprof_gcm2nc(dir_model,list_model);
10     %note:
11     % by assumption, dir_model contains the binaries,
12     % dir_model/input contains the matching MITprof file
13     % that was provided as input to MITgcm/pkg/profiles, and
14     % the recomposed MITprof file will be put in dir_model/output
15    
16     warning off MATLAB:mir_warning_variable_used_as_function;
17    
18     dir_out=[dir_model 'output/']; dir_data=[dir_model 'input/'];
19    
20     %loop over files:
21     for ff=1:length(list_model)
22    
23     %initialize the process:
24     clear prof_*;
25     file_data=dir([dir_data list_model{ff} '*.nc']);
26     file_data2=file_data.name;
27    
28     %load the data:
29     MITprof=MITprof_read([dir_data file_data2]);
30    
31     %prepare relevant output:
32     varList={'T','S','U','V','ptr','ssh'}; varNum=zeros(6,1); varCount=0;
33     for v=1:6; vv=varList{v};
34     if isfield(MITprof,['prof_' vv]);
35     varCount=varCount+1; varNum(v)=varCount;
36     eval(['prof_' vv '=-9999*ones(size(MITprof.prof_' vv ')); prof_' vv 'mask=prof_' vv ';']);
37     end;
38     end;
39     varList={varList{find(varNum)}};
40     nr=length(MITprof.prof_depth);
41    
42     %list tile/processor model files:
43     eval(['model_list_model=dir(''' dir_model list_model{ff} '*.data'');']);
44    
45     %if no model files then stop
46     if size(model_list_model,1)==0; fprintf(['file: ' file_data2 ' \n, no model files found\n']);
47     else;
48    
49     %loop over model files:
50     for ffM=1:length(model_list_model)
51     file_model2=model_list_model(ffM).name;
52     np=model_list_model(ffM).bytes/8/2/(nr+1)/varCount;
53     tmp_prof=read2memory([dir_model file_model2],[nr+1 2 varCount np],64);
54    
55     for v=1:varCount; vv=varList{v};
56     tmp1=squeeze(tmp_prof(1:nr,1,v,:))'; tmp2=squeeze(tmp_prof(1:nr,2,v,:))'; tmp3=squeeze(tmp_prof(nr+1,1,v,:));
57     tmp4=find(tmp3>0); tmp1=tmp1(tmp4,:); tmp2=tmp2(tmp4,:); tmp3=tmp3(tmp4,:);
58     eval(['prof_' vv '(tmp3,:)=tmp1; prof_' vv 'mask(tmp3,:)=tmp2;']);
59     end;
60     end; %for ffM
61    
62     %include in structure:
63     for v=1:varCount; vv=varList{v}; eval(['prof_' vv '(prof_' vv 'mask==0)=-9999; MITprof.prof_' vv 'estim=prof_' vv ';']); end;
64    
65     %prepare fields list:
66     list_out=fieldnames(MITprof)';
67     ii=find(strncmp(list_out,'prof_U',6)+strncmp(list_out,'prof_S',6)+strncmp(list_out,'prof_T',6)+...
68     strncmp(list_out,'prof_V',6)+strncmp(list_out,'prof_ssh',8)+strncmp(list_out,'prof_ptr',8));
69     list_out={list_out{ii}};
70     %prepare other fields:
71     file_out=[file_data2(1:end-3) '_model.nc'];
72     nr=length(MITprof.prof_depth);
73     np=length(MITprof.prof_lon);
74     %write to file:
75     MITprof_create([dir_out file_out],np,nr,list_out);
76     MITprof_write([dir_out file_out],MITprof);
77    
78     fprintf(['file: ' file_data2 ' \n has been processed \n']);
79     end %if size(model_list_model,1)~=0;
80     end%for ff=1:length(list_model)
81    
82    

  ViewVC Help
Powered by ViewVC 1.1.22