diff --git a/workflow/src/legenddataflow/scripts/tier/raw_blind.py b/workflow/src/legenddataflow/scripts/tier/raw_blind.py index 57df92db..72c6ab35 100644 --- a/workflow/src/legenddataflow/scripts/tier/raw_blind.py +++ b/workflow/src/legenddataflow/scripts/tier/raw_blind.py @@ -11,7 +11,6 @@ """ import argparse -from pathlib import Path import numexpr as ne import numpy as np @@ -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::]) @@ -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, ) @@ -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, ) @@ -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) diff --git a/workflow/src/legenddataflow/scripts/tier/raw_fcio.py b/workflow/src/legenddataflow/scripts/tier/raw_fcio.py index c52f441a..67942b93 100644 --- a/workflow/src/legenddataflow/scripts/tier/raw_fcio.py +++ b/workflow/src/legenddataflow/scripts/tier/raw_fcio.py @@ -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 @@ -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: @@ -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) diff --git a/workflow/src/legenddataflow/scripts/tier/raw_orca.py b/workflow/src/legenddataflow/scripts/tier/raw_orca.py index ca6a9f3b..9ee5a0f1 100644 --- a/workflow/src/legenddataflow/scripts/tier/raw_orca.py +++ b/workflow/src/legenddataflow/scripts/tier/raw_orca.py @@ -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 @@ -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) diff --git a/workflow/src/legenddataflow/scripts/tier/tcm.py b/workflow/src/legenddataflow/scripts/tier/tcm.py index 6f53b1fe..8152c0bd 100644 --- a/workflow/src/legenddataflow/scripts/tier/tcm.py +++ b/workflow/src/legenddataflow/scripts/tier/tcm.py @@ -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 @@ -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 = {} @@ -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)