Skip to content

Commit

Permalink
Fixing mag tests, removing temp fix (#1142)
Browse files Browse the repository at this point in the history
* Fixing mag tests, removing temp fix

* Fix type error
  • Loading branch information
maxinelasp authored Nov 13, 2024
1 parent 1aa96aa commit 812ddc2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion imap_processing/mag/l0/decom_mag.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,4 @@ def generate_dataset(
attrs=attribute_manager.get_variable_attributes(key),
)

return output.drop_duplicates("epoch")
return output
2 changes: 1 addition & 1 deletion imap_processing/mag/l1b/mag_l1b.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def rescale_vector(
if not compression_flags[0]:
return input_vector
else:
factor = float(2 ** (16 - compression_flags[1]))
factor = np.float_power(2, (16 - compression_flags[1]))
return input_vector * factor # type: ignore


Expand Down
Binary file not shown.
Binary file not shown.
15 changes: 8 additions & 7 deletions imap_processing/tests/mag/test_mag_l1b.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def mag_l1a_dataset():
dims=["epoch", "direction"],
coords={"epoch": epoch, "direction": direction},
)
compression_flags = xr.DataArray(np.zeros((20, 2)), dims=["epoch", "compression"])
compression_flags = xr.DataArray(
np.zeros((20, 2), dtype=np.int8), dims=["epoch", "compression"]
)

vectors[0, :] = np.array([1, 1, 1, 0])

Expand Down Expand Up @@ -69,10 +71,9 @@ def test_mag_attributes(mag_l1a_dataset):
assert output.attrs["Data_level"] == "L1B"


@pytest.mark.skip(reason="Epoch variable data need to be monotonically increasing")
def test_cdf_output():
l1a_cdf = load_cdf(
Path(__file__).parent / "imap_mag_l1a_burst-magi_20231025_v001.cdf"
Path(__file__).parent / "imap_mag_l1a_norm-magi_20251017_v001.cdf"
)
l1b_dataset = mag_l1b(l1a_cdf, "v001")

Expand All @@ -94,10 +95,10 @@ def test_mag_compression_scale(mag_l1a_dataset):
mag_l1a_dataset["vectors"][2, :] = np.array([1, 1, 1, 0])
mag_l1a_dataset["vectors"][3, :] = np.array([1, 1, 1, 0])

mag_l1a_dataset["compression_flags"][0, :] = np.array([1, 16])
mag_l1a_dataset["compression_flags"][1, :] = np.array([0, 0])
mag_l1a_dataset["compression_flags"][2, :] = np.array([1, 18])
mag_l1a_dataset["compression_flags"][3, :] = np.array([1, 14])
mag_l1a_dataset["compression_flags"][0, :] = np.array([1, 16], dtype=np.int8)
mag_l1a_dataset["compression_flags"][1, :] = np.array([0, 0], dtype=np.int8)
mag_l1a_dataset["compression_flags"][2, :] = np.array([1, 18], dtype=np.int8)
mag_l1a_dataset["compression_flags"][3, :] = np.array([1, 14], dtype=np.int8)

mag_l1a_dataset.attrs["Logical_source"] = ["imap_mag_l1a_norm-mago"]
output = mag_l1b(mag_l1a_dataset, "v001")
Expand Down

0 comments on commit 812ddc2

Please sign in to comment.