@@ -145,29 +145,17 @@ function initialize_argo()
145145 ' jma' ; ' kma' ; ' kordi' ; ' meds' };
146146
147147% Write Sprof index file from GDAC to Index directory
148- sprof = ' argo_synthetic-profile_index.txt' ; % file used locally
149- sprof_gz = [sprof , ' .gz' ]; % file that is available at GDAC
150- Settings.dest_path_sprof = [Settings .index_dir , sprof ];
151- dest_path_sprof_gz = [Settings .index_dir , sprof_gz ];
152- if do_download(dest_path_sprof_gz )
153- if Settings .verbose
154- disp(' Sprof index file will now be downloaded.' )
155- disp(' Depending on your internet connection, this may take a while.' )
156- end
157- if ~try_download(sprof_gz , dest_path_sprof_gz )
158- error(' Sprof index file could not be downloaded' )
159- end
160- gunzip(dest_path_sprof_gz )
161- elseif ~exist(Settings .dest_path_sprof , ' file' )
162- gunzip(dest_path_sprof_gz )
148+ sprof = ' argo_synthetic-profile_index.txt' ; % file at GDAC
149+ if ~download_index([sprof , ' .gz' ], ' Sprof' )
150+ error(' Sprof index file could not be downloaded' )
163151end
164152
165153% Extract information from Sprof index file
166154% NOTE that some quantities will be kept per float (struct Float):
167155% file_path, file_name, dac, params, wmoid, update
168156% Others will be kept per profile (struct Sprof):
169157% date, lat, lon, sens(ors), data_mode
170- fid = fopen(Settings .dest_path_sprof );
158+ fid = fopen([ Settings .index_dir , sprof ] );
171159H = textscan(fid ,' %s %s %f %f %s %d %s %s %s %s ' ,' headerlines' ,9 ,...
172160 ' delimiter' ,' ,' ,' whitespace' ,' ' );
173161fclose(fid );
@@ -207,39 +195,22 @@ function initialize_argo()
207195Sprof.wmo = regexp(sprof_urls ,' \d{7}' ,' once' ,' match' );
208196[uwmo_sprof ,ia ] = unique(Sprof .wmo ,' stable' ); % keep list order
209197Sprof.wmo = str2double(Sprof .wmo );
210- ulist = sprof_urls(ia );
211- dacs = regexp(ulist(: ,1 ),' ^\w+' ,' once' ,' match' );
212- Sprof_fnames = regexprep(uwmo_sprof ,' \d{7}' ,' $0_Sprof.nc' );
213- tmp = regexprep(ulist(: ,1 ),' profiles.+' ,' ' );
214- Sprof_fp = strcat(tmp ,Sprof_fnames );
215198ia(end + 1 ) = length(sprof_urls ) + 1 ;
216199bgc_prof_idx1 = ia(1 : end - 1 );
217200bgc_prof_idx2 = ia(2 : end ) - 1 ;
218201
219202% Write prof index file from GDAC to Index directory
220- prof = ' ar_index_global_prof.txt' ; % file used locally
221- prof_gz = [prof , ' .gz' ]; % gzipped file that is available at GDAC
222- Settings.dest_path_prof = [Settings .index_dir , prof ];
223- dest_path_prof_gz = [Settings .index_dir , prof_gz ];
224- if do_download(dest_path_prof_gz )
225- if Settings .verbose
226- disp(' prof index file will now be downloaded.' )
227- disp(' Depending on your internet connection, this may take a while.' )
228- end
229- if ~try_download(prof_gz , dest_path_prof_gz )
230- error(' prof index file could not be downloaded' )
231- end
232- gunzip(dest_path_prof_gz )
233- elseif ~exist(Settings .dest_path_prof , ' file' )
234- gunzip(dest_path_prof_gz )
203+ prof = ' ar_index_global_prof.txt' ; % file at GDAC
204+ if ~download_index([prof , ' .gz' ], ' prof' )
205+ error(' prof index file could not be downloaded' )
235206end
236207
237208% Extract information from prof index file
238209% NOTE that some quantities will be kept per float (struct Float):
239210% file_path, file_name, dac, params, wmoid, update
240211% Others will be kept per profile (struct Prof):
241212% date, lat, lon, sens(ors), data_mode
242- fid = fopen(Settings .dest_path_prof );
213+ fid = fopen([ Settings .index_dir , prof ] );
243214H = textscan(fid ,' %s %s %f %f %s %d %s %s ' ,' headerlines' ,9 ,...
244215 ' delimiter' ,' ,' ,' whitespace' ,' ' );
245216fclose(fid );
@@ -362,20 +333,14 @@ function initialize_argo()
362333 Sprof .date_update(bgc_prof_idx2(is_true_bgc == 1 ));
363334
364335% Write meta index file from GDAC to Index directory
365- % Since it is rather small, download the uncompressed file
336+ % Since it is rather small, download the uncompressed file directly
366337meta = ' ar_index_global_meta.txt' ;
367- Settings.dest_path_meta = [Settings .index_dir , meta ];
368- if do_download(Settings .dest_path_meta )
369- if Settings .verbose
370- disp(' meta index file will now be downloaded.' )
371- end
372- if ~try_download(meta , Settings .dest_path_meta )
373- error(' meta index file could not be downloaded' )
374- end
338+ if ~download_index(meta , ' meta' )
339+ error(' meta index file could not be downloaded' )
375340end
376341
377342% Extract information from meta index file
378- fid = fopen(Settings .dest_path_meta );
343+ fid = fopen([ Settings .index_dir , meta ] );
379344H = textscan(fid ,' %s %s %s %s ' ,' headerlines' ,9 ,...
380345 ' delimiter' ,' ,' ,' whitespace' ,' ' );
381346fclose(fid );
0 commit comments