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

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

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


Revision 1.4 - (hide annotations) (download)
Thu Nov 4 18:43:42 2010 UTC (14 years, 8 months ago) by gforget
Branch: MAIN
Changes since 1.3: +14 -15 lines
- remove the step 2 file update from profiles_prep_write_nc.
  It is now done directly in profiles_prep_main.m e.g.
- MITprof_create, MITprof_read, MITprof_write: get
  full filename (not dir,file) as argument.
- MITprof_create: hard-code fillval and length of prof_descr.

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 gforget 1.4 %usage: [MITprof]=MITprof_create(fileOut,nProf,nLev);
7 gforget 1.1 % ---> create an empty MITprof netcdf file that contains all T/S fields
8 gforget 1.4 % [MITprof]=MITprof_create(fileOut,nProf,nLev,list_vars);
9 gforget 1.1 % ---> same but specifying the list of variables in list_vars cell
10     % array (e.g. list_vars={'prof_T','prof_Tweight'}).
11     %
12 gforget 1.4 %inputs: fileOut data file name
13     % nProf number of profiles
14     % nLev number of levels
15     % list_vars variable list (optional)
16 gforget 1.1 %
17 gforget 1.4 %outputs: (none)
18 gforget 1.1
19 gforget 1.4 function []=MITprof_create(fileOut,nProf,nLev,varargin);
20 gforget 1.1
21     %=============list of variables that will actually be in the file==============%
22 gforget 1.4 if nargin>3; list_vars=varargin{1};
23 gforget 1.2 else; list_vars={'prof_T','prof_Tweight','prof_Testim','prof_Terr','prof_Tflag',...
24     'prof_S','prof_Sweight','prof_Sestim','prof_Serr','prof_Sflag'};
25 gforget 1.1 end;
26    
27     list_vars_plus=[{'prof_depth','prof_date','prof_YYYYMMDD','prof_HHMMSS',...
28     'prof_lon','prof_lat','prof_basin','prof_point'}...
29     list_vars];
30    
31     %==========masters table of variables, units, names and dimensions=============%
32    
33     mt_v={'prof_depth'}; mt_u={'me'}; mt_n={'depth'}; mt_d={'iDEPTH'};
34     %mt_v=[mt_v '']; mt_u=[mt_u ' ']; mt_n=[mt_n '']; mt_d=[mt_d ''];
35     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'];
36     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'];
37     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'];
38     mt_v=[mt_v 'prof_lon']; mt_u=[mt_u ' ']; mt_n=[mt_n 'Longitude (degree East)']; mt_d=[mt_d 'iPROF'];
39     mt_v=[mt_v 'prof_lat']; mt_u=[mt_u ' ']; mt_n=[mt_n 'Latitude (degree North)']; mt_d=[mt_d 'iPROF'];
40     mt_v=[mt_v 'prof_basin']; mt_u=[mt_u ' ']; mt_n=[mt_n 'ocean basin index (ecco 4g)']; mt_d=[mt_d 'iPROF'];
41     mt_v=[mt_v 'prof_point']; mt_u=[mt_u ' ']; mt_n=[mt_n 'grid point index (ecco 4g)']; mt_d=[mt_d 'iPROF'];
42     %
43     mt_v=[mt_v 'prof_T']; mt_u=[mt_u 'degree C']; mt_n=[mt_n 'potential temperature']; mt_d=[mt_d 'iPROF,iDEPTH'];
44     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'];
45 gforget 1.2 mt_v=[mt_v 'prof_Testim']; mt_u=[mt_u 'degree C']; mt_n=[mt_n 'pot. temp. estimate (e.g. from atlas)']; mt_d=[mt_d 'iPROF,iDEPTH'];
46 gforget 1.1 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'];
47 gforget 1.2 mt_v=[mt_v 'prof_Tflag']; mt_u=[mt_u ' ']; mt_n=[mt_n 'flag = i > 0 means test i rejected data.']; mt_d=[mt_d 'iPROF,iDEPTH'];
48 gforget 1.1 %
49     mt_v=[mt_v 'prof_S']; mt_u=[mt_u 'psu']; mt_n=[mt_n 'salinity']; mt_d=[mt_d 'iPROF,iDEPTH'];
50     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'];
51 gforget 1.2 mt_v=[mt_v 'prof_Sestim']; mt_u=[mt_u 'psu']; mt_n=[mt_n 'salinity estimate (e.g. from atlas)']; mt_d=[mt_d 'iPROF,iDEPTH'];
52 gforget 1.1 mt_v=[mt_v 'prof_Serr']; mt_u=[mt_u 'psu']; mt_n=[mt_n 'salinity instrumental error']; mt_d=[mt_d 'iPROF,iDEPTH'];
53 gforget 1.2 mt_v=[mt_v 'prof_Sflag']; mt_u=[mt_u ' ']; mt_n=[mt_n 'flag = i > 0 means test i rejected data.']; mt_d=[mt_d 'iPROF,iDEPTH'];
54 gforget 1.1 %
55     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'];
56     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'];
57     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'];
58     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'];
59     mt_v=[mt_v 'prof_ptr']; mt_u=[mt_u 'X']; mt_n=[mt_n 'passive tracer']; mt_d=[mt_d 'iPROF,iDEPTH'];
60     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'];
61     %
62     mt_v=[mt_v 'prof_bp']; mt_u=[mt_u 'cm']; mt_n=[mt_n 'bottom pressure']; mt_d=[mt_d 'iPROF'];
63     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'];
64     mt_v=[mt_v 'prof_ssh']; mt_u=[mt_u 'cm']; mt_n=[mt_n 'sea surface height']; mt_d=[mt_d 'iPROF'];
65     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'];
66    
67     %=============================create the file=================================%
68    
69     if ~strcmp(fileOut(end-2:end),'.nc'); suff='.nc'; else; suff=''; end;
70 gforget 1.4 nc=netcdf([fileOut suff],'clobber');
71 gforget 1.1
72 gforget 1.3 %put a couple global attributes
73     aa=sprintf(['Format: MITprof. This file was created using \n' ...
74     'the matlab toolbox which can be obtained (see README) from \n'...
75     'http://mitgcm.org/viewvc/MITgcm/MITgcm_contrib/gael/profilesMatlabProcessing/']);
76     nc.description=aa;
77     nc.date = date;
78    
79 gforget 1.1 %define netcdf dimensions :
80 gforget 1.4 iPROF=nProf; iDEPTH=nLev;
81     lTXT=30; fillval=-9999;
82 gforget 1.1
83     nc('iPROF') = iPROF;
84     nc('iDEPTH') = iDEPTH;
85     nc('lTXT') = lTXT;
86    
87     %mt_v=[mt_v 'prof_descr']; mt_u=[mt_u ' ']; mt_n=[mt_n 'profile description']; mt_d=[mt_d 'iPROF,lTXT'];
88     nc{'prof_descr'} = ncchar('iPROF','lTXT');
89     nc{'prof_descr'}.long_name='profile description';
90    
91     for ii=1:length(list_vars_plus);
92     jj=find(strcmp(mt_v,list_vars_plus{ii}));
93     if ~isempty(jj);
94     if strcmp(mt_d{jj},'iPROF,iDEPTH');
95     nc{mt_v{jj}} = ncdouble('iPROF','iDEPTH');
96     else;
97     nc{mt_v{jj}} = mt_d{jj};
98     end;
99     nc{mt_v{jj}}.long_name = mt_n{jj};
100     nc{mt_v{jj}}.units = mt_u{jj};
101     nc{mt_v{jj}}.missing_value=fillval;
102 gforget 1.4 else;
103     warning([list_vars_plus{ii} ' not included -- it is not a MITprof varaiable']);
104 gforget 1.1 end;
105     end;
106    
107     close(nc);
108    

  ViewVC Help
Powered by ViewVC 1.1.22