Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #105, updates to raw_fcio.py #113

Merged
merged 2 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions workflow/src/legenddataflow/scripts/tier/raw_blind.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"""

import argparse
from pathlib import Path

import numexpr as ne
import numpy as np
Expand Down Expand Up @@ -111,12 +110,6 @@ def build_tier_raw_blind() -> None:
# gets events that should not be blinded
tokeep = allind[np.logical_not(np.isin(allind, toblind))]

# make some temp file to write the output to before renaming it
rng = np.random.default_rng()
rand_num = f"{rng.integers(0,99999):05d}"
temp_output = f"{args.output}.{rand_num}"
Path(temp_output).parent.mkdir(parents=True, exist_ok=True)

for channel in all_channels:
try:
chnum = int(channel[2::])
Expand All @@ -126,7 +119,7 @@ def build_tier_raw_blind() -> None:
store.write_object(
chobj,
channel,
lh5_file=temp_output,
lh5_file=args.output,
wo_mode="w",
**hdf_settings,
)
Expand All @@ -139,7 +132,7 @@ def build_tier_raw_blind() -> None:
chobj,
group=channel,
name="raw",
lh5_file=temp_output,
lh5_file=args.output,
wo_mode="w",
**hdf_settings,
)
Expand All @@ -157,11 +150,7 @@ def build_tier_raw_blind() -> None:
blinded_chobj,
group=channel,
name="raw",
lh5_file=temp_output,
lh5_file=args.output,
wo_mode="w",
**hdf_settings,
)

# rename the temp file
Path(args.output).parent.mkdir(parents=True, exist_ok=True)
Path(temp_output).rename(args.output)
24 changes: 1 addition & 23 deletions workflow/src/legenddataflow/scripts/tier/raw_fcio.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import argparse
from copy import deepcopy
from pathlib import Path

import numpy as np
from daq2lh5 import build_raw
from dbetto import TextDB
from dbetto.catalog import Props
Expand Down Expand Up @@ -36,24 +34,11 @@ def build_tier_raw_fcio() -> None:
channel_dict = channel_dict.out_spec
all_config = Props.read_from(channel_dict.gen_config)

chmap = (
TextDB(args.chan_maps, lazy=True).channelmaps.on(args.timestamp).group("system")
)

if "geds_config" in channel_dict:
raise NotImplementedError()

if "spms_config" in channel_dict:
spm_config = Props.read_from(channel_dict.spms_config)
spm_channels = chmap.spms.map("daq.rawid")

for rawid, chinfo in spm_channels.items():
cfg_block = deepcopy(spm_config["FCEventDecoder"]["__output_table_name__"])
cfg_block["key_list"] = [chinfo.daq.fc_channel]
spm_config["FCEventDecoder"][f"ch{rawid:07d}/raw"] = cfg_block

spm_config["FCEventDecoder"].pop("__output_table_name__")

Props.add_to(all_config, spm_config)

if "auxs_config" in channel_dict:
Expand All @@ -62,11 +47,4 @@ def build_tier_raw_fcio() -> None:
if "muon_config" in channel_dict:
raise NotImplementedError()

rng = np.random.default_rng()
rand_num = f"{rng.integers(0,99999):05d}"
temp_output = f"{args.output}.{rand_num}"

build_raw(args.input, out_spec=all_config, filekey=temp_output, **settings)

# rename the temp file
Path(temp_output).rename(args.output)
build_raw(args.input, out_spec=all_config, filekey=args.output, **settings)
10 changes: 1 addition & 9 deletions workflow/src/legenddataflow/scripts/tier/raw_orca.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import logging
from pathlib import Path

import numpy as np
from daq2lh5 import build_raw
from dbetto import TextDB
from dbetto.catalog import Props
Expand Down Expand Up @@ -100,11 +99,4 @@ def build_tier_raw_orca() -> None:
)
Props.add_to(all_config, muon_config)

rng = np.random.default_rng()
rand_num = f"{rng.integers(0,99999):05d}"
temp_output = f"{args.output}.{rand_num}"

build_raw(args.input, out_spec=all_config, filekey=temp_output, **settings)

# rename the temp file
Path(temp_output).rename(args.output)
build_raw(args.input, out_spec=all_config, filekey=args.output, **settings)
10 changes: 1 addition & 9 deletions workflow/src/legenddataflow/scripts/tier/tcm.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import argparse
from pathlib import Path

import lgdo.lh5 as lh5
import numpy as np
from daq2lh5.orca import orca_flashcam
from dbetto import TextDB
from dbetto.catalog import Props
Expand All @@ -28,10 +26,6 @@ def build_tier_tcm() -> None:

settings = Props.read_from(config_dict["inputs"]["config"])

rng = np.random.default_rng()
temp_output = f"{args.output}.{rng.integers(0, 99999):05d}"
Path(args.output).parent.mkdir(parents=True, exist_ok=True)

# get the list of channels by fcid
ch_list = lh5.ls(args.input, "/ch*")
fcid_channels = {}
Expand All @@ -46,10 +40,8 @@ def build_tier_tcm() -> None:
for fcid, fcid_dict in fcid_channels.items():
build_tcm(
[(args.input, fcid_dict)],
out_file=temp_output,
out_file=args.output,
out_name=f"hardware_tcm_{fcid}",
wo_mode="o",
**settings,
)

Path(temp_output).rename(args.output)
Loading