Skip to content

Commit

Permalink
extend tsa_plot testing for all datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
jgieseler committed Feb 6, 2024
1 parent 7ee7490 commit 3677f2c
Showing 1 changed file with 87 additions and 18 deletions.
105 changes: 87 additions & 18 deletions seppy/tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
import matplotlib.pyplot as plt
import pandas as pd

# TODO:
# - test tsa for all dataset?
# - test print(Event1.print_energies()) after it has been fixed

# TODO: test print(Event1.print_energies()) after it has been fixed

def test_onset_SOLO_STEP_ions_old_data_online():

def test_onset_spectrum_tsa_SOLO_STEP_ions_old_data_online():
startdate = datetime.date(2020, 9, 21)
enddate = datetime.date(2020, 9, 21)
lpath = f"{os.getcwd()}/data/"
Expand Down Expand Up @@ -42,8 +41,13 @@ def test_onset_SOLO_STEP_ions_old_data_online():
Event1.dynamic_spectrum(view='Pixel averaged')
assert Event1.fig.get_axes()[0].get_title() == 'SOLO/STEP (Pixel averaged) ions, 2020-09-21'

# test tsa plot:
plt.close('all') # in order to pick the right figure, make sure all previous are closed
Event1.tsa_plot('Pixel averaged', selection=(0, 4, 1), resample='1min')
assert plt.figure(1).get_axes()[0].get_title() == 'Solar Orbiter STEP, ions'


def test_onset_SOLO_STEP_ions_new_data_online():
def test_onset_spectrum_tsa_SOLO_STEP_ions_new_data_online():
startdate = datetime.date(2022, 1, 9)
enddate = datetime.date(2022, 1, 9)
lpath = f"{os.getcwd()}/data/"
Expand Down Expand Up @@ -76,8 +80,13 @@ def test_onset_SOLO_STEP_ions_new_data_online():
Event1.dynamic_spectrum(view='Pixel 8')
assert Event1.fig.get_axes()[0].get_title() == 'SOLO/STEP (Pixel 8) ions, 2022-01-09'

# test tsa plot:
plt.close('all') # in order to pick the right figure, make sure all previous are closed
Event1.tsa_plot('Pixel 8', selection=(0, 4, 1), resample='1min')
assert plt.figure(1).get_axes()[0].get_title() == 'Solar Orbiter STEP, ions'

def test_onset_spectrum_SOLO_HET_online():

def test_onset_spectrum_tsa_SOLO_HET_online():
startdate = datetime.date(2022, 11, 8)
enddate = datetime.date(2022, 11, 8)
lpath = f"{os.getcwd()}/data/"
Expand Down Expand Up @@ -109,6 +118,11 @@ def test_onset_spectrum_SOLO_HET_online():
Event1.dynamic_spectrum(view='sun')
assert Event1.fig.get_axes()[0].get_title() == 'SOLO/HET (sun) electrons, 2022-11-08'

# test tsa plot:
plt.close('all') # in order to pick the right figure, make sure all previous are closed
Event1.tsa_plot('north', selection=None, resample='1min')
assert plt.figure(1).get_axes()[0].get_title() == 'Solar Orbiter HET, electrons'


def test_onset_spectrum_tsa_SOLO_EPT_online():
startdate = datetime.date(2022, 6, 6)
Expand Down Expand Up @@ -141,14 +155,14 @@ def test_onset_spectrum_tsa_SOLO_EPT_online():
# test dynamic spectrum:
Event1.dynamic_spectrum(view='sun')
assert Event1.fig.get_axes()[0].get_title() == 'SOLO/EPT (sun) electrons, 2022-06-06'

# test tsa plot:
plt.close('all') # in order to pick the right figure, make sure all previous are closed
Event1.tsa_plot('sun', selection=(0, 4, 1), resample='1min')
assert plt.figure(1).get_axes()[0].get_title() == 'Solar Orbiter EPT, electrons'


def test_onset_PSP_ISOIS_EPIHI_online():
def test_onset_spectrum_tsa_PSP_ISOIS_EPIHI_online():
startdate = datetime.date(2021, 10, 28)
enddate = datetime.date(2021, 10, 29)
lpath = f"{os.getcwd()}/data/"
Expand Down Expand Up @@ -180,8 +194,13 @@ def test_onset_PSP_ISOIS_EPIHI_online():
Event1.dynamic_spectrum(view='A')
assert Event1.fig.get_axes()[0].get_title() == 'PSP/ISOIS-EPIHI (A) protons, 2021-10-28'

