seppy 0.1.18__py3-none-any.whl → 0.2.0__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/__init__.py +3 -6
- seppy/_version.py +21 -0
- seppy/loader/psp.py +27 -21
- seppy/loader/stereo.py +16 -11
- seppy/loader/wind.py +1 -1
- seppy/tests/__init__.py +0 -1
- seppy/tests/test_loader.py +6 -6
- seppy/tests/test_time_shift_analysis.ipynb +286 -0
- seppy/tests/test_tools.py +13 -14
- seppy/tests/tsa_org.png +0 -0
- seppy/tools/__init__.py +58 -21
- seppy/version.py +15 -6
- {seppy-0.1.18.dist-info → seppy-0.2.0.dist-info}/METADATA +16 -13
- {seppy-0.1.18.dist-info → seppy-0.2.0.dist-info}/RECORD +17 -14
- {seppy-0.1.18.dist-info → seppy-0.2.0.dist-info}/WHEEL +1 -1
- seppy-0.2.0.dist-info/licenses/LICENSE.rst +29 -0
- seppy-0.1.18.dist-info/LICENSE.rst +0 -25
- {seppy-0.1.18.dist-info → seppy-0.2.0.dist-info}/top_level.txt +0 -0
seppy/__init__.py
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
# Licensed under a 3-clause BSD style license - see LICENSE.rst
|
|
2
1
|
|
|
3
|
-
from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
except DistributionNotFound:
|
|
7
|
-
pass # package is not installed
|
|
2
|
+
from .version import version as __version__
|
|
3
|
+
|
|
4
|
+
# __all__ = [] # defines which functions, variables etc. will be loaded when running "from pyonset import *"
|
seppy/_version.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# file generated by setuptools-scm
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
|
|
4
|
+
__all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
|
|
5
|
+
|
|
6
|
+
TYPE_CHECKING = False
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
from typing import Tuple
|
|
9
|
+
from typing import Union
|
|
10
|
+
|
|
11
|
+
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
12
|
+
else:
|
|
13
|
+
VERSION_TUPLE = object
|
|
14
|
+
|
|
15
|
+
version: str
|
|
16
|
+
__version__: str
|
|
17
|
+
__version_tuple__: VERSION_TUPLE
|
|
18
|
+
version_tuple: VERSION_TUPLE
|
|
19
|
+
|
|
20
|
+
__version__ = version = '0.2.0'
|
|
21
|
+
__version_tuple__ = version_tuple = (0, 2, 0)
|
seppy/loader/psp.py
CHANGED
|
@@ -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':
|
|
@@ -386,7 +392,7 @@ def calc_av_en_flux_PSP_EPIHI(df, energies, en_channel, species, instrument, vie
|
|
|
386
392
|
df : pd.DataFrame DataFrame containing HET data
|
|
387
393
|
DataFrame containing PSP data
|
|
388
394
|
energies : dict
|
|
389
|
-
Energy dict returned from
|
|
395
|
+
Energy dict returned from psp_load
|
|
390
396
|
en_channel : int or list
|
|
391
397
|
energy channel number(s) to be used
|
|
392
398
|
species : string
|
|
@@ -435,7 +441,7 @@ def calc_av_en_flux_PSP_EPIHI(df, energies, en_channel, species, instrument, vie
|
|
|
435
441
|
flux_out = pd.DataFrame({'flux': df[f'{viewing.upper()}_{flux_key}_{en_channel}']}, index=df.index)
|
|
436
442
|
else:
|
|
437
443
|
flux_out = pd.DataFrame({'flux': df[f'{viewing.upper()}_{flux_key}_{en_channel}']}, index=df.index)
|
|
438
|
-
en_channel_string = en_str[en_channel][0]
|
|
444
|
+
en_channel_string = en_str[en_channel].flat[0]
|
|
439
445
|
# replace multiple whitespaces with single ones
|
|
440
446
|
en_channel_string = ' '.join(en_channel_string.split())
|
|
441
447
|
return flux_out, en_channel_string
|
|
@@ -453,7 +459,7 @@ def calc_av_en_flux_PSP_EPILO(df, en_dict, en_channel, species, mode, chan, view
|
|
|
453
459
|
df : pd.DataFrame DataFrame containing HET data
|
|
454
460
|
DataFrame containing PSP data
|
|
455
461
|
energies : dict
|
|
456
|
-
Energy dict returned from
|
|
462
|
+
Energy dict returned from psp_load
|
|
457
463
|
en_channel : int or list
|
|
458
464
|
energy channel number(s) to be used
|
|
459
465
|
species : string
|
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]
|
|
@@ -504,6 +507,8 @@ def calc_av_en_flux_HET(df, channels_dict_df, avg_channels, species):
|
|
|
504
507
|
avg_channels : list of int, optional
|
|
505
508
|
averaging channels m to n if [m, n] is provided (both integers), by default None
|
|
506
509
|
"""
|
|
510
|
+
if type(avg_channels) is int:
|
|
511
|
+
avg_channels = [avg_channels]
|
|
507
512
|
# calculation of total delta-E for averaging multiple channels:
|
|
508
513
|
if len(avg_channels) > 1:
|
|
509
514
|
DE_total = channels_dict_df.loc[avg_channels[0]:avg_channels[-1]]['DE'].sum()
|
seppy/loader/wind.py
CHANGED
|
@@ -34,7 +34,7 @@ def _download_metafile(dataset, path=None):
|
|
|
34
34
|
downloaded_file = pooch.retrieve(url=url, known_hash=None, fname=fname, path=path, progressbar=True)
|
|
35
35
|
except ModuleNotFoundError:
|
|
36
36
|
downloaded_file = pooch.retrieve(url=url, known_hash=None, fname=fname, path=path, progressbar=False)
|
|
37
|
-
|
|
37
|
+
#
|
|
38
38
|
return downloaded_file
|
|
39
39
|
|
|
40
40
|
|
seppy/tests/__init__.py
CHANGED
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'
|
|
@@ -143,8 +143,8 @@ def test_stereo_sept_load_offline():
|
|
|
143
143
|
|
|
144
144
|
def test_wind3dp_load_online():
|
|
145
145
|
df, meta = wind3dp_load(dataset="WI_SFPD_3DP",
|
|
146
|
-
startdate="2021/04/
|
|
147
|
-
enddate="2021/04/
|
|
146
|
+
startdate="2021/04/15",
|
|
147
|
+
enddate="2021/04/17",
|
|
148
148
|
resample='1min',
|
|
149
149
|
multi_index=True,
|
|
150
150
|
path=None)
|
|
@@ -152,7 +152,7 @@ def test_wind3dp_load_online():
|
|
|
152
152
|
assert df.shape == (2880, 76)
|
|
153
153
|
assert meta['FLUX_LABELS'].flatten()[0] == 'ElecNoFlux_Ch1_Often~27keV '
|
|
154
154
|
# Check that fillvals are replaced by NaN
|
|
155
|
-
assert np.sum(np.isnan(df['FLUX_E0', 'FLUX_E0_P0'])) ==
|
|
155
|
+
assert np.sum(np.isnan(df['FLUX_E0', 'FLUX_E0_P0'])) == 129
|
|
156
156
|
|
|
157
157
|
|
|
158
158
|
def test_wind3dp_load_offline():
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "markdown",
|
|
5
|
+
"id": "dff1322b",
|
|
6
|
+
"metadata": {},
|
|
7
|
+
"source": [
|
|
8
|
+
"# Visual time shift analysis\n",
|
|
9
|
+
"\n",
|
|
10
|
+
"<div class=\"alert alert-block alert-success\">\n",
|
|
11
|
+
"<b>Please refer to the following paper for more information and cite it if you use this tool in your publication:</b><br><br>\n",
|
|
12
|
+
"Palmroos, C., Gieseler, J., Dresing N., Morosan D. E., Asvestari E., Yli-Laurila A., Price D. J., Valkila S., Vainio R. (2022).\n",
|
|
13
|
+
"Solar energetic particle time series analysis with Python. <i>Front. Astronomy Space Sci.</i> 9. <a href=\"https://doi.org/10.3389/fspas.2022.1073578\">doi:10.3389/fspas.2022.1073578</a>\n",
|
|
14
|
+
"</div>"
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"cell_type": "code",
|
|
19
|
+
"execution_count": 1,
|
|
20
|
+
"id": "5e05e989",
|
|
21
|
+
"metadata": {},
|
|
22
|
+
"outputs": [],
|
|
23
|
+
"source": [
|
|
24
|
+
"# add parent-parent dir to path so that seppy can be imported from there\n",
|
|
25
|
+
"import sys \n",
|
|
26
|
+
"sys.path.append('../../')"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"cell_type": "markdown",
|
|
31
|
+
"id": "0eb22e28",
|
|
32
|
+
"metadata": {},
|
|
33
|
+
"source": [
|
|
34
|
+
"#### First import the necessary library"
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"cell_type": "code",
|
|
39
|
+
"execution_count": 2,
|
|
40
|
+
"id": "2a6f4f3b",
|
|
41
|
+
"metadata": {},
|
|
42
|
+
"outputs": [],
|
|
43
|
+
"source": [
|
|
44
|
+
"from seppy.tools import Event\n",
|
|
45
|
+
"import seppy.tools.widgets as w\n",
|
|
46
|
+
"import datetime, os"
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"cell_type": "markdown",
|
|
51
|
+
"id": "9b30a708",
|
|
52
|
+
"metadata": {},
|
|
53
|
+
"source": [
|
|
54
|
+
"#### Choose spacecraft, sensor, viewing direction and particle species from the drop-down menu:"
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"cell_type": "code",
|
|
59
|
+
"execution_count": 3,
|
|
60
|
+
"id": "f0f78c1e",
|
|
61
|
+
"metadata": {},
|
|
62
|
+
"outputs": [
|
|
63
|
+
{
|
|
64
|
+
"data": {
|
|
65
|
+
"application/vnd.jupyter.widget-view+json": {
|
|
66
|
+
"model_id": "4e18dbfeecb545ce9937822840229059",
|
|
67
|
+
"version_major": 2,
|
|
68
|
+
"version_minor": 0
|
|
69
|
+
},
|
|
70
|
+
"text/plain": [
|
|
71
|
+
"Dropdown(description='Spacecraft:', options=('PSP', 'SOHO', 'Solar Orbiter', 'STEREO-A', 'STEREO-B', 'Wind'), …"
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
"metadata": {},
|
|
75
|
+
"output_type": "display_data"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"data": {
|
|
79
|
+
"application/vnd.jupyter.widget-view+json": {
|
|
80
|
+
"model_id": "e4d208c9d56247589e2f6d6e7cdce78c",
|
|
81
|
+
"version_major": 2,
|
|
82
|
+
"version_minor": 0
|
|
83
|
+
},
|
|
84
|
+
"text/plain": [
|
|
85
|
+
"Dropdown(description='Sensor:', options=('isois-epihi', 'isois-epilo'), value='isois-epihi')"
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
"metadata": {},
|
|
89
|
+
"output_type": "display_data"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"data": {
|
|
93
|
+
"application/vnd.jupyter.widget-view+json": {
|
|
94
|
+
"model_id": "879e5a4a10fa4cbdaf5b80623ebff13e",
|
|
95
|
+
"version_major": 2,
|
|
96
|
+
"version_minor": 0
|
|
97
|
+
},
|
|
98
|
+
"text/plain": [
|
|
99
|
+
"Dropdown(description='Viewing:', options=('A', 'B'), value='A')"
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
"metadata": {},
|
|
103
|
+
"output_type": "display_data"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"data": {
|
|
107
|
+
"application/vnd.jupyter.widget-view+json": {
|
|
108
|
+
"model_id": "8b70ac3184b04b1e9f9cbc2291682e66",
|
|
109
|
+
"version_major": 2,
|
|
110
|
+
"version_minor": 0
|
|
111
|
+
},
|
|
112
|
+
"text/plain": [
|
|
113
|
+
"Dropdown(description='Species:', options=('protons', 'electrons'), value='protons')"
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
"metadata": {},
|
|
117
|
+
"output_type": "display_data"
|
|
118
|
+
}
|
|
119
|
+
],
|
|
120
|
+
"source": [
|
|
121
|
+
"display(w.spacecraft_drop, w.sensor_drop, w.view_drop, w.species_drop)"
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"cell_type": "code",
|
|
126
|
+
"execution_count": 4,
|
|
127
|
+
"id": "cab4dfae",
|
|
128
|
+
"metadata": {},
|
|
129
|
+
"outputs": [],
|
|
130
|
+
"source": [
|
|
131
|
+
"# overwrite GUI returns for testing\n",
|
|
132
|
+
"w.spacecraft_drop.value = 'SOHO'\n",
|
|
133
|
+
"w.sensor_drop.value = 'ERNE-HED'\n",
|
|
134
|
+
"w.view_drop.value = None\n",
|
|
135
|
+
"w.species_drop.value = 'protons'"
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"cell_type": "markdown",
|
|
140
|
+
"id": "f72fd6b5",
|
|
141
|
+
"metadata": {},
|
|
142
|
+
"source": [
|
|
143
|
+
"#### Set the data path and date range to load data:"
|
|
144
|
+
]
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"cell_type": "code",
|
|
148
|
+
"execution_count": 5,
|
|
149
|
+
"id": "c8b4570e",
|
|
150
|
+
"metadata": {},
|
|
151
|
+
"outputs": [],
|
|
152
|
+
"source": [
|
|
153
|
+
"# The path to where data is located / to be downloaded (by default the current directory)\n",
|
|
154
|
+
"data_path = f\"{os.getcwd()}/data/\"\n",
|
|
155
|
+
"\n",
|
|
156
|
+
"# Format of date: year, month, day\n",
|
|
157
|
+
"startdate = datetime.date(2024, 5, 10)\n",
|
|
158
|
+
"enddate = datetime.date(2024, 5, 11)\n",
|
|
159
|
+
"\n",
|
|
160
|
+
"# Set the averaging period, or leave to None to not resample data\n",
|
|
161
|
+
"# averaging should be a pandas-compatible string, e.g. '1h', '2min', '15s'\n",
|
|
162
|
+
"averaging = '1min' #\"1min\""
|
|
163
|
+
]
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"cell_type": "code",
|
|
167
|
+
"execution_count": 6,
|
|
168
|
+
"id": "b9184561",
|
|
169
|
+
"metadata": {},
|
|
170
|
+
"outputs": [],
|
|
171
|
+
"source": [
|
|
172
|
+
"# Get event data:\n",
|
|
173
|
+
"Event_class = Event(spacecraft=w.spacecraft_drop.value, sensor=w.sensor_drop.value, \n",
|
|
174
|
+
" data_level='l2', species = w.species_drop.value, viewing=w.view_drop.value,\n",
|
|
175
|
+
" start_date=startdate, end_date=enddate, \n",
|
|
176
|
+
" data_path=data_path)"
|
|
177
|
+
]
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"cell_type": "code",
|
|
181
|
+
"execution_count": 7,
|
|
182
|
+
"id": "af9b46b3",
|
|
183
|
+
"metadata": {},
|
|
184
|
+
"outputs": [],
|
|
185
|
+
"source": [
|
|
186
|
+
"# Select the channels to be plotted (first, last, step), end-exclusively (use None to choose all)\n",
|
|
187
|
+
"channels = (2, 8, 1) #(1, 11, 2)"
|
|
188
|
+
]
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"cell_type": "code",
|
|
192
|
+
"execution_count": null,
|
|
193
|
+
"id": "3820516e",
|
|
194
|
+
"metadata": {},
|
|
195
|
+
"outputs": [],
|
|
196
|
+
"source": [
|
|
197
|
+
"%matplotlib widget\n",
|
|
198
|
+
"Event_class.tsa_plot(w.view_drop.value, selection=channels, resample=averaging)"
|
|
199
|
+
]
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"cell_type": "markdown",
|
|
203
|
+
"id": "fb9dd2f1",
|
|
204
|
+
"metadata": {},
|
|
205
|
+
"source": [
|
|
206
|
+
"#### Saving the figure is done in the plot window, by hovering mouse to the left side of the plot and clicking \"Download plot\""
|
|
207
|
+
]
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"cell_type": "code",
|
|
211
|
+
"execution_count": 9,
|
|
212
|
+
"id": "a17ff153",
|
|
213
|
+
"metadata": {},
|
|
214
|
+
"outputs": [],
|
|
215
|
+
"source": [
|
|
216
|
+
"import matplotlib.pyplot as plt\n",
|
|
217
|
+
"plt.savefig('tsa_test.png')"
|
|
218
|
+
]
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"cell_type": "markdown",
|
|
222
|
+
"id": "fbc35c0b",
|
|
223
|
+
"metadata": {},
|
|
224
|
+
"source": [
|
|
225
|
+
"---\n",
|
|
226
|
+
"## FAQ / Problems <a class=\"anchor\" id=\"faq\"></a>\n",
|
|
227
|
+
"\n",
|
|
228
|
+
"- **I get some error about missing data, or that the data is broken, or something I don't understand.**\n",
|
|
229
|
+
"\n",
|
|
230
|
+
"Most times such a problem originates in an incomplete download of the corresponding data file. The easiest approach to solve that problem is to delete the file and run the code again to re-download it. \n",
|
|
231
|
+
"To do this, first check if a `path` has been provided. If `path` has *not* been defined (or as `None`), the standard `path` for SunPy downloads should have been used. You can obtain it by running the following code cell:\n"
|
|
232
|
+
]
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
"cell_type": "code",
|
|
236
|
+
"execution_count": 2,
|
|
237
|
+
"id": "5a98af1b",
|
|
238
|
+
"metadata": {},
|
|
239
|
+
"outputs": [
|
|
240
|
+
{
|
|
241
|
+
"data": {
|
|
242
|
+
"text/plain": [
|
|
243
|
+
"'/home/gieseler/sunpy/data'"
|
|
244
|
+
]
|
|
245
|
+
},
|
|
246
|
+
"execution_count": 2,
|
|
247
|
+
"metadata": {},
|
|
248
|
+
"output_type": "execute_result"
|
|
249
|
+
}
|
|
250
|
+
],
|
|
251
|
+
"source": [
|
|
252
|
+
"import sunpy \n",
|
|
253
|
+
"sunpy.config.get('downloads', 'download_dir')"
|
|
254
|
+
]
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"cell_type": "markdown",
|
|
258
|
+
"id": "4ebec703",
|
|
259
|
+
"metadata": {},
|
|
260
|
+
"source": [
|
|
261
|
+
"Open the corresponding directory in your file browser and look for the corresponding data file. Usually it's easiest to order the files by modification date, so that the latest modified file (which usually should be the culprit) comes first. Then delete the corresponding file(s), and run the code again."
|
|
262
|
+
]
|
|
263
|
+
}
|
|
264
|
+
],
|
|
265
|
+
"metadata": {
|
|
266
|
+
"kernelspec": {
|
|
267
|
+
"display_name": "Python 3 (ipykernel)",
|
|
268
|
+
"language": "python",
|
|
269
|
+
"name": "python3"
|
|
270
|
+
},
|
|
271
|
+
"language_info": {
|
|
272
|
+
"codemirror_mode": {
|
|
273
|
+
"name": "ipython",
|
|
274
|
+
"version": 3
|
|
275
|
+
},
|
|
276
|
+
"file_extension": ".py",
|
|
277
|
+
"mimetype": "text/x-python",
|
|
278
|
+
"name": "python",
|
|
279
|
+
"nbconvert_exporter": "python",
|
|
280
|
+
"pygments_lexer": "ipython3",
|
|
281
|
+
"version": "3.12.5"
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
"nbformat": 4,
|
|
285
|
+
"nbformat_minor": 5
|
|
286
|
+
}
|
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/tests/tsa_org.png
ADDED
|
Binary file
|
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':
|
|
@@ -1782,7 +1819,7 @@ class Event:
|
|
|
1782
1819
|
ax[DYN_SPEC_INDX].yaxis.set_major_formatter(ScalarFormatter(useMathText=False))
|
|
1783
1820
|
|
|
1784
1821
|
# gets rid of minor ticks and labels
|
|
1785
|
-
ax[DYN_SPEC_INDX].yaxis.
|
|
1822
|
+
ax[DYN_SPEC_INDX].yaxis.minorticks_off()
|
|
1786
1823
|
ax[DYN_SPEC_INDX].yaxis.set_tick_params(length=12., width=2.0, which='major')
|
|
1787
1824
|
|
|
1788
1825
|
# x-axis settings
|
|
@@ -1898,7 +1935,7 @@ class Event:
|
|
|
1898
1935
|
ax[DYN_SPEC_INDX].set_ylabel(f"Energy [{y_unit}]")
|
|
1899
1936
|
|
|
1900
1937
|
# Introduce minor ticks back
|
|
1901
|
-
ax[DYN_SPEC_INDX].yaxis.set_tick_params(length=8., width=1.2, which='minor'
|
|
1938
|
+
ax[DYN_SPEC_INDX].yaxis.set_tick_params(length=8., width=1.2, which='minor')
|
|
1902
1939
|
|
|
1903
1940
|
fig.set_size_inches((27, 18))
|
|
1904
1941
|
|
|
@@ -2061,7 +2098,7 @@ class Event:
|
|
|
2061
2098
|
shift_coefficients = [METERS_PER_AU/v for v in particle_speeds]
|
|
2062
2099
|
|
|
2063
2100
|
stepsize = 0.05
|
|
2064
|
-
min_slider_val, max_slider_val = 0.0,
|
|
2101
|
+
min_slider_val, max_slider_val = 0.0, 10
|
|
2065
2102
|
|
|
2066
2103
|
# Only the selected channels will be plotted
|
|
2067
2104
|
if selection is not None:
|
|
@@ -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/version.py
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
#
|
|
1
|
+
# NOTE: First try _dev.scm_version if it exists and setuptools_scm is installed
|
|
2
|
+
# This file is not included in wheels/tarballs, so otherwise it will
|
|
3
|
+
# fall back on the generated _version module.
|
|
4
4
|
try:
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
try:
|
|
6
|
+
from ._dev.scm_version import version
|
|
7
|
+
except ImportError:
|
|
8
|
+
from ._version import version
|
|
7
9
|
except Exception:
|
|
8
|
-
|
|
10
|
+
import warnings
|
|
11
|
+
|
|
12
|
+
warnings.warn(
|
|
13
|
+
f'could not determine {__name__.split(".")[0]} package version; this indicates a broken installation'
|
|
14
|
+
)
|
|
15
|
+
del warnings
|
|
16
|
+
|
|
17
|
+
version = '0.2.0'
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: seppy
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: SEPpy
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
License: BSD 3-clause
|
|
5
|
+
Author-email: Jan Gieseler <jan.gieseler@utu.fi>
|
|
6
|
+
License-Expression: BSD-3-Clause
|
|
7
|
+
Project-URL: repository, https://github.com/serpentine-h2020/SEPpy
|
|
9
8
|
Classifier: Intended Audience :: Science/Research
|
|
10
|
-
Classifier: License :: OSI Approved :: BSD License
|
|
11
9
|
Classifier: Natural Language :: English
|
|
12
10
|
Classifier: Operating System :: OS Independent
|
|
13
11
|
Classifier: Programming Language :: Python
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
15
12
|
Classifier: Programming Language :: Python :: 3.9
|
|
16
13
|
Classifier: Programming Language :: Python :: 3.10
|
|
17
14
|
Classifier: Programming Language :: Python :: 3.11
|
|
18
15
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
17
|
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
20
|
-
Requires-Python: >=3.
|
|
21
|
-
|
|
18
|
+
Requires-Python: >=3.9
|
|
19
|
+
Description-Content-Type: text/x-rst
|
|
20
|
+
License-File: LICENSE.rst
|
|
22
21
|
Requires-Dist: astropy
|
|
23
22
|
Requires-Dist: astroquery
|
|
24
23
|
Requires-Dist: bs4
|
|
25
24
|
Requires-Dist: cdflib
|
|
25
|
+
Requires-Dist: ipympl
|
|
26
26
|
Requires-Dist: ipywidgets
|
|
27
27
|
Requires-Dist: matplotlib
|
|
28
28
|
Requires-Dist: mpl-animators>=1.0.0
|
|
@@ -32,7 +32,6 @@ Requires-Dist: pooch
|
|
|
32
32
|
Requires-Dist: requests
|
|
33
33
|
Requires-Dist: solo-epd-loader
|
|
34
34
|
Requires-Dist: sunpy>=4.1.0
|
|
35
|
-
Provides-Extra: all
|
|
36
35
|
Provides-Extra: test
|
|
37
36
|
Requires-Dist: pytest; extra == "test"
|
|
38
37
|
Requires-Dist: pytest-doctestplus; extra == "test"
|
|
@@ -40,11 +39,12 @@ Requires-Dist: pytest-cov; extra == "test"
|
|
|
40
39
|
Provides-Extra: docs
|
|
41
40
|
Requires-Dist: sphinx; extra == "docs"
|
|
42
41
|
Requires-Dist: sphinx-automodapi; extra == "docs"
|
|
42
|
+
Dynamic: license-file
|
|
43
43
|
|
|
44
44
|
seppy
|
|
45
45
|
=====
|
|
46
46
|
|
|
47
|
-
|pypi Version| |python version| |pytest| |codecov| |zenodo doi|
|
|
47
|
+
|pypi Version| |python version| |pytest| |codecov| |repostatus| |zenodo doi|
|
|
48
48
|
|
|
49
49
|
.. |pypi Version| image:: https://img.shields.io/pypi/v/seppy?style=flat&logo=pypi
|
|
50
50
|
:target: https://pypi.org/project/seppy/
|
|
@@ -54,6 +54,9 @@ seppy
|
|
|
54
54
|
.. |pytest| image:: https://github.com/serpentine-h2020/SEPpy/actions/workflows/pytest.yml/badge.svg?branch=main
|
|
55
55
|
.. |codecov| image:: https://codecov.io/gh/serpentine-h2020/SEPpy/branch/main/graph/badge.svg?token=FYELM4Y7DF
|
|
56
56
|
:target: https://codecov.io/gh/serpentine-h2020/SEPpy
|
|
57
|
+
.. |repostatus| image:: https://www.repostatus.org/badges/latest/active.svg
|
|
58
|
+
:alt: Project Status: Active – The project has reached a stable, usable state and is being actively developed.
|
|
59
|
+
:target: https://www.repostatus.org/#active
|
|
57
60
|
|
|
58
61
|
*This package is in development status! Intended for internal use only, as the syntax is in a floating state and the documentation is incomplete.*
|
|
59
62
|
|
|
@@ -77,7 +80,7 @@ This software is provided "as is", with no guarantee. It is no official data sou
|
|
|
77
80
|
Installation
|
|
78
81
|
------------
|
|
79
82
|
|
|
80
|
-
seppy requires python >= 3.
|
|
83
|
+
seppy requires python >= 3.9.
|
|
81
84
|
|
|
82
85
|
It can be installed from `PyPI <https://pypi.org/project/seppy/>`_ using:
|
|
83
86
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
seppy/__init__.py,sha256=
|
|
2
|
-
seppy/
|
|
1
|
+
seppy/__init__.py,sha256=hk6JGncma6FHC5b8g5ZelvpsF1Jo-3Pz_3MneUcNWMg,156
|
|
2
|
+
seppy/_version.py,sha256=iB5DfB5V6YB5Wo4JmvS-txT42QtmGaWcWp3udRT7zCI,511
|
|
3
|
+
seppy/version.py,sha256=PZgPleE6XAqu6r2weGUc7loda2-omM0TFm57cWOPdnA,531
|
|
3
4
|
seppy/data/test/20230719_side0.csv,sha256=0htTQcdQydRc92bkO26lxK8tDRSeN6uov13VfsqmUFQ,72368
|
|
4
5
|
seppy/data/test/20230719_side1.csv,sha256=iHCfHmOIltJatncWpns_zq3ym_-2yRu0twmDvQDbmJw,72368
|
|
5
6
|
seppy/data/test/20230719_side2.csv,sha256=eYyEQX5fNDO4E57KwKN3bHs6u5-lHaAhIHt-3f20Urg,72368
|
|
@@ -10,20 +11,22 @@ seppy/data/test/solo_l2_mag-rtn-normal-1-minute_20210712_v01.cdf,sha256=Tc_-3YQM
|
|
|
10
11
|
seppy/data/test/sta_l1_het_20211028_v01.cdf,sha256=429TIPXSQI5heQVNqyRYLF7HUDZPByzk-xYf9IzSJ0U,215082
|
|
11
12
|
seppy/data/test/wi_sfsp_3dp_00000000_v01.cdf,sha256=ifAM0FiB2tepHmlpsqbotJMyQqSB3bwpPcKD6VhukFA,30939
|
|
12
13
|
seppy/data/test/wi_sfsp_3dp_20200213_v01.cdf,sha256=UiKcBPcWZkh3KIBigoZubTJ3Fw90E8p7XhbA9uW6VWk,67008
|
|
13
|
-
seppy/loader/psp.py,sha256=
|
|
14
|
+
seppy/loader/psp.py,sha256=jIXzuOBL5Fi8LMJTqltGrpmlUauvtb0XXqqvO8UtPbE,32045
|
|
14
15
|
seppy/loader/soho.py,sha256=e6SzUD_WxUiaAMlWQcTGVvdER4Wv9rI-PtCCEoUHVRw,20290
|
|
15
16
|
seppy/loader/solo.py,sha256=Nst2ZJU2yH5NHsB6M_69ryVfzt978hbmqhxaHZJREVg,3054
|
|
16
|
-
seppy/loader/stereo.py,sha256=
|
|
17
|
-
seppy/loader/wind.py,sha256=
|
|
18
|
-
seppy/tests/__init__.py,sha256=
|
|
19
|
-
seppy/tests/test_loader.py,sha256=
|
|
20
|
-
seppy/tests/
|
|
21
|
-
seppy/
|
|
17
|
+
seppy/loader/stereo.py,sha256=dkfxPiwCFmn9UfD0QYoIBW6rx6-faXjjk8IU2WMN-j4,24823
|
|
18
|
+
seppy/loader/wind.py,sha256=LC-pbjbhpgTowsR20mflk35ebb2lOZClMyJ94aZ-ecQ,18987
|
|
19
|
+
seppy/tests/__init__.py,sha256=W9JYSayCPwoTmtRpjYCkKnnbPQqpf26ANqXe52YASmk,44
|
|
20
|
+
seppy/tests/test_loader.py,sha256=OZc4sKn2OZcCrmu5awMB_nWdWkbuFoAonD5Amlaxk4g,8254
|
|
21
|
+
seppy/tests/test_time_shift_analysis.ipynb,sha256=4DIKqqRI_AdburzP9RnMwdOAvZovpgON2TJscDABIco,7904
|
|
22
|
+
seppy/tests/test_tools.py,sha256=qSTAtaZTEw_oz32BsSzYX5BFNowJooWX6p-QEkOboiU,31685
|
|
23
|
+
seppy/tests/tsa_org.png,sha256=80xrGx1unP1iXGLhPsKHHqMLrg2qhivsGh532hBVCqM,138501
|
|
24
|
+
seppy/tools/__init__.py,sha256=GwxGektqXHmqbuFCAW66XreGOp0PJImqujN0swlBmKE,117677
|
|
22
25
|
seppy/tools/swaves.py,sha256=OcohPXLko0ik9FLyYMVkYxI75W4XzOKvQ2Ylnwi-wlQ,3139
|
|
23
26
|
seppy/tools/widgets.py,sha256=atQj9vvus0UgrUV6vlPcTdjpaidnERUevOp6FUmGLSI,6820
|
|
24
27
|
seppy/util/__init__.py,sha256=RMMeH37L75wwQPHb_-_-2Rk7lzlDtBC2K6lkWKtxAMg,15253
|
|
25
|
-
seppy-0.
|
|
26
|
-
seppy-0.
|
|
27
|
-
seppy-0.
|
|
28
|
-
seppy-0.
|
|
29
|
-
seppy-0.
|
|
28
|
+
seppy-0.2.0.dist-info/licenses/LICENSE.rst,sha256=O5RzTapB1HKcaagHaoNKHBvjkzU6Kh1Ax6HZ_9Q4-kI,1520
|
|
29
|
+
seppy-0.2.0.dist-info/METADATA,sha256=aLfWO8hX9DFftOSgYAYoF9j9khWbnOxr_KGX1QfPiTo,4670
|
|
30
|
+
seppy-0.2.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
31
|
+
seppy-0.2.0.dist-info/top_level.txt,sha256=G2Op1GREPmbCX81isNhYY_7ZZyLWLIm-MJC04J4Fgc4,6
|
|
32
|
+
seppy-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022, Jan Gieseler
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2022, Jan Gieseler
|
|
2
|
-
All rights reserved.
|
|
3
|
-
|
|
4
|
-
Redistribution and use in source and binary forms, with or without modification,
|
|
5
|
-
are permitted provided that the following conditions are met:
|
|
6
|
-
|
|
7
|
-
* Redistributions of source code must retain the above copyright notice, this
|
|
8
|
-
list of conditions and the following disclaimer.
|
|
9
|
-
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
10
|
-
list of conditions and the following disclaimer in the documentation and/or
|
|
11
|
-
other materials provided with the distribution.
|
|
12
|
-
* Neither the name of SEPpy nor the names of its contributors may be
|
|
13
|
-
used to endorse or promote products derived from this software without
|
|
14
|
-
specific prior written permission.
|
|
15
|
-
|
|
16
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
17
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
18
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
19
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
20
|
-
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
21
|
-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
22
|
-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
23
|
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
24
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
File without changes
|