Skip to content

Commit

Permalink
calibration: make sure offset is accessible
Browse files Browse the repository at this point in the history
  • Loading branch information
JoepVanlier committed Nov 13, 2024
1 parent c672518 commit fccb0b1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ def number_of_samples(self):
@property
def offset(self):
"""Force offset (pN)"""
return self._get_parameter("NA", "Offset")
return self._get_parameter("NA", "Offset (pN)")

@property
def active_calibration(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"test": "passive_item",
"parametrization": {},
"result": {
"str": "Property Description Value\n------------------------ -------------------------------------------------- ----------------------------------\nstiffness Trap stiffness (pN/nm) 0.24211\ndisplacement_sensitivity Displacement sensitivity (\u00b5m/V) 5.6357e+05\nforce_sensitivity Force sensitivity (pN/V) 1.3644e+08\ndiffusion_constant Fitted diffusion constant (\u00b5m\u00b2/s) 0.49075\ncorner_frequency Estimated corner frequency (Hz) 4593.7\ndiffusion_constant_volts Fitted diffusion constant (V\u00b2/s) 1.5451e-12\ntheoretical_bulk_drag Expected bulk drag coefficient (kg/s) 8.3881e-09\nbacking Statistical backing (%) 100\nchi_squared_per_degree Chi squared per degree of freedom 199.87\ncorner_frequency_std_err Corner frequency std error (Hz) 17.458\ndiffusion_volts_std_err Diffusion constant std error (V\u00b2/s) 4.098e-15\nbead_diameter Bead diameter (microns) 1\ntemperature Temperature (C) 25\nviscosity Viscosity of the medium (Pa s) 0.00089\nfitted_diode Diode parameters were fitted False\ndiode_relaxation_factor Diode relaxation factor (-) 0.45\ndiode_frequency Diode filtering frequency (Hz). 10000\ndistance_to_surface Distance from bead center to surface (\u00b5m) 1\nhydrodynamically_correct Hydrodynamically correct model. True\nrho_bead Density of the bead (kg/m\u00b3). 1100\nrho_sample Density of the medium (kg/m\u00b3). 1000\nfit_range Spectral frequency range used for calibration (Hz) (100.0, 23000.0)\nexcluded_ranges Frequency exclusion ranges (Hz) [(100.0, 500.0), (1000.0, 2000.0)]\nsample_rate Acquisition sample rate (Hz). 78125\nnumber_of_samples Number of fitted samples (-). 7.8125e+05",
"repr": "ForceCalibrationItem(stiffness=0.2421057076519628, displacement_sensitivity=563574.3158653651, force_sensitivity=136444558.55705503, diffusion_constant=0.49074621908890365, measured_drag_coefficient=None, corner_frequency=4593.7147688881405, diffusion_constant_volts=1.5450928303539805e-12, driving_amplitude=None, driving_frequency=None, driving_power=None, theoretical_bulk_drag=8.388052385084746e-09, backing=100.0, chi_squared_per_degree=199.87179339908212, stiffness_std_err=None, displacement_sensitivity_std_err=None, corner_frequency_std_err=17.4576138032815, diffusion_volts_std_err=4.0980394310000066e-15, diode_relaxation_factor_std_err=None, diode_frequency_std_err=None, offset=None, bead_diameter=1.0, temperature=25.0, viscosity=0.00089, fitted_diode=False, diode_relaxation_factor=0.45, diode_frequency=10000.0, distance_to_surface=1.0, driving_frequency_guess=None, transferred_lateral_drag_coefficient=None, hydrodynamically_correct=True, rho_bead=1100.0, rho_sample=1000.0, fit_range=(100.0, 23000.0), excluded_ranges=[(100.0, 500.0), (1000.0, 2000.0)], sample_rate=78125, number_of_samples=781250.0)",
"repr_html": "<table>\n<thead>\n<tr><th>Property </th><th>Description </th><th>Value </th></tr>\n</thead>\n<tbody>\n<tr><td>stiffness </td><td>Trap stiffness (pN/nm) </td><td> 0.24211 </td></tr>\n<tr><td>displacement_sensitivity</td><td>Displacement sensitivity (\u00b5m/V) </td><td> 5.6357e+05 </td></tr>\n<tr><td>force_sensitivity </td><td>Force sensitivity (pN/V) </td><td> 1.3644e+08 </td></tr>\n<tr><td>diffusion_constant </td><td>Fitted diffusion constant (\u00b5m\u00b2/s) </td><td> 0.49075 </td></tr>\n<tr><td>corner_frequency </td><td>Estimated corner frequency (Hz) </td><td> 4593.7 </td></tr>\n<tr><td>diffusion_constant_volts</td><td>Fitted diffusion constant (V\u00b2/s) </td><td> 1.5451e-12 </td></tr>\n<tr><td>theoretical_bulk_drag </td><td>Expected bulk drag coefficient (kg/s) </td><td> 8.3881e-09 </td></tr>\n<tr><td>backing </td><td>Statistical backing (%) </td><td> 100 </td></tr>\n<tr><td>chi_squared_per_degree </td><td>Chi squared per degree of freedom </td><td> 199.87 </td></tr>\n<tr><td>corner_frequency_std_err</td><td>Corner frequency std error (Hz) </td><td> 17.458 </td></tr>\n<tr><td>diffusion_volts_std_err </td><td>Diffusion constant std error (V\u00b2/s) </td><td> 4.098e-15 </td></tr>\n<tr><td>bead_diameter </td><td>Bead diameter (microns) </td><td> 1 </td></tr>\n<tr><td>temperature </td><td>Temperature (C) </td><td> 25 </td></tr>\n<tr><td>viscosity </td><td>Viscosity of the medium (Pa s) </td><td> 0.00089 </td></tr>\n<tr><td>fitted_diode </td><td>Diode parameters were fitted </td><td>False </td></tr>\n<tr><td>diode_relaxation_factor </td><td>Diode relaxation factor (-) </td><td> 0.45 </td></tr>\n<tr><td>diode_frequency </td><td>Diode filtering frequency (Hz). </td><td>10000 </td></tr>\n<tr><td>distance_to_surface </td><td>Distance from bead center to surface (\u00b5m) </td><td> 1 </td></tr>\n<tr><td>hydrodynamically_correct</td><td>Hydrodynamically correct model. </td><td> True </td></tr>\n<tr><td>rho_bead </td><td>Density of the bead (kg/m\u00b3). </td><td> 1100 </td></tr>\n<tr><td>rho_sample </td><td>Density of the medium (kg/m\u00b3). </td><td> 1000 </td></tr>\n<tr><td>fit_range </td><td>Spectral frequency range used for calibration (Hz)</td><td>(100.0, 23000.0) </td></tr>\n<tr><td>excluded_ranges </td><td>Frequency exclusion ranges (Hz) </td><td>[(100.0, 500.0), (1000.0, 2000.0)]</td></tr>\n<tr><td>sample_rate </td><td>Acquisition sample rate (Hz). </td><td>78125 </td></tr>\n<tr><td>number_of_samples </td><td>Number of fitted samples (-). </td><td> 7.8125e+05 </td></tr>\n</tbody>\n</table>"
"str": "Property Description Value\n------------------------ -------------------------------------------------- ----------------------------------\nstiffness Trap stiffness (pN/nm) 0.24211\ndisplacement_sensitivity Displacement sensitivity (\u00b5m/V) 5.6357e+05\nforce_sensitivity Force sensitivity (pN/V) 1.3644e+08\ndiffusion_constant Fitted diffusion constant (\u00b5m\u00b2/s) 0.49075\ncorner_frequency Estimated corner frequency (Hz) 4593.7\ndiffusion_constant_volts Fitted diffusion constant (V\u00b2/s) 1.5451e-12\ntheoretical_bulk_drag Expected bulk drag coefficient (kg/s) 8.3881e-09\nbacking Statistical backing (%) 100\nchi_squared_per_degree Chi squared per degree of freedom 199.87\ncorner_frequency_std_err Corner frequency std error (Hz) 17.458\ndiffusion_volts_std_err Diffusion constant std error (V\u00b2/s) 4.098e-15\noffset Force offset (pN) 0\nbead_diameter Bead diameter (microns) 1\ntemperature Temperature (C) 25\nviscosity Viscosity of the medium (Pa s) 0.00089\nfitted_diode Diode parameters were fitted False\ndiode_relaxation_factor Diode relaxation factor (-) 0.45\ndiode_frequency Diode filtering frequency (Hz). 10000\ndistance_to_surface Distance from bead center to surface (\u00b5m) 1\nhydrodynamically_correct Hydrodynamically correct model. True\nrho_bead Density of the bead (kg/m\u00b3). 1100\nrho_sample Density of the medium (kg/m\u00b3). 1000\nfit_range Spectral frequency range used for calibration (Hz) (100.0, 23000.0)\nexcluded_ranges Frequency exclusion ranges (Hz) [(100.0, 500.0), (1000.0, 2000.0)]\nsample_rate Acquisition sample rate (Hz). 78125\nnumber_of_samples Number of fitted samples (-). 7.8125e+05",
"repr": "ForceCalibrationItem(stiffness=0.2421057076519628, displacement_sensitivity=563574.3158653651, force_sensitivity=136444558.55705503, diffusion_constant=0.49074621908890365, measured_drag_coefficient=None, corner_frequency=4593.7147688881405, diffusion_constant_volts=1.5450928303539805e-12, driving_amplitude=None, driving_frequency=None, driving_power=None, theoretical_bulk_drag=8.388052385084746e-09, backing=100.0, chi_squared_per_degree=199.87179339908212, stiffness_std_err=None, displacement_sensitivity_std_err=None, corner_frequency_std_err=17.4576138032815, diffusion_volts_std_err=4.0980394310000066e-15, diode_relaxation_factor_std_err=None, diode_frequency_std_err=None, offset=0.0, bead_diameter=1.0, temperature=25.0, viscosity=0.00089, fitted_diode=False, diode_relaxation_factor=0.45, diode_frequency=10000.0, distance_to_surface=1.0, driving_frequency_guess=None, transferred_lateral_drag_coefficient=None, hydrodynamically_correct=True, rho_bead=1100.0, rho_sample=1000.0, fit_range=(100.0, 23000.0), excluded_ranges=[(100.0, 500.0), (1000.0, 2000.0)], sample_rate=78125, number_of_samples=781250.0)",
"repr_html": "<table>\n<thead>\n<tr><th>Property </th><th>Description </th><th>Value </th></tr>\n</thead>\n<tbody>\n<tr><td>stiffness </td><td>Trap stiffness (pN/nm) </td><td> 0.24211 </td></tr>\n<tr><td>displacement_sensitivity</td><td>Displacement sensitivity (\u00b5m/V) </td><td> 5.6357e+05 </td></tr>\n<tr><td>force_sensitivity </td><td>Force sensitivity (pN/V) </td><td> 1.3644e+08 </td></tr>\n<tr><td>diffusion_constant </td><td>Fitted diffusion constant (\u00b5m\u00b2/s) </td><td> 0.49075 </td></tr>\n<tr><td>corner_frequency </td><td>Estimated corner frequency (Hz) </td><td> 4593.7 </td></tr>\n<tr><td>diffusion_constant_volts</td><td>Fitted diffusion constant (V\u00b2/s) </td><td> 1.5451e-12 </td></tr>\n<tr><td>theoretical_bulk_drag </td><td>Expected bulk drag coefficient (kg/s) </td><td> 8.3881e-09 </td></tr>\n<tr><td>backing </td><td>Statistical backing (%) </td><td> 100 </td></tr>\n<tr><td>chi_squared_per_degree </td><td>Chi squared per degree of freedom </td><td> 199.87 </td></tr>\n<tr><td>corner_frequency_std_err</td><td>Corner frequency std error (Hz) </td><td> 17.458 </td></tr>\n<tr><td>diffusion_volts_std_err </td><td>Diffusion constant std error (V\u00b2/s) </td><td> 4.098e-15 </td></tr>\n<tr><td>offset </td><td>Force offset (pN) </td><td> 0 </td></tr>\n<tr><td>bead_diameter </td><td>Bead diameter (microns) </td><td> 1 </td></tr>\n<tr><td>temperature </td><td>Temperature (C) </td><td> 25 </td></tr>\n<tr><td>viscosity </td><td>Viscosity of the medium (Pa s) </td><td> 0.00089 </td></tr>\n<tr><td>fitted_diode </td><td>Diode parameters were fitted </td><td>False </td></tr>\n<tr><td>diode_relaxation_factor </td><td>Diode relaxation factor (-) </td><td> 0.45 </td></tr>\n<tr><td>diode_frequency </td><td>Diode filtering frequency (Hz). </td><td>10000 </td></tr>\n<tr><td>distance_to_surface </td><td>Distance from bead center to surface (\u00b5m) </td><td> 1 </td></tr>\n<tr><td>hydrodynamically_correct</td><td>Hydrodynamically correct model. </td><td> True </td></tr>\n<tr><td>rho_bead </td><td>Density of the bead (kg/m\u00b3). </td><td> 1100 </td></tr>\n<tr><td>rho_sample </td><td>Density of the medium (kg/m\u00b3). </td><td> 1000 </td></tr>\n<tr><td>fit_range </td><td>Spectral frequency range used for calibration (Hz)</td><td>(100.0, 23000.0) </td></tr>\n<tr><td>excluded_ranges </td><td>Frequency exclusion ranges (Hz) </td><td>[(100.0, 500.0), (1000.0, 2000.0)]</td></tr>\n<tr><td>sample_rate </td><td>Acquisition sample rate (Hz). </td><td>78125 </td></tr>\n<tr><td>number_of_samples </td><td>Number of fitted samples (-). </td><td> 7.8125e+05 </td></tr>\n</tbody>\n</table>"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def test_passive_item(compare_to_reference_dict, reference_data, calibration_dat
assert not item.diode_frequency_std_err
assert not item.diode_relaxation_factor_std_err
assert item.applied_at == 1696171386701856700
assert item.offset == ref_active["Offset (pN)"]

compare_to_reference_dict(item.power_spectrum_params(), test_name="power")
compare_to_reference_dict(item._model_params(), test_name="model")
Expand Down Expand Up @@ -201,6 +202,7 @@ def test_active_item_fixed_diode(compare_to_reference_dict, calibration_data):
assert item.stiffness is ref_active["kappa (pN/nm)"]
assert item.force_sensitivity is ref_active["Rf (pN/V)"]
assert item.displacement_sensitivity is ref_active["Rd (um/V)"]
assert item.offset == ref_active["Offset (pN)"]

assert item.rho_bead == item["Bead density (Kg/m3)"]
assert item.hydrodynamically_correct
Expand Down Expand Up @@ -235,6 +237,7 @@ def test_axial_fast_sensor(compare_to_reference_dict, calibration_data):
assert item.stiffness is ref_axial["kappa (pN/nm)"]
assert item.force_sensitivity is ref_axial["Rf (pN/V)"]
assert item.displacement_sensitivity is ref_axial["Rd (um/V)"]
assert item.offset == ref_axial["Offset (pN)"]

assert not item.rho_bead
assert not item.rho_bead
Expand Down Expand Up @@ -269,6 +272,7 @@ def test_non_full(compare_to_reference_dict):
assert item.force_sensitivity == 1.0
assert item.start == 1714391268938540100
assert item.stop == 1714391268938540200
assert item.offset is None

for func in ("calibration_params", "power_spectrum_params"):
with pytest.raises(
Expand Down

0 comments on commit fccb0b1

Please sign in to comment.