# test tsa plot:
plt.close('all') # in order to pick the right figure, make sure all previous are closed
Event1.tsa_plot('A', selection=(0, 4, 1), resample='1min')
assert plt.figure(1).get_axes()[0].get_title() == 'Parker Solar Probe ISOIS-EPIHI, protons'


def test_onset_PSP_ISOIS_EPILO_e_online():
def test_onset_spectrum_tsa_PSP_ISOIS_EPILO_e_online():
startdate = datetime.date(2021, 10, 28)
enddate = datetime.date(2021, 10, 29)
lpath = f"{os.getcwd()}/data/"
Expand Down Expand Up @@ -211,8 +230,13 @@ def test_onset_PSP_ISOIS_EPILO_e_online():
Event1.dynamic_spectrum(view='7')
assert Event1.fig.get_axes()[0].get_title() == 'PSP/ISOIS-EPILO (7) electrons, 2021-10-28'

# test tsa plot:
plt.close('all') # in order to pick the right figure, make sure all previous are closed
Event1.tsa_plot('3', selection=(0, 4, 1), resample='1min')
assert plt.figure(1).get_axes()[0].get_title() == 'Parker Solar Probe ISOIS-EPILO, electrons'


def test_onset_Wind_3DP_p_online():
def test_onset_spectrum_tsa_Wind_3DP_p_online():
startdate = datetime.date(2021, 10, 28)
enddate = datetime.date(2021, 10, 29)
lpath = f"{os.getcwd()}/data/"
Expand Down Expand Up @@ -243,8 +267,13 @@ def test_onset_Wind_3DP_p_online():
Event1.dynamic_spectrum(view='sector 3')
assert Event1.fig.get_axes()[0].get_title() == 'WIND/3DP (sector 3) protons, 2021-10-28'

# test tsa plot:
plt.close('all') # in order to pick the right figure, make sure all previous are closed
Event1.tsa_plot('omnidirectional', selection=(0, 4, 1), resample=None)
assert plt.figure(1).get_axes()[0].get_title() == 'Wind 3DP, protons'


def test_onset_Wind_3DP_e_online():
def test_onset_spectrum_tsa_Wind_3DP_e_online():
startdate = datetime.date(2021, 10, 28)
enddate = datetime.date(2021, 10, 29)
lpath = f"{os.getcwd()}/data/"
Expand Down Expand Up @@ -275,8 +304,13 @@ def test_onset_Wind_3DP_e_online():
Event1.dynamic_spectrum(view='omnidirectional')
assert Event1.fig.get_axes()[0].get_title() == 'WIND/3DP (omnidirectional) electrons, 2021-10-28'

# test tsa plot:
plt.close('all') # in order to pick the right figure, make sure all previous are closed
Event1.tsa_plot('sector 3', selection=(0, 4, 1), resample=None)
assert plt.figure(1).get_axes()[0].get_title() == 'Wind 3DP, electrons'


def test_onset_spectrum_STEREOB_HET_p_online():
def test_onset_spectrum_tsa_STEREOB_HET_p_online():
startdate = datetime.date(2006, 12, 13)
enddate = datetime.date(2006, 12, 14)
lpath = f"{os.getcwd()}/data/"
Expand All @@ -297,8 +331,13 @@ def test_onset_spectrum_STEREOB_HET_p_online():
Event1.dynamic_spectrum(view=None)
assert Event1.fig.get_axes()[0].get_title() == 'STB/HET protons, 2006-12-13'

# test tsa plot:
plt.close('all') # in order to pick the right figure, make sure all previous are closed
Event1.tsa_plot(None, selection=None, resample=None)
assert plt.figure(1).get_axes()[0].get_title() == 'STEREO-B HET, protons'


def test_onset_spectrum_STEREOB_HET_e_online():
def test_onset_spectrum_tsa_STEREOB_HET_e_online():
startdate = datetime.date(2006, 12, 13)
enddate = datetime.date(2006, 12, 14)
lpath = f"{os.getcwd()}/data/"
Expand All @@ -319,8 +358,13 @@ def test_onset_spectrum_STEREOB_HET_e_online():
Event1.dynamic_spectrum(view=None)
assert Event1.fig.get_axes()[0].get_title() == 'Radio & Dynamic Spectrum, STB/HET electrons, 2006-12-13'

