seppy 0.1.16__tar.gz → 0.1.18__tar.gz

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.

Files changed (46) hide show
  1. {seppy-0.1.16/seppy.egg-info → seppy-0.1.18}/PKG-INFO +3 -3
  2. {seppy-0.1.16 → seppy-0.1.18}/README.rst +1 -1
  3. {seppy-0.1.16 → seppy-0.1.18}/requirements.txt +1 -0
  4. {seppy-0.1.16 → seppy-0.1.18}/seppy/loader/psp.py +2 -2
  5. {seppy-0.1.16 → seppy-0.1.18}/seppy/loader/soho.py +4 -4
  6. {seppy-0.1.16 → seppy-0.1.18}/seppy/loader/wind.py +16 -4
  7. {seppy-0.1.16 → seppy-0.1.18}/seppy/tests/test_loader.py +14 -5
  8. {seppy-0.1.16 → seppy-0.1.18}/seppy/tools/__init__.py +12 -13
  9. {seppy-0.1.16 → seppy-0.1.18}/seppy/version.py +1 -1
  10. {seppy-0.1.16 → seppy-0.1.18/seppy.egg-info}/PKG-INFO +3 -3
  11. {seppy-0.1.16 → seppy-0.1.18}/LICENSE.rst +0 -0
  12. {seppy-0.1.16 → seppy-0.1.18}/MANIFEST.in +0 -0
  13. {seppy-0.1.16 → seppy-0.1.18}/docs/Makefile +0 -0
  14. {seppy-0.1.16 → seppy-0.1.18}/docs/conf.py +0 -0
  15. {seppy-0.1.16 → seppy-0.1.18}/docs/index.rst +0 -0
  16. {seppy-0.1.16 → seppy-0.1.18}/docs/make.bat +0 -0
  17. {seppy-0.1.16 → seppy-0.1.18}/licenses/LICENSE.rst +0 -0
  18. {seppy-0.1.16 → seppy-0.1.18}/licenses/SUNPY_LICENSE.rst +0 -0
  19. {seppy-0.1.16 → seppy-0.1.18}/licenses/TEMPLATE_LICENSE.rst +0 -0
  20. {seppy-0.1.16 → seppy-0.1.18}/pyproject.toml +0 -0
  21. {seppy-0.1.16 → seppy-0.1.18}/seppy/__init__.py +0 -0
  22. {seppy-0.1.16 → seppy-0.1.18}/seppy/data/test/20230719_side0.csv +0 -0
  23. {seppy-0.1.16 → seppy-0.1.18}/seppy/data/test/20230719_side1.csv +0 -0
  24. {seppy-0.1.16 → seppy-0.1.18}/seppy/data/test/20230719_side2.csv +0 -0
  25. {seppy-0.1.16 → seppy-0.1.18}/seppy/data/test/epi21106.rl2 +0 -0
  26. {seppy-0.1.16 → seppy-0.1.18}/seppy/data/test/sept_ahead_ele_sun_2006_318_1min_l2_v03.dat +0 -0
  27. {seppy-0.1.16 → seppy-0.1.18}/seppy/data/test/soho_erne-hed_l2-1min_20211028_v01.cdf +0 -0
  28. {seppy-0.1.16 → seppy-0.1.18}/seppy/data/test/solo_l2_mag-rtn-normal-1-minute_20210712_v01.cdf +0 -0
  29. {seppy-0.1.16 → seppy-0.1.18}/seppy/data/test/sta_l1_het_20211028_v01.cdf +0 -0
  30. {seppy-0.1.16 → seppy-0.1.18}/seppy/data/test/wi_sfsp_3dp_00000000_v01.cdf +0 -0
  31. {seppy-0.1.16 → seppy-0.1.18}/seppy/data/test/wi_sfsp_3dp_20200213_v01.cdf +0 -0
  32. {seppy-0.1.16 → seppy-0.1.18}/seppy/loader/solo.py +0 -0
  33. {seppy-0.1.16 → seppy-0.1.18}/seppy/loader/stereo.py +0 -0
  34. {seppy-0.1.16 → seppy-0.1.18}/seppy/tests/__init__.py +0 -0
  35. {seppy-0.1.16 → seppy-0.1.18}/seppy/tests/test_tools.py +0 -0
  36. {seppy-0.1.16 → seppy-0.1.18}/seppy/tools/swaves.py +0 -0
  37. {seppy-0.1.16 → seppy-0.1.18}/seppy/tools/widgets.py +0 -0
  38. {seppy-0.1.16 → seppy-0.1.18}/seppy/util/__init__.py +0 -0
  39. {seppy-0.1.16 → seppy-0.1.18}/seppy.egg-info/SOURCES.txt +0 -0
  40. {seppy-0.1.16 → seppy-0.1.18}/seppy.egg-info/dependency_links.txt +0 -0
  41. {seppy-0.1.16 → seppy-0.1.18}/seppy.egg-info/not-zip-safe +0 -0
  42. {seppy-0.1.16 → seppy-0.1.18}/seppy.egg-info/requires.txt +0 -0
  43. {seppy-0.1.16 → seppy-0.1.18}/seppy.egg-info/top_level.txt +0 -0
  44. {seppy-0.1.16 → seppy-0.1.18}/setup.cfg +0 -0
  45. {seppy-0.1.16 → seppy-0.1.18}/setup.py +0 -0
  46. {seppy-0.1.16 → seppy-0.1.18}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: seppy
