Skip to content

Commit

Permalink
Merge pull request #63 from jgieseler/main
Browse files Browse the repository at this point in the history
bepi data now correctly time-centered
  • Loading branch information
jgieseler authored Aug 30, 2024
2 parents d87a4bd + cf9c820 commit 6397f9c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 27 deletions.
16 changes: 8 additions & 8 deletions seppy/tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_onset_spectrum_tsa_SOLO_STEP_ions_new_data_online():
assert flux.shape == (164,)
assert len(onset_stats) == 6
assert isinstance(onset_stats[5], pd._libs.tslibs.nattype.NaTType) # onset_stats[5].isoformat().split('.')[0] == '2021-10-28T16:07:30'
assert ~onset_found
assert not onset_found
assert peak_time.isoformat().split('.')[0] == '2022-01-09T01:32:31'
assert fig.get_axes()[0].get_title() == 'SOLO/STEP 0.0061 - 0.0091 MeV protons\n5min averaging, viewing: PIXEL AVERAGED'
# Pixel 8
Expand All @@ -71,7 +71,7 @@ def test_onset_spectrum_tsa_SOLO_STEP_ions_new_data_online():
assert flux.shape == (164,)
assert len(onset_stats) == 6
assert isinstance(onset_stats[5], pd._libs.tslibs.nattype.NaTType) # onset_stats[5].isoformat().split('.')[0] == '2021-10-28T16:12:30'
assert ~onset_found
assert not onset_found
assert peak_time.isoformat().split('.')[0] == '2022-01-09T00:02:31'
assert fig.get_axes()[0].get_title() == 'SOLO/STEP 0.0061 - 0.0091 MeV protons\n5min averaging, viewing: PIXEL 8'

Expand Down Expand Up @@ -101,7 +101,7 @@ def test_onset_spectrum_tsa_SOLO_HET_online():
assert flux.shape == (73,)
assert len(onset_stats) == 6
assert isinstance(onset_stats[5], pd._libs.tslibs.nattype.NaTType) # onset_stats[5] == pd.Timestamp('2021-10-28 15:31:59.492059')
assert ~onset_found
assert not onset_found
assert peak_time.isoformat().split('.')[0] == '2022-11-08T17:58:09'
assert fig.get_axes()[0].get_title() == 'SOLO/HET 7.3540 - 7.8900 MeV protons\n5min averaging, viewing: SUN'
# viewing "north", combined channel, electrons
Expand All @@ -112,7 +112,7 @@ def test_onset_spectrum_tsa_SOLO_HET_online():
assert flux.shape == (73,)
assert len(onset_stats) == 6
assert isinstance(onset_stats[5], pd._libs.tslibs.nattype.NaTType) # onset_stats[5] == pd.Timestamp('2021-10-28 15:31:59.492059')
assert ~onset_found
assert not onset_found
assert peak_time.isoformat().split('.')[0] == '2022-11-08T22:27:56'
assert fig.get_axes()[0].get_title() == 'SOLO/HET 0.4533 - 18.8300 MeV electrons\n5min averaging, viewing: NORTH'

Expand All @@ -139,7 +139,7 @@ def test_onset_spectrum_tsa_SOLO_EPT_online():
assert flux.shape == (288,)
assert len(onset_stats) == 6
assert isinstance(onset_stats[5], pd._libs.tslibs.nattype.NaTType) # onset_stats[5] == pd.Timestamp('2021-10-28 15:31:59.492059')
assert ~onset_found
assert not onset_found
assert peak_time.isoformat().split('.')[0] == '2022-06-06T01:02:31'
assert fig.get_axes()[0].get_title() == 'SOLO/EPT 0.0608 - 0.0678 MeV protons\n5min averaging, viewing: SUN'
# viewing "north", combined channel, electrons
Expand All @@ -150,7 +150,7 @@ def test_onset_spectrum_tsa_SOLO_EPT_online():
assert flux.shape == (288,)
assert len(onset_stats) == 6
assert isinstance(onset_stats[5], pd._libs.tslibs.nattype.NaTType) # onset_stats[5] == pd.Timestamp('2021-10-28 15:31:59.492059')
assert ~onset_found
assert not onset_found
assert peak_time.isoformat().split('.')[0] == '2022-06-06T23:02:31'
assert fig.get_axes()[0].get_title() == 'SOLO/EPT 0.0334 - 0.0439 MeV electrons\n5min averaging, viewing: NORTH'

Expand Down Expand Up @@ -533,6 +533,6 @@ def test_onset_Bepi_SIXS_offline():
assert flux.shape == (161,)
assert len(onset_stats) == 6
assert isinstance(onset_stats[5], pd._libs.tslibs.nattype.NaTType)
assert ~onset_found
assert peak_time.isoformat().split('.')[0] == '2023-07-19T02:25:42'
assert not onset_found
assert peak_time.isoformat().split('.')[0] == '2023-07-19T02:25:30'
assert fig.get_axes()[0].get_title() == 'BEPI/SIXS 106 keV electrons\n1min averaging, viewing: 1'
25 changes: 7 additions & 18 deletions seppy/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,24 +109,13 @@ def bepicolombo_sixs_stack(path, date, side, pos_timestamp='center'):
df.index = np.array(times)
df = df.drop(columns=['TimeUTC'])

# TODO: (as it's not really nicely done so far)
# careful!
# adjusting the position of the timestamp manually.
# requires knowledge of the original time resolution and timestamp position!
if type(date) is datetime.datetime:
change_date = pd.Timestamp(2022, 8, 29)
elif type(date) is datetime.date:
change_date = pd.Timestamp(2022, 8, 29).date()
if date < change_date:
cadence = 8
elif date >= change_date:
cadence = 24
#
if pos_timestamp == 'center':
df.index = df.index+pd.Timedelta(f'{cadence/2}s')
# warnings.warn("Assuming cadence of 8s before 2022-08-29 and 24s after!")
custom_warning("Assuming cadence of 8s before 2022-08-29 and 24s after!")
elif pos_timestamp == 'start':
if pos_timestamp == 'start':
cadence1 = (df.index[1]-df.index[0]).seconds
cadence2 = (df.index[-1]-df.index[-2]).seconds
if cadence1 != cadence2:
custom_warning("Bepi/SIXS cadence is changing throughout the day; something is wrong!")
df.index = df.index-pd.Timedelta(f'{cadence1/2}s')
elif pos_timestamp == 'center':
pass
except FileNotFoundError:
print(f'Unable to open {filename}')
Expand Down
2 changes: 1 addition & 1 deletion seppy/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
from setuptools_scm import get_version
__version__ = get_version(root='..', relative_to=__file__)
except Exception:
__version__ = '0.1.15'
__version__ = '0.1.16'

0 comments on commit 6397f9c

Please sign in to comment.