|
102 | 102 |
|
103 | 103 | for itemp, uberset in enumerate(pedfiles): |
104 | 104 | temp = uberset["T"] |
105 | | - print("Analyzing data for temperature {}".format(temp)) |
| 105 | + print(f"Analyzing data for temperature {temp}") |
106 | 106 |
|
107 | 107 | # create output directory if needed |
108 | | - outdir = os.path.join(outfigroot, "NSB_T{}deg".format(temp)) |
| 108 | + outdir = os.path.join(outfigroot, f"NSB_T{temp}deg") |
109 | 109 | if not os.path.exists(outdir): |
110 | 110 | os.makedirs(outdir) |
111 | 111 |
|
|
118 | 118 | flagged_pixels = 0 |
119 | 119 |
|
120 | 120 | for pixel_id in pixel_process: |
121 | | - print("Working on pixel {}".format(pixel_id)) |
| 121 | + print(f"Working on pixel {pixel_id}") |
122 | 122 | # fill panda dataframe |
123 | 123 | nsbs = [] |
124 | 124 | channels = [] |
|
128 | 128 | for dataset in uberset["data"]: |
129 | 129 | for run_number in dataset["runs"]: |
130 | 130 | run_number = int(run_number) |
131 | | - filename = os.environ[ |
132 | | - "NECTARCAMDATA" |
133 | | - ] + "/runs/pedestal_cfilt3s_{}.h5".format(run_number) |
| 131 | + filename = ( |
| 132 | + os.environ["NECTARCAMDATA"] |
| 133 | + + f"/runs/pedestal_cfilt3s_{run_number}.h5" |
| 134 | + ) |
134 | 135 | h5file = tables.open_file(filename) |
135 | 136 | table = h5file.root["data_combined"]["NectarCAMPedestalContainer_0"][0] |
136 | 137 | for channel in ["hg", "lg"]: |
137 | | - pedestal = table["pedestal_mean_{}".format(channel)][ |
| 138 | + pedestal = table[f"pedestal_mean_{channel}"][ |
138 | 139 | table["pixels_id"] == pixel_id |
139 | 140 | ][0] |
140 | | - rms = table["pedestal_charge_std_{}".format(channel)][ |
| 141 | + rms = table[f"pedestal_charge_std_{channel}"][ |
141 | 142 | table["pixels_id"] == pixel_id |
142 | 143 | ][0] |
143 | 144 | avgped = np.average(pedestal) |
|
212 | 213 | slopes_rms_lg[pixel_id] = slope |
213 | 214 | if pixel_id in pixel_display: |
214 | 215 | ax.annotate( |
215 | | - "y = {:.4f} I + {:.4f}".format(slope, intercept), |
| 216 | + f"y = {slope:.4f} I + {intercept:.4f}", |
216 | 217 | (0.05, 0.85 - s * 0.05), |
217 | 218 | color=colors[s], |
218 | 219 | xycoords="axes fraction", |
219 | 220 | ) |
220 | 221 |
|
221 | 222 | if pixel_id in pixel_display: |
222 | | - ax.set_title("Pixel {}, T {} deg".format(pixel_id, temp)) |
223 | | - fig.savefig("{}/pixel_{}_{}.png".format(outdir, pixel_id, k)) |
| 223 | + ax.set_title(f"Pixel {pixel_id}, T {temp} deg") |
| 224 | + fig.savefig(f"{outdir}/pixel_{pixel_id}_{k}.png") |
224 | 225 | del fig |
225 | 226 | plt.close() |
226 | 227 |
|
227 | 228 | print( |
228 | | - "{} pixels were flagged as bad by the pedestal estimation tool".format( |
229 | | - flagged_pixels |
230 | | - ) |
| 229 | + f"{flagged_pixels} pixels were flagged as bad by the pedestal estimation tool" |
231 | 230 | ) |
232 | 231 | print( |
233 | | - "{} pixels were removed because they had a pedestal RMS exceeding {}".format( |
234 | | - removed_pixels, rms_threshold |
235 | | - ) |
| 232 | + f"{removed_pixels} pixels were removed because they had a pedestal RMS " |
| 233 | + f"exceeding {rms_threshold}" |
236 | 234 | ) |
237 | 235 |
|
238 | 236 | slopes_width_hg[itemp] = slopes_rms_hg |
|
259 | 257 | if k == 1: |
260 | 258 | ax.set_yscale("log") |
261 | 259 | if k == 0 and s == 0: |
262 | | - ax.set_title("Pedestal slope (ADC/mA), hg, T {} deg".format(temp)) |
| 260 | + ax.set_title(f"Pedestal slope (ADC/mA), hg, T {temp} deg") |
263 | 261 | elif k == 0 and s == 1: |
264 | | - ax.set_title("Pedestal slope (ADC/mA), lg, T {} deg".format(temp)) |
| 262 | + ax.set_title(f"Pedestal slope (ADC/mA), lg, T {temp} deg") |
265 | 263 | elif k == 1 and s == 0: |
266 | | - ax.set_title( |
267 | | - "Pedestal width slope (ADC^2/mA), hg, T {} deg".format(temp) |
268 | | - ) |
| 264 | + ax.set_title(f"Pedestal width slope (ADC^2/mA), hg, T {temp} deg") |
269 | 265 | elif k == 1 and s == 1: |
270 | | - ax.set_title( |
271 | | - "Pedestal width slope (ADC^2/mA), lg, T {} deg".format(temp) |
272 | | - ) |
| 266 | + ax.set_title(f"Pedestal width slope (ADC^2/mA), lg, T {temp} deg") |
273 | 267 | plt.axvline(np.nanmean(slopes), linestyle=":") |
274 | 268 | plt.axvline(np.nanmean(slopes) - np.nanstd(slopes), linestyle=":") |
275 | 269 | plt.axvline(np.nanmean(slopes) + np.nanstd(slopes), linestyle=":") |
|
292 | 286 | disp.add_colorbar() |
293 | 287 | disp.update() |
294 | 288 | ax.set_title("") |
295 | | - fig.savefig("{}/camera_{}.png".format(outdir, k)) |
| 289 | + fig.savefig(f"{outdir}/camera_{k}.png") |
296 | 290 |
|
297 | 291 | # Ped width^2-I slope as a function of temp |
298 | 292 | # create output directory if needed |
|
308 | 302 | bad_pixels_hg = 0 |
309 | 303 | bad_pixels_lg = 0 |
310 | 304 | for pixel_id in pixel_process: |
311 | | - print("Working on pixel {}".format(pixel_id)) |
| 305 | + print(f"Working on pixel {pixel_id}") |
312 | 306 |
|
313 | 307 | for s in range(2): # channels |
314 | 308 | isgood = True |
|
353 | 347 | fig.subplots_adjust(top=0.9) |
354 | 348 |
|
355 | 349 | ax.annotate( |
356 | | - "y = {:.4f} T + {:.4f}".format(slope, intercept), |
| 350 | + f"y = {slope:.4f} T + {intercept:.4f}", |
357 | 351 | (0.05, 0.85 - s * 0.05), |
358 | 352 | xycoords="axes fraction", |
359 | 353 | ) |
360 | | - ax.set_title("Pixel {}, ".format(pixel_id, label)) |
361 | | - fig.savefig("{}/pixel_{}_{}.png".format(outdir, pixel_id, label)) |
| 354 | + ax.set_title(f"Pixel {pixel_id}, {label}") |
| 355 | + fig.savefig(f"{outdir}/pixel_{pixel_id}_{label}.png") |
362 | 356 | del fig |
363 | 357 | plt.close() |
364 | 358 |
|
365 | | -print("Bad pixels: HG {}, LG {}".format(bad_pixels_hg, bad_pixels_lg)) |
| 359 | +print(f"Bad pixels: HG {bad_pixels_hg}, LG {bad_pixels_lg}") |
366 | 360 |
|
367 | 361 | camera = CameraGeometry.from_name("NectarCam-003") |
368 | 362 | camera = camera.transform_to(EngineeringCameraFrame()) |
|
402 | 396 | disp.add_colorbar() |
403 | 397 | disp.update() |
404 | 398 | ax.set_title("") |
405 | | -fig.savefig("{}/camera.png".format(outdir)) |
| 399 | +fig.savefig(f"{outdir}/camera.png") |
0 commit comments