Skip to content

Commit

Permalink
Single Test for one file test_calibration.py
Browse files Browse the repository at this point in the history
changed name of stats var
removing unsusable bin file
  • Loading branch information
rstrub committed Dec 6, 2023
1 parent a61435f commit 044daa3
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 51 deletions.
4 changes: 2 additions & 2 deletions hermes_eea/calibration/build_spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ def build_HermesData(self):
iso_times = Time(epoch_to_iso(self.EEA.Epoch[:]), scale='utc')
ts_1d_uQ = TimeSeries(
time=iso_times,
data={"stats": astropy_units.Quantity(self.EEA.stats, "gauss", dtype=np.uint16)}
data={"hermes_eea_stats": astropy_units.Quantity(self.EEA.stats, "gauss", dtype=np.uint16)}
) # this works
self._hermes_eea_spectra()
bare_attrs = HermesData.global_attribute_template("eea", "l1", "1.0.0")
ts_justTime = TimeSeries(time=iso_times)

self.hermes_eea_data = HermesData(timeseries=ts_1d_uQ, spectra=self.multiple_spectra, meta=bare_attrs)
self.hermes_eea_data.timeseries['stats'].meta.update({"CATDESC": "Sum of skymap for each sweep"})
self.hermes_eea_data.timeseries['hermes_eea_stats'].meta.update({"CATDESC": "Sum of skymap for each sweep"})

def _hermes_eea_spectra(self):
self.multiple_spectra = NDCollection(
Expand Down
Binary file removed hermes_eea/data/hermes_EEA_l0_2023038-000000_v0.bin
Binary file not shown.
49 changes: 0 additions & 49 deletions hermes_eea/tests/test_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,7 @@ def small_level0_file(tmp_path_factory):
fn = Path(os.path.join(_data_directory, "hermes_EEA_l0_2023042-000000_v0.bin"))
return fn

@pytest.fixture(scope="session") # this is a pytest fixture
def large_level0_file(tmp_path_factory):
fn = Path(os.path.join(_data_directory, "hermes_EEA_l0_2023041-000000_v0.bin"))
return fn

@pytest.fixture(scope="session")
def level1_file(tmp_path_factory):
fn = tmp_path_factory.mktemp("data") / level1_filename
with open(fn, "w"):
pass
return fn

def test_get_calibration_file():
file = Path(os.path.join(_data_directory, stepper_table))
assert file.is_file()

def test_read_calibration_file():
file = Path(os.path.join(_data_directory, stepper_table))
calib.read_calibration_file(file)
assert len(calib.energies) == 164
assert len(calib.deflections) == 164


def test_calibrate_file(small_level0_file):
Expand All @@ -48,35 +28,6 @@ def test_calibrate_file(small_level0_file):



# This drops all the way down to ccsdspy but seems to work
def test_calibrate_file_nofile_error():
"""Test that if file does not exist it produces the correct error. The file needs to be in the correct format."""
with pytest.raises(FileNotFoundError):
calib.calibrate_file(Path("hermes_EEA_l0_2032339-000000_v0.bin"))

# This one is less clear as yet...
def test_process_file_nofile_error():
"""Test that if file does not exist it produces the correct error. The file needs to be in the correct format."""
files = []
files.append((Path("hermes_EEA_l0_2032339-000000_v0.bin")))
files.append((Path("hermes_EEA_l0_2032340-000000_v0.bin")))

with pytest.raises(FileNotFoundError):
calib.process_file(files)



# this processes more than one file
def test_process_file_level0(large_level0_file,small_level0_file):
"""Test that the output filenames are correct and that a file was actually created."""

output_files = calib.process_file(
[large_level0_file, small_level0_file]
)
assert os.path.basename(output_files[0]) == "hermes_eea_l1_20000101T124114_v1.0.0.cdf"
assert os.path.basename(output_files[1]) == "hermes_eea_l1_20000101T170901_v1.0.0.cdf"
assert os.path.getsize(output_files[0]) == 266568541
assert os.path.getsize(output_files[1]) == 275299



Expand Down

0 comments on commit 044daa3

Please sign in to comment.