Skip to content

Commit

Permalink
added test for bit mask
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosanna Deckert authored and Rosanna Deckert committed Nov 21, 2023
1 parent fc88bfd commit 890bdfb
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/hit/configs/aggregations-hit-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"outputs": [
"is_valid_rt",
"is_valid_t0",
"is_valid_tmax",
"aggr1",
"aggr2"
],
"operations": {
"is_valid_rt": {
"expression": "((tp_90-tp_10)>96) & ((tp_50-tp_10)>=16)",
"parameters": {}
},
"is_valid_t0": {
"expression": "(tp_0_est>47000) & (tp_0_est<55000)",
"parameters": {}
},
"is_valid_tmax": {
"expression": "(tp_max>47000) & (tp_max<120000)",
"parameters": {}
}
},
"aggregations": {
"aggr1": {
"bit0": "is_valid_rt",
"bit1": "is_valid_t0",
"bit2": "is_valid_tmax"
},
"aggr2": {
"bit0": "is_valid_t0",
"bit1": "is_valid_tmax"
}
}
}
25 changes: 25 additions & 0 deletions tests/hit/test_build_hit.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,32 @@ def test_outputs_specification(dsp_test_file, tmptestdir):
store = LH5Store()
obj, _ = store.read_object("/geds/hit", outfile)
assert list(obj.keys()) == ["calE", "AoE", "A_max"]


def test_aggregation_outputs(dsp_test_file, tmptestdir):
outfile = f"{tmptestdir}/LDQTA_r117_20200110T105115Z_cal_geds_hit.lh5"

build_hit(
dsp_test_file,
outfile=outfile,
hit_config=f"{config_dir}/aggregations-hit-config.json",
wo_mode="overwrite",
)

sto = LH5Store()
obj, _ = sto.read_object("/geds/hit", outfile)
assert list(obj.keys()) == ["is_valid_rt", "is_valid_t0", "is_valid_tmax", "aggr1", "aggr2"]

df = store.load_dfs(outfile, ["aggr1", "aggr2"], "geds/hit/")

assert df["aggr1"].dtype == 'int'
assert df["aggr2"].dtype == 'int'

# aggr1 consists of 3 bits --> max number can be 7, aggr2 consists of 2 bits so max numer can be 3
assert (df["aggr1"] > 7).any() == False
assert (df["aggr2"] > 3).any() == False



def test_build_hit_spms_basic(dsp_test_file_spm, tmptestdir):
out_file = f"{tmptestdir}/L200-comm-20211130-phy-spms_hit.lh5"
Expand Down

0 comments on commit 890bdfb

Please sign in to comment.