pyepr.hardware.PyEPR_control.PyEPRControlInterface

class pyepr.hardware.PyEPR_control.PyEPRControlInterface(config_file_path)[source]

Bases: pyepr.hardware.BaseInterfaceClass.Interface

Represents the interface for spectrometers built using PyEPR and connected with a local flask server.

Parameters:
config_file_pathfloat

The file path for the spectrometer configuration file.

Parameters:

config_file_path (str)

Attributes

IFgain_options[source]
IFgain = 1[source]
config_file[source]
server = None[source]
cur_exp = None[source]
property savefolder[source]

Methods

connect(ip='localhost', port=5000)[source]

Connects to the spectrometer server and configures the spectrometer if it is not already configured.

disconnect()[source]

Disconnets the spectrometer from the components and stops the server.

acquire_dataset(verbosity=0, sum_scans=True, **kwargs)[source]

Acquires the dataset from the spectrometer. If no full scan has been completed, this will return the current buffer. Otherwise, the inclusion of the current buffer is determined by the live argument.

Parameters:
verbosityint, optional

The level of verbosity for logging, by default 0. Higher values will log more information.

sum_scansbool, optional

Whether to sum the scans together, by default True. If False, the returned dataset will include a ‘Scan’ dimension with each individual scan. If True, the returned dataset will be summed over the ‘Scan’ dimension, returning a single averaged scan.

livebool, optional

Whether to include the current buffer in the returned dataset, by default False.

downconvertbool, optional

Whether to downconvert the data, by default True.

filter_typestr, optional

The type of filter to apply to the data, by default ‘cheby’. Possible values are ‘cheby’ for a Chebyshev filter and ‘boxcar’ for a boxcar filter.

filter_widthint, optional

The width of the filter to apply to the data, by default 100 MHz for cheby and 250 ns for boxcar. For a Chebyshev filter, this is the width of the stopband in MHz. For a boxcar filter, this is the width of the filter in ns.

IFfreqfloat, optional

The intermediate frequency to use. If None the IFfreq is extracted from the dataset, by default 0.15

Returns:
datasetxarray.DataArray

The acquired dataset, following the standard PyEPR format.

get_buffer(verbosity=0, sum_scans=True, **kwargs)[source]

Returns the current scan from the spectrometer buffer.

Parameters:
verbosityint, optional

The level of verbosity for logging, by default 0. Higher values will log more information.

sum_scansbool, optional

Whether to sum the scans together, by default True. If False, the returned dataset will include a ‘Scan’ dimension with each individual scan. If True, the returned dataset will be summed over the ‘Scan’ dimension, returning a single averaged scan.

downconvertbool, optional

Whether to downconvert the data, by default True.

filter_typestr, optional

The type of filter to apply to the data, by default ‘cheby’. Possible values are ‘cheby’ for a Chebyshev filter and ‘boxcar’ for a boxcar filter.

filter_widthint, optional

The width of the filter to apply to the data, by default 100 MHz for cheby and 250 ns for boxcar. For a Chebyshev filter, this is the width of the stopband in MHz. For a boxcar filter, this is the width of the filter in ns.

IFfreqfloat, optional

The intermediate frequency to use. If None the IFfreq is extracted from the dataset, by default 0.15

Returns:
datasetxarray.DataArray

The acquired dataset, following the standard PyEPR format.

status(get_errors=True)[source]

Returns the status of the spectrometer, including any errors.

Parameters:
get_errorsbool, optional

Whether to include errors in the status, by default True

Returns:
dict

A dictionary containing the status of the spectrometer, including any errors if get_errors is True.

set_param(param, value)[source]

Set a parameter for the spectrometer.

Parameters:
paramstr

The parameter to set. Possible values are ‘LO’, ‘temp’, ‘reptime’, ‘field’, ‘videoGain’.

valuefloat

The value to set the parameter to.

Parameters:
  • param (str)

  • value (float)

set_field(field, ramp_rate=None, wait=False, persistance=None)[source]

Sets the magnetic field

Parameters:
fieldfloat

The target magnetic field in Gauss.

ramp_ratefloat, optional

The ramp rate in Gauss per second. If not specified, the current ramp rate is used.

waitbool, optional

If True, the method will block until the field is reached. Default is False.

persistancebool, optional

If True, the magnet will be set to persistent mode after reaching the target field. If False, the magnet will be set to driven mode. If None, the current mode is maintained. Default is None.

terminate()[source]

Terminates the current sequence immediately and stops the AWG and digitiser processes

stop()[source]

Stops the current sequence after the current scan is finished. The AWG and digitiser processes will be stopped after the current scan is finished.

launch(sequence, savename, IFgain=None, save_scans=False, *args, **kwargs)[source]
sequenceSequence

The sequence object to be launched.

savenamestr

The name of the file to save the dataset to. The full path will be determined by the savefolder attribute of the interface and the savename argument.

modestr, optional

The operating mode of the bridge. By default the mode is “normal”. Other options are [“tune”,”amp_view”,”ampbypass”,”ampinput”].

IFgainint, float, or None, optional

If None the IFgain will be automatically determined by the interface. If an int or float, the IF gain will be set to this value.

IFfreqfloat, optional

The IF frequency to be set on the AWG, by default None. If None, the IF frequency will be either automatically calculated or set to the default value in the config file.

save_scansbool, optional

Whether to save individual scans, by default False. If True, individual scans will be saved to a temporary file and can be accessed by setting sum_scans to False when acquiring the dataset. If False, individual scans will not be saved and only the averaged dataset will be returned.

overwritebool, optional

If True, subsequent scans will overwrite the previous scans, by default False

Parameters:
isrunning()[source]

Checks if the spectrometer is currently running a sequence.

Return type:

bool

tune_rectpulse(*, tp, freq, B, reptime, shots=400, tau=500, IFgain=None, offset=0)[source]

Generates a rectangular pi and pi/2 pulse of the given length at the given field position. This value is stored in the pulse cache.

Parameters:
tpfloat

Pulse length of pi/2 pulse in ns

freqfloat

Central frequency of this pulse in GHz

Bfloat

Magnetic B0 field position in Gauss

reptime: float

Shot repetion time in us.

shots: int

The number of shots

tau: float

The tau value for the Hahn echo sequence in ns, default is 500 ns

IFgain: float

The IF gain to be used for the tuning sequence. If None, the IF gain will be automatically determined by the interface.

offset: float

The frequency offset of the pulse in GHz. This is added to the central frequency of the pulse. Default is 0.

Returns:
p90: RectPulse

A tuned rectangular pi/2 pulse of length tp

p180: RectPulse

A tuned rectangular pi pulse of length tp

tune_pulse(pulse, mode, freq, B, reptime, shots=400, IFgain=None, tau=500)[source]

Tunes a single pulse a range of methods.

Parameters:
pulsePulse

The Pulse object in need of tuning.

modestr

The method to be used.

freqfloat

The local oscilator frequency in GHz

Bfloat

Magnetic B0 field position in Gauss

reptimeus

Shot repetion time in us.

shots: int

The number of shots

Returns:
Tunned Pulse: Pulse

The returned pulse object that is now tunned.

tune(*, sequence=None, mode='amp_hahn', freq=None, gyro=None)[source]
tune_resonator(*, freq, sweep, reptime=1000.0, shots=100, step=0.05, dim=25)[source]
get_config()[source]

Returns the current configuration of the spectrometer.

set_config(config)[source]

Sets the configuration of the spectrometer.

Parameters:
configdict

The configuration to set.