| 1 |
king |
1.1 |
|
| 2 |
|
|
rep_out='/bay/scratch2/TAO_PIRATA/'; |
| 3 |
|
|
filename_out='tao_pirata_92_08'; |
| 4 |
|
|
for num_var=1:3; |
| 5 |
|
|
if num_var==1; |
| 6 |
|
|
nom_var='T';list_files=strvcat('tao_92_08T.nc','pirata_92_08T.nc','rama_92_08T.nc'); |
| 7 |
|
|
elseif num_var==2; |
| 8 |
|
|
nom_var='S';list_files=strvcat('tao_92_08S.nc','pirata_92_08S.nc','rama_92_08S.nc'); |
| 9 |
|
|
else; |
| 10 |
|
|
nom_var='UV';list_files=strvcat('tao_92_08UV.nc','pirata_92_08UV.nc','rama_92_08UV.nc'); |
| 11 |
|
|
end; |
| 12 |
|
|
|
| 13 |
|
|
%compile lists and handle different depths |
| 14 |
|
|
nb_prof=0; list_alldepth=[]; |
| 15 |
|
|
for num_file=1:size(list_files,1) |
| 16 |
|
|
eval(['ncload ' rep_out deblank(list_files(num_file,:)) ' prof_lon depth;']); |
| 17 |
|
|
nb_prof=nb_prof+length(prof_lon); |
| 18 |
|
|
depth %CKCKCKC |
| 19 |
|
|
if ~isempty(strfind(nom_var,'U')); |
| 20 |
|
|
eval(['ncload ' rep_out deblank(list_files(num_file,:)) ' prof_Uweight;']); |
| 21 |
|
|
prof_w=prof_Uweight; |
| 22 |
|
|
else |
| 23 |
|
|
eval(['ncload ' rep_out deblank(list_files(num_file,:)) ' prof_' nom_var 'weight']); |
| 24 |
|
|
%CKCKCKCK prof_w=(['prof_' nom_var 'weight']); |
| 25 |
|
|
eval(['prof_w=prof_' nom_var 'weight' ';']) |
| 26 |
|
|
end |
| 27 |
|
|
tmp1=sum(prof_w,1); tmp1=find(tmp1>0); |
| 28 |
|
|
for kcur=1:length(tmp1); |
| 29 |
|
|
if isempty(find(list_alldepth==depth(tmp1(kcur)))); |
| 30 |
|
|
list_alldepth=[list_alldepth depth(tmp1(kcur))]; |
| 31 |
|
|
end; |
| 32 |
|
|
list_alldepth %CKCKCKCKC |
| 33 |
|
|
end;%for kcur=1:length(tmp1); |
| 34 |
|
|
end;%for num_file=1:size(list_files,1) |
| 35 |
|
|
|
| 36 |
|
|
dmod=sort(list_alldepth); |
| 37 |
|
|
nb_lev=length(dmod); nb_char=30; |
| 38 |
|
|
|
| 39 |
|
|
|
| 40 |
|
|
%create the combined file: |
| 41 |
|
|
%------------------------ |
| 42 |
|
|
fcdf=netcdf([rep_out filename_out nom_var '.nc'], 'clobber'); |
| 43 |
|
|
|
| 44 |
|
|
%define netcdf dimensions : |
| 45 |
|
|
fcdf('iPROF') = nb_prof; |
| 46 |
|
|
fcdf('iDEPTH') = nb_lev; |
| 47 |
|
|
fcdf('lTXT') = nb_char; |
| 48 |
|
|
|
| 49 |
|
|
%define netcdf variables : |
| 50 |
|
|
fcdf{'depth'} = ncdouble('iDEPTH'); |
| 51 |
|
|
fcdf{'depth'}.units='meters'; |
| 52 |
|
|
fcdf{'prof_YYYYMMDD'} = ncdouble('iPROF'); |
| 53 |
|
|
fcdf{'prof_YYYYMMDD'}.missing_value=-9999; |
| 54 |
|
|
fcdf{'prof_YYYYMMDD'}.long_name='year (4 digits), month (2 digits), day (2 digits)'; |
| 55 |
|
|
fcdf{'prof_HHMMSS'} = ncdouble('iPROF'); |
| 56 |
|
|
fcdf{'prof_HHMMSS'}.missing_value=-9999; |
| 57 |
|
|
fcdf{'prof_HHMMSS'}.long_name='hour (2 digits), minute (2 digits), seconde (2 digits)'; |
| 58 |
|
|
fcdf{'prof_lon'} = ncdouble('iPROF'); |
| 59 |
|
|
fcdf{'prof_lon'}.units='(degree E)'; |
| 60 |
|
|
fcdf{'prof_lon'}.missing_value=-9999; |
| 61 |
|
|
fcdf{'prof_lat'} = ncdouble('iPROF'); |
| 62 |
|
|
fcdf{'prof_lat'}.units='(degree N)'; |
| 63 |
|
|
fcdf{'prof_lat'}.missing_value=-9999; |
| 64 |
|
|
if ~isempty(strfind(nom_var,'T')); |
| 65 |
|
|
fcdf{'prof_T'} = ncdouble('iPROF','iDEPTH'); |
| 66 |
|
|
fcdf{'prof_T'}.long_name='potential temperature'; |
| 67 |
|
|
fcdf{'prof_T'}.units='degree Celsius'; |
| 68 |
|
|
fcdf{'prof_T'}.missing_value=-9999; |
| 69 |
|
|
fcdf{'prof_Tweight'} = ncdouble('iPROF','iDEPTH'); |
| 70 |
|
|
fcdf{'prof_Tweight'}.long_name='weights'; |
| 71 |
|
|
fcdf{'prof_Tweight'}.units='(degree Celsius)^-2'; |
| 72 |
|
|
fcdf{'prof_Tweight'}.missing_value=0; |
| 73 |
|
|
elseif ~isempty(strfind(nom_var,'S')); |
| 74 |
|
|
fcdf{'prof_S'} = ncdouble('iPROF','iDEPTH'); |
| 75 |
|
|
fcdf{'prof_S'}.long_name='salinity'; |
| 76 |
|
|
fcdf{'prof_S'}.units='(no units)'; |
| 77 |
|
|
fcdf{'prof_S'}.missing_value=-9999; |
| 78 |
|
|
fcdf{'prof_Sweight'} = ncdouble('iPROF','iDEPTH'); |
| 79 |
|
|
fcdf{'prof_Sweight'}.long_name='weights'; |
| 80 |
|
|
fcdf{'prof_Sweight'}.units='(no units)^-2'; |
| 81 |
|
|
fcdf{'prof_Sweight'}.missing_value=0; |
| 82 |
|
|
else |
| 83 |
|
|
fcdf{'prof_U'} = ncdouble('iPROF','iDEPTH'); |
| 84 |
|
|
fcdf{'prof_U'}.long_name='zonal velocity'; |
| 85 |
|
|
fcdf{'prof_U'}.units='m/s'; |
| 86 |
|
|
fcdf{'prof_U'}.missing_value=-9999; |
| 87 |
|
|
fcdf{'prof_Uweight'} = ncdouble('iPROF','iDEPTH'); |
| 88 |
|
|
fcdf{'prof_Uweight'}.long_name='weights'; |
| 89 |
|
|
fcdf{'prof_Uweight'}.units='(m/s)^-2'; |
| 90 |
|
|
fcdf{'prof_Uweight'}.missing_value=0; |
| 91 |
|
|
fcdf{'prof_V'} = ncdouble('iPROF','iDEPTH'); |
| 92 |
|
|
fcdf{'prof_V'}.long_name='meridional velocity'; |
| 93 |
|
|
fcdf{'prof_V'}.units='m/s'; |
| 94 |
|
|
fcdf{'prof_V'}.missing_value=-9999; |
| 95 |
|
|
fcdf{'prof_Vweight'} = ncdouble('iPROF','iDEPTH'); |
| 96 |
|
|
fcdf{'prof_Vweight'}.long_name='weights'; |
| 97 |
|
|
fcdf{'prof_Vweight'}.units='(m/s)^-2'; |
| 98 |
|
|
fcdf{'prof_Vweight'}.missing_value=0; |
| 99 |
|
|
end |
| 100 |
|
|
fcdf{'prof_descr'} = ncchar('iPROF','lTXT'); |
| 101 |
|
|
fcdf{'prof_descr'}.long_name='profile description'; |
| 102 |
|
|
|
| 103 |
|
|
|
| 104 |
|
|
%fill the vector of the standard depths : |
| 105 |
|
|
fcdf{'depth'}(1:nb_lev)=dmod; |
| 106 |
|
|
|
| 107 |
|
|
%fill the rest of the variables: |
| 108 |
|
|
prev_ind=0; |
| 109 |
|
|
for num_file=1:size(list_files,1) |
| 110 |
|
|
eval(['ncload ' rep_out deblank(list_files(num_file,:)) ';']); |
| 111 |
|
|
prof_lon(find(prof_lon>360))=prof_lon(find(prof_lon>360))-360; |
| 112 |
|
|
list_prof=[1:length(prof_lon)]; |
| 113 |
|
|
fprintf(num2str(num_file)); |
| 114 |
|
|
|
| 115 |
|
|
if ~isempty(strfind(nom_var,'U')); prof_w=prof_Uweight; |
| 116 |
|
|
else; eval(['prof_w=prof_' nom_var 'weight;']); |
| 117 |
|
|
end; |
| 118 |
|
|
tmp1=sum(prof_w,1); tmp1=find(tmp1>0); |
| 119 |
|
|
|
| 120 |
|
|
kcur_glob=zeros(length(tmp1),1); |
| 121 |
|
|
for kcur=1:length(tmp1); kcur_glob(kcur)=find(dmod==depth(tmp1(kcur))); end; |
| 122 |
|
|
kcur_loc=tmp1; |
| 123 |
|
|
|
| 124 |
|
|
%fill the date and position vectors : |
| 125 |
|
|
fcdf{'prof_YYYYMMDD'}(prev_ind+list_prof)=prof_YYYYMMDD(list_prof); |
| 126 |
|
|
fcdf{'prof_HHMMSS'}(prev_ind+list_prof)=prof_HHMMSS(list_prof); |
| 127 |
|
|
fcdf{'prof_lon'}(prev_ind+list_prof)=prof_lon(list_prof); |
| 128 |
|
|
fcdf{'prof_lat'}(prev_ind+list_prof)=prof_lat(list_prof); |
| 129 |
|
|
|
| 130 |
|
|
%fill the data matrices : |
| 131 |
|
|
for kcur=1:length(kcur_glob) |
| 132 |
|
|
if ~isempty(strfind(nom_var,'T')); |
| 133 |
|
|
fcdf{'prof_T'}(prev_ind+list_prof,kcur_glob(kcur))=prof_T(list_prof,kcur_loc(kcur)); |
| 134 |
|
|
fcdf{'prof_Tweight'}(prev_ind+list_prof,kcur_glob(kcur))=prof_Tweight(list_prof,kcur_loc(kcur)); |
| 135 |
|
|
elseif ~isempty(strfind(nom_var,'S')); |
| 136 |
|
|
fcdf{'prof_S'}(prev_ind+list_prof,kcur_glob(kcur))=prof_S(list_prof,kcur_loc(kcur)); |
| 137 |
|
|
fcdf{'prof_Sweight'}(prev_ind+list_prof,kcur_glob(kcur))=prof_Sweight(list_prof,kcur_loc(kcur)); |
| 138 |
|
|
else |
| 139 |
|
|
fcdf{'prof_U'}(prev_ind+list_prof,kcur_glob(kcur))=prof_U(list_prof,kcur_loc(kcur)); |
| 140 |
|
|
fcdf{'prof_Uweight'}(prev_ind+list_prof,kcur_glob(kcur))=prof_Uweight(list_prof,kcur_loc(kcur)); |
| 141 |
|
|
fcdf{'prof_V'}(prev_ind+list_prof,kcur_glob(kcur))=prof_V(list_prof,kcur_loc(kcur)); |
| 142 |
|
|
fcdf{'prof_Vweight'}(prev_ind+list_prof,kcur_glob(kcur))=prof_Vweight(list_prof,kcur_loc(kcur)); |
| 143 |
|
|
end |
| 144 |
|
|
end |
| 145 |
|
|
for kcur=1:length(dmod) |
| 146 |
|
|
if isempty(find(kcur_glob==kcur)) |
| 147 |
|
|
if ~isempty(strfind(nom_var,'T')); |
| 148 |
|
|
fcdf{'prof_T'}(prev_ind+list_prof,kcur)=-9999*ones(length(list_prof),1); |
| 149 |
|
|
fcdf{'prof_Tweight'}(prev_ind+list_prof,kcur)=0*ones(length(list_prof),1); |
| 150 |
|
|
elseif ~isempty(strfind(nom_var,'S')); |
| 151 |
|
|
fcdf{'prof_S'}(prev_ind+list_prof,kcur)=-9999*ones(length(list_prof),1); |
| 152 |
|
|
fcdf{'prof_Sweight'}(prev_ind+list_prof,kcur)=0*ones(length(list_prof),1); |
| 153 |
|
|
else |
| 154 |
|
|
fcdf{'prof_U'}(prev_ind+list_prof,kcur)=-9999*ones(length(list_prof),1); |
| 155 |
|
|
fcdf{'prof_Uweight'}(prev_ind+list_prof,kcur)=0*ones(length(list_prof),1); |
| 156 |
|
|
fcdf{'prof_V'}(prev_ind+list_prof,kcur)=-9999*ones(length(list_prof),1); |
| 157 |
|
|
fcdf{'prof_Vweight'}(prev_ind+list_prof,kcur)=0*ones(length(list_prof),1); |
| 158 |
|
|
end |
| 159 |
|
|
end |
| 160 |
|
|
end |
| 161 |
|
|
%fill the field describing the instruments : |
| 162 |
|
|
fcdf{'prof_descr'}(prev_ind+list_prof,:)=prof_descr(list_prof,:); |
| 163 |
|
|
|
| 164 |
|
|
prev_ind=prev_ind+length(list_prof); |
| 165 |
|
|
end |
| 166 |
|
|
%close the file : |
| 167 |
|
|
fcdf=close(fcdf); |
| 168 |
|
|
|
| 169 |
|
|
end;%for num_var=1:2; |
| 170 |
|
|
|