Skip to content

Commit c344a8f

Browse files
committed
Enhance wind3dp_download and wind3dp_load functions to improve error handling and data retrieval
1 parent edceff4 commit c344a8f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

seppy/loader/wind.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ def wind3dp_download(dataset, startdate, enddate, path=None, **kwargs):
180180
if not os.path.exists(f):
181181
# downloaded_file = Fido.fetch(result[0][i], path=path, max_conn=max_conn)
182182
downloaded_file = wind3dp_single_download(files[i], path=path)
183+
if downloaded_file == []:
184+
print('Trying download from CDAWeb...')
185+
downloaded_file = Fido.fetch(result[0][i], path=path) #, max_conn=max_conn)
183186

184187
except (RuntimeError, IndexError):
185188
print(f'Unable to obtain "{dataset}" data for {startdate}-{enddate}!')
@@ -288,13 +291,18 @@ def wind3dp_load(dataset, startdate, enddate, resample="1min", multi_index=True,
288291
energies['Bins_Text']= np.around(e_low/1e3, 2).astype('string') +' - '+ np.around(e_high/1e3, 2).astype('string') + ' keV'
289292

290293
meta = {'channels_dict_df': energies,
291-
'APPROX_ENERGY_LABELS': metacdf.varget('APPROX_ENERGY_LABELS'),
292294
'ENERGY_UNITS': metacdf.varattsget('ENERGY')['UNITS'],
293295
'FLUX_UNITS': metacdf.varattsget('FLUX')['UNITS'],
294296
'FLUX_FILLVAL': metacdf.varattsget('FLUX')['FILLVAL'],
295-
'FLUX_LABELS': metacdf.varget('FLUX_ENERGY_LABL'),
296297
}
297298

299+
# for SFSP, SOSP, SFPD, SFSP:
300+
try:
301+
meta['APPROX_ENERGY_LABELS'] = metacdf.varget('APPROX_ENERGY_LABELS')
302+
meta['FLUX_LABELS'] = metacdf.varget('FLUX_ENERGY_LABL')
303+
except:
304+
pass
305+
298306
# create multi-index data frame of flux
299307
if multi_index:
300308
if dataset == 'WI_SFPD_3DP' or dataset == 'WI_SOPD_3DP':

0 commit comments

Comments
 (0)