Constants
Physical constants and parameters of the experiments. These are mainly used in the ImageAnalysis.
- class data_eng_utokyo.constants.CameraConstants(Cell_xsize: float, Cell_ysize: float, T_exp: float, magnification: float, eta: float, x_power: float, y_power: float, z_power: float, detuning: float, beam_diam: float, model: callable, pulse_per_coulomb: float, Gain: float, beta_cathode: float, Xmin: int, Xmax: int, Ymin: int, Ymax: int)[source]
Bases:
objectStores the constants of the setup related to the CMOS camera.
The class has custom getters for composite attributes, which are calculated from multiple attributes. This makes it possible to update attributes without introducing inconsistencies.
- Parameters:
Cell_xsize (float)
Cell_ysize (float)
T_exp (float)
magnification (float)
eta (float)
x_power (float)
y_power (float)
z_power (float)
detuning (float)
beam_diam (float)
model (callable)
pulse_per_coulomb (float)
Gain (float)
beta_cathode (float)
Xmin (int)
Xmax (int)
Ymin (int)
Ymax (int)
- data_eng_utokyo.constants.c_config(config)[source]
run = configuration_filename
# Load configuration with open(f”configuration/temperature/{run}.json”) as file:
config = json.load(file)
- data_eng_utokyo.constants.two_D_gauss(X: tuple, A: float, sigma_x: float, sigma_y: float, mu_x: float, mu_y: float, C: float, Cell_xsize: float, Cell_ysize: float)[source]
- Parameters:
X (tuple)
A (float)
sigma_x (float)
sigma_y (float)
mu_x (float)
mu_y (float)
C (float)
Cell_xsize (float)
Cell_ysize (float)
In the following, we demonstrate the use of the CameraConstants class with a simplified implementation.
import numpy as np
class Constants:
def __init__(self, x_power: float, beam_diam: float):
self.x_power = x_power
self.beam_diam = beam_diam
@property
def x_intens(self) -> float:
return self.x_power/(np.pi * ((self.beam_diam/2)**2))
Without the property decorator, the x_intens attribute would have to be set in the constructor. This has the problem, that updating the other attributes is not possible without causing inconsistencies between the attributes, as some attributes are calculated from the other. However, using the properties decorator, we can now easily do update like
from data_engineering_utokyo import Constants
c = Constants(x_power=100, beam_diam=1)
for x_power in range(100):
c.x_power = x_power
print(f"The derived value is x_intens = {c.x_intens}.")
We see that we can access the method x_intens() like an attribute and it always gives us the value based on the most up-to-date value of the other attributes. This is especially important when we want to vary parameters in an experiment.