Skip to content

Commit e92ac21

Browse files
committed
Replace .format with f-strings
1 parent 7cd5353 commit e92ac21

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

src/nectarchain/user_scripts/ltibaldo/pedestal_temperature.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
flagged_pixels = 0
4040

4141
for pixel_id in np.arange(N_PIXELS):
42-
print("Working on pixel {}".format(pixel_id))
42+
print(f"Working on pixel {pixel_id}")
4343
# fill panda dataframe
4444
temperatures = []
4545
channels = []
@@ -49,16 +49,16 @@
4949
for dataset in data:
5050
for run_number in dataset["runs"]:
5151
run_number = int(run_number)
52-
filename = os.environ[
53-
"NECTARCAMDATA"
54-
] + "/runs/pedestal_cfilt3s_{}.h5".format(run_number)
52+
filename = (
53+
os.environ["NECTARCAMDATA"] + f"/runs/pedestal_cfilt3s_{run_number}.h5"
54+
)
5555
h5file = tables.open_file(filename)
5656
table = h5file.root["data_combined"]["NectarCAMPedestalContainer_0"][0]
5757
for channel in ["hg", "lg"]:
58-
pedestal = table["pedestal_mean_{}".format(channel)][
58+
pedestal = table[f"pedestal_mean_{channel}"][
5959
table["pixels_id"] == pixel_id
6060
][0]
61-
rms = table["pedestal_charge_std_{}".format(channel)][
61+
rms = table[f"pedestal_charge_std_{channel}"][
6262
table["pixels_id"] == pixel_id
6363
][0]
6464
avgped = np.average(pedestal)
@@ -131,29 +131,24 @@
131131
slopes_rms_lg[pixel_id] = slope
132132
if pixel_id in pixel_display:
133133
ax.annotate(
134-
"y = {:.4f} T + {:.4f}".format(slope, intercept),
134+
f"y = {slope:.4f} T + {intercept:.4f}",
135135
(0.05, 0.85 - s * 0.05),
136136
color=colors[s],
137137
xycoords="axes fraction",
138138
)
139139

140140
if pixel_id in pixel_display:
141-
ax.set_title("Pixel {}, NSB OFF".format(pixel_id))
141+
ax.set_title(f"Pixel {pixel_id}, NSB OFF")
142142
fig.savefig(
143-
"{}/pixel{}_{}.png".format(os.environ["FIGDIR"], pixel_id, k)
143+
f"{os.environ['NECTARCHAIN_FIGURES']}/pixel{pixel_id}_{k}.png"
144144
)
145145
del fig
146146
plt.close()
147147

148+
print(f"{flagged_pixels} pixels were flagged as bad by the pedestal estimation tool")
148149
print(
149-
"{} pixels were flagged as bad by the pedestal estimation tool".format(
150-
flagged_pixels
151-
)
152-
)
153-
print(
154-
"{} pixels were removed because they had a pedestal RMS exceeding {}".format(
155-
removed_pixels, rms_threshold
156-
)
150+
f"{removed_pixels} pixels were removed because they had a pedestal RMS "
151+
f"exceeding {rms_threshold}"
157152
)
158153

159154
camera = CameraGeometry.from_name("NectarCam-003")
@@ -204,4 +199,4 @@
204199
disp.add_colorbar()
205200
disp.update()
206201
ax.set_title("")
207-
fig.savefig("{}/camera_{}.png".format(os.environ["FIGDIR"], k))
202+
fig.savefig(f"{os.environ['NECTARCHAIN_FIGURES']}/camera_{k}.png")

0 commit comments

Comments
 (0)