Skip to content

Commit

Permalink
swe l1a validation data (#1038)
Browse files Browse the repository at this point in the history
  • Loading branch information
tech3371 authored Oct 23, 2024
1 parent 95b93d6 commit d6daf1b
Show file tree
Hide file tree
Showing 7 changed files with 5,286 additions and 754 deletions.
41 changes: 41 additions & 0 deletions imap_processing/tests/swe/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pandas as pd
import pytest

from imap_processing import imap_module_directory
Expand Down Expand Up @@ -33,3 +34,43 @@ def decom_test_data_derived():
packet_file, xtce_document, use_derived_value=True
)
return datasets_by_apid[SWEAPID.SWE_SCIENCE]


@pytest.fixture(scope="session")
def l1a_validation_df():
"""Read validation data from file"""
l1_val_path = imap_module_directory / "tests/swe/l1_validation"
filename = "swe_l0_unpacked-data_20240510_v001_VALIDATION_L1A.dat"

# Define column names for validation data
column_names = [
"shcoarse",
"raw_cnt_cem_1",
"raw_cnt_cem_2",
"raw_cnt_cem_3",
"raw_cnt_cem_4",
"raw_cnt_cem_5",
"raw_cnt_cem_6",
"raw_cnt_cem_7",
"decom_cnt_cem_1",
"decom_cnt_cem_2",
"decom_cnt_cem_3",
"decom_cnt_cem_4",
"decom_cnt_cem_5",
"decom_cnt_cem_6",
"decom_cnt_cem_7",
]

# Read the data, specifying na_values and delimiter
df = pd.read_csv(
l1_val_path / filename,
skiprows=10, # Skip the first 10 rows of comments
sep=r"\s*,\s*", # Regex to handle spaces and commas as delimiters
names=column_names,
na_values=["", " "], # Treat empty strings or spaces as NaN
engine="python",
)

# Fill NaNs with the previous value
df["shcoarse"] = df["shcoarse"].ffill()
return df

This file was deleted.

Loading

0 comments on commit d6daf1b

Please sign in to comment.