1 |
gforget |
1.1 |
%function: MITprof_create |
2 |
|
|
%object: read netcdf data files in the "MIT format" |
3 |
|
|
%author: Gael Forget (gforget@mit.edu) |
4 |
|
|
%date: june 21th, 2006 |
5 |
|
|
% |
6 |
|
|
%usage: []=MITprof_create(dirOut,fileOut,specs); |
7 |
|
|
% ---> create an empty MITprof netcdf file that contains all T/S fields |
8 |
|
|
% []=MITprof_create(dirOut,fileOut,specs,list_vars); |
9 |
|
|
% ---> same but specifying the list of variables in list_vars cell |
10 |
|
|
% array (e.g. list_vars={'prof_T','prof_Tweight'}). |
11 |
|
|
% |
12 |
|
|
%inputs: dirOut data file directory |
13 |
|
|
% fileOut data file name |
14 |
|
|
% specs {iProf,iLev,lTXT,fillval} |
15 |
|
|
% nProf is the number of profiles |
16 |
|
|
% nLev is the number of levels, |
17 |
|
|
% nChar is the length of profiles description |
18 |
|
|
% (list_vars optional variable list) |
19 |
|
|
% |
20 |
|
|
%outputs: (none) |
21 |
|
|
|
22 |
|
|
function []=MITprof_create(dirOut,fileOut,specs,varargin); |
23 |
|
|
|
24 |
|
|
%=============list of variables that will actually be in the file==============% |
25 |
|
|
if nargin>4; list_vars=varargin{1}; |
26 |
|
|
else; list_vars={'prof_T','prof_Tweight','prof_Tatlas','prof_Terr','prof_Ttest',... |
27 |
|
|
'prof_S','prof_Sweight','prof_Satlas','prof_Serr','prof_Stest'}; |
28 |
|
|
end; |
29 |
|
|
|
30 |
|
|
list_vars_plus=[{'prof_depth','prof_date','prof_YYYYMMDD','prof_HHMMSS',... |
31 |
|
|
'prof_lon','prof_lat','prof_basin','prof_point'}... |
32 |
|
|
list_vars]; |
33 |
|
|
|
34 |
|
|
%==========masters table of variables, units, names and dimensions=============% |
35 |
|
|
|
36 |
|
|
mt_v={'prof_depth'}; mt_u={'me'}; mt_n={'depth'}; mt_d={'iDEPTH'}; |
37 |
|
|
%mt_v=[mt_v '']; mt_u=[mt_u ' ']; mt_n=[mt_n '']; mt_d=[mt_d '']; |
38 |
|
|
mt_v=[mt_v 'prof_date']; mt_u=[mt_u ' ']; mt_n=[mt_n 'Julian day since Jan-1-0000']; mt_d=[mt_d 'iPROF']; |
39 |
|
|
mt_v=[mt_v 'prof_YYYYMMDD']; mt_u=[mt_u ' ']; mt_n=[mt_n 'year (4 digits), month (2 digits), day (2 digits)']; mt_d=[mt_d 'iPROF']; |
40 |
|
|
mt_v=[mt_v 'prof_HHMMSS']; mt_u=[mt_u ' ']; mt_n=[mt_n 'hour (2 digits), minute (2 digits), second (2 digits)']; mt_d=[mt_d 'iPROF']; |
41 |
|
|
mt_v=[mt_v 'prof_lon']; mt_u=[mt_u ' ']; mt_n=[mt_n 'Longitude (degree East)']; mt_d=[mt_d 'iPROF']; |
42 |
|
|
mt_v=[mt_v 'prof_lat']; mt_u=[mt_u ' ']; mt_n=[mt_n 'Latitude (degree North)']; mt_d=[mt_d 'iPROF']; |
43 |
|
|
mt_v=[mt_v 'prof_basin']; mt_u=[mt_u ' ']; mt_n=[mt_n 'ocean basin index (ecco 4g)']; mt_d=[mt_d 'iPROF']; |
44 |
|
|
mt_v=[mt_v 'prof_point']; mt_u=[mt_u ' ']; mt_n=[mt_n 'grid point index (ecco 4g)']; mt_d=[mt_d 'iPROF']; |
45 |
|
|
% |
46 |
|
|
mt_v=[mt_v 'prof_T']; mt_u=[mt_u 'degree C']; mt_n=[mt_n 'potential temperature']; mt_d=[mt_d 'iPROF,iDEPTH']; |
47 |
|
|
mt_v=[mt_v 'prof_Tweight']; mt_u=[mt_u '(degree C)^-2']; mt_n=[mt_n 'pot. temp. least-square weight']; mt_d=[mt_d 'iPROF,iDEPTH']; |
48 |
|
|
mt_v=[mt_v 'prof_Tatlas']; mt_u=[mt_u 'degree C']; mt_n=[mt_n 'pot. temp. estimate (e.g. from atlas)']; mt_d=[mt_d 'iPROF,iDEPTH']; |
49 |
|
|
mt_v=[mt_v 'prof_Terr']; mt_u=[mt_u 'degree C']; mt_n=[mt_n 'pot. temp. instrumental error']; mt_d=[mt_d 'iPROF,iDEPTH']; |
50 |
|
|
mt_v=[mt_v 'prof_Ttest']; mt_u=[mt_u ' ']; mt_n=[mt_n 'flag = i > 0 means test i rejected data.']; mt_d=[mt_d 'iPROF,iDEPTH']; |
51 |
|
|
% |
52 |
|
|
mt_v=[mt_v 'prof_S']; mt_u=[mt_u 'psu']; mt_n=[mt_n 'salinity']; mt_d=[mt_d 'iPROF,iDEPTH']; |
53 |
|
|
mt_v=[mt_v 'prof_Sweight']; mt_u=[mt_u '(psu)^-2']; mt_n=[mt_n 'salinity least-square weight']; mt_d=[mt_d 'iPROF,iDEPTH']; |
54 |
|
|
mt_v=[mt_v 'prof_Satlas']; mt_u=[mt_u 'psu']; mt_n=[mt_n 'salinity estimate (e.g. from atlas)']; mt_d=[mt_d 'iPROF,iDEPTH']; |
55 |
|
|
mt_v=[mt_v 'prof_Serr']; mt_u=[mt_u 'psu']; mt_n=[mt_n 'salinity instrumental error']; mt_d=[mt_d 'iPROF,iDEPTH']; |
56 |
|
|
mt_v=[mt_v 'prof_Stest']; mt_u=[mt_u ' ']; mt_n=[mt_n 'flag = i > 0 means test i rejected data.']; mt_d=[mt_d 'iPROF,iDEPTH']; |
57 |
|
|
% |
58 |
|
|
mt_v=[mt_v 'prof_U']; mt_u=[mt_u 'm/s']; mt_n=[mt_n 'eastward velocity comp.']; mt_d=[mt_d 'iPROF,iDEPTH']; |
59 |
|
|
mt_v=[mt_v 'prof_Uweight']; mt_u=[mt_u '(m/s)^-2']; mt_n=[mt_n 'east. v. least-square weight']; mt_d=[mt_d 'iPROF,iDEPTH']; |
60 |
|
|
mt_v=[mt_v 'prof_V']; mt_u=[mt_u 'm/s']; mt_n=[mt_n 'northward velocity comp.']; mt_d=[mt_d 'iPROF,iDEPTH']; |
61 |
|
|
mt_v=[mt_v 'prof_Vweight']; mt_u=[mt_u '(m/s)^-2']; mt_n=[mt_n 'north. v. least-square weight']; mt_d=[mt_d 'iPROF,iDEPTH']; |
62 |
|
|
mt_v=[mt_v 'prof_ptr']; mt_u=[mt_u 'X']; mt_n=[mt_n 'passive tracer']; mt_d=[mt_d 'iPROF,iDEPTH']; |
63 |
|
|
mt_v=[mt_v 'prof_ptrweight']; mt_u=[mt_u '(X)^-2']; mt_n=[mt_n 'pass. tracer least-square weight']; mt_d=[mt_d 'iPROF,iDEPTH']; |
64 |
|
|
% |
65 |
|
|
mt_v=[mt_v 'prof_bp']; mt_u=[mt_u 'cm']; mt_n=[mt_n 'bottom pressure']; mt_d=[mt_d 'iPROF']; |
66 |
|
|
mt_v=[mt_v 'prof_bpweight']; mt_u=[mt_u '(cm)^-2']; mt_n=[mt_n 'bot. pres. least-square weight']; mt_d=[mt_d 'iPROF']; |
67 |
|
|
mt_v=[mt_v 'prof_ssh']; mt_u=[mt_u 'cm']; mt_n=[mt_n 'sea surface height']; mt_d=[mt_d 'iPROF']; |
68 |
|
|
mt_v=[mt_v 'prof_sshweight']; mt_u=[mt_u '(cm)^-2']; mt_n=[mt_n 'ssh least-square weight']; mt_d=[mt_d 'iPROF']; |
69 |
|
|
|
70 |
|
|
%=============================create the file=================================% |
71 |
|
|
|
72 |
|
|
if ~strcmp(fileOut(end-2:end),'.nc'); suff='.nc'; else; suff=''; end; |
73 |
|
|
nc=netcdf([dirOut fileOut suff],'clobber'); |
74 |
|
|
|
75 |
|
|
%define netcdf dimensions : |
76 |
|
|
iPROF=specs{1}; iDEPTH=specs{2}; |
77 |
|
|
lTXT=specs{3}; fillval=specs{4}; |
78 |
|
|
|
79 |
|
|
nc('iPROF') = iPROF; |
80 |
|
|
nc('iDEPTH') = iDEPTH; |
81 |
|
|
nc('lTXT') = lTXT; |
82 |
|
|
|
83 |
|
|
%mt_v=[mt_v 'prof_descr']; mt_u=[mt_u ' ']; mt_n=[mt_n 'profile description']; mt_d=[mt_d 'iPROF,lTXT']; |
84 |
|
|
nc{'prof_descr'} = ncchar('iPROF','lTXT'); |
85 |
|
|
nc{'prof_descr'}.long_name='profile description'; |
86 |
|
|
|
87 |
|
|
for ii=1:length(list_vars_plus); |
88 |
|
|
jj=find(strcmp(mt_v,list_vars_plus{ii})); |
89 |
|
|
if ~isempty(jj); |
90 |
|
|
if strcmp(mt_d{jj},'iPROF,iDEPTH'); |
91 |
|
|
nc{mt_v{jj}} = ncdouble('iPROF','iDEPTH'); |
92 |
|
|
else; |
93 |
|
|
nc{mt_v{jj}} = mt_d{jj}; |
94 |
|
|
end; |
95 |
|
|
nc{mt_v{jj}}.long_name = mt_n{jj}; |
96 |
|
|
nc{mt_v{jj}}.units = mt_u{jj}; |
97 |
|
|
nc{mt_v{jj}}.missing_value=fillval; |
98 |
|
|
end; |
99 |
|
|
end; |
100 |
|
|
|
101 |
|
|
close(nc); |
102 |
|
|
|