Skip to content

Commit

Permalink
add download test files from elfin server
Browse files Browse the repository at this point in the history
  • Loading branch information
jiashuwu89 committed Sep 22, 2023
1 parent 7ecc379 commit d33da72
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 21 deletions.
43 changes: 37 additions & 6 deletions pyspedas/elfin/tests/test_epd_l1.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
import pytplot.get_data
from pytplot.importers.tplot_restore import tplot_restore
from numpy.testing import assert_allclose

import pyspedas.elfin
from pyspedas.utilities.download import download
from pyspedas.elfin.config import CONFIG

TEST_DATASET_PATH="pyspedas/elfin/tests/test_dataset/"
TEST_DATASET_PATH="test/"

class TestELFL1Validation(unittest.TestCase):
"""Tests of the data been identical to SPEDAS (IDL)."""
Expand All @@ -24,26 +27,54 @@ def setUpClass(cls):
The IDL script that creates data file: epd_level1_check.pro
"""
# Testing time range
cls.t = ['2022-04-12/19:00:00','2022-04-12/19:15:00']
cls.t = ['2022-04-12/19:00:00','2022-04-12/19:15:00']
cls.probe = 'b'

# load epd l1 raw flux
filename = f"{TEST_DATASET_PATH}validation_el{cls.probe}_epd_l1_raw_{cls.t[0][0:4]+cls.t[0][5:7]+cls.t[0][8:10]}.tplot"
calfile_name = f"{TEST_DATASET_PATH}validation_el{cls.probe}_epd_l1_raw_{cls.t[0][0:4]+cls.t[0][5:7]+cls.t[0][8:10]}.tplot"
calfile = download(remote_file=calfile_name,
remote_path=CONFIG['remote_data_dir'],
local_path=CONFIG['local_data_dir'],
no_download=False)
if not calfile:
raise unittest.SkipTest(f"Cannot download validation file {calfile_name}")
filename = CONFIG['local_data_dir'] + calfile_name
tplot_restore(filename)
cls.elf_pef_raw = pytplot.get_data(f"el{cls.probe}_pef_raw")

# load epd l1 cps flux
filename = f"{TEST_DATASET_PATH}validation_el{cls.probe}_epd_l1_cps_{cls.t[0][0:4]+cls.t[0][5:7]+cls.t[0][8:10]}.tplot"
calfile_name = f"{TEST_DATASET_PATH}validation_el{cls.probe}_epd_l1_cps_{cls.t[0][0:4]+cls.t[0][5:7]+cls.t[0][8:10]}.tplot"
calfile = download(remote_file=calfile_name,
remote_path=CONFIG['remote_data_dir'],
local_path=CONFIG['local_data_dir'],
no_download=False)
if not calfile:
raise unittest.SkipTest(f"Cannot download validation file {calfile_name}")
filename = CONFIG['local_data_dir'] + calfile_name
tplot_restore(filename)
cls.elf_pef_cps = pytplot.get_data(f"el{cls.probe}_pef_cps")

# load epd l1 nflux flux
filename = f"{TEST_DATASET_PATH}validation_el{cls.probe}_epd_l1_nflux_{cls.t[0][0:4]+cls.t[0][5:7]+cls.t[0][8:10]}.tplot"
calfile_name = f"{TEST_DATASET_PATH}validation_el{cls.probe}_epd_l1_nflux_{cls.t[0][0:4]+cls.t[0][5:7]+cls.t[0][8:10]}.tplot"
calfile = download(remote_file=calfile_name,
remote_path=CONFIG['remote_data_dir'],
local_path=CONFIG['local_data_dir'],
no_download=False)
if not calfile:
raise unittest.SkipTest(f"Cannot download validation file {calfile_name}")
filename = CONFIG['local_data_dir'] + calfile_name
tplot_restore(filename)
cls.elf_pef_nflux = pytplot.get_data(f"el{cls.probe}_pef_nflux")

# load epd l1 eflux spectrogram
filename = f"{TEST_DATASET_PATH}validation_el{cls.probe}_epd_l1_eflux_{cls.t[0][0:4]+cls.t[0][5:7]+cls.t[0][8:10]}.tplot"
calfile_name = f"{TEST_DATASET_PATH}validation_el{cls.probe}_epd_l1_eflux_{cls.t[0][0:4]+cls.t[0][5:7]+cls.t[0][8:10]}.tplot"
calfile = download(remote_file=calfile_name,
remote_path=CONFIG['remote_data_dir'],
local_path=CONFIG['local_data_dir'],
no_download=False)
if not calfile:
raise unittest.SkipTest(f"Cannot download validation file {calfile_name}")
filename = CONFIG['local_data_dir'] + calfile_name
tplot_restore(filename)
cls.elf_pef_eflux = pytplot.get_data(f"el{cls.probe}_pef_eflux")
cls.elf_pef_sectnum = pytplot.get_data(f"el{cls.probe}_pef_sectnum")
Expand Down
60 changes: 47 additions & 13 deletions pyspedas/elfin/tests/test_epd_l2.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
from numpy.testing import assert_allclose
import pytplot.get_data
from pytplot.importers.tplot_restore import tplot_restore

import pyspedas.elfin
from pyspedas.elfin.epd.calibration_l2 import spec_pa_sort
from pyspedas.utilities.download import download
from pyspedas.elfin.config import CONFIG

TEST_DATASET_PATH="pyspedas/elfin/tests/test_dataset/"
TEST_DATASET_PATH="test/"

class TestELFL2Validation(unittest.TestCase):
"""Tests of the data been identical to SPEDAS (IDL)."""
Expand All @@ -31,8 +34,16 @@ def setUpClass(cls):
cls.t = ['2022-08-28/15:54','2022-08-28/16:15'] # pass
cls.probe = 'a'

# load epd l2 hs nflux spectrogram
filename = f"{TEST_DATASET_PATH}validation_el{cls.probe}_epd_l2_hs_nflux_{cls.t[0][0:4]+cls.t[0][5:7]+cls.t[0][8:10]}.tplot"
# load epd l2 hs nflux spectrogram
calfile_name = f"{TEST_DATASET_PATH}validation_el{cls.probe}_epd_l2_hs_nflux_{cls.t[0][0:4]+cls.t[0][5:7]+cls.t[0][8:10]}.tplot"
calfile = download(remote_file=calfile_name,
remote_path=CONFIG['remote_data_dir'],
local_path=CONFIG['local_data_dir'],
no_download=False)
if not calfile:
# Skip tests
raise unittest.SkipTest(f"Cannot download validation file {calfile_name}")
filename = CONFIG['local_data_dir'] + calfile_name
tplot_restore(filename)
cls.elf_pef_hs_nflux_ch0 = pytplot.get_data(f"el{cls.probe}_pef_hs_nflux_ch0")
cls.elf_pef_hs_nflux_ch1 = pytplot.get_data(f"el{cls.probe}_pef_hs_nflux_ch1")
Expand All @@ -46,12 +57,19 @@ def setUpClass(cls):
cls.elf_pef_hs_LCdeg = pytplot.get_data(f"el{cls.probe}_pef_hs_LCdeg")
cls.elf_pef_Et_nflux = pytplot.get_data(f"el{cls.probe}_pef_Et_nflux")
cls.elf_pef_pa = pytplot.get_data(f"el{cls.probe}_pef_pa")
cls.elf_pef_hs_Epat_nflux_ch0 = pytplot.get_data(f"el{cls.probe}_pef_hs_Epat_nflux_ch0")
cls.elf_pef_hs_Epat_nflux_ch0 = pytplot.get_data(f"el{cls.probe}_pef_hs_Epat_nflux_ch0")
# Epat is 3d, can't save it with idl
cls.elf_pef_hs_Epat_nflux_ch1 = pytplot.get_data(f"el{cls.probe}_pef_hs_Epat_nflux_ch1")

# load epd l2 hs eflux spectrogram
filename = f"{TEST_DATASET_PATH}validation_el{cls.probe}_epd_l2_hs_eflux_{cls.t[0][0:4]+cls.t[0][5:7]+cls.t[0][8:10]}.tplot"
calfile_name = f"{TEST_DATASET_PATH}validation_el{cls.probe}_epd_l2_hs_eflux_{cls.t[0][0:4]+cls.t[0][5:7]+cls.t[0][8:10]}.tplot"
calfile = download(remote_file=calfile_name,
remote_path=CONFIG['remote_data_dir'],
local_path=CONFIG['local_data_dir'],
no_download=False)
if not calfile:
raise unittest.SkipTest(f"Cannot download validation file {calfile_name}")
filename = CONFIG['local_data_dir'] + calfile_name
tplot_restore(filename)
cls.elf_pef_hs_eflux_ch0 = pytplot.get_data(f"el{cls.probe}_pef_hs_eflux_ch0")
cls.elf_pef_hs_eflux_ch1 = pytplot.get_data(f"el{cls.probe}_pef_hs_eflux_ch1")
Expand All @@ -62,12 +80,20 @@ def setUpClass(cls):
cls.elf_pef_hs_eflux_anti = pytplot.get_data(f"el{cls.probe}_pef_hs_eflux_anti")
cls.elf_pef_hs_eflux_perp = pytplot.get_data(f"el{cls.probe}_pef_hs_eflux_perp")
cls.elf_pef_Et_eflux = pytplot.get_data(f"el{cls.probe}_pef_Et_eflux")
cls.elf_pef_hs_Epat_eflux_ch0 = pytplot.get_data(f"el{cls.probe}_pef_hs_Epat_eflux_ch0")
cls.elf_pef_hs_Epat_eflux_ch0 = pytplot.get_data(f"el{cls.probe}_pef_hs_Epat_eflux_ch0")
# Epat is 3d, can't save it with idl
cls.elf_pef_hs_Epat_eflux_ch1 = pytplot.get_data(f"el{cls.probe}_pef_hs_Epat_eflux_ch1")

# load epd l2 fs nflux spectrogram
filename = f"{TEST_DATASET_PATH}validation_el{cls.probe}_epd_l2_fs_nflux_{cls.t[0][0:4]+cls.t[0][5:7]+cls.t[0][8:10]}.tplot"


# load epd l2 fs nflux spectrogram
calfile_name = f"{TEST_DATASET_PATH}validation_el{cls.probe}_epd_l2_fs_nflux_{cls.t[0][0:4]+cls.t[0][5:7]+cls.t[0][8:10]}.tplot"
calfile = download(remote_file=calfile_name,
remote_path=CONFIG['remote_data_dir'],
local_path=CONFIG['local_data_dir'],
no_download=False)
if not calfile:
raise unittest.SkipTest(f"Cannot download validation file {calfile_name}")
filename = CONFIG['local_data_dir'] + calfile_name
tplot_restore(filename)
cls.elf_pef_fs_nflux_ch0 = pytplot.get_data(f"el{cls.probe}_pef_fs_nflux_ch0")
cls.elf_pef_fs_nflux_ch1 = pytplot.get_data(f"el{cls.probe}_pef_fs_nflux_ch1")
Expand All @@ -77,20 +103,28 @@ def setUpClass(cls):
cls.elf_pef_fs_nflux_perp = pytplot.get_data(f"el{cls.probe}_pef_fs_nflux_perp")
cls.elf_pef_fs_antiLCdeg = pytplot.get_data(f"el{cls.probe}_pef_fs_antiLCdeg")
cls.elf_pef_fs_LCdeg = pytplot.get_data(f"el{cls.probe}_pef_fs_LCdeg")
cls.elf_pef_fs_Epat_nflux_ch0 = pytplot.get_data(f"el{cls.probe}_pef_fs_Epat_nflux_ch0")
cls.elf_pef_fs_Epat_nflux_ch0 = pytplot.get_data(f"el{cls.probe}_pef_fs_Epat_nflux_ch0")
# Epat is 3d, can't save it with idl
cls.elf_pef_fs_Epat_nflux_ch1 = pytplot.get_data(f"el{cls.probe}_pef_fs_Epat_nflux_ch1")

# load epd l2 fs eflux spectrogram
filename = f"{TEST_DATASET_PATH}validation_el{cls.probe}_epd_l2_fs_eflux_{cls.t[0][0:4]+cls.t[0][5:7]+cls.t[0][8:10]}.tplot"

# load epd l2 fs eflux spectrogram
calfile_name = f"{TEST_DATASET_PATH}validation_el{cls.probe}_epd_l2_fs_eflux_{cls.t[0][0:4]+cls.t[0][5:7]+cls.t[0][8:10]}.tplot"
calfile = download(remote_file=calfile_name,
remote_path=CONFIG['remote_data_dir'],
local_path=CONFIG['local_data_dir'],
no_download=False)
if not calfile:
raise unittest.SkipTest(f"Cannot download validation file {calfile_name}")
filename = CONFIG['local_data_dir'] + calfile_name
tplot_restore(filename)
cls.elf_pef_fs_eflux_ch0 = pytplot.get_data(f"el{cls.probe}_pef_fs_eflux_ch0")
cls.elf_pef_fs_eflux_ch1 = pytplot.get_data(f"el{cls.probe}_pef_fs_eflux_ch1")
cls.elf_pef_fs_eflux_omni = pytplot.get_data(f"el{cls.probe}_pef_fs_eflux_omni")
cls.elf_pef_fs_eflux_para = pytplot.get_data(f"el{cls.probe}_pef_fs_eflux_para")
cls.elf_pef_fs_eflux_anti = pytplot.get_data(f"el{cls.probe}_pef_fs_eflux_anti")
cls.elf_pef_fs_eflux_perp = pytplot.get_data(f"el{cls.probe}_pef_fs_eflux_perp")
cls.elf_pef_fs_Epat_eflux_ch0 = pytplot.get_data(f"el{cls.probe}_pef_fs_Epat_eflux_ch0")
cls.elf_pef_fs_Epat_eflux_ch0 = pytplot.get_data(f"el{cls.probe}_pef_fs_Epat_eflux_ch0")
# Epat is 3d, can't save it with idl
cls.elf_pef_fs_Epat_eflux_ch1 = pytplot.get_data(f"el{cls.probe}_pef_fs_Epat_eflux_ch1")

Expand Down
14 changes: 12 additions & 2 deletions pyspedas/elfin/tests/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
import pytplot.get_data
from pytplot.importers.tplot_restore import tplot_restore
from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal

import pyspedas.elfin
from pyspedas.utilities.download import download
from pyspedas.elfin.config import CONFIG

TEST_DATASET_PATH="pyspedas/elfin/tests/test_dataset/"
TEST_DATASET_PATH="test/"

class TestELFStateValidation(unittest.TestCase):
"""Tests of the data been identical to SPEDAS (IDL)."""
Expand All @@ -28,7 +31,14 @@ def setUpClass(cls):
cls.probe = 'b'

# Load validation variables from the test file
filename = f"{TEST_DATASET_PATH}validation_el{cls.probe}_state_{cls.t[0][0:4]+cls.t[0][5:7]+cls.t[0][8:10]}.tplot"
calfile_name = f"{TEST_DATASET_PATH}validation_el{cls.probe}_state_{cls.t[0][0:4]+cls.t[0][5:7]+cls.t[0][8:10]}.tplot"
calfile = download(remote_file=calfile_name,
remote_path=CONFIG['remote_data_dir'],
local_path=CONFIG['local_data_dir'],
no_download=False)
if not calfile:
raise unittest.SkipTest(f"Cannot download validation file {calfile_name}")
filename = CONFIG['local_data_dir'] + calfile_name
tplot_restore(filename)
cls.elf_pos_gei = pytplot.get_data(f"el{cls.probe}_pos_gei")
cls.elf_vel_gei = pytplot.get_data(f"el{cls.probe}_vel_gei")
Expand Down

0 comments on commit d33da72

Please sign in to comment.