diff --git a/array_analysis.py b/array_analysis.py index 364505d2ffab8f9f26486eba053dbf8850c05175..3f733c10fcbdfc66b9ff239fc668ef41d15483ac 100644 --- a/array_analysis.py +++ b/array_analysis.py @@ -68,9 +68,14 @@ paramslist = [ ### cool # PS("shims_cool_fb", "G"), # PS("shims_cool_lr", "G"), - # PS("shims_cool_ud", "G"), + PS("shims_cool_ud", "G"), PS("tau_cool", "ms", lambda t: 1000.0 * t), + ### probe cool + PS("tau_pcool", "ms", lambda t: 1000.0 * t), + PS("p_pcool_am", "Isat"), + PS("det_pcool", "MHz"), + ### pump # PS("u_pump", "uK"), # PS("shims_pump_fb", "G"), @@ -80,13 +85,13 @@ paramslist = [ PS("tau_pump", "ms", lambda t: 1000.0 * t), PS("p_pump", "'Isat'"), PS("det_pump", "MHz"), - PS("det_pump_chirp", "MHz"), + # PS("det_pump_chirp", "MHz"), ### mag # PS("shims_mag_fb", "G"), # PS("shims_mag_lr", "G"), # PS("shims_mag_ud", "G"), - PS("tau_mag", "ms", lambda t: 1000.0 * t), + # PS("tau_mag", "ms", lambda t: 1000.0 * t), ### test # PS("u_test", "uK"), @@ -107,7 +112,7 @@ paramslist = [ # PS("shims_lifetime_lr", "G"), # PS("shims_lifetime_ud", "G"), # PS("hholtz_lifetime", "G"), - PS("tau_lifetime", "ms", lambda t: 1000.0 * t), + # PS("tau_lifetime", "ms", lambda t: 1000.0 * t), # PS("p_lifetime_cmot_beg", "dBm"), # PS("p_lifetime_cmot_end", "dBm"), # PS("det_lifetime_cmot_beg", "MHz"), @@ -132,8 +137,8 @@ paramslist = [ # PS("shims_kill_ud", "G"), # PS("hholtz_kill", "G"), PS("tau_kill", "ms", lambda t: 1000.0 * t), - # PS("p_kill", "'Isat'"), - # PS("det_kill", "MHz"), + PS("p_kill", "'Isat'"), + PS("det_kill", "MHz"), ### image # PS("shims_probe_fb", "G"), @@ -196,26 +201,26 @@ roi_locs: list[list[int, 2]] = [ # [ x (j), y (i) ] # [ 98, 2], # 8 # [103, 2], # 9 - [ 15, 3], # 00 - [ 19, 3], # 01 - [ 24, 3], # 02 - [ 29, 3], # 03 - [ 34, 3], # 04 - [ 39, 3], # 05 - [ 43, 3], # 06 - [ 48, 3], # 07 - [ 53, 3], # 08 - [ 58, 3], # 09 - [ 63, 3], # 10 - [ 67, 3], # 11 - [ 73, 3], # 12 - [ 77, 3], # 13 - [ 82, 3], # 14 - [ 87, 3], # 15 - [ 92, 3], # 16 - [ 96, 3], # 17 - [101, 3], # 18 - [106, 3], # 19 + [ 24, 4], # 00 + [ 29, 4], # 01 + [ 34, 4], # 02 + [ 39, 4], # 03 + [ 43, 4], # 04 + [ 48, 4], # 05 + [ 53, 4], # 06 + [ 58, 4], # 07 + [ 63, 4], # 08 + [ 68, 4], # 09 + [ 72, 4], # 10 + [ 77, 4], # 11 + [ 82, 4], # 12 + [ 87, 4], # 13 + [ 91, 4], # 14 + [ 97, 4], # 15 + [101, 4], # 16 + [106, 4], # 17 + [111, 4], # 18 + [116, 4], # 19 ] num_images: int = 1 # expect two shots per param config optim_pad: int = 0 # additional padding area for ROI optimization @@ -247,9 +252,9 @@ sort_axes: bool = True # plot against two variables using slices instead of a color plot force_lines: bool = True # plot MPC/FAT/survival as slices versus these parameters (must be 1 or 2) -plot_versus: list[str] = ["det_cool"] +plot_versus: list[str] = ["det_probe"] # for multiline plots, plot versus this `plot_versus` axis (must be 0 or 1) -multiline_plot_versus: int = 0 +multiline_plot_versus: int = 1 # plot info on this shot shot_num: int = 0 # add violin plots to MPC lineplots diff --git a/config.toml b/config.toml index 7ae76bb688812b56efe476e5f978e4bc80ef956c..1cd908dc69ed13e95c56709b50ab75f043e4017b 100644 --- a/config.toml +++ b/config.toml @@ -14,7 +14,7 @@ colorbar_limits = [500.0, 600.0] # [int, int] : negative values are auto [camera] acquisition_mode = "kinetic" # str : single, accum, kinetic, fast_kinetic, cont -roi = [431, 581, 513, 523] # [int, int, int, int] : [xmin, xmax, ymin, ymax] +roi = [400, 550, 525, 535] # [int, int, int, int] : [xmin, xmax, ymin, ymax] # roi = [431, 581, 470, 570] bin = [1, 1] # [int, int] : [hbin, vbin] exposure_time_ms = 20.0 # float @@ -46,7 +46,7 @@ hsspeed_idx = 3 # int : {0 = 30 MHz, 1 = 20 MHz, 2 = 10 MHz, 3 = 1 MHz} vsspeed_idx = 1 # int : {0 = 0.6 us, 1 = 1.13 us, 2 = 2.2 us, 3 = 4.33 us} [camera.kinetic] -buffer_size = 10000 # int +buffer_size = 1000000 # int cycle_time = 0.0 # float num_acc = 1 # int cycle_time_acc = 0.0 # float diff --git a/lib/frame_processing.py b/lib/frame_processing.py index 65f7fb4db3d6af9b750dfe74dad3cce5adc96b9b..23b4da715793ed83d6495a8576e6ccbb8b8aa0a5 100644 --- a/lib/frame_processing.py +++ b/lib/frame_processing.py @@ -2,7 +2,7 @@ from __future__ import annotations import numpy as np import serial from .config import Config -from .image import to_photons +from .image import to_photons, _e_per_count def qq(X): print(X) @@ -94,6 +94,7 @@ class FFPrep(IFrameProcessor): return roi def deinit(self): + self.arduino.write(b"1100\n") self.arduino.close() class FFSeries(IFrameProcessor): @@ -104,7 +105,7 @@ class FFSeries(IFrameProcessor): 2: 10.0, 3: 1.0, }[config.camera.read.hsspeed_idx] - self.preamp_idx = { + self.preamp = { 0: 1.0, 1: 2.0, }[config.camera.amp.preamp_gain_idx] @@ -123,14 +124,20 @@ class FFSeries(IFrameProcessor): self.box[1] : self.box[1] + self.box[3], self.box[0] : self.box[0] + self.box[2], ] - self.to_photons = lambda x: to_photons( - x, - self.hs_rate, - self.preamp_idx, - self.em_gain, - self.count_bias, - self.qe, - )[0] + + self.e_per_count = _e_per_count(self.hs_rate, self.preamp) + self.a = self.e_per_count * self.em_gain * self.qe + self.b = self.count_bias + self.to_photons = lambda x: (x - self.b) / self.a + + # self.to_photons = lambda x: to_photons( + # x, + # self.hs_rate, + # self.preamp, + # self.em_gain, + # self.count_bias, + # self.qe, + # )[0] self.logic = { 1: { @@ -166,6 +173,7 @@ class FFSeries(IFrameProcessor): return roi def deinit(self): + self.arduino.write(b"1100\n") self.arduino.close() proc_registry = {