Full API documentation for models¶
models.model
module¶
-
class
scan_framework.models.model.
Model
(managers_or_parent, *args, **kwargs)[source]¶ Class for dataset handling
-
__module__
= 'scan_framework.models.model'¶
-
bind
(**kwargs)[source]¶ Map the namespace and mirror namespace from the model’s current attribute values and bind all future dataset access to those namespaces
-
broadcast
= True¶ If true the default behavior is to broadcast datasets when they are created.
-
build
(bind=True, **kwargs)[source]¶ Build the model.
- Parameters
namespace – Tokened namespace of the model. All dataset keys passed to get(), set(), mutate(), and exists() are prefixed with the namespace.
mirror_namespace – Tokened namespace of the mirror. All changes to datasets through set() and mutate() are mirrored under this namespace.
bind – Map the namespace and mirror namespace and bind future calls to them. If set to False, bind should be called manually.
mirror – If True, all datasets set or mutated will be mirrored to the mirror namespace. Can be disabled by setting model.mirror = False after model is built.
-
default_fallback
= False¶
-
default_key
(key)[source]¶ Returns the dataset key where default values for the dataset identified by key are stored. For example, if key is raman.rsb.frequency, the key raman.rsb.defaults.frequency will be returned.
- Parameters
key – Key of the datset whose default values are needed.
- Returns
Key of the data set that contains the default values for key.
- Return type
string
-
errors
= {}¶
-
exists
(key)[source]¶ Return true if a dataset with the specified key exists under the model namespace. :param key: Key of the dataset, this will be automatically prefixed with the model namespace.
-
get
(key, default=<class 'artiq.language.environment.NoDefault'>, mirror=False, default_fallback=None, archive=True, warn=False)[source]¶ Get the value of a dataset that is stored under the model namespace or the mirror namespace. :param key: The dataset key. The key is automatically prefixed with either the model or mirror namespace. :param default: The default value to return if the dataset does not exist. :param default_fallback: If True and no value for the default argument is provided, attempt to use the default value stored in the default dataset for the specified key. If no default dataset exists, and the main dataset do not exist, a KeyError exception is thrown. :param mirror: Set to True to get the value of the datset stored under the mirror namespace
-
get_default
(key, archive=False)[source]¶ Get the dataset that contains default values for the dataset specified by key. :param key: Key of the dataset whose default dataset will be returned.
-
init
(key, shape=0, varname=None, fill_value=nan, dtype=<class 'numpy.float64'>, init_local=True, broadcast=None, persist=None, save=None, which='both')[source]¶ Set a dataset with the specified shape and initializes its values to the specified fill_value. A local member variable of the model can also be initialized to the same value as the dataset. This is useful when using methods like mutate() which updates the local variable with values as the associated dataset is mutated.
- Parameters
key (String) – The datsaet key. This key will be prefixed with the namespace automatically
shape (Integer or tuple) – The shape of the data. See numpy.full.
fill_value (Any data time) – Initialize the each element of the dataset to this value. See numpy.full.
dtype (Numpy datatype) – The datatype of each element of the dataset. See numpy.full.
init_local (Boolean) – Set to True to also set a member variable of the model which contains the a copy of the data that is written to the dataset. The variables name defaults to the key parameter if none is provided.
varname – The name of the variable which will contain a local copy of the dataset.
broadcast (Boolean) – When setting the dataset, this value of the broadcast argument is used. see ARTIQ documentation.
persist (Boolean) – When setting the dataset, this value of the persist argument is used. see ARTIQ documentation.
save (Boolean) – When setting the dataset, this value of the save argument is used. see ARTIQ documentation.
which (String) – [‘both’, ‘main’, or ‘mirror’] Set to ‘both’ (default) to set the datasets under both the model namespace and mirror namespace, set to ‘main’ to set only the dataset under the model namespace, set to ‘mirror’ to set only the dataset under the mirror namespace.
-
key
(key, mirror=False)[source]¶ Prefix key with the namespace and return the prefixed key. :param mirror: Set to True to return key prefixed with the mirror namespace instead.
-
load
(key, varname=None, default=<class 'artiq.language.environment.NoDefault'>, mirror=False, archive=True)[source]¶ Assign the value stored in a dataset to an attribute of the model. :param key: The dataset’s key. :param varname: The name of the model attribute. Defaults to the value of the key argument. :param default: Default value to use if the datset doesn’t exist. :param mirror: Set to True to load the value of the datset stored under the mirror namespace instead. :param archive: Set to True to archive the dataset value to the hdf5 file for the current experiment.
-
map_namespace
(namespace)[source]¶ Replace tokens in the provided namespace with model attributes of the same name. If there is not a model attribute for a token it is omited. Example: model.build_namespace(“raman.%temp.%transition”) will return “raman.m1_rsb” if model.transition is set to “m1_rsb” but model.temp does not exist.
-
mirror
= False¶ Set to True to enable dataset mirroring or False to disable dataset mirroring.
-
mirror_namespace
= 'current'¶
-
mutate
(key, i, value, which='both', varname=None, update_local=True)[source]¶ Prefix key with the namespace and call self.mutate_dataset() using the prefixed key. Prefix key with the mirror namespace and call self.mutate_dataset() using the prefixed key (if mirroring is enabled).
- Parameters
['both', 'main', or 'mirror'] (which) – Set to ‘both’ (default) to mutate the datasets under both the model namespace and mirror namespace, set to ‘main’ to mutate only the dataset under the model namespace, set to ‘mirror’ to set only the dataset under the mirror namespace.
-
namespace
= ''¶
-
persist
= True¶ If true the default behavior is to persist datasets when they are created.
-
save
= True¶ If true the default behavior is to archive datasets to the hdf5 file when they are created.
-
set
(key, value=None, which='both', broadcast=None, persist=None, save=None, mirror=None)[source]¶ - Set the dataset with the specified key to the specified value. By default, the dataset is also
set under the mirror namespace.
- Parameters
key (String) – The datsaet key. This key will be prefixed with the namespace automatically.
value (Any datatype) – The value to write to the dataset.
which (String ['both', 'main', or 'mirror']) – Set to ‘both’ (default) to set the datasets under both the model namespace and mirror namespace, set to ‘main’ to set only the dataset under the model namespace, set to ‘mirror’ to set only the dataset under the mirror namespace.
broadcast (Boolean) – When setting the dataset, this value of the broadcast argument is used. see ARTIQ documentation.
persist (Boolean) – When setting the dataset, this value of the persist argument is used. see ARTIQ documentation.
save (Boolean) – When setting the dataset, this value of the save argument is used. see ARTIQ documentation.
-
setattr
(key, default=<class 'artiq.language.environment.NoDefault'>, archive=True)[source]¶ Set the contents of a dataset under the model namespace as a class attribute. The name of the dataset and the name of the attribute are the same.
-
valid
= True¶
-
validate_between
(field, value, min_, max_)[source]¶ Return False if value is not between min_ and max_ and add a validation error for the field.
-
validate_greater_than
(field, value, min_)[source]¶ Return False if value <= min_ and add a validation error for the field.
-
validate_height
(series_name, data, min_height, error_msg=None)[source]¶ Return False if the difference between the max value in data and the min value in data is less than the specified minimum height and add a validation error for the field.
-
validate_less_than
(field, value, max_)[source]¶ Return False if value >= max_ and add a validation error for the field.
-
validate_max_change
(field, value, max_diff, prev_value)[source]¶ Return False if value has changed by more than max_diff from it’s previous value and add a validation error for the field.
-
validators
= {}¶ Dictionary containing definitions all fit validations
-
write
(key, varname=None, which='both', broadcast=None, persist=None, save=None)[source]¶ Set a dataset with the value of an attribute of the model.
- Parameters
key – Key of the dataset to set.
varname – The name of the model attribute. Defaults to the value of the key argument.
which (String ['both', 'main', or 'mirror']) – Set to ‘both’ (default) to set the datasets stored under both the model namespace and mirror namespace, set to ‘main’ to set only the dataset stored under the model namespace, set to ‘mirror’ to set only the dataset stored under the mirror namespace.
broadcast – When setting the dataset, this value of the broadcast argument is used. see ARTIQ documentation.
persist – When setting the dataset, this value of the persist argument is used. see ARTIQ documentation.
save – When setting the dataset, this value of the save argument is used. see ARTIQ 1documentation.
-
models.scan_model
module¶
-
class
scan_framework.models.scan_model.
ScanModel
(managers_or_parent, *args, **kwargs)[source]¶ An extension of the
Model
class that handles initializing and mutating scan datasets, calculating statistics on scan data, and performing fits on the scan data. All scan models inherit from this class.Functions performed during a scan
The ScanModel class performs the following functions when a scan is run.
Initializes all datasets for a scan.
Mutates the dataset containing raw counts measured at each scan point.
Calculates statistics (means, errors, histograms) at each scan point and mutates associated datasets.
Performs a fit on the mean values using the
curvefits
package and saves all data generated by thefit_data()
method to datasets.All statistical and fit data are mirrored to the current_scan and current_hist namespaces.
Gives a standardized way of fetching the main fit (e.g. pi_time or res_frequency of a transition)
Organization of datasets
Datasets are organized under the namespace by the following hierarchy.
- <namespace> All data is stored under this location which is specified in the child class.
- <namespace>.stats Contains statistical data, raw data from the scan, and the list of scan points.
<namespace>.points List of scan points.
<namespace>.counts Raw counts recorded at each scan point and repetition.
<namespace>.mean Mean count values calculated at each scan point.
<namespace>.error Standard deviation of each mean value in the <namespace>.mean array.
<namespace>.hist Binned mean values at each scan point. Each entry is the histogram at the corresponding scan point.
<namespace>.bins Defines the bin boundaries for histograms.
<namespace>.nbins The number of bins to use for histograms.
- <namespace>.fits: Contains all fit data
<namespace>.fits.params The value of each fitted parameter.
<namespace>.fits.guesses The guess that was used for each fitted parameter.
<namespace>.fits.errors The estimated error in each fitted parameter.
<namespace>.fits.fitline The line of best fit to the data.
<namespace>.fits.analysis The standard error in the regression and coefficient of determination (R^2) values of the fit.
- <namespace>.plots: Contains all data necessary to plot the scan
<namespace>.plots.x: x data of the plot.
<namespace>.plots.y: y data of the plot.
<namespace>.plots.plot_title: Title of the plot.
<namespace>.plots.x_label: Label of the x-axis.
<namespace>.plots.y_label: Label of the y-axis.
<namespace>.plots.x_units: Units to display on the x-axis.
<namespace>.plots.y_units: Units to display on the y-axis.
<namespace>.plots.x_scale: x-axis is scaled by this amount.
<namespace>.plots.y_scale: y-axis is scaled by this amount.
<namespace>.plots.trigger: Plots are redrawn by
plot_xy
only when trigger is set to 1.<namespace>.plots.fitline: The line of best fit.
<namespace>.%main_fit Contains the main fitted parameter of the scan. %main_fit is replaced by the value of the models ‘main_fit’ attribute (see dynamic namespaces below). For example, a microwave frequency scan might have ‘main_fit’ set to frequency and the fitted frequency would be saved to microwaves.3322.frequency.
<namespace>.defaults: Contains default values for the main fit which are used when a fitted value does not exist.
current_scan: Namespace under which a mirror of all data generated is stored. This is used by the current_scan applet to display results of the current scan.
Dynamic namespace syntax
Example:
>>> model = ScanModel(namespace="raman.%transition.%type") >>> model.transition = 'm1_rsb' >>> model.type = 'frequency' >>> model.bind() >>> print(model.namespace) # prints 'raman.m1_rsb.frequency'
%transition and %type are tokens that name an attribute of the model. After calling self.bind() on the model, the %transition and %type tokens are replaced by self.transition and self.type and the final namespace is “raman.m1_rsb.frequency”. All future datasets will be stored and accessed under the ‘raman.m1_rsb.frequency’ namespace.
- Parameters
namespace (string) – Dataset key under which all datasets are created, defaults to None
mirror_namespace (string) – Dataset key under which all datasets are mirrored – datasets under this key are plotted by the current scan applet, defaults to ‘current_scan’
broadcast (bool, optional) – If True all datasets besides the main fit dataset are broadcast when created, defaults to False
persist (bool, optional) – If True all datasets besides the main fit dataset are persisted, defaults to False
save (bool, optional) – If True all datasets besides the main fit dataset are archived to the hdf5 file, defaults to True
mirror (bool, optional) – If False datasets will not be mirrored to the mirror_namespace, default to True
enable_histograms (bool, optional) – If True, histogram data is generated for plotting by the current scan histogram applet – this applet displays a histogram of the data collected at each scan point, defaults to True
aggregate_histogram (bool, optional) – If True, histogram data is generated for plotting by the current scan aggregate histogram applet – this applet displays a histogram of all data collected, aggregated over all scan points, defaults to True
disable_validations (bool, optional) – If True, no fit validatons will be performed, fits will always be performed and no fit param values will be validated, defaults to False
fit_map (dict, optional) – Dictionary of fit param names to dataset name mappings. Fit params are renamed according to this mapping before the fit is saved to the datasets. Keys specify to a fit param name and the corresponding value in the dictionary specifies the dataset name. Defaluts to {}
fit_function (
scan_framework.analysis.curvefits.FitFunction
, required if the model performs fits.) – Specifies the fit function that will be used during fitting. Defaults to Nonefit_use_yerr (bool, optional) – If set to True a weighted fit will be performed using the calculated error in the measurued value at each scan point (by default this is the standard error of the mean value at each scan point). Defaults to True.
guess (dict, optional) – Dictionary containing initial guesses for the fit params. Keys specify fit params and the corresponding value gives the numerical guess. Defaults to {}
man_bounds (dict, optional) – Dictionary containing manual bounds for each fit param. Keys specify fit params and the corresponding value is a list specifying the bounds – see
scan_framework.analysis.curvefits.Fit
for more details. Defaults to {}man_scale (dict, optional) – Dictionary containing manual scales for each fit param. Keys specify fit params and the corresponding value is a float specifying the scale – see
scan_framework.analysis.curvefits.Fit
for more details. Defaults to {}hold (dict, optional) – Dictionary containing held values for each fit param. Keys specify fit params and the corresponding value is a float specifying the held fit param value – see
scan_framework.analysis.curvefits.Fit
for more details, defaults to Nonemain_fit (string, optional) – Dataset name for the main fit param – this name is automatically prefixed by self.namespace to give the full dataset name. Defaults to None
fits_to_save (dict, optional) – Any fit param specified in this dictionary will broadcast, persisted, and saved to the datasets. The format of this dictionary is the same as fit_map, with keys specifying fit param names and values specifiying the corresponding dataset name. Defaults to {}
validators (dict, optional) – Dictionary containing validation rules of all soft fit validations that will be performed, defaults to None
strong_validators (dict, optional) – Dictionary containing validation rules of all strong fit validations that will be performed, defaults to None
pre_validators (dict, optional) – Dictionary containing validation rules of all all pre-fit validations validations that will be performed, defaults to None
fit_performed (bool) – Set to true by the Scan class if fit’s have been performed, defaults to None
fit_valid (bool) – Set to True by the Scan class if the fit passed validations, False if it failed any validations, None if validations haven’t been performed. Default to None
fit_valid_pre (bool) – Set to True by the Scan class if the fit passed pre-validation, False if it falied, None if pre-validation has not yet been performed. Defaults to None
fit_valid_soft (bool) – Set to True by the Scan class if the fit passed soft-validation, False if it falied, None if soft-validation has not yet been performed. Defaults to None
fit_valid_strong (bool) – Set to True by the Scan class if the fit passed strong-validation, False if it falied, None if strong-validation has not yet been performed. Defaults to None
_fit_saved (bool) – Set to True by the Scan class after the main fit has been broadcast, saved, and persisted to the datasets. Defaults to None
fits_set (dict) – Dictionary of fit params that were set to the datasets during fitting – keys specify the full dataset key and the corresponding value is set to the fitted parameter value, defaults to {}
fits_saved (dict) – Dictionary of fit params that were broadcast, persisted, and saved to the datasets during fitting – keys specify the full dataset key and the corresponding value is set to the fitted parameter value, defaults to {}
x_label (string, optional) – Label of the x-axis for the current scan plot, defaults to “”
y_label (string, optional) – Label of the y-axis for the current scan plot, defaults to “”
x_scale (float, optional) – Scale of the x-axis for the current scan plot, defaults to 1
y_scale (float, optional) – Scale of the y-axis for the current scan plot, defaults to 1
x_units (string, optional) – Unit of the x-axis for the current scan plot, defaults to “”
y_units (string, optional) – Unit of the y-axis for the current scan plot, defaults to “”
plot_title (string, optional) – Title of the current scan plot, defaults to “”
counts (Numpy ndarray) – Contains the value returned by each call to the Scan measure method() – contains a value for each scan point, repeat, and pass.
-
__module__
= 'scan_framework.models.scan_model'¶
-
_fit_saved
= None¶ Set to True by the Scan class after the main fit has been broadcast, saved, and persisted to the datasets.
-
aggregate_histogram
= True¶ If True, histogram data is generated for plotting by the current scan aggregate histogram applet – this applet displays a histogram of all data collected, aggregated over all scan points
-
attach
(scan)[source]¶ Attach a scan to the model. Gather’s parameters of the scan – such as scan.nrepeats, scan.npasses, etc. – and sets these as attributes of the model.
-
before_validate
(fit)[source]¶ User callback (runs on host).
Executed after a fit was successfully performed by the scan model, but before fits are validated or saved to the datasets. This callback allows additional fit parameters to be calculated from the parameters of the fit function. e.g. calculating a pi time from a transition rate. Any calculated fit parameters will also be validated by any validation rules that are defined for name of the calculated parameter.
- Parameters
fit – Fit object for the fit that was just performed
-
bin_end
= 'auto'¶
-
bin_start
= 0¶
-
bind
()[source]¶ Bind the scan model to it’s namespace and additional sub-spaces for fits, stats, hists, and defaults.
-
broadcast
= False¶ If True all datasets besides the main fit dataset are broadcast when created
-
build
(bind=True, **kwargs)[source]¶ Build the model.
- Parameters
namespace – Tokened namespace of the model. All dataset keys passed to get(), set(), mutate(), and exists() are prefixed with the namespace.
mirror_namespace – Tokened namespace of the mirror. All changes to datasets through set() and mutate() are mirrored under this namespace.
bind – Map the namespace and mirror namespace and bind future calls to them. If set to False, bind should be called manually.
mirror – If True, all datasets set or mutated will be mirrored to the mirror namespace. Can be disabled by setting model.mirror = False after model is built.
-
calc_amplitude
(use_current_scan=False)[source]¶ Calculate the ‘amplitude’ of the means, i.e. the maximum mean value minus the minimum mean value
-
calc_error
(counts)[source]¶ Calculate the standard deviation of the mean
- Parameters
counts – Array of counts
-
calc_hist
(counts)[source]¶ Return a histogram of counts
- Parameters
counts – Array of counts to be binned
-
counts
= None¶ Contains the value returned by each call to the Scan measure method() – contains a value for each scan point, repeat, and pass.
-
default_fit
= None¶
-
disable_validations
= False¶ If True, no fit validatons will be performed, fits will always be performed and no fit param values will be validated, defaults to False
-
enable_debugging
= False¶
-
enable_histograms
= True¶ If True, histogram data is generated for plotting by the current scan histogram applet – this applet displays a histogram of the data collected at each scan point
-
property
errors
¶ Return the internal value of the ‘errors’ dataset
-
fit_data
(x_data, y_data, errors, fit_function, guess=None, i=None, validate=True, set=True, save=False, man_bounds={}, man_scale={})[source]¶ Perform a fit of the x values, y values, and errors to the specified fit function.
- Parameters
x_data – X values of the experimental data
y_data – Y values of the experimental data
errors – Error in each corresponding Y value of the experimental data
fit_function – The function being fit to the data points and errors given by x_data, y_data, and errors.
guess (dict) – Dictionary containing the initial guess for each fit param. Keys specify fit param names and values the initial guess of that fit param.
validate – If True, fit validations will be performed
set – If True, all generated data pertaining to the fit will be saved to the datasets under the model’s namespace
save – If True, the main fit will be saved to the datasets, as long as any defined strong validations pass.
man_bounds – Dictionary containing the allowed bounds for each fit param. Keys specify fit param names and values are set to a list to specify the bounds of that fit param.
man_scale – Dictionary containing the scale of each fit param. Keys specify fit param names and values are set to floats that specify the scale of that fit param.
-
fit_function
= None¶ Specifies the fit function that will be used during fitting
-
fit_map
= {}¶ Dictionary of fit param names to dataset name mappings. Fit params are renamed according to this mapping before the fit is saved to the datasets. Keys specify to a fit param name and the corresponding value in the dictionary specifies the dataset name.
-
fit_performed
= None¶ Set to true by the Scan class if fit’s have been performed
-
fit_use_yerr
= True¶ If set to True a weighted fit will be performed using the calculated error in the measurued value at each scan point (by default this is the standard error of the mean value at each scan point)
-
fit_valid
= None¶ Set to True by the Scan class if the fit passed validations, False if it failed any validations, None if validations haven’t been performed.
-
fit_valid_pre
= None¶ Set to True by the Scan class if the fit passed pre-validation, False if it falied, None if pre-validation has not yet been performed.
-
fit_valid_soft
= None¶ Set to True by the Scan class if the fit passed soft-validation, False if it falied, None if soft-validation has not yet been performed.
-
fit_valid_strong
= None¶ Set to True by the Scan class if the fit passed strong-validation, False if it falied, None if strong-validation has not yet been performed.
-
fits_saved
= {}¶ Set to True by the Scan class after the fit params have saved to the datasets.
-
fits_set
= {}¶ Set to true by the Scan class if fit’s have been performed
-
fits_to_save
= {}¶ Any fit param specified in this dictionary will broadcast, persisted, and saved to the datasets. The format of this dictionary is the same as fit_map, with keys specifying fit param names and values specifiying the corresponding dataset name.
-
get_fit
(name, use_fit_result=False, i=None)[source]¶ Helper method. Fetches the value of fit param that was found during the last fit performed. The fit param returned will either be read from the datasets or from the model’s fit object attribvute.
- Parameters
name (string) – Name of the fit param
use_fit_result (bool) – If True, the fit param is fetched from the models’ fit object (self.fit) instead of from the datasets.
-
get_main_fit
(use_fit_result=False, i=None, archive=False)[source]¶ Helper method. Fetches the value of the main fit from its dataset or from the fitresults.
- Parameters
use_fit_result – If True, the fit param value in the models fit object is returned. Otherwise the fir param value will be fetched from the datasets.
value.
-
get_means
(default=<class 'artiq.language.environment.NoDefault'>, mirror=False)[source]¶ Fetches from the datasets and returns the mean values measured at each scan point. i.e. the ‘means’ dataset
-
get_plot_data
(mirror)[source]¶ Returns the plots.x and plots.y datasets (always dimension 0)
- Parameters
mirror – True to pull from the current_scan namespace, False to pull from the actual namespace.
-
get_xs
(default=<class 'artiq.language.environment.NoDefault'>, mirror=False)[source]¶ Fetches from the datasets and returns the list of scan points. i.e. the ‘x’ dataset
-
get_xs_key
(default=<class 'artiq.language.environment.NoDefault'>, mirror=False)[source]¶ Return the dataset key of the ‘x’ dataset
-
guess
= {}¶ Dictionary containing initial guesses for the fit params. Keys specify fit params and the corresponding value gives the numerical guess.
-
hold
= None¶ Dictionary containing held values for each fit param. Keys specify fit params and the corresponding value is a float specifying the held fit param value – see
scan_framework.analysis.curvefits.Fit
for more details, defaults to None
-
init_datasets
(shape, plot_shape, points, dimension=0)[source]¶ Initializes all datasets pertaining to scans. This method is called by the scan during the initialization stage.
-
init_plots
(dimension)[source]¶ Initialize the plot datasets.
- Parameters
dimension – 0 for initializing dimension 0 plots, 1 for initializing dimension 1 plots
-
load
()[source]¶ Fetches the ‘x’, ‘means’, ‘errors’, and ‘counts’ datasets and sets their values to attributes of the model.
-
main_fit
= None¶ Dataset name for the main fit param – this name is automatically prefixed by self.namespace to give the full dataset name.
-
property
main_fit_ds
¶
-
property
main_fit_param
¶
-
man_bounds
= {}¶ Dictionary containing manual bounds for each fit param. Keys specify fit params and the corresponding value is a list specifying the bounds – see
scan_framework.analysis.curvefits.Fit
for more details.
-
man_scale
= {}¶ Dictionary containing manual scales for each fit param. Keys specify fit params and the corresponding value is a float specifying the scale – see
scan_framework.analysis.curvefits.Fit
for more details.
-
mirror
= True¶ If False datasets will not be mirrored to the mirror_namespace
-
mirror_namespace
= 'current_scan'¶ Dataset key under which all datasets are mirrored – datasets under this key are plotted by the current scan applet
-
mutate_datasets
(i_point, point, counts)[source]¶ Generates the mean and standard error of the mean for the measured value at the specified scan point and mutates the corresponding datasets. The points and counts datasets are also mutated with the specified scan point value and raw values measured at the specified scan point. If histograms are enabled, each measured value in counts will also be binned and the histogram datasets will be mutated with the binned values to updated the histogram plots.
- Parameters
i_point – scan point index
point – value of scan point
counts – array containing all values returned by the scan’s measure() method during the specified scan point
-
mutate_datasets_calc
(i_point, point, calculation)[source]¶ Mutates the statistics datasets at a specified scan point using a calculated value
- Parameters
i_point – index of the current scan point
point – value of the current scan point
calculation (string) – name of the calculation to perform
-
mutate_errors
(i_point, error)[source]¶ “Mutate the ‘error’ dataset with the error in the mean value calculated at the specified scan point
- Parameters
i_point – index of the scan point
error – error in the mean measured value at the given scan point
-
mutate_means
(i_point, mean)[source]¶ “Mutate the ‘means’ dataset with a mean value calculated at the specified scan point
- Parameters
i_point – index of the scan point
mean – mean of the measured value at the given scan point
-
mutate_plot
(i_point, x, y, error=None, dim=None)[source]¶ Mutate the plots.x and plots.y datasets. This method is called by the scan to update the plot as the scan runs.
- Parameters
i – Scan point index. Plot datasets are mutated at this index.
x – X value to plot
y – Y value to plot
dim – Which dimension is being plotted. 0 for normal 1D plots. For 2D plots, dim=1 updates the dimension 1 plot, dim=0 updates the final dimension 0 plot.
-
mutate_points
(i_point, point)[source]¶ Mutate the ‘points’ dataset with the value of a scan point
- Parameters
i_point – index of the scan point
point – value of the scan point
-
namespace
= ''¶ Dataset key under which all datasets are created
-
persist
= False¶ If True all datasets besides the main fit dataset are persisted
-
plot_title
= ''¶ Title of the current scan plot.
-
pre_validators
= None¶ Dictionary containing validation rules of all all pre-fit validations validations that will be performed
-
save
= True¶ If True all datasets besides the main fit dataset are save to the hdf5 file
-
save_fit
(fitparam, dskey, broadcast=False, persist=False, save=True)[source]¶ Helper method. Saves the specified fit param to the datasets under the model’s namespace.
- Parameters
fitparam (string) – Name of the fit param to save
dskey – Datset key to save the fit param value to
broadcast – Indicates if the dataset should be broadcast, defaults to False
persist – Indicates if the dataset should be persisted, defaults to False
save – Indicates if the dataset should be saved to the hdf5 file, defaults to True
-
set_fits
(i=None)[source]¶ Helper method. Set’s all data generated during fitting to datasets under the model’s namespace.
-
set_main_fit
(value)[source]¶ Helper method. Broadcasts, persists, and saves to the datasets the main fit param specified by the model’s main_fit attribute.
- Parameters
value – value of the main fit that will be saved.
-
property
simulation_args
¶ Function arguments passed to the fit function when running simulations
-
strong_validators
= None¶ Dictionary containing validation rules of all strong fit validations that will be performed.
-
subspace
= {}¶
-
type
= None¶ Set by the TimeFreqScan class to either ‘time’ or ‘frequency’ to indiciate to the model if it will be processing data from a time scan or from a frequency scan.
-
validate_in_scan_range
(field, value, padding_left=None, padding_right=None)[source]¶ Return False if the value is outside the range of scan points and add a validation error for the field.
- Parameters
field – name of the field who’s value will be checked
padding_left – increase the allowable range by this amount below the scan point with the smallest value.
Defaults to self._scan.tick which is the difference between adjacent scan points. :param padding_left: increase the allowable range by this amount above the scan point with the largest value. Defaults to self._scan.tick which is the difference between adjacent scan points.
-
validators
= None¶ Dictionary containing definitions all soft fit validations
-
write_datasets
(dimension)[source]¶ Writes all internal values to their datasets. This method is called by the scan when it is resuming from a pause to restore previous scan values to their datasets.
-
x_label
= ''¶ Label of the x-axis for the current scan plot.
-
x_offset
= 0.0¶
-
x_scale
= 1¶ Scale of the x-axis for the current scan plot.
-
x_units
= ''¶ Unit of the x-axis for the current scan plot.
-
property
xs
¶ Return the internal value of the ‘x’ dataset
-
y_label
= ''¶ Label of the y-axis for the current scan plot.
-
y_scale
= 1¶ Scale of the y-axis for the current scan plot.
-
y_units
= ''¶ Unit of the y-axis for the current scan plot.
models.hist_model
module¶
-
class
scan_framework.models.hist_model.
HistModel
(managers_or_parent, *args, **kwargs)[source]¶ -
__module__
= 'scan_framework.models.hist_model'¶
-
aggregate
= False¶
-
build
(**kwargs)[source]¶ Build the model.
- Parameters
namespace – Tokened namespace of the model. All dataset keys passed to get(), set(), mutate(), and exists() are prefixed with the namespace.
mirror_namespace – Tokened namespace of the mirror. All changes to datasets through set() and mutate() are mirrored under this namespace.
bind – Map the namespace and mirror namespace and bind future calls to them. If set to False, bind should be called manually.
mirror – If True, all datasets set or mutated will be mirrored to the mirror namespace. Can be disabled by setting model.mirror = False after model is built.
-
discrete
= True¶
-
mirror
= True¶ Set to True to enable dataset mirroring or False to disable dataset mirroring.
-
mirror_namespace
= 'current_hist'¶
-
mutate
(values, broadcast=None, persist=None, save=None)[source]¶ Bin each value and mutate the bins dataset
-
namespace
= ''¶
-
plot_title
= ''¶
-
x_label
= ''¶
-
x_units
= 1¶
-
y_label
= ''¶
-
models.fit_model
module¶
-
exception
scan_framework.models.fit_model.
BadFit
[source]¶ -
__module__
= 'scan_framework.models.fit_model'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
exception
scan_framework.models.fit_model.
CantFit
[source]¶ -
__module__
= 'scan_framework.models.fit_model'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
class
scan_framework.models.fit_model.
FitModel
(managers_or_parent, *args, **kwargs)[source]¶ -
__module__
= 'scan_framework.models.fit_model'¶
-
fit_data
(x, y, fit_function, hold=None, guess={}, yerr=None, man_bounds={}, man_scale={})[source]¶ Fit data in x and y to self.fit_function
-
fit_map
= {}¶
-
mirror
= True¶ Set to True to enable dataset mirroring or False to disable dataset mirroring.
-
valid
= True¶
-
validation_errors
= {}¶
-
validators
= {}¶ Dictionary containing definitions all fit validations
-
models.time_model
module¶
-
class
scan_framework.models.time_model.
TimeModel
(managers_or_parent, *args, **kwargs)[source]¶ -
__module__
= 'scan_framework.models.time_model'¶
-
property
x_label
¶ str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
-
property
x_units
¶ str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
-
models.freq_model
module¶
-
class
scan_framework.models.freq_model.
FreqModel
(managers_or_parent, *args, **kwargs)[source]¶ -
__module__
= 'scan_framework.models.freq_model'¶
-
property
x_label
¶ str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
-
property
x_units
¶ str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
-
models.time_freq_model
module¶
-
class
scan_framework.models.time_freq_model.
TimeFreqModel
(managers_or_parent, *args, **kwargs)[source]¶ -
__module__
= 'scan_framework.models.time_freq_model'¶
-
property
x_label
¶ str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
-
property
x_units
¶ str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
-