# test tsa plot:
plt.close('all') # in order to pick the right figure, make sure all previous are closed
Event1.tsa_plot(None, selection=None, resample=None)
assert plt.figure(1).get_axes()[0].get_title() == 'STEREO-B HET, electrons'

def test_onset_spectrum_STEREOA_SEPT_p_online():

def test_onset_spectrum_tsa_STEREOA_SEPT_p_online():
startdate = datetime.date(2021, 10, 28)
enddate = datetime.date(2021, 10, 28)
lpath = f"{os.getcwd()}/data/"
Expand All @@ -341,8 +385,13 @@ def test_onset_spectrum_STEREOA_SEPT_p_online():
Event1.dynamic_spectrum(view=None)
assert Event1.fig.get_axes()[0].get_title() == 'STA/SEPT protons, 2021-10-28'

# test tsa plot:
plt.close('all') # in order to pick the right figure, make sure all previous are closed
Event1.tsa_plot(None, selection=None, resample=None)
assert plt.figure(1).get_axes()[0].get_title() == 'STEREO-A SEPT, protons'

def test_onset_spectrum_STEREOA_SEPT_e_online():

def test_onset_spectrum_tsa_STEREOA_SEPT_e_online():
startdate = datetime.date(2021, 10, 28)
enddate = datetime.date(2021, 10, 28)
lpath = f"{os.getcwd()}/data/"
Expand All @@ -363,8 +412,13 @@ def test_onset_spectrum_STEREOA_SEPT_e_online():
Event1.dynamic_spectrum(view=None)
assert Event1.fig.get_axes()[0].get_title() == 'Radio & Dynamic Spectrum, STA/SEPT electrons, 2021-10-28'

# test tsa plot:
plt.close('all') # in order to pick the right figure, make sure all previous are closed
Event1.tsa_plot(None, selection=None, resample=None)
assert plt.figure(1).get_axes()[0].get_title() == 'STEREO-A SEPT, electrons'


def test_onset_spectrum_SOHO_EPHIN_online():
def test_onset_spectrum_tsa_SOHO_EPHIN_online():
startdate = datetime.date(2021, 10, 28)
enddate = datetime.date(2021, 10, 28)
lpath = f"{os.getcwd()}/data/"
Expand All @@ -390,8 +444,13 @@ def test_onset_spectrum_SOHO_EPHIN_online():
check = True
assert check

# test tsa plot:
plt.close('all') # in order to pick the right figure, make sure all previous are closed
Event1.tsa_plot(None, selection=(0, 4, 1), resample='5min')
assert plt.figure(1).get_axes()[0].get_title() == 'SOHO EPHIN, electrons'


def test_onset_spectrum_SOHO_ERNE_online():
def test_onset_spectrum_tsa_SOHO_ERNE_online():
startdate = datetime.date(2021, 10, 28)
enddate = datetime.date(2021, 10, 29)
lpath = f"{os.getcwd()}/data/"
Expand All @@ -413,8 +472,13 @@ def test_onset_spectrum_SOHO_ERNE_online():

assert Event1.fig.get_axes()[0].get_title() == 'Radio & Dynamic Spectrum, SOHO/ERNE protons, 2021-10-28'

# test tsa plot:
plt.close('all') # in order to pick the right figure, make sure all previous are closed
Event1.tsa_plot(None, selection=(0, 4, 1), resample='5min')
assert plt.figure(1).get_axes()[0].get_title() == 'SOHO ERNE, protons'


def test_onset_SOHO_ERNE_offline():
def test_onset_tsa_SOHO_ERNE_offline():
startdate = datetime.date(2021, 10, 28)
enddate = datetime.date(2021, 10, 29)
fullpath = get_pkg_data_filename('data/test/soho_erne-hed_l2-1min_20211028_v01.cdf', package='seppy')
Expand All @@ -432,6 +496,11 @@ def test_onset_SOHO_ERNE_offline():
assert peak_time.isoformat().split('.')[0] == '2021-10-28T22:53:05'
assert fig.get_axes()[0].get_title() == 'SOHO/ERNE 16.0 - 32.0 MeV protons\n5min averaging'

# test tsa plot:
plt.close('all') # in order to pick the right figure, make sure all previous are closed
Event1.tsa_plot(None, selection=(0, 4, 1), resample='5min')
assert plt.figure(1).get_axes()[0].get_title() == 'SOHO ERNE, protons'


def test_dynamic_spectrum_SOHO_ERNE_offline():
startdate = datetime.date(2021, 10, 28)
Expand Down

0 comments on commit 3677f2c

Please sign in to comment.