seppy 0.1.19__py3-none-any.whl → 0.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of seppy might be problematic. Click here for more details.
- seppy/_version.py +2 -2
- seppy/loader/psp.py +26 -20
- seppy/loader/stereo.py +14 -11
- seppy/tests/test_loader.py +3 -3
- seppy/tests/test_tools.py +13 -14
- seppy/tools/__init__.py +55 -18
- seppy/util/__init__.py +12 -0
- seppy/version.py +1 -1
- {seppy-0.1.19.dist-info → seppy-0.2.1.dist-info}/METADATA +2 -28
- {seppy-0.1.19.dist-info → seppy-0.2.1.dist-info}/RECORD +13 -13
- {seppy-0.1.19.dist-info → seppy-0.2.1.dist-info}/WHEEL +1 -1
- {seppy-0.1.19.dist-info → seppy-0.2.1.dist-info}/licenses/LICENSE.rst +0 -0
- {seppy-0.1.19.dist-info → seppy-0.2.1.dist-info}/top_level.txt +0 -0
seppy/_version.py
CHANGED
seppy/loader/psp.py
CHANGED
|
@@ -199,8 +199,8 @@ def psp_isois_load(dataset, startdate, enddate, epilo_channel='F', epilo_thresho
|
|
|
199
199
|
Name of PSP dataset:
|
|
200
200
|
- 'PSP_ISOIS-EPIHI_L2-HET-RATES60'
|
|
201
201
|
- 'PSP_ISOIS-EPIHI_L2-HET-RATES3600' (higher coverage than 'RATES60' before mid-2021)
|
|
202
|
-
- 'PSP_ISOIS-EPIHI_L2-LET1-RATES60'
|
|
203
|
-
- 'PSP_ISOIS-EPIHI_L2-LET2-RATES60'
|
|
202
|
+
- 'PSP_ISOIS-EPIHI_L2-LET1-RATES60'
|
|
203
|
+
- 'PSP_ISOIS-EPIHI_L2-LET2-RATES60'
|
|
204
204
|
- 'PSP_ISOIS-EPILO_L2-PE'
|
|
205
205
|
- 'PSP_ISOIS-EPILO_L2-IC'
|
|
206
206
|
startdate, enddate : {datetime or str}
|
|
@@ -254,19 +254,20 @@ def psp_isois_load(dataset, startdate, enddate, epilo_channel='F', epilo_thresho
|
|
|
254
254
|
df = data.to_dataframe()
|
|
255
255
|
# df = read_cdf(downloaded_files[0])
|
|
256
256
|
|
|
257
|
-
# reduce data frame to only H_Flux, H_Uncertainty, Electron_Counts, and Electron_Rate.
|
|
258
|
-
# There is no Electron_Uncertainty, maybe one could use at least the Poission error from Electron_Counts for that.
|
|
259
|
-
# df = df.filter(like='H_Flux') + df.filter(like='H_Uncertainty') + df.filter(like='Electrons')
|
|
260
|
-
if dataset.split('-')[2].upper() == 'HET':
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
if dataset.split('-')[2].upper() == 'LET1':
|
|
266
|
-
|
|
267
|
-
if dataset.split('-')[2].upper() == 'LET2':
|
|
268
|
-
|
|
269
|
-
df = df[df.columns[df.columns.str.startswith(tuple(selected_cols))]]
|
|
257
|
+
# # reduce data frame to only H_Flux, H_Uncertainty, Electron_Counts, and Electron_Rate.
|
|
258
|
+
# # There is no Electron_Uncertainty, maybe one could use at least the Poission error from Electron_Counts for that.
|
|
259
|
+
# # df = df.filter(like='H_Flux') + df.filter(like='H_Uncertainty') + df.filter(like='Electrons')
|
|
260
|
+
# if dataset.split('-')[2].upper() == 'HET':
|
|
261
|
+
# if dataset.split('-')[3] == 'RATES60':
|
|
262
|
+
# selected_cols = ["A_H_Flux", "B_H_Flux", "A_H_Uncertainty", "B_H_Uncertainty", "A_Electrons", "B_Electrons"]
|
|
263
|
+
# if dataset.split('-')[3] == 'RATES3600':
|
|
264
|
+
# selected_cols = ["A_H_Flux", "B_H_Flux", "A_H_Uncertainty", "B_H_Uncertainty", "A_Electrons", "B_Electrons"]
|
|
265
|
+
# if dataset.split('-')[2].upper() == 'LET1':
|
|
266
|
+
# selected_cols = ["A_H_Flux", "B_H_Flux", "A_H_Uncertainty", "B_H_Uncertainty", "A_Electrons", "B_Electrons"]
|
|
267
|
+
# if dataset.split('-')[2].upper() == 'LET2':
|
|
268
|
+
# selected_cols = ["A_H_Flux", "B_H_Flux", "A_H_Uncertainty", "B_H_Uncertainty", "A_Electrons", "B_Electrons"]
|
|
269
|
+
# df = df[df.columns[df.columns.str.startswith(tuple(selected_cols))]]
|
|
270
|
+
# raise Warning(f"{dataset} is not fully suppported, only proton and electron data will be processed!")
|
|
270
271
|
|
|
271
272
|
cdf = cdflib.CDF(downloaded_files[0])
|
|
272
273
|
|
|
@@ -288,8 +289,6 @@ def psp_isois_load(dataset, startdate, enddate, epilo_channel='F', epilo_thresho
|
|
|
288
289
|
cdf['H_ENERGY_DELTAMINUS'],
|
|
289
290
|
"H_ENERGY_LABL":
|
|
290
291
|
cdf['H_ENERGY_LABL'],
|
|
291
|
-
"H_FLUX_UNITS":
|
|
292
|
-
cdf.varattsget('A_H_Flux')['UNITS'],
|
|
293
292
|
"Electrons_ENERGY":
|
|
294
293
|
cdf['Electrons_ENERGY'],
|
|
295
294
|
"Electrons_ENERGY_DELTAPLUS":
|
|
@@ -297,10 +296,17 @@ def psp_isois_load(dataset, startdate, enddate, epilo_channel='F', epilo_thresho
|
|
|
297
296
|
"Electrons_ENERGY_DELTAMINUS":
|
|
298
297
|
cdf['Electrons_ENERGY_DELTAMINUS'],
|
|
299
298
|
"Electrons_ENERGY_LABL":
|
|
300
|
-
cdf['Electrons_ENERGY_LABL']
|
|
301
|
-
"Electrons_Rate_UNITS":
|
|
302
|
-
cdf.varattsget('A_Electrons_Rate')['UNITS']
|
|
299
|
+
cdf['Electrons_ENERGY_LABL']
|
|
303
300
|
}
|
|
301
|
+
try:
|
|
302
|
+
energies_dict["H_FLUX_UNITS"] = cdf.varattsget('A_H_Flux')['UNITS']
|
|
303
|
+
energies_dict["Electrons_Rate_UNITS"] = cdf.varattsget('A_Electrons_Rate')['UNITS']
|
|
304
|
+
except ValueError:
|
|
305
|
+
try:
|
|
306
|
+
energies_dict["H_FLUX_UNITS"] = cdf.varattsget('C_H_Flux')['UNITS']
|
|
307
|
+
energies_dict["Electrons_Rate_UNITS"] = cdf.varattsget('C_Electrons_Rate')['UNITS']
|
|
308
|
+
except ValueError:
|
|
309
|
+
raise Warning(f"Can't obtain UNITS from metadata. Possibly an unsupported dataset is loaded!")
|
|
304
310
|
|
|
305
311
|
# loading for EPILO
|
|
306
312
|
if dataset.split('-')[1] == 'EPILO_L2':
|
seppy/loader/stereo.py
CHANGED
|
@@ -290,7 +290,7 @@ def _get_metadata(dataset, path_to_cdf):
|
|
|
290
290
|
return metadata
|
|
291
291
|
|
|
292
292
|
|
|
293
|
-
def stereo_load(instrument, startdate, enddate, spacecraft='ahead', mag_coord='RTN', sept_species='e', sept_viewing=
|
|
293
|
+
def stereo_load(instrument, startdate, enddate, spacecraft='ahead', mag_coord='RTN', sept_species='e', sept_viewing=None, path=None, resample=None, pos_timestamp='center', max_conn=5):
|
|
294
294
|
"""
|
|
295
295
|
Downloads CDF files via SunPy/Fido from CDAWeb for HET, LET, MAG, and SEPT onboard STEREO
|
|
296
296
|
|
|
@@ -358,16 +358,19 @@ def stereo_load(instrument, startdate, enddate, spacecraft='ahead', mag_coord='R
|
|
|
358
358
|
spacecraft='behind'
|
|
359
359
|
|
|
360
360
|
if instrument.upper()=='SEPT':
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
361
|
+
if not sept_viewing:
|
|
362
|
+
raise Exception("STEREO/SEPT loading requires a defined 'sept_viewing'!")
|
|
363
|
+
else:
|
|
364
|
+
df, channels_dict_df = stereo_sept_loader(startdate=startdate,
|
|
365
|
+
enddate=enddate,
|
|
366
|
+
spacecraft=spacecraft,
|
|
367
|
+
species=sept_species,
|
|
368
|
+
viewing=sept_viewing,
|
|
369
|
+
resample=resample,
|
|
370
|
+
path=path,
|
|
371
|
+
all_columns=False,
|
|
372
|
+
pos_timestamp=pos_timestamp)
|
|
373
|
+
return df, channels_dict_df
|
|
371
374
|
else:
|
|
372
375
|
# define spacecraft string
|
|
373
376
|
sc = 'ST' + spacecraft.upper()[0]
|
seppy/tests/test_loader.py
CHANGED
|
@@ -13,7 +13,7 @@ def test_psp_load_online():
|
|
|
13
13
|
df, meta = psp_isois_load(dataset='PSP_ISOIS-EPIHI_L2-HET-RATES60', startdate="2021/05/31",
|
|
14
14
|
enddate="2021/06/01", path=None, resample="1min")
|
|
15
15
|
assert isinstance(df, pd.DataFrame)
|
|
16
|
-
assert df.shape == (48,
|
|
16
|
+
assert df.shape == (48, 1304)
|
|
17
17
|
assert meta['H_ENERGY_LABL'].flatten()[0] == ' 6.7 - 8.0 MeV'
|
|
18
18
|
# Check that fillvals are replaced by NaN
|
|
19
19
|
assert np.sum(np.isnan(df['B_H_Uncertainty_14'])) == 48
|
|
@@ -120,7 +120,7 @@ def test_stereo_het_load_offline():
|
|
|
120
120
|
|
|
121
121
|
def test_stereo_sept_load_online():
|
|
122
122
|
df, meta = stereo_load(instrument="SEPT", startdate="2006/11/14", enddate="2006/11/14",
|
|
123
|
-
path=None, resample="1min", pos_timestamp='center')
|
|
123
|
+
path=None, resample="1min", pos_timestamp='center', sept_viewing='north')
|
|
124
124
|
assert isinstance(df, pd.DataFrame)
|
|
125
125
|
assert df.shape == (371, 30)
|
|
126
126
|
assert meta.ch_strings[meta.index==2].values[0] == '45.0-55.0 keV'
|
|
@@ -133,7 +133,7 @@ def test_stereo_sept_load_offline():
|
|
|
133
133
|
fullpath = get_pkg_data_filename('data/test/sept_ahead_ele_sun_2006_318_1min_l2_v03.dat', package='seppy')
|
|
134
134
|
path = Path(fullpath).parent.as_posix()
|
|
135
135
|
df, meta = stereo_load(instrument="SEPT", startdate="2006/11/14", enddate="2006/11/14",
|
|
136
|
-
path=path, resample="1min", pos_timestamp=None)
|
|
136
|
+
path=path, resample="1min", pos_timestamp=None, sept_viewing='sun')
|
|
137
137
|
assert isinstance(df, pd.DataFrame)
|
|
138
138
|
assert df.shape == (371, 30)
|
|
139
139
|
assert meta.ch_strings[meta.index==2].values[0] == '45.0-55.0 keV'
|
seppy/tests/test_tools.py
CHANGED
|
@@ -170,7 +170,7 @@ def test_onset_spectrum_tsa_PSP_ISOIS_EPIHI_online():
|
|
|
170
170
|
lpath = f"{os.getcwd()}/data/"
|
|
171
171
|
background_range = (datetime.datetime(2021, 10, 28, 10, 0, 0), datetime.datetime(2021, 10, 28, 12, 0, 0))
|
|
172
172
|
# viewing "A", single channel, electrons
|
|
173
|
-
Event1 = Event(spacecraft='PSP', sensor='isois-epihi', data_level='l2', species='electrons', start_date=startdate, end_date=enddate, data_path=lpath)
|
|
173
|
+
Event1 = Event(spacecraft='PSP', sensor='isois-epihi', viewing='A', data_level='l2', species='electrons', start_date=startdate, end_date=enddate, data_path=lpath)
|
|
174
174
|
print(Event1.print_energies())
|
|
175
175
|
flux, onset_stats, onset_found, peak_flux, peak_time, fig, bg_mean = Event1.find_onset(viewing='A', background_range=background_range, channels=4, resample_period="5min", yscale='log', cusum_window=30)
|
|
176
176
|
assert isinstance(flux, pd.Series)
|
|
@@ -181,7 +181,7 @@ def test_onset_spectrum_tsa_PSP_ISOIS_EPIHI_online():
|
|
|
181
181
|
assert peak_time.isoformat().split('.')[0] == '2021-10-28T16:06:59'
|
|
182
182
|
assert fig.get_axes()[0].get_title() == 'PSP/ISOIS-EPIHI 0.8 - 1.0 MeV electrons\n5min averaging, viewing: A'
|
|
183
183
|
# viewing "B", combined channel, protons
|
|
184
|
-
Event1 = Event(spacecraft='PSP', sensor='isois-epihi', data_level='l2', species='protons', start_date=startdate, end_date=enddate, data_path=lpath)
|
|
184
|
+
Event1 = Event(spacecraft='PSP', sensor='isois-epihi', viewing='B', data_level='l2', species='protons', start_date=startdate, end_date=enddate, data_path=lpath)
|
|
185
185
|
print(Event1.print_energies())
|
|
186
186
|
flux, onset_stats, onset_found, peak_flux, peak_time, fig, bg_mean = Event1.find_onset(viewing='B', background_range=background_range, channels=[1, 5], resample_period="5min", yscale='log', cusum_window=30)
|
|
187
187
|
assert isinstance(flux, pd.Series)
|
|
@@ -206,7 +206,7 @@ def test_onset_spectrum_tsa_PSP_ISOIS_EPILO_e_online():
|
|
|
206
206
|
startdate = datetime.date(2021, 10, 28)
|
|
207
207
|
enddate = datetime.date(2021, 10, 29)
|
|
208
208
|
lpath = f"{os.getcwd()}/data/"
|
|
209
|
-
Event1 = Event(spacecraft='PSP', sensor='isois-epilo', data_level='l2', species='electrons', start_date=startdate, end_date=enddate, data_path=lpath)
|
|
209
|
+
Event1 = Event(spacecraft='PSP', sensor='isois-epilo', viewing='7', data_level='l2', species='electrons', start_date=startdate, end_date=enddate, data_path=lpath)
|
|
210
210
|
print(Event1.print_energies())
|
|
211
211
|
background_range = (datetime.datetime(2021, 10, 28, 10, 0, 0), datetime.datetime(2021, 10, 28, 12, 0, 0))
|
|
212
212
|
# viewing "7", single channel
|
|
@@ -242,7 +242,7 @@ def test_onset_spectrum_tsa_Wind_3DP_p_online():
|
|
|
242
242
|
startdate = datetime.date(2021, 10, 28)
|
|
243
243
|
enddate = datetime.date(2021, 10, 29)
|
|
244
244
|
lpath = f"{os.getcwd()}/data/"
|
|
245
|
-
Event1 = Event(spacecraft='Wind', sensor='3DP', data_level='l2', species='protons', start_date=startdate, end_date=enddate, data_path=lpath)
|
|
245
|
+
Event1 = Event(spacecraft='Wind', sensor='3DP', data_level='l2', viewing="Sector 3", species='protons', start_date=startdate, end_date=enddate, data_path=lpath)
|
|
246
246
|
print(Event1.print_energies())
|
|
247
247
|
background_range = (datetime.datetime(2021, 10, 28, 10, 0, 0), datetime.datetime(2021, 10, 28, 12, 0, 0))
|
|
248
248
|
# viewng "sector 3"
|
|
@@ -279,7 +279,7 @@ def test_onset_spectrum_tsa_Wind_3DP_e_online():
|
|
|
279
279
|
startdate = datetime.date(2021, 10, 28)
|
|
280
280
|
enddate = datetime.date(2021, 10, 29)
|
|
281
281
|
lpath = f"{os.getcwd()}/data/"
|
|
282
|
-
Event1 = Event(spacecraft='Wind', sensor='3DP', data_level='l2', species='electrons', start_date=startdate, end_date=enddate, data_path=lpath) # TODO: radio_spacecraft=('wind', 'WIND')
|
|
282
|
+
Event1 = Event(spacecraft='Wind', sensor='3DP', viewing="Sector 3", data_level='l2', species='electrons', start_date=startdate, end_date=enddate, data_path=lpath) # TODO: radio_spacecraft=('wind', 'WIND')
|
|
283
283
|
print(Event1.print_energies())
|
|
284
284
|
background_range = (datetime.datetime(2021, 10, 28, 10, 0, 0), datetime.datetime(2021, 10, 28, 12, 0, 0))
|
|
285
285
|
#
|
|
@@ -370,7 +370,7 @@ def test_onset_spectrum_tsa_STEREOA_SEPT_p_online():
|
|
|
370
370
|
startdate = datetime.date(2021, 10, 28)
|
|
371
371
|
enddate = datetime.date(2021, 10, 28)
|
|
372
372
|
lpath = f"{os.getcwd()}/data/"
|
|
373
|
-
Event1 = Event(spacecraft='STEREO-A', sensor='SEPT', data_level='l2', species='ions', start_date=startdate, end_date=enddate, data_path=lpath)
|
|
373
|
+
Event1 = Event(spacecraft='STEREO-A', sensor='SEPT', viewing="north", data_level='l2', species='ions', start_date=startdate, end_date=enddate, data_path=lpath)
|
|
374
374
|
print(Event1.print_energies())
|
|
375
375
|
background_range = (datetime.datetime(2021, 10, 28, 10, 0, 0), datetime.datetime(2021, 10, 28, 12, 0, 0))
|
|
376
376
|
flux, onset_stats, onset_found, peak_flux, peak_time, fig, bg_mean = Event1.find_onset(viewing='north', background_range=background_range, channels=[5, 8], resample_period="5min", yscale='log', cusum_window=30)
|
|
@@ -384,12 +384,12 @@ def test_onset_spectrum_tsa_STEREOA_SEPT_p_online():
|
|
|
384
384
|
assert fig.get_axes()[0].get_title() == 'STA/SEPT 110-174.6 keV protons\n5min averaging, viewing: NORTH'
|
|
385
385
|
|
|
386
386
|
# test dynamic spectrum:
|
|
387
|
-
Event1.dynamic_spectrum(view=
|
|
388
|
-
assert Event1.fig.get_axes()[0].get_title() == 'STA/SEPT protons, 2021-10-28'
|
|
387
|
+
Event1.dynamic_spectrum(view="north")
|
|
388
|
+
assert Event1.fig.get_axes()[0].get_title() == 'STA/SEPT (north) protons, 2021-10-28'
|
|
389
389
|
|
|
390
390
|
# test tsa plot:
|
|
391
391
|
plt.close('all') # in order to pick the right figure, make sure all previous are closed
|
|
392
|
-
Event1.tsa_plot(
|
|
392
|
+
Event1.tsa_plot(view="north", selection=None, resample=None)
|
|
393
393
|
assert plt.figure(1).get_axes()[0].get_title() == 'STEREO-A SEPT, protons'
|
|
394
394
|
|
|
395
395
|
|
|
@@ -397,7 +397,7 @@ def test_onset_spectrum_tsa_STEREOA_SEPT_e_online():
|
|
|
397
397
|
startdate = datetime.date(2021, 10, 28)
|
|
398
398
|
enddate = datetime.date(2021, 10, 28)
|
|
399
399
|
lpath = f"{os.getcwd()}/data/"
|
|
400
|
-
Event1 = Event(spacecraft='STEREO-A', sensor='SEPT', data_level='l2', species='electrons', start_date=startdate, end_date=enddate, data_path=lpath, radio_spacecraft=('ahead', 'STEREO-A'))
|
|
400
|
+
Event1 = Event(spacecraft='STEREO-A', sensor='SEPT', viewing="asun", data_level='l2', species='electrons', start_date=startdate, end_date=enddate, data_path=lpath, radio_spacecraft=('ahead', 'STEREO-A'))
|
|
401
401
|
print(Event1.print_energies())
|
|
402
402
|
background_range = (datetime.datetime(2021, 10, 28, 10, 0, 0), datetime.datetime(2021, 10, 28, 12, 0, 0))
|
|
403
403
|
flux, onset_stats, onset_found, peak_flux, peak_time, fig, bg_mean = Event1.find_onset(viewing='asun', background_range=background_range, channels=[8], resample_period="5min", yscale='log', cusum_window=30)
|
|
@@ -411,12 +411,12 @@ def test_onset_spectrum_tsa_STEREOA_SEPT_e_online():
|
|
|
411
411
|
assert fig.get_axes()[0].get_title() == 'STA/SEPT 125-145 keV electrons\n5min averaging, viewing: ASUN'
|
|
412
412
|
|
|
413
413
|
# test dynamic spectrum:
|
|
414
|
-
Event1.dynamic_spectrum(view=
|
|
415
|
-
assert Event1.fig.get_axes()[0].get_title() == 'Radio & Dynamic Spectrum, STA/SEPT electrons, 2021-10-28'
|
|
414
|
+
Event1.dynamic_spectrum(view="asun")
|
|
415
|
+
assert Event1.fig.get_axes()[0].get_title() == 'Radio & Dynamic Spectrum, STA/SEPT (asun) electrons, 2021-10-28'
|
|
416
416
|
|
|
417
417
|
# test tsa plot:
|
|
418
418
|
plt.close('all') # in order to pick the right figure, make sure all previous are closed
|
|
419
|
-
Event1.tsa_plot(
|
|
419
|
+
Event1.tsa_plot(view="asun", selection=None, resample=None)
|
|
420
420
|
assert plt.figure(1).get_axes()[0].get_title() == 'STEREO-A SEPT, electrons'
|
|
421
421
|
|
|
422
422
|
|
|
@@ -448,7 +448,6 @@ def test_onset_spectrum_tsa_SOHO_EPHIN_online():
|
|
|
448
448
|
Event1.dynamic_spectrum(view=None)
|
|
449
449
|
assert Event1.fig.get_axes()[0].get_title() == 'SOHO/EPHIN electrons, 2021-10-28'
|
|
450
450
|
|
|
451
|
-
|
|
452
451
|
# test tsa plot:
|
|
453
452
|
plt.close('all') # in order to pick the right figure, make sure all previous are closed
|
|
454
453
|
Event1.tsa_plot(None, selection=(0, 4, 1), resample='5min')
|
seppy/tools/__init__.py
CHANGED
|
@@ -32,6 +32,16 @@ warnings.filterwarnings(action="ignore",
|
|
|
32
32
|
decreasing. This may lead to incorrectly calculated cell edges, in which case, please supply explicit cell edges to pcolormesh.",
|
|
33
33
|
category=UserWarning)
|
|
34
34
|
|
|
35
|
+
STEREO_SEPT_VIEWINGS = ("sun", "asun", "north", "south")
|
|
36
|
+
WIND_3DP_VIEWINGS = ("omnidirectional", '0', '1', '2', '3', '4', '5', '6', '7')
|
|
37
|
+
SOLO_EPT_VIEWINGS = ("sun", "asun", "north", "south")
|
|
38
|
+
SOLO_HET_VIEWINGS = ("sun", "asun", "north", "south")
|
|
39
|
+
SOLO_STEP_VIEWINGS = ("Pixel averaged", "Pixel 1", "Pixel 2", "Pixel 3", "Pixel 4", "Pixel 5", "Pixel 6",
|
|
40
|
+
"Pixel 7", "Pixel 8", "Pixel 9", "Pixel 10", "Pixel 11", "Pixel 12", "Pixel 13",
|
|
41
|
+
"Pixel 14", "Pixel 15")
|
|
42
|
+
PSP_EPILO_VIEWINGS = ('3', '7')
|
|
43
|
+
PSP_EPIHI_VIEWINGS = ('A', 'B')
|
|
44
|
+
|
|
35
45
|
|
|
36
46
|
class Event:
|
|
37
47
|
|
|
@@ -63,7 +73,9 @@ class Event:
|
|
|
63
73
|
self.data_path = data_path + os.sep
|
|
64
74
|
self.threshold = threshold
|
|
65
75
|
self.radio_spacecraft = radio_spacecraft # this is a 2-tuple, e.g., ("ahead", "STEREO-A")
|
|
66
|
-
|
|
76
|
+
|
|
77
|
+
# Sets the self.viewing to the given viewing
|
|
78
|
+
self.update_viewing(viewing=viewing)
|
|
67
79
|
|
|
68
80
|
self.radio_files = None
|
|
69
81
|
|
|
@@ -146,17 +158,52 @@ class Event:
|
|
|
146
158
|
}
|
|
147
159
|
|
|
148
160
|
def update_viewing(self, viewing):
|
|
161
|
+
|
|
162
|
+
invalid_viewing_msg = f"{viewing} is an invalid viewing direction for {self.spacecraft}/{self.sensor}!"
|
|
163
|
+
|
|
149
164
|
if self.spacecraft != "wind":
|
|
165
|
+
|
|
166
|
+
# Validate viewing here. It may be nonsensical and that affects choose_data() and print_energies().
|
|
167
|
+
if self.spacecraft in ("sta", "stb"):
|
|
168
|
+
if self.sensor == "sept" and viewing not in STEREO_SEPT_VIEWINGS:
|
|
169
|
+
raise ValueError(invalid_viewing_msg)
|
|
170
|
+
if self.sensor == "het" and viewing is not None:
|
|
171
|
+
raise ValueError(invalid_viewing_msg)
|
|
172
|
+
|
|
173
|
+
if self.spacecraft == "solo":
|
|
174
|
+
if self.sensor == "step" and viewing not in SOLO_STEP_VIEWINGS:
|
|
175
|
+
raise ValueError(invalid_viewing_msg)
|
|
176
|
+
if self.sensor == "ept" and viewing not in SOLO_EPT_VIEWINGS:
|
|
177
|
+
raise ValueError(invalid_viewing_msg)
|
|
178
|
+
if self.sensor == "het" and viewing not in SOLO_HET_VIEWINGS:
|
|
179
|
+
raise ValueError(invalid_viewing_msg)
|
|
180
|
+
|
|
181
|
+
if self.spacecraft == "psp":
|
|
182
|
+
if self.sensor == "isois-epilo" and viewing not in PSP_EPILO_VIEWINGS:
|
|
183
|
+
raise ValueError(invalid_viewing_msg)
|
|
184
|
+
if self.sensor == "isois-epihi" and viewing not in PSP_EPIHI_VIEWINGS:
|
|
185
|
+
raise ValueError(invalid_viewing_msg)
|
|
186
|
+
|
|
187
|
+
if self.spacecraft == "soho":
|
|
188
|
+
if viewing is not None:
|
|
189
|
+
raise ValueError(invalid_viewing_msg)
|
|
190
|
+
|
|
191
|
+
# Finally set validated viewing
|
|
150
192
|
self.viewing = viewing
|
|
193
|
+
|
|
151
194
|
else:
|
|
152
|
-
# Wind/3DP viewing directions are omnidirectional, section 0, section 1... section
|
|
195
|
+
# Wind/3DP viewing directions are omnidirectional, section 0, section 1... section 7.
|
|
153
196
|
# This catches the number or the word if omnidirectional
|
|
154
197
|
try:
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
# AttributeError is cause by initializing Event with spacecraft='Wind' and viewing=None
|
|
198
|
+
sector_direction = viewing.split(" ")[-1]
|
|
199
|
+
# AttributeError is caused by calling None.split()
|
|
158
200
|
except AttributeError:
|
|
159
|
-
|
|
201
|
+
raise ValueError(invalid_viewing_msg)
|
|
202
|
+
|
|
203
|
+
if sector_direction not in WIND_3DP_VIEWINGS:
|
|
204
|
+
raise ValueError(invalid_viewing_msg)
|
|
205
|
+
|
|
206
|
+
self.viewing = sector_direction
|
|
160
207
|
|
|
161
208
|
# I suggest we at some point erase the arguments ´spacecraft´ and ´threshold´ due to them not being used.
|
|
162
209
|
# `viewing` and `autodownload` are actually the only necessary input variables for this function, the rest
|
|
@@ -174,7 +221,7 @@ class Event:
|
|
|
174
221
|
enddate=self.end_date,
|
|
175
222
|
path=self.data_path,
|
|
176
223
|
autodownload=autodownload)
|
|
177
|
-
|
|
224
|
+
|
|
178
225
|
return df_i, df_e, meta
|
|
179
226
|
|
|
180
227
|
elif self.sensor == "step":
|
|
@@ -186,7 +233,6 @@ class Event:
|
|
|
186
233
|
path=self.data_path,
|
|
187
234
|
autodownload=autodownload)
|
|
188
235
|
|
|
189
|
-
# self.update_viewing(viewing) Why is viewing updated here?
|
|
190
236
|
return df, meta
|
|
191
237
|
|
|
192
238
|
if self.spacecraft[:2].lower() == 'st':
|
|
@@ -204,7 +250,6 @@ class Event:
|
|
|
204
250
|
path=self.data_path)
|
|
205
251
|
df_e, channels_dict_df_e = [], []
|
|
206
252
|
|
|
207
|
-
self.update_viewing(viewing)
|
|
208
253
|
return df_i, df_e, channels_dict_df_i, channels_dict_df_e
|
|
209
254
|
|
|
210
255
|
if self.species == "e":
|
|
@@ -221,7 +266,6 @@ class Event:
|
|
|
221
266
|
|
|
222
267
|
df_i, channels_dict_df_i = [], []
|
|
223
268
|
|
|
224
|
-
self.update_viewing(viewing)
|
|
225
269
|
return df_i, df_e, channels_dict_df_i, channels_dict_df_e
|
|
226
270
|
|
|
227
271
|
if self.sensor == 'het':
|
|
@@ -233,7 +277,6 @@ class Event:
|
|
|
233
277
|
pos_timestamp="center",
|
|
234
278
|
path=self.data_path)
|
|
235
279
|
|
|
236
|
-
self.update_viewing(viewing)
|
|
237
280
|
return df, meta
|
|
238
281
|
|
|
239
282
|
if self.spacecraft.lower() == 'soho':
|
|
@@ -245,7 +288,6 @@ class Event:
|
|
|
245
288
|
resample=None,
|
|
246
289
|
pos_timestamp="center")
|
|
247
290
|
|
|
248
|
-
self.update_viewing(viewing)
|
|
249
291
|
return df, meta
|
|
250
292
|
|
|
251
293
|
if self.sensor == 'ephin':
|
|
@@ -256,7 +298,6 @@ class Event:
|
|
|
256
298
|
resample=None,
|
|
257
299
|
pos_timestamp="center")
|
|
258
300
|
|
|
259
|
-
self.update_viewing(viewing)
|
|
260
301
|
return df, meta
|
|
261
302
|
|
|
262
303
|
if self.sensor in ("ephin-5", "ephin-15"):
|
|
@@ -277,7 +318,6 @@ class Event:
|
|
|
277
318
|
# - add resample_df here?
|
|
278
319
|
# - add pos_timestamp here
|
|
279
320
|
|
|
280
|
-
self.update_viewing(viewing)
|
|
281
321
|
return df, meta
|
|
282
322
|
|
|
283
323
|
if self.spacecraft.lower() == 'wind':
|
|
@@ -320,7 +360,6 @@ class Event:
|
|
|
320
360
|
path=self.data_path,
|
|
321
361
|
threshold=self.threshold)
|
|
322
362
|
|
|
323
|
-
self.update_viewing(viewing)
|
|
324
363
|
return df_omni_i, df_omni_e, df_i, df_e, meta_i, meta_e
|
|
325
364
|
|
|
326
365
|
if self.spacecraft.lower() == 'psp':
|
|
@@ -331,7 +370,6 @@ class Event:
|
|
|
331
370
|
path=self.data_path,
|
|
332
371
|
resample=None)
|
|
333
372
|
|
|
334
|
-
self.update_viewing(viewing)
|
|
335
373
|
return df, meta
|
|
336
374
|
if self.sensor.lower() == 'isois-epilo':
|
|
337
375
|
df, meta = psp_isois_load(dataset='PSP_ISOIS-EPILO_L2-PE',
|
|
@@ -342,7 +380,6 @@ class Event:
|
|
|
342
380
|
epilo_channel='F',
|
|
343
381
|
epilo_threshold=self.threshold)
|
|
344
382
|
|
|
345
|
-
self.update_viewing(viewing)
|
|
346
383
|
return df, meta
|
|
347
384
|
|
|
348
385
|
if self.spacecraft.lower() == 'bepi':
|
|
@@ -2216,7 +2253,7 @@ class Event:
|
|
|
2216
2253
|
line.set_xdata(line.get_xdata() - pd.Timedelta(seconds=timedelta_sec))
|
|
2217
2254
|
|
|
2218
2255
|
# Update the path label artist
|
|
2219
|
-
text.set_text(f"R={radial_distance_value:.2f} AU\nL = {np.round(slider.value,2)} AU")
|
|
2256
|
+
text.set_text(f"R={radial_distance_value:.2f} AU\nL = {np.round(slider.value, 2)} AU")
|
|
2220
2257
|
|
|
2221
2258
|
# Effectively this refreshes the figure
|
|
2222
2259
|
fig.canvas.draw_idle()
|
seppy/util/__init__.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import datetime
|
|
3
|
+
import psutil
|
|
3
4
|
import warnings
|
|
4
5
|
|
|
5
6
|
import astropy.constants as const
|
|
@@ -429,3 +430,14 @@ def intensity2vsd(species, kinetic_energy, intensity):
|
|
|
429
430
|
p = energy2momentum(species, kinetic_energy)
|
|
430
431
|
f = intensity / (p**2) * mass_dict[species]**3
|
|
431
432
|
return f.to(u.s**3/(u.sr*u.cm**6))
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
def jupyterhub_data_path(path_org, path_hub='/home/jovyan/data'):
|
|
436
|
+
"""
|
|
437
|
+
Checks if Notebook is run within SOLER/SERPENTINE JupyterHub. Returns the path of a common data folder if yes, and the original path if not.
|
|
438
|
+
"""
|
|
439
|
+
if (psutil.Process().parent().name() == 'jupyterhub-sing') and all(x in psutil.Process().parent().environ()['PYTHONPATH'] for x in ['/home/jovyan/serpentine/', '/home/jovyan/soler/sep_tools/']):
|
|
440
|
+
print(f"JupyterHub detected. Adjusting data path to {path_hub}")
|
|
441
|
+
return path_hub
|
|
442
|
+
else:
|
|
443
|
+
return path_org
|
seppy/version.py
CHANGED
|
@@ -1,37 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: seppy
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: SEPpy
|
|
5
5
|
Author-email: Jan Gieseler <jan.gieseler@utu.fi>
|
|
6
|
-
License:
|
|
7
|
-
All rights reserved.
|
|
8
|
-
|
|
9
|
-
Redistribution and use in source and binary forms, with or without modification,
|
|
10
|
-
are permitted provided that the following conditions are met:
|
|
11
|
-
|
|
12
|
-
* Redistributions of source code must retain the above copyright notice, this
|
|
13
|
-
list of conditions and the following disclaimer.
|
|
14
|
-
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
15
|
-
list of conditions and the following disclaimer in the documentation and/or
|
|
16
|
-
other materials provided with the distribution.
|
|
17
|
-
* Neither the name of SEPpy nor the names of its contributors may be
|
|
18
|
-
used to endorse or promote products derived from this software without
|
|
19
|
-
specific prior written permission.
|
|
20
|
-
|
|
21
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
22
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
23
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
24
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
25
|
-
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
26
|
-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
27
|
-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
28
|
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
29
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
30
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
31
|
-
|
|
6
|
+
License-Expression: BSD-3-Clause
|
|
32
7
|
Project-URL: repository, https://github.com/serpentine-h2020/SEPpy
|
|
33
8
|
Classifier: Intended Audience :: Science/Research
|
|
34
|
-
Classifier: License :: OSI Approved :: BSD License
|
|
35
9
|
Classifier: Natural Language :: English
|
|
36
10
|
Classifier: Operating System :: OS Independent
|
|
37
11
|
Classifier: Programming Language :: Python
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
seppy/__init__.py,sha256=hk6JGncma6FHC5b8g5ZelvpsF1Jo-3Pz_3MneUcNWMg,156
|
|
2
|
-
seppy/_version.py,sha256
|
|
3
|
-
seppy/version.py,sha256=
|
|
2
|
+
seppy/_version.py,sha256=UoNvMtd4wCG76RwoSpNCUtaFyTwakGcZolfjXzNVSMY,511
|
|
3
|
+
seppy/version.py,sha256=s9jrGGO9QQFBgDmuFff6kUkpz-CIO0Sx5J3q0nn2YLU,531
|
|
4
4
|
seppy/data/test/20230719_side0.csv,sha256=0htTQcdQydRc92bkO26lxK8tDRSeN6uov13VfsqmUFQ,72368
|
|
5
5
|
seppy/data/test/20230719_side1.csv,sha256=iHCfHmOIltJatncWpns_zq3ym_-2yRu0twmDvQDbmJw,72368
|
|
6
6
|
seppy/data/test/20230719_side2.csv,sha256=eYyEQX5fNDO4E57KwKN3bHs6u5-lHaAhIHt-3f20Urg,72368
|
|
@@ -11,22 +11,22 @@ seppy/data/test/solo_l2_mag-rtn-normal-1-minute_20210712_v01.cdf,sha256=Tc_-3YQM
|
|
|
11
11
|
seppy/data/test/sta_l1_het_20211028_v01.cdf,sha256=429TIPXSQI5heQVNqyRYLF7HUDZPByzk-xYf9IzSJ0U,215082
|
|
12
12
|
seppy/data/test/wi_sfsp_3dp_00000000_v01.cdf,sha256=ifAM0FiB2tepHmlpsqbotJMyQqSB3bwpPcKD6VhukFA,30939
|
|
13
13
|
seppy/data/test/wi_sfsp_3dp_20200213_v01.cdf,sha256=UiKcBPcWZkh3KIBigoZubTJ3Fw90E8p7XhbA9uW6VWk,67008
|
|
14
|
-
seppy/loader/psp.py,sha256=
|
|
14
|
+
seppy/loader/psp.py,sha256=cOunehm9gvUl9hVF2CgAqje1aA6r4HGhvEnHkvddFyU,32005
|
|
15
15
|
seppy/loader/soho.py,sha256=e6SzUD_WxUiaAMlWQcTGVvdER4Wv9rI-PtCCEoUHVRw,20290
|
|
16
16
|
seppy/loader/solo.py,sha256=Nst2ZJU2yH5NHsB6M_69ryVfzt978hbmqhxaHZJREVg,3054
|
|
17
|
-
seppy/loader/stereo.py,sha256=
|
|
17
|
+
seppy/loader/stereo.py,sha256=dkfxPiwCFmn9UfD0QYoIBW6rx6-faXjjk8IU2WMN-j4,24823
|
|
18
18
|
seppy/loader/wind.py,sha256=LC-pbjbhpgTowsR20mflk35ebb2lOZClMyJ94aZ-ecQ,18987
|
|
19
19
|
seppy/tests/__init__.py,sha256=W9JYSayCPwoTmtRpjYCkKnnbPQqpf26ANqXe52YASmk,44
|
|
20
|
-
seppy/tests/test_loader.py,sha256=
|
|
20
|
+
seppy/tests/test_loader.py,sha256=OZc4sKn2OZcCrmu5awMB_nWdWkbuFoAonD5Amlaxk4g,8254
|
|
21
21
|
seppy/tests/test_time_shift_analysis.ipynb,sha256=4DIKqqRI_AdburzP9RnMwdOAvZovpgON2TJscDABIco,7904
|
|
22
|
-
seppy/tests/test_tools.py,sha256=
|
|
22
|
+
seppy/tests/test_tools.py,sha256=qSTAtaZTEw_oz32BsSzYX5BFNowJooWX6p-QEkOboiU,31685
|
|
23
23
|
seppy/tests/tsa_org.png,sha256=80xrGx1unP1iXGLhPsKHHqMLrg2qhivsGh532hBVCqM,138501
|
|
24
|
-
seppy/tools/__init__.py,sha256=
|
|
24
|
+
seppy/tools/__init__.py,sha256=GwxGektqXHmqbuFCAW66XreGOp0PJImqujN0swlBmKE,117677
|
|
25
25
|
seppy/tools/swaves.py,sha256=OcohPXLko0ik9FLyYMVkYxI75W4XzOKvQ2Ylnwi-wlQ,3139
|
|
26
26
|
seppy/tools/widgets.py,sha256=atQj9vvus0UgrUV6vlPcTdjpaidnERUevOp6FUmGLSI,6820
|
|
27
|
-
seppy/util/__init__.py,sha256=
|
|
28
|
-
seppy-0.1.
|
|
29
|
-
seppy-0.1.
|
|
30
|
-
seppy-0.1.
|
|
31
|
-
seppy-0.1.
|
|
32
|
-
seppy-0.1.
|
|
27
|
+
seppy/util/__init__.py,sha256=49gq3JkFcpZw65HPNslUnMjJ1wdVtJc-bbymPhb78I4,15826
|
|
28
|
+
seppy-0.2.1.dist-info/licenses/LICENSE.rst,sha256=O5RzTapB1HKcaagHaoNKHBvjkzU6Kh1Ax6HZ_9Q4-kI,1520
|
|
29
|
+
seppy-0.2.1.dist-info/METADATA,sha256=Lw_qh2vBRO2Qt1UdwyvDofJNwUudbCcrwzpwO0nLFJc,4670
|
|
30
|
+
seppy-0.2.1.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
|
|
31
|
+
seppy-0.2.1.dist-info/top_level.txt,sha256=G2Op1GREPmbCX81isNhYY_7ZZyLWLIm-MJC04J4Fgc4,6
|
|
32
|
+
seppy-0.2.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|