|
1 | 1 | function []=MITprof_gcm2nc(varargin);
|
2 |
| -%[]=MITprof_gcm2nc; |
3 |
| -%[]=MITprof_gcm2nc; |
4 |
| -%object: takes binary output from MITgcm/pkg/profiles (in dir_model) |
5 |
| -% and recomposes a MITprof netcdf file (in dir_model/input) |
6 |
| -%optional inputs: |
7 |
| -% dir_model is the directory where the binary files are ('./' by default) |
8 |
| -% list_model is the list of the corresponding MITprof files, which |
9 |
| -% need to be copied or linked to dir_model/input |
10 |
| -% ({'seals*','WOD09_XBT*','WOD09_CTD*','argo_at*','argo_pa*','argo_in*'} by default) |
| 2 | +%MITPROF_GCM2NC(dir_model,list_model); |
11 | 3 | %
|
12 |
| -%e.g. dir_model='./'; |
13 |
| -% list_model={'seals*','WOD09_XBT*','WOD09_CTD*','argo_at*','argo_pa*','argo_in*'}; |
| 4 | +%object: reformat MITprof binary files from MITgcm into MITprof netcdf files |
| 5 | +% |
| 6 | +%inputs: |
| 7 | +% dir_model is the directory where the binary files are ('./' by default). If dir_model is a cell containing |
| 8 | +% two directory names then the first will be used for inputs whereas the second will be used for output. |
| 9 | +% By assumption the input directory contains the nc files listed in list_model and a subdirectory called |
| 10 | +% 'profiles/' that contains the corresponding binary files generated by MITgcm |
| 11 | +% list_model is the list of the corresponding MITprof files; by default: |
| 12 | +% {'argo_feb2016_set1.nc','argo_feb2016_set2.nc','argo_feb2016_set3.nc','argo_feb2016_set4.nc','argo_feb2016_set5.nc',... |
| 13 | +% 'argo_feb2016_set6.nc','climode_jan2016.nc','ctd_jan2016.nc','itp_jan2016.nc','seals_jan2016.nc','xbt_jan2016.nc'} |
| 14 | +% |
| 15 | +%example: |
| 16 | +% MITprof_gcm2nc; |
| 17 | +%or: |
| 18 | +% dir_model='./'; |
| 19 | +% list_model={'argo_feb2016_set1.nc','argo_feb2016_set2.nc','argo_feb2016_set3.nc','argo_feb2016_set4.nc','argo_feb2016_set5.nc',... |
| 20 | +% 'argo_feb2016_set6.nc','climode_jan2016.nc','ctd_jan2016.nc','itp_jan2016.nc','seals_jan2016.nc','xbt_jan2016.nc'}; |
14 | 21 | % MITprof_gcm2nc(dir_model,list_model);
|
15 |
| -%note: |
16 |
| -% by assumption, dir_model contains the binaries, |
17 |
| -% dir_model/input contains the matching MITprof file |
18 |
| -% that was provided as input to MITgcm/pkg/profiles, and |
19 |
| -% the recomposed MITprof file will be put in dir_model/output |
20 | 22 |
|
21 | 23 | warning off MATLAB:mir_warning_variable_used_as_function;
|
22 | 24 |
|
23 | 25 | if nargin==2; dir_model=varargin{1}; list_model=varargin{2};
|
24 | 26 | else;
|
25 | 27 | dir_model='./';
|
26 |
| - list_model={'seals*','WOD09_XBT*','WOD09_CTD*','argo_at*','argo_pa*','argo_in*'}; |
| 28 | + list_model={'argo_feb2016_set1.nc','argo_feb2016_set2.nc','argo_feb2016_set3.nc','argo_feb2016_set4.nc','argo_feb2016_set5.nc',... |
| 29 | + 'argo_feb2016_set6.nc','climode_jan2016.nc','ctd_jan2016.nc','itp_jan2016.nc','seals_jan2016.nc','xbt_jan2016.nc'}; |
27 | 30 | end;
|
28 | 31 |
|
29 | 32 | if iscell(dir_model);
|
|
35 | 38 | dir_model=[dir_model{1} 'profiles/'];
|
36 | 39 | else;
|
37 | 40 | %the following assumes that
|
38 |
| - %dir_model is where MITgcm input and output files have been linked to dir_model (*.bin) |
39 |
| - %and dir_model/input/ (*.nc) -- the new *.nc files will then be created in dir_model/output/ |
40 |
| - dir_out=[dir_model 'output/']; |
41 |
| - dir_data=[dir_model 'input/']; |
| 41 | + %dir_model is where MITgcm directory where *.nc MITgcm input files and profiles/*bin MITgcm output files are |
| 42 | + %and where the new *model.nc files will then be created |
| 43 | + dir_out=dir_model; |
| 44 | + dir_data=dir_model; |
| 45 | + dir_model=[dir_model 'profiles/']; |
42 | 46 | end;
|
43 | 47 |
|
44 | 48 | %loop over files:
|
45 | 49 | for ff=1:length(list_model)
|
| 50 | + |
| 51 | + fil_root=list_model{ff}; |
| 52 | + if strcmp(fil_root(end-2:end),'.nc'); fil_root=fil_root(1:end-3); end; |
| 53 | + if strcmp(fil_root(end),'*'); fil_root=fil_root(1:end-1); end; |
46 | 54 |
|
47 | 55 | %initialize the process:
|
48 | 56 | clear prof_*;
|
49 |
| - file_data=dir([dir_data list_model{ff} '*.nc']); |
| 57 | + file_data=dir([dir_data fil_root '*.nc']); |
50 | 58 | file_data2=file_data.name;
|
51 | 59 |
|
52 | 60 | %load the data:
|
|
66 | 74 | nr=length(MITprof.prof_depth);
|
67 | 75 |
|
68 | 76 | %list tile/processor model files:
|
69 |
| - eval(['model_list_model=dir(''' dir_model list_model{ff} '*.data'');']); |
| 77 | + eval(['model_list_model=dir(''' dir_model fil_root '*.data'');']); |
70 | 78 |
|
71 | 79 | %if no model files then stop
|
72 | 80 | if size(model_list_model,1)==0; fprintf(['file: ' file_data2 ' \n, no model files found\n']);
|
|
0 commit comments