Skip to content

Commit f00dbca

Browse files
committed
pre-commit fixes
1 parent f205fb7 commit f00dbca

File tree

3 files changed

+31
-18
lines changed

3 files changed

+31
-18
lines changed

scripts/blinding_calibration.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,14 @@
7474

7575
# dictionary to pass to build hit
7676
out_dict = {
77-
"pars":{
78-
"operations":{
77+
"pars": {
78+
"operations": {
7979
"daqenergy_cal": {
8080
"expression": "daqenergy*a",
8181
"parameters": {"a": round(roughpars[0], 5)},
8282
}
8383
}
8484
}
85-
8685
}
8786

8887
# plot to check thagt the calibration is correct with zoom on 2.6 peak

scripts/build_raw.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,6 @@
8181
rand_num = f"{rng.integers(0,99999):05d}"
8282
temp_output = f"{args.output}.{rand_num}"
8383

84-
build_raw(
85-
args.input,
86-
out_spec=all_config,
87-
filekey=temp_output,
88-
**settings
89-
)
84+
build_raw(args.input, out_spec=all_config, filekey=temp_output, **settings)
9085

9186
os.rename(temp_output, args.output)

scripts/build_raw_blind.py

+28-9
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@
4141
configs = LegendMetadata(path=args.configs)
4242
channel_dict = configs.on(args.timestamp, system=args.datatype)
4343

44-
hdf_settings = Props.read_from(channel_dict["snakemake_rules"]["tier_raw"]["inputs"]["settings"])["hdf5_settings"]
45-
blinding_settings = Props.read_from(channel_dict["snakemake_rules"]["tier_raw_blind"]["inputs"]["config"])
44+
hdf_settings = Props.read_from(channel_dict["snakemake_rules"]["tier_raw"]["inputs"]["settings"])[
45+
"hdf5_settings"
46+
]
47+
blinding_settings = Props.read_from(
48+
channel_dict["snakemake_rules"]["tier_raw_blind"]["inputs"]["config"]
49+
)
4650

4751
centroid = blinding_settings["centroid_in_keV"] # keV
4852
width = blinding_settings["width_in_keV"] # keV
@@ -83,7 +87,9 @@
8387
)
8488

8589
# figure out which event indices should be blinded
86-
toblind = np.append(toblind, np.nonzero(np.abs(np.asarray(daqenergy_cal) - centroid) <= width)[0])
90+
toblind = np.append(
91+
toblind, np.nonzero(np.abs(np.asarray(daqenergy_cal) - centroid) <= width)[0]
92+
)
8793

8894
# remove duplicates
8995
toblind = np.unique(toblind)
@@ -105,15 +111,22 @@
105111
except ValueError:
106112
# if this isn't an interesting channel, just copy it to the output file
107113
chobj, _ = store.read_object(channel, args.input, decompress=False)
108-
store.write_object(chobj, channel, lh5_file=temp_output, wo_mode="w",
109-
hdf5_settings=hdf_settings)
114+
store.write_object(
115+
chobj, channel, lh5_file=temp_output, wo_mode="w", hdf5_settings=hdf_settings
116+
)
110117
continue
111118

112119
if (chnum not in list(ged_channels)) and (chnum not in list(spms_channels)):
113120
# if this is a PMT or not included for some reason, just copy it to the output file
114121
chobj, _ = store.read_object(channel + "/raw", args.input, decompress=False)
115-
store.write_object(chobj, group=channel, name="raw", lh5_file=temp_output, wo_mode="w",
116-
hdf5_settings=hdf_settings)
122+
store.write_object(
123+
chobj,
124+
group=channel,
125+
name="raw",
126+
lh5_file=temp_output,
127+
wo_mode="w",
128+
hdf5_settings=hdf_settings,
129+
)
117130
continue
118131

119132
# the rest should be the Ge and SiPM channels that need to be blinded
@@ -124,8 +137,14 @@
124137
)
125138

126139
# now write the blinded data for this channel
127-
store.write_object(blinded_chobj, group=channel, name="raw", lh5_file=temp_output, wo_mode="w",
128-
hdf5_settings=hdf_settings)
140+
store.write_object(
141+
blinded_chobj,
142+
group=channel,
143+
name="raw",
144+
lh5_file=temp_output,
145+
wo_mode="w",
146+
hdf5_settings=hdf_settings,
147+
)
129148

130149
# rename the temp file
131150
os.rename(temp_output, args.output)

0 commit comments

Comments
 (0)