Welcome to nvtools’s documentation!

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.

Magnetic field from a ODMR spectra

If you have measured upper and lower spin resonance frequencies (fu and fl) of a single NV axis, you can calculate the absolute magnetic field value and the angle between the magnetic field and the NV axis like so

from nvtools import unit
from nvtools.solver import Solver

solver = Solver()
b_abs, theta = solver.field_from_resonances(2840 * unit.MHz, 2900 * unit.MHz)

print(b_abs, theta.to("deg"))

Check out the documentation for the Solver class for more details.

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

D = \SI{2870}{\mega\hertz}, \quad E = \SI{5}{\mega\hertz}, \quad \gamma_{\text{NV}} = \SI{28.032\pm0.004}{\mega\hertz\per\milli\tesla}

you can overwrite them if needed like so

import nvtools

nvtools.D_SPLITTING = 2870 * unit.MHz
nvtools.E_SPLITTING = 0 * unit.MHz
nvtools.GAMMA = 28.032 * unit.MHz / unit.mT

Contents

Indices and tables