1 |
gforget |
1.4 |
function [MITprof]=MITprof_struct(nProf,dataset,varargin); |
2 |
gforget |
1.1 |
% [MITprof]=MITprof_struct; |
3 |
|
|
% create an empty struct variable using the format MITprof |
4 |
|
|
% nProf: number of profiles |
5 |
roquet |
1.3 |
% prof_depth: list of depth levels |
6 |
|
|
% list_var: specify name of created fields |
7 |
|
|
% |
8 |
|
|
% list of fields always created: |
9 |
|
|
% prof_depth [nDepth x 1] |
10 |
|
|
% prof_descr {nProf x 1} |
11 |
|
|
% prof_date [nProf x 1] |
12 |
|
|
% prof_YYYYMMDD [nProf x 1] |
13 |
|
|
% prof_HHMMSS [nProf x 1] |
14 |
|
|
% prof_lon [nProf x 1] |
15 |
|
|
% prof_lat [nProf x 1] |
16 |
|
|
% prof_basin [nProf x 1] |
17 |
|
|
% prof_point [nProf x 1] |
18 |
|
|
% np, nr, list_descr, nd |
19 |
|
|
% |
20 |
|
|
% list of fields created by default, if list_var not specified |
21 |
|
|
% prof_T, prof_Tflag, prof_Terr, prof_Tweight, prof_Testim |
22 |
|
|
% prof_S, prof_Sflag, prof_Serr, prof_Sweight, prof_Sestim |
23 |
|
|
% array size: [nProf x nLev] |
24 |
|
|
|
25 |
gforget |
1.4 |
prof_depth=dataset.z_std; |
26 |
roquet |
1.3 |
|
27 |
|
|
list_vars={'prof_T','prof_Tweight','prof_Testim','prof_Terr','prof_Tflag',... |
28 |
|
|
'prof_S','prof_Sweight','prof_Sestim','prof_Serr','prof_Sflag'}; |
29 |
gforget |
1.4 |
if ~strcmp(dataset.coord,'depth'); |
30 |
|
|
list_vars={list_vars{:},'prof_D','prof_Destim'}; |
31 |
|
|
end; |
32 |
roquet |
1.3 |
if nargin>2, |
33 |
|
|
list_vars=varargin{1}; |
34 |
|
|
end |
35 |
roquet |
1.2 |
|
36 |
gforget |
1.1 |
|
37 |
|
|
MITprof=[]; |
38 |
roquet |
1.3 |
|
39 |
|
|
nLev=length(prof_depth); |
40 |
|
|
prof_depth=reshape(prof_depth,length(prof_depth),1); |
41 |
|
|
MITprof.prof_depth=prof_depth; |
42 |
|
|
|
43 |
gforget |
1.1 |
MITprof.prof_date=zeros(nProf,1); |
44 |
|
|
MITprof.prof_YYYYMMDD=zeros(nProf,1); |
45 |
|
|
MITprof.prof_HHMMSS=zeros(nProf,1); |
46 |
|
|
MITprof.prof_lon=zeros(nProf,1); |
47 |
|
|
MITprof.prof_lat=zeros(nProf,1); |
48 |
|
|
MITprof.prof_basin=zeros(nProf,1); |
49 |
|
|
MITprof.prof_point=zeros(nProf,1); |
50 |
roquet |
1.3 |
|
51 |
gforget |
1.1 |
MITprof.prof_descr=cell(nProf,1); |
52 |
roquet |
1.3 |
|
53 |
|
|
for ii=1:length(list_vars), |
54 |
|
|
MITprof=setfield(MITprof,list_vars{ii},zeros(nProf,nLev)); |
55 |
|
|
end |
56 |
|
|
|
57 |
gforget |
1.1 |
MITprof.np=nProf; |
58 |
|
|
MITprof.nr=nLev; |
59 |
|
|
MITprof.nd=0; |
60 |
|
|
MITprof.list_descr={}; |
61 |
|
|
|
62 |
|
|
|
63 |
|
|
|