3
- Version: 0.1.16
3
+ Version: 0.1.18
4
4
  Summary: SEPpy
5
5
  Home-page: https://github.com/serpentine-h2020/SEPpy
6
6
  Author: Jan Gieseler
@@ -51,7 +51,7 @@ seppy
51
51
  .. |python version| image:: https://img.shields.io/pypi/pyversions/seppy?style=flat&logo=python
52
52
  .. |zenodo doi| image:: https://zenodo.org/badge/451799504.svg
53
53
  :target: https://zenodo.org/badge/latestdoi/451799504
54
- .. |pytest| image:: https://github.com/serpentine-h2020/SEPpy/workflows/pytest/badge.svg
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
57
 
@@ -8,7 +8,7 @@ seppy
8
8
  .. |python version| image:: https://img.shields.io/pypi/pyversions/seppy?style=flat&logo=python
9
9
  .. |zenodo doi| image:: https://zenodo.org/badge/451799504.svg
10
10
  :target: https://zenodo.org/badge/latestdoi/451799504
11
- .. |pytest| image:: https://github.com/serpentine-h2020/SEPpy/workflows/pytest/badge.svg
11
+ .. |pytest| image:: https://github.com/serpentine-h2020/SEPpy/actions/workflows/pytest.yml/badge.svg?branch=main
12
12
  .. |codecov| image:: https://codecov.io/gh/serpentine-h2020/SEPpy/branch/main/graph/badge.svg?token=FYELM4Y7DF
13
13
  :target: https://codecov.io/gh/serpentine-h2020/SEPpy
14
14
 
@@ -10,5 +10,6 @@ numpy
10
10
  pandas
11
11
  pooch
12
12
  requests
13
+ setuptools
13
14
  solo-epd-loader
14
15
  sunpy>=4.1.0
