Welcome to nvtools’s documentation!
General usage
This library contains helper functions for plotting and analyzing ODMR spectra of nitrogen-vacancy centers in diamond. The typical usage consists of loading a spectrum, fitting a model function and calculating the magnetic field from the fitted resonances.
Global variables can be set to customize different behaviour.
from nvtools.io import H5Loader
from nvtools.plot import ODMRPlotter
def main():
data = H5Loader().load_odmr_lia()
ODMRPlotter().plot_from_spectrum(data.mw_frequency, data.observables["X"]["20"])
if __name__ == "__main__":
main()
Units and uncertainties
nvtools uses the Python packages pint and uncertainties to deal with physical units and error propagation wherever possible.
Here is a quick example to get you started, but be sure to check out their documentation to understand how to deal with units and error values!
from nvtools import unit
# pint units
length = 5.3 * unit.meter # value with unit
print(length.to("cm")) # = 530cm convert to different unit
print(length.magnitude) # = 5.3 remove unit
# uncertainties errors
length = (5.3 * unit.meter).plus_minus(0.1) # value with unit and error
print(length.magnitude.nominal_value) # = 5.3 value without unit and error
print(length.magnitude.std_dev) # = 0.1 error of value without unit
Default values
The default values for the D and E splitting and the gyromagnetic ratio are
you can overwrite them if needed like so
import nvtools
nvtools.D_SPLITTING = <new_value>
nvtools.E_SPLITTING = <new_value>
nvtools.GAMMA = <new_value>