@@ -164,6 +164,7 @@ function initialize_argo()
164164
165165% Extract unique BGC floats
166166[uwmo_sprof ,ia ] = unique(Sprof .wmo ,' stable' ); % keep list order
167+ Sprof_wmo = Sprof .wmo ; % needed later if sprof_only is not empty
167168Sprof.wmo = str2double(Sprof .wmo );
168169ia(end + 1 ) = length(Sprof .urls ) + 1 ;
169170bgc_prof_idx1 = ia(1 : end - 1 );
@@ -185,13 +186,50 @@ function initialize_argo()
185186% Extract unique floats
186187% note that older floats have 5-digit IDs
187188[uwmo_prof ,ia2 ] = unique(Prof .wmo ,' stable' ); % keep list order
189+ Prof_wmo = Prof .wmo ; % needed later if sprof_only is not empty
188190Prof.wmo = str2double(Prof .wmo );
189191ulist = Prof .urls(ia2 );
190- dacs = regexp(ulist(: , 1 ),' ^\w+' ,' once' ,' match' );
192+ dacs = regexp(ulist(: ),' ^\w+' ,' once' ,' match' );
191193prof_fnames = regexprep(uwmo_prof ,' \d+' ,' $0_prof.nc' );
192- tmp = regexprep(ulist(: , 1 ),' profiles.+' ,' ' );
194+ tmp = regexprep(ulist(: ),' profiles.+' ,' ' );
193195prof_fp = strcat(tmp ,prof_fnames );
194196
197+ % are there any floats that have only Sprof files, but not prof files?
198+ sprof_only = setdiff(uwmo_sprof , uwmo_prof );
199+ if ~isempty(sprof_only )
200+ n_sprof_only = length(sprof_only );
201+ fprintf(' The following %d floats have only Sprof files, not prof files:\n ' , ...
202+ n_sprof_only )
203+ disp(cell2mat(sprof_only ))
204+ disp(' ' ) % empty line in command window
205+ idx_sprof_only = cellfun(@(x ) find(strcmp(Sprof_wmo , x ), 1 ), sprof_only );
206+ add_dacs = regexp(Sprof .urls(idx_sprof_only ),' ^\w+' ,' once' ,' match' );
207+ % since the float type is 'bgc', prof will be replaced by Sprof later
208+ add_fnames = regexprep(sprof_only ,' \d+' ,' $0_prof.nc' );
209+ tmp = regexprep(Sprof .urls(idx_sprof_only ),' profiles.+' ,' ' );
210+ add_fp = strcat(tmp , add_fnames );
211+ % add them to other variables so Float structure will have them
212+ prof_fp = [prof_fp ; add_fp ];
213+ prof_fnames = [prof_fnames ; add_fnames ];
214+ dacs = [dacs ; add_dacs ];
215+ wmo_sprof_only = str2double(sprof_only );
216+ idx_in_sprof = cell2mat(arrayfun(@(x ) find(Sprof .wmo == x ), ...
217+ wmo_sprof_only , ' UniformOutput' , false ));
218+ % add all fields from the "special" floats into the Prof structure
219+ Prof.urls = [Prof .urls ; Sprof .urls(idx_in_sprof )];
220+ Prof.date = [Prof .date ; Sprof .date(idx_in_sprof )];
221+ Prof.lat = [Prof .lat ; Sprof .lat(idx_in_sprof )];
222+ Prof.lon = [Prof .lon ; Sprof .lon(idx_in_sprof )];
223+ Prof.ocean = [Prof .ocean ; Sprof .ocean(idx_in_sprof )];
224+ Prof.profiler = [Prof .profiler ; Sprof .profiler(idx_in_sprof )];
225+ Prof.update = [Prof .update ; Sprof .update(idx_in_sprof )];
226+ Prof.split_sens = [Prof .split_sens ; Sprof .split_sens(idx_in_sprof )];
227+ Prof.wmo = [Prof .wmo ; Sprof .wmo(idx_in_sprof )];
228+ Prof_wmo = [Prof_wmo ; Sprof_wmo(idx_in_sprof )];
229+ [uwmo_prof ,ia2 ] = unique(Prof_wmo ,' stable' );
230+ end
231+
232+
195233% need to find out which floats are phys (in Prof only) and bgc (in Sprof)
196234is_uniq_bgc = ismember(uwmo_prof ,uwmo_sprof );
197235nbgc = sum(is_uniq_bgc ); % # of bgc floats (this may be revised later)
@@ -271,6 +309,15 @@ function initialize_argo()
271309bgc_prof_idx2 = bgc_prof_idx2(is_true_bgc == 1 );
272310Float .bgc_prof_idx1(strcmp(Float .type , ' bgc' )) = bgc_prof_idx1 ;
273311Float .bgc_prof_idx2(strcmp(Float .type , ' bgc' )) = bgc_prof_idx2 ;
312+ % add this check in case that files without prof files do not have
313+ % any BGC sensors, so that they will be classified as 'phys' floats
314+ % but Sprof files need to be read anyway
315+ Float.has_prof_file = ones(length(Float .type ), 1 );
316+ if ~isempty(sprof_only )
317+ idx_in_float = cell2mat(arrayfun(@(x ) find(Float .wmoid == x ), ...
318+ wmo_sprof_only , ' UniformOutput' , false ));
319+ Float .has_prof_file(idx_in_float ) = 0 ;
320+ end
274321
275322% for all "true" BGC floats, i.e., those that are listed in the Sprof
276323% index file and have more than pTS sensors, Sprof files will be used
@@ -279,12 +326,14 @@ function initialize_argo()
279326fprintf(' %d "true" BGC floats were found\n ' , sum(idx_bgc ));
280327idx_phys = strcmp(Float .type , ' phys' );
281328fprintf(' %d core and deep floats were found\n ' , sum(idx_phys ));
282- Float .file_path(strcmp(Float .type , ' bgc' )) = ...
329+ Float .file_path(strcmp(Float .type , ' bgc' ) | ~ Float . has_prof_file ) = ...
283330 cellfun(@(x ) strrep(x , ' prof' , ' Sprof' ), ...
284- Float .file_path(strcmp(Float .type , ' bgc' )), ' UniformOutput' , false );
285- Float .file_name(strcmp(Float .type , ' bgc' )) = ...
331+ Float .file_path(strcmp(Float .type , ' bgc' ) | ~Float .has_prof_file ), ...
332+ ' UniformOutput' , false );
333+ Float .file_name(strcmp(Float .type , ' bgc' ) | ~Float .has_prof_file ) = ...
286334 cellfun(@(x ) strrep(x , ' prof' , ' Sprof' ), ...
287- Float .file_name(strcmp(Float .type , ' bgc' )), ' UniformOutput' , false );
335+ Float .file_name(strcmp(Float .type , ' bgc' ) | ~Float .has_prof_file ), ...
336+ ' UniformOutput' , false );
288337
289338% use the update date of the last profile of each float
290339Float .update(strcmp(Float .type , ' bgc' )) = Sprof .update(bgc_prof_idx2 );
0 commit comments