@@ -410,8 +410,8 @@ def calc_av_en_flux_PSP_EPIHI(df, energies, en_channel, species, instrument, vie
410
410
  flux_key = 'H_Flux'
411
411
  en_str = energies[f'{species_str}_ENERGY_LABL']
412
412
  if type(en_channel) == list:
413
- energy_low = en_str[en_channel[0]][0].split('-')[0]
414
- energy_up = en_str[en_channel[-1]][0].split('-')[-1]
413
+ energy_low = en_str[en_channel[0]].flat[0].split('-')[0]
414
+ energy_up = en_str[en_channel[-1]].flat[0].split('-')[-1]
415
415
  en_channel_string = energy_low + '-' + energy_up
416
416
 
417
417
  DE = energies[f'{species_str}_ENERGY_DELTAPLUS']+energies[f'{species_str}_ENERGY_DELTAMINUS']
@@ -39,13 +39,13 @@ def _get_metadata(dataset, path_to_cdf):
39
39
  if dataset=='SOHO_ERNE-LED_L2-1MIN':
40
40
  alpha = 'A'
41
41
  m = 'L'
42
- metadata = {'He_E_label': cdf.varget('He_E_label')[0],
42
+ metadata = {'He_E_label': cdf.varget('He_E_label').flatten(),
43
43
  'He_energy': cdf.varget('He_energy'),
44
44
  'He_energy_delta': cdf.varget('He_energy_delta'),
45
45
  f'{alpha}{m}_LABL': cdf.varattsget(f'{alpha}{m}')['LABLAXIS'],
46
46
  f'{alpha}{m}_UNITS': cdf.varattsget(f'{alpha}{m}')['UNITS'],
47
47
  f'{alpha}{m}_FILLVAL': cdf.varattsget(f'{alpha}{m}')['FILLVAL'],
48
- 'P_E_label': cdf.varget('P_E_label')[0],
48
+ 'P_E_label': cdf.varget('P_E_label').flatten(),
49
49
  'P_energy': cdf.varget('P_energy'),
50
50
  'P_energy_delta': cdf.varget('P_energy_delta'),
51
51
  f'P{m}_LABL': cdf.varattsget(f'P{m}')['LABLAXIS'],
@@ -53,14 +53,14 @@ def _get_metadata(dataset, path_to_cdf):
53
53
  f'P{m}_FILLVAL': cdf.varattsget(f'P{m}')['FILLVAL'],
54
54
  }
55
55
 
56
- channels_dict_df_He = pd.DataFrame(cdf.varget('He_E_label')[0], columns=['ch_strings'])
56
+ channels_dict_df_He = pd.DataFrame(cdf.varget('He_E_label').flatten(), columns=['ch_strings'])
57
57
  channels_dict_df_He['lower_E'] = cdf.varget("He_energy")-cdf.varget("He_energy_delta")
58
58
  channels_dict_df_He['upper_E'] = cdf.varget("He_energy")+cdf.varget("He_energy_delta")
59
59
  channels_dict_df_He['DE'] = cdf.varget("He_energy_delta")
60
60
  # channels_dict_df_He['mean_E'] = np.sqrt(channels_dict_df_He['upper_E'] * channels_dict_df_He['lower_E'])
61
61
  channels_dict_df_He['mean_E'] = cdf.varget("He_energy")
62
62
 
63
- channels_dict_df_p = pd.DataFrame(cdf.varget('P_E_label')[0], columns=['ch_strings'])
63
+ channels_dict_df_p = pd.DataFrame(cdf.varget('P_E_label').flatten(), columns=['ch_strings'])
64
64
  channels_dict_df_p['lower_E'] = cdf.varget("P_energy")-cdf.varget("P_energy_delta")
65
65
  channels_dict_df_p['upper_E'] = cdf.varget("P_energy")+cdf.varget("P_energy_delta")
66
66
  channels_dict_df_p['DE'] = cdf.varget("P_energy_delta")
@@ -180,6 +180,9 @@ def wind3dp_download(dataset, startdate, enddate, path=None, **kwargs):
180
180
  if not os.path.exists(f):
181
181
  # downloaded_file = Fido.fetch(result[0][i], path=path, max_conn=max_conn)
182
182
  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)
183
186
 
184
187
  except (RuntimeError, IndexError):
185
188
  print(f'Unable to obtain "{dataset}" data for {startdate}-{enddate}!')
@@ -279,22 +282,31 @@ def wind3dp_load(dataset, startdate, enddate, resample="1min", multi_index=True,
279
282
  metacdf = cdflib.CDF(path_to_metafile)
280
283
 
281
284
  e_mean = df.filter(like='ENERGY_').mean()
282
- # ∼30% ΔE/E => ΔE = 0.3*E
283
285
  # from Table 3 of Wilson et al. 2021, https://doi.org/10.1029/2020RG000714
284
- delta_e = 0.3 * e_mean
286
+ # ∼30% ΔE/E => ΔE = 0.3*E
287
+ if dataset in ['WI_SFSP_3DP', 'WI_SFPD_3DP', 'WI_SOSP_3DP', 'WI_SOPD_3DP']:
288
+ delta_e = 0.3 * e_mean
289
+ # ∼20% ΔE/E => ΔE = 0.2*E
290
+ elif dataset in ['WI_ELSP_3DP', 'WI_ELPD_3DP', 'WI_EHSP_3DP', 'WI_EHPD_3DP']:
291
+ delta_e = 0.2 * e_mean
285
292
  e_low = e_mean - delta_e
286
293
  e_high = e_mean + delta_e
287
294
  energies = pd.concat([e_mean, delta_e, e_low, e_high], axis=1, keys=['mean_E', 'DE', 'lower_E', 'upper_E'])
288
295
  energies['Bins_Text']= np.around(e_low/1e3, 2).astype('string') +' - '+ np.around(e_high/1e3, 2).astype('string') + ' keV'
289
296
 
290
297
  meta = {'channels_dict_df': energies,
291
- 'APPROX_ENERGY_LABELS': metacdf.varget('APPROX_ENERGY_LABELS'),
292
298
  'ENERGY_UNITS': metacdf.varattsget('ENERGY')['UNITS'],
293
299
  'FLUX_UNITS': metacdf.varattsget('FLUX')['UNITS'],
294
300
  'FLUX_FILLVAL': metacdf.varattsget('FLUX')['FILLVAL'],
295
- 'FLUX_LABELS': metacdf.varget('FLUX_ENERGY_LABL'),
296
301
  }
297
302
 
303
+ # for SFSP, SOSP, SFPD, SFSP:
304
+ try:
305
+ meta['APPROX_ENERGY_LABELS'] = metacdf.varget('APPROX_ENERGY_LABELS')
306
+ meta['FLUX_LABELS'] = metacdf.varget('FLUX_ENERGY_LABL')
307
+ except:
308
+ pass
309
+
298
310
  # create multi-index data frame of flux
299
311
  if multi_index:
300
312
  if dataset == 'WI_SFPD_3DP' or dataset == 'WI_SOPD_3DP':
@@ -14,7 +14,7 @@ def test_psp_load_online():
14
14
  enddate="2021/06/01", path=None, resample="1min")
15
15
  assert isinstance(df, pd.DataFrame)
16
16
  assert df.shape == (48, 136)
17
- assert meta['H_ENERGY_LABL'][0][0] == ' 6.7 - 8.0 MeV'
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
20
20
  #
@@ -71,6 +71,15 @@ def test_soho_ephin_load_offline():
71
71
  assert np.sum(np.isnan(df['E1300'])) == 444
72
72
 
73
73
 
74
+ def test_soho_erne_load_online():
75
+ df, meta = soho_load(dataset='SOHO_ERNE-HED_L2-1MIN', startdate="2021/04/16", enddate="2021/04/17",
76
+ path=None, resample="1min", pos_timestamp='center')
77
+ assert isinstance(df, pd.DataFrame)
78
+ assert df.shape == (1145, 41)
79
+ assert meta['channels_dict_df_p']['ch_strings'].iloc[9] == '100 - 130 MeV'
80
+ assert df['PHC_9'].sum() == 1295.0
81
+
82
+
74
83
  def test_solo_mag_load_online():
75
84
  df = mag_load("2021/07/12", "2021/07/13", level='l2', data_type='normal-1-minute', frame='rtn', path=None)
76
85
  assert isinstance(df, pd.DataFrame)
@@ -93,7 +102,7 @@ def test_stereo_het_load_online():
93
102
  path=None, resample="1min", pos_timestamp='center')
94
103
  assert isinstance(df, pd.DataFrame)
95
104
  assert df.shape == (1440, 28)
96
- assert meta['Proton_Bins_Text'][0][0] == '13.6 - 15.1 MeV '
105
+ assert meta['Proton_Bins_Text'].flatten()[0] == '13.6 - 15.1 MeV '
97
106
  assert np.sum(np.isnan(df['Electron_Flux_0'])) == 0
98
107
 
99
108
 
@@ -105,7 +114,7 @@ def test_stereo_het_load_offline():
105
114
  path=path, resample="1min", pos_timestamp=None)
106
115
  assert isinstance(df, pd.DataFrame)
107
116
  assert df.shape == (1440, 28)
108
- assert meta['Proton_Bins_Text'][0][0] == '13.6 - 15.1 MeV '
117
+ assert meta['Proton_Bins_Text'].flatten()[0] == '13.6 - 15.1 MeV '
109
118
  assert np.sum(np.isnan(df['Electron_Flux_0'])) == 0
110
119
 
111
120
 
@@ -141,7 +150,7 @@ def test_wind3dp_load_online():
141
150
  path=None)
142
151
  assert isinstance(df, pd.DataFrame)
143
152
  assert df.shape == (2880, 76)
144
- assert meta['FLUX_LABELS'][0][0] == 'ElecNoFlux_Ch1_Often~27keV '
153
+ assert meta['FLUX_LABELS'].flatten()[0] == 'ElecNoFlux_Ch1_Often~27keV '
145
154
  # Check that fillvals are replaced by NaN
146
155
  assert np.sum(np.isnan(df['FLUX_E0', 'FLUX_E0_P0'])) == 169
147
156
 
@@ -158,6 +167,6 @@ def test_wind3dp_load_offline():
158
167
  path=path)
159
168
  assert isinstance(df, pd.DataFrame)
160
169
  assert df.shape == (897, 15)
161
- assert meta['FLUX_LABELS'][0][0] == 'ElecNoFlux_Ch1_Often~27keV '
170
+ assert meta['FLUX_LABELS'].flatten()[0] == 'ElecNoFlux_Ch1_Often~27keV '
162
171
  # Check that fillvals are replaced by NaN
163
172
  assert np.sum(np.isnan(df['FLUX_0'])) == 352
@@ -675,9 +675,9 @@ class Event:
675
675
 
676
676
  # An IndexError here is caused by invalid channel choice
677
677
  try:
678
- en_channel_string = en_str[en_channel[0]][0].split()[0] + ' - '\
679
- + en_str[en_channel[-1]][0].split()[2] + ' ' +\
680
- en_str[en_channel[-1]][0].split()[3]
678
+ en_channel_string = en_str[en_channel[0]].flat[0].split()[0] + ' - '\
679
+ + en_str[en_channel[-1]].flat[0].split()[2] + ' ' +\
680
+ en_str[en_channel[-1]].flat[0].split()[3]
681
681
 
682
682
  except IndexError:
683
683
  raise Exception(f"{en_channel} is an invalid channel or a combination of channels!")
@@ -781,9 +781,9 @@ class Event:
781
781
 
782
782
  # An IndexError here is caused by invalid channel choice
783
783
  try:
784
- en_channel_string = en_str[en_channel[0]][0].split()[0] + ' - '\
785
- + en_str[en_channel[-1]][0].split()[2] + ' '\
786
- + en_str[en_channel[-1]][0].split()[3]
784
+ en_channel_string = en_str[en_channel[0]].flat[0].split()[0] + ' - '\
785
+ + en_str[en_channel[-1]].flat[0].split()[2] + ' '\
786
+ + en_str[en_channel[-1]].flat[0].split()[3]
787
787
 
788
788
  except IndexError:
789
789
  raise Exception(f"{en_channel} is an invalid channel or a combination of channels!")
@@ -2276,8 +2276,8 @@ class Event:
2276
2276
  p_identifier = "Ion_Bins_Text" if self.sensor == "ept" else "H_Bins_Text" if self.sensor == "het" else "Bins_Text"
2277
2277
  energy_ranges = energy_dict[p_identifier]
2278
2278
 
2279
- # Each element in the list is also a list with len==1, so fix that
2280
- energy_ranges = [element[0] for element in energy_ranges]
2279
+ # Each element in the list is also a list with len==1 for cdflib < 1.3.3, so fix that
2280
+ energy_ranges = energy_ranges.flatten()
2281
2281
 
2282
2282
  if self.spacecraft[:2] == "st":
2283
2283
 
@@ -2299,8 +2299,8 @@ class Event:
2299
2299
  else:
2300
2300
  energy_ranges = energy_dict["Proton_Bins_Text"]
2301
2301
 
2302
- # Each element in the list is also a list with len==1, so fix that
2303
- energy_ranges = [element[0] for element in energy_ranges]
2302
+ # Each element in the list is also a list with len==1 for cdflib < 1.3.3, so fix that
2303
+ energy_ranges = energy_ranges.flatten()
2304
2304
 
2305
2305
  if self.spacecraft == "soho":
2306
2306
  if self.sensor.lower() == "erne":
@@ -2322,9 +2322,8 @@ class Event:
2322
2322
  if self.species == 'p':
2323
2323
  energy_ranges = energy_dict["H_ENERGY_LABL"]
2324
2324
 
2325
- # In the case of ISOIS-EPIHI, each iterable object is a list with len=1 that contains
2326
- # the str
2327
- energy_ranges = [element[0] for element in energy_ranges]
2325
+ # Each element in the list is also a list with len==1 for cdflib < 1.3.3, so fix that
2326
+ energy_ranges = energy_ranges.flatten()
2328
2327
 
2329
2328
  if self.sensor == "isois-epilo":
2330
2329
  # The metadata of ISOIS-EPILO comes in a bit of complex form, so some handling is required
@@ -5,4 +5,4 @@ try:
5
5
  from setuptools_scm import get_version
6
6
  __version__ = get_version(root='..', relative_to=__file__)
7
7
  except Exception:
8
- __version__ = '0.1.16'
8
+ __version__ = '0.1.18'
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: seppy
3
- Version: 0.1.16
3
+ Version: 0.1.18
4
4
  Summary: SEPpy
5
5
  Home-page: https://github.com/serpentine-h2020/SEPpy
6
6
  Author: Jan Gieseler
@@ -51,7 +51,7 @@ seppy
51
51
  .. |python version| image:: https://img.shields.io/pypi/pyversions/seppy?style=flat&logo=python
52
52
  .. |zenodo doi| image:: https://zenodo.org/badge/451799504.svg
53
53
  :target: https://zenodo.org/badge/latestdoi/451799504
54
- .. |pytest| image:: https://github.com/serpentine-h2020/SEPpy/workflows/pytest/badge.svg
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
57
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes