Parameters and Objects

Contents

Parameters and Objects#

Descriptors#

class easyscience.Objects.Variable.Descriptor(name, value, units=None, unique_name=None, description=None, url=None, display_name=None, callback=<property object>, enabled=True, parent=None)[source]#

This is the base of all variable descriptions for models. It contains all information to describe a single unique property of an object. This description includes a name and value as well as optionally a unit, description and url (for reference material). Also implemented is a callback so that the value can be read/set from a linked library object.

A Descriptor is typically something which describes part of a model and is non-fittable and generally changes the state of an object.

Units are provided by pint: hgrecco/pint

Parameters:
  • name (str) – Name of this object

  • value (Any) – Value of this object

  • units (Union[str, Unit, None]) – This object can have a physical unit associated with it

  • description (Optional[str]) – A brief summary of what this object is

  • url (Optional[str]) – Lookup url for documentation/information

  • callback (Optional[property]) – The property which says how the object is linked to another one

  • parent (Optional[Any]) – The object which is the parent to this one

from easyscience.Objects.Base import Descriptor
# Describe a color by text
color_text = Descriptor('fav_colour', 'red')
# Describe a color by RGB
color_num = Descriptor('fav_colour', [1, 0, 0])

Note

Undo/Redo functionality is implemented for the attributes value, unit and display name.

property compatible_units: List[str]#

Returns all possible units for which the current unit can be converted.

Returns:

Possible conversion units

convert_unit(unit_str)[source]#

Convert the value from one unit system to another. You will should use compatible_units to see if your new unit is compatible.

Parameters:

unit_str (str) – New unit in string form

property display_name: str#

Get a pretty display name.

Returns:

The pretty display name.

property enabled: bool#

Logical property to see if the objects value can be directly set.

Returns:

Can the objects value be set

property raw_value: Any#

Return the raw value of self without a unit.

Returns:

The raw value of self

to_obj_type(data_type, *kwargs)[source]#

Convert between a Parameter and a Descriptor.

Parameters:
  • data_type (Type[Parameter]) – class constructor of what we want to be

  • kwargs – Additional keyword/value pairs for conversion

Returns:

self as a new type

property unique_name: str#

Get the unique name of this object.

Returns:

Unique name of this object

property unit: UnitRegistry#

Get the unit associated with the object.

Returns:

Unit associated with self in pint form.

property value: Any#

Get the value of self as a pint. This is should be usable for most cases. If a pint is not acceptable then the raw value can be obtained through obj.raw_value.

Returns:

Value of self with unit.

Parameters#

class easyscience.Objects.Variable.Parameter(name, value, error=0.0, min=-inf, max=inf, fixed=False, **kwargs)[source]#

This class is an extension of a EasyScience.Object.Base.Descriptor. Where the descriptor was for static objects, a Parameter is for dynamic objects. A parameter has the ability to be used in fitting and has additional fields to facilitate this.

Parameters:
from easyscience.Objects.Base import Parameter
# Describe a phase
phase_basic = Parameter('phase', 3)
# Describe a phase with a unit
phase_unit = Parameter('phase', 3, units,='rad/s')

Note

Undo/Redo functionality is implemented for the attributes value, error, min, max, fixed

as_data_dict(skip=None)#

Returns a dictionary containing just the data of an EasyScience object.

Parameters:

skip (Optional[List[str]]) – List of field names as strings to skip when forming the dictionary

Return type:

Dict[str, Any]

Returns:

dictionary containing just the data of an EasyScience object.

as_dict(skip=None)#

Convert an EasyScience object into a full dictionary using DictSerializer. This is a shortcut for `obj.encode(encoder=DictSerializer)`

Parameters:

skip (Optional[List[str]]) – List of field names as strings to skip when forming the dictionary

Return type:

Dict[str, Any]

Returns:

encoded object containing all information to reform an EasyScience object.

property bounds: Tuple[Number, Number]#

Get the bounds of the parameter.

Returns:

Tuple of the parameters minimum and maximum values

property builtin_constraints: mappingproxy[str, C]#

Get the built in constrains of the object. Typically these are the min/max

Returns:

Dictionary of constraints which are built into the system

property compatible_units: List[str]#

Returns all possible units for which the current unit can be converted.

Returns:

Possible conversion units

convert_unit(new_unit)[source]#

Perform unit conversion. The value, max and min can change on unit change.

Parameters:

new_unit (str) – new unit

Returns:

None

classmethod decode(obj, decoder=None)#

Re-create an EasyScience object from the output of an encoder. The default decoder is DictSerializer.

Parameters:
  • obj (Any) – encoded EasyScience object

  • decoder (Optional[Type[TypeVar(EC, bound= BaseEncoderDecoder)]]) – decoder to be used to reform the EasyScience object

Return type:

Any

Returns:

Reformed EasyScience object

property display_name: str#

Get a pretty display name.

Returns:

The pretty display name.

property enabled: bool#

Logical property to see if the objects value can be directly set.

Returns:

Can the objects value be set

encode(skip=None, encoder=None, **kwargs)#

Use an encoder to covert an EasyScience object into another format. Default is to a dictionary using DictSerializer.

Parameters:
  • skip (Optional[List[str]]) – List of field names as strings to skip when forming the encoded object

  • encoder (Optional[Type[TypeVar(EC, bound= BaseEncoderDecoder)]]) – The encoder to be used for encoding the data. Default is DictSerializer

  • kwargs – Any additional key word arguments to be passed to the encoder

Return type:

Any

Returns:

encoded object containing all information to reform an EasyScience object.

encode_data(skip=None, encoder=None, **kwargs)#

Returns just the data in an EasyScience object win the format specified by an encoder.

Parameters:
  • skip (Optional[List[str]]) – List of field names as strings to skip when forming the dictionary

  • encoder (Optional[Type[TypeVar(EC, bound= BaseEncoderDecoder)]]) – The encoder to be used for encoding the data. Default is DataDictSerializer

  • kwargs – Any additional keywords to pass to the encoder when encoding

Return type:

Any

Returns:

encoded object containing just the data of an EasyScience object.

property error: float#

The error associated with the parameter.

Returns:

Error associated with parameter

property fixed: bool#

Can the parameter vary while fitting?

Returns:

True = fixed, False = can vary

Return type:

bool

classmethod from_dict(obj_dict)#

Re-create an EasyScience object from a full encoded dictionary.

Parameters:

obj_dict (Dict[str, Any]) – dictionary containing the serialized contents (from DictSerializer) of an EasyScience object

Return type:

None

Returns:

Reformed EasyScience object

property max: Number#

Get the maximum value for fitting.

Returns:

maximum value

property min: Number#

Get the minimum value for fitting.

Returns:

minimum value

property raw_value: Any#

Return the raw value of self without a unit.

Returns:

The raw value of self

to_obj_type(data_type, *kwargs)#

Convert between a Parameter and a Descriptor.

Parameters:
  • data_type (Type[Parameter]) – class constructor of what we want to be

  • kwargs – Additional keyword/value pairs for conversion

Returns:

self as a new type

property unique_name: str#

Get the unique name of this object.

Returns:

Unique name of this object

property unit: UnitRegistry#

Get the unit associated with the object.

Returns:

Unit associated with self in pint form.

unsafe_hash()#

Returns an hash of the current object. This uses a generic but low performance method of converting the object to a dictionary, flattening any nested keys, and then performing a hash on the resulting object

Return type:

openssl_sha1

property user_constraints: Dict[str, C]#

Get the user specified constrains of the object.

Returns:

Dictionary of constraints which are user supplied

property value: Any#

Get the value of self as a pint. This is should be usable for most cases. If a pint is not acceptable then the raw value can be obtained through obj.raw_value.

Returns:

Value of self with unit.

Super Classes and Collections#

Super Classes#

class easyscience.Objects.ObjectClasses.BasedBase(name, interface=None, unique_name=None)[source]#
as_data_dict(skip=None)#

Returns a dictionary containing just the data of an EasyScience object.

Parameters:

skip (Optional[List[str]]) – List of field names as strings to skip when forming the dictionary

Return type:

Dict[str, Any]

Returns:

dictionary containing just the data of an EasyScience object.

as_dict(skip=None)#

Convert an EasyScience object into a full dictionary using DictSerializer. This is a shortcut for `obj.encode(encoder=DictSerializer)`

Parameters:

skip (Optional[List[str]]) – List of field names as strings to skip when forming the dictionary

Return type:

Dict[str, Any]

Returns:

encoded object containing all information to reform an EasyScience object.

classmethod decode(obj, decoder=None)#

Re-create an EasyScience object from the output of an encoder. The default decoder is DictSerializer.

Parameters:
  • obj (Any) – encoded EasyScience object

  • decoder (Optional[Type[TypeVar(EC, bound= BaseEncoderDecoder)]]) – decoder to be used to reform the EasyScience object

Return type:

Any

Returns:

Reformed EasyScience object

encode(skip=None, encoder=None, **kwargs)#

Use an encoder to covert an EasyScience object into another format. Default is to a dictionary using DictSerializer.

Parameters:
  • skip (Optional[List[str]]) – List of field names as strings to skip when forming the encoded object

  • encoder (Optional[Type[TypeVar(EC, bound= BaseEncoderDecoder)]]) – The encoder to be used for encoding the data. Default is DictSerializer

  • kwargs – Any additional key word arguments to be passed to the encoder

Return type:

Any

Returns:

encoded object containing all information to reform an EasyScience object.

encode_data(skip=None, encoder=None, **kwargs)#

Returns just the data in an EasyScience object win the format specified by an encoder.

Parameters:
  • skip (Optional[List[str]]) – List of field names as strings to skip when forming the dictionary

  • encoder (Optional[Type[TypeVar(EC, bound= BaseEncoderDecoder)]]) – The encoder to be used for encoding the data. Default is DataDictSerializer

  • kwargs – Any additional keywords to pass to the encoder when encoding

Return type:

Any

Returns:

encoded object containing just the data of an EasyScience object.

classmethod from_dict(obj_dict)#

Re-create an EasyScience object from a full encoded dictionary.

Parameters:

obj_dict (Dict[str, Any]) – dictionary containing the serialized contents (from DictSerializer) of an EasyScience object

Return type:

None

Returns:

Reformed EasyScience object

generate_bindings()[source]#

Generate or re-generate bindings to an interface (if exists)

Raises:

AttributeError

get_fit_parameters()[source]#

Get all objects which can be fitted (and are not fixed) as a list.

Return type:

Union[List[Parameter], List[Parameter]]

Returns:

List of Parameter objects which can be used in fitting.

get_parameters()[source]#

Get all parameter objects as a list.

Return type:

Union[List[Parameter], List[Parameter]]

Returns:

List of Parameter objects.

property interface: iF#

Get the current interface of the object

property name: str#

Get the common name of the object.

Returns:

Common name of the object

switch_interface(new_interface_name)[source]#

Switch or create a new interface.

property unique_name: str#

Get the unique name of the object.

unsafe_hash()#

Returns an hash of the current object. This uses a generic but low performance method of converting the object to a dictionary, flattening any nested keys, and then performing a hash on the resulting object

Return type:

openssl_sha1

class easyscience.Objects.ObjectClasses.BaseObj(name, unique_name=None, *args, **kwargs)[source]#

Set up the base class.

Parameters:
  • name (str) – Name of this object

  • args (Optional[TypeVar(BV, bound= ComponentSerializer)]) – Any arguments?

  • kwargs (Optional[TypeVar(BV, bound= ComponentSerializer)]) – Fields which this class should contain

as_data_dict(skip=None)#

Returns a dictionary containing just the data of an EasyScience object.

Parameters:

skip (Optional[List[str]]) – List of field names as strings to skip when forming the dictionary

Return type:

Dict[str, Any]

Returns:

dictionary containing just the data of an EasyScience object.

as_dict(skip=None)#

Convert an EasyScience object into a full dictionary using DictSerializer. This is a shortcut for `obj.encode(encoder=DictSerializer)`

Parameters:

skip (Optional[List[str]]) – List of field names as strings to skip when forming the dictionary

Return type:

Dict[str, Any]

Returns:

encoded object containing all information to reform an EasyScience object.

classmethod decode(obj, decoder=None)#

Re-create an EasyScience object from the output of an encoder. The default decoder is DictSerializer.

Parameters:
  • obj (Any) – encoded EasyScience object

  • decoder (Optional[Type[TypeVar(EC, bound= BaseEncoderDecoder)]]) – decoder to be used to reform the EasyScience object

Return type:

Any

Returns:

Reformed EasyScience object

encode(skip=None, encoder=None, **kwargs)#

Use an encoder to covert an EasyScience object into another format. Default is to a dictionary using DictSerializer.

Parameters:
  • skip (Optional[List[str]]) – List of field names as strings to skip when forming the encoded object

  • encoder (Optional[Type[TypeVar(EC, bound= BaseEncoderDecoder)]]) – The encoder to be used for encoding the data. Default is DictSerializer

  • kwargs – Any additional key word arguments to be passed to the encoder

Return type:

Any

Returns:

encoded object containing all information to reform an EasyScience object.

encode_data(skip=None, encoder=None, **kwargs)#

Returns just the data in an EasyScience object win the format specified by an encoder.

Parameters:
  • skip (Optional[List[str]]) – List of field names as strings to skip when forming the dictionary

  • encoder (Optional[Type[TypeVar(EC, bound= BaseEncoderDecoder)]]) – The encoder to be used for encoding the data. Default is DataDictSerializer

  • kwargs – Any additional keywords to pass to the encoder when encoding

Return type:

Any

Returns:

encoded object containing just the data of an EasyScience object.

classmethod from_dict(obj_dict)#

Re-create an EasyScience object from a full encoded dictionary.

Parameters:

obj_dict (Dict[str, Any]) – dictionary containing the serialized contents (from DictSerializer) of an EasyScience object

Return type:

None

Returns:

Reformed EasyScience object

generate_bindings()#

Generate or re-generate bindings to an interface (if exists)

Raises:

AttributeError

get_fit_parameters()#

Get all objects which can be fitted (and are not fixed) as a list.

Return type:

Union[List[Parameter], List[Parameter]]

Returns:

List of Parameter objects which can be used in fitting.

get_parameters()#

Get all parameter objects as a list.

Return type:

Union[List[Parameter], List[Parameter]]

Returns:

List of Parameter objects.

property interface: iF#

Get the current interface of the object

property name: str#

Get the common name of the object.

Returns:

Common name of the object

switch_interface(new_interface_name)#

Switch or create a new interface.

property unique_name: str#

Get the unique name of the object.

unsafe_hash()#

Returns an hash of the current object. This uses a generic but low performance method of converting the object to a dictionary, flattening any nested keys, and then performing a hash on the resulting object

Return type:

openssl_sha1

Collections#

class easyscience.Objects.Groups.BaseCollection(name, *args, interface=None, unique_name=None, **kwargs)[source]#

Set up the base collection class.

Parameters:
append(value)#

S.append(value) – append value to the end of the sequence

as_data_dict(skip=None)#

Returns a dictionary containing just the data of an EasyScience object.

Parameters:

skip (Optional[List[str]]) – List of field names as strings to skip when forming the dictionary

Return type:

Dict[str, Any]

Returns:

dictionary containing just the data of an EasyScience object.

as_dict(skip=None)#

Convert an EasyScience object into a full dictionary using DictSerializer. This is a shortcut for `obj.encode(encoder=DictSerializer)`

Parameters:

skip (Optional[List[str]]) – List of field names as strings to skip when forming the dictionary

Return type:

Dict[str, Any]

Returns:

encoded object containing all information to reform an EasyScience object.

clear() None -- remove all items from S#
count(value) integer -- return number of occurrences of value#
property data: Tuple#

The data function returns a tuple of the keyword arguments passed to the constructor. This is useful for when you need to pass in a dictionary of data to other functions, such as with matplotlib’s plot function.

Parameters:

self – Access attributes of the class within the method

Returns:

The values of the attributes in a tuple

Doc-author:

Trelent

classmethod decode(obj, decoder=None)#

Re-create an EasyScience object from the output of an encoder. The default decoder is DictSerializer.

Parameters:
  • obj (Any) – encoded EasyScience object

  • decoder (Optional[Type[TypeVar(EC, bound= BaseEncoderDecoder)]]) – decoder to be used to reform the EasyScience object

Return type:

Any

Returns:

Reformed EasyScience object

encode(skip=None, encoder=None, **kwargs)#

Use an encoder to covert an EasyScience object into another format. Default is to a dictionary using DictSerializer.

Parameters:
  • skip (Optional[List[str]]) – List of field names as strings to skip when forming the encoded object

  • encoder (Optional[Type[TypeVar(EC, bound= BaseEncoderDecoder)]]) – The encoder to be used for encoding the data. Default is DictSerializer

  • kwargs – Any additional key word arguments to be passed to the encoder

Return type:

Any

Returns:

encoded object containing all information to reform an EasyScience object.

encode_data(skip=None, encoder=None, **kwargs)#

Returns just the data in an EasyScience object win the format specified by an encoder.

Parameters:
  • skip (Optional[List[str]]) – List of field names as strings to skip when forming the dictionary

  • encoder (Optional[Type[TypeVar(EC, bound= BaseEncoderDecoder)]]) – The encoder to be used for encoding the data. Default is DataDictSerializer

  • kwargs – Any additional keywords to pass to the encoder when encoding

Return type:

Any

Returns:

encoded object containing just the data of an EasyScience object.

extend(values)#

S.extend(iterable) – extend sequence by appending elements from the iterable

classmethod from_dict(obj_dict)#

Re-create an EasyScience object from a full encoded dictionary.

Parameters:

obj_dict (Dict[str, Any]) – dictionary containing the serialized contents (from DictSerializer) of an EasyScience object

Return type:

None

Returns:

Reformed EasyScience object

generate_bindings()#

Generate or re-generate bindings to an interface (if exists)

Raises:

AttributeError

get_fit_parameters()#

Get all objects which can be fitted (and are not fixed) as a list.

Return type:

Union[List[Parameter], List[Parameter]]

Returns:

List of Parameter objects which can be used in fitting.

get_parameters()#

Get all parameter objects as a list.

Return type:

Union[List[Parameter], List[Parameter]]

Returns:

List of Parameter objects.

index(value[, start[, stop]]) integer -- return first index of value.#

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

insert(index, value)[source]#

Insert an object into the collection at an index.

Parameters:
  • index (int) – Index for EasyScience object to be inserted.

  • value (Union[BasedBase, Descriptor]) – Object to be inserted.

Returns:

None

Return type:

None

property interface: iF#

Get the current interface of the object

property name: str#

Get the common name of the object.

Returns:

Common name of the object

pop([index]) item -- remove and return item at index (default last).#

Raise IndexError if list is empty or index is out of range.

remove(value)#

S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.

reverse()#

S.reverse() – reverse IN PLACE

sort(mapping, reverse=False)[source]#

Sort the collection according to the given mapping.

Parameters:
  • mapping (Callable) – mapping function to sort the collection. i.e. lambda parameter: parameter.raw_value

  • reverse (bool) – Reverse the sorting.

Return type:

None

switch_interface(new_interface_name)#

Switch or create a new interface.

property unique_name: str#

Get the unique name of the object.

unsafe_hash()#

Returns an hash of the current object. This uses a generic but low performance method of converting the object to a dictionary, flattening any nested keys, and then performing a hash on the resulting object

Return type:

openssl_sha1

Data Containers#

class easyscience.Datasets.xarray.EasyScienceDataarrayAccessor(xarray_obj)[source]#

Accessor to extend an xarray DataArray to EasyScience. These functions can be accessed by obj.EasyScience.func.

property compute_func: Callable#

Get the computational function which will be executed during a fit

Returns:

Computational function applied to the DataArray

Return type:

Callable

property core_object#

Get the core object associated to a DataArray. Note that this is called from a weakref. If the EasyScience obj is garbage collected, None will be returned.

Returns:

EasyScience object associated with the DataArray

Return type:

Any

fit(fitter, *args, fit_kwargs=None, fn_kwargs=None, vectorize=False, dask='forbidden', **kwargs)[source]#

Perform a fit on the given DataArray. This fit utilises a given fitter from EasyScience.fitting.Fitter, though there are a few differences to a standard EasyScience fit. In particular, key-word arguments to control the optimisation algorithm go in the fit_kwargs dictionary, fit function key-word arguments go in the fn_kwargs and given key-word arguments control the xarray.apply_ufunc function.

Parameters:
  • fitter (EasyScience.fitting.Fitter) – Fitting object which controls the fitting

  • args (Any) – Arguments to go to the fit function

  • dask (str) – Dask control string. See xarray.apply_ufunc documentation

  • fit_kwargs (dict) – Dictionary of key-word arguments to be supplied to the Fitting control

  • fn_kwargs (dict) – Dictionary of key-words to be supplied to the fit function

  • vectorize (bool) – Should the fit function be given dependents in a single object or split

  • kwargs (Any) – Key-word arguments for xarray.apply_ufunc. See xarray.apply_ufunc documentation

Returns:

Results of the fit

Return type:

FitResults

fit_prep(func_in, bdims=None, dask_chunks=None)[source]#

Generate broadcasted coordinates for fitting and reform the fitting function into one which can handle xarrays.

Parameters:
  • func_in (Callable) – Function to be wrapped and made xarray fitting compatible.

  • bdims (xarray.DataArray) – Optional precomputed broadcasted dimensions.

  • dask_chunks (Tuple[int..]) – How to split the broadcasted dimensions for dask.

Returns:

Tuple of broadcasted fit arrays and wrapped fit function.

Return type:

xarray.DataArray, Callable

generate_points()[source]#

Generate an expanded DataArray of points which corresponds to broadcasted dimensions (all_x) which have been concatenated along the second axis (fit_dim).

Returns:

Broadcasted and concatenated coordinates

Return type:

xarray.DataArray

property postcompute_func: Callable#

Get the post-computational function which will be executed after a fit

Returns:

Computational function applied to the DataArray after fitting

Return type:

Callable

property precompute_func: Callable#

Get the pre-computational function which will be executed before a fit

Returns:

Computational function applied to the DataArray before fitting

Return type:

Callable

class easyscience.Datasets.xarray.EasyScienceDatasetAccessor(xarray_obj)[source]#

This is called whenever you access obj.EasyScience, hence the attributes in the obj should only be written if they have not been previously instantiated.

Parameters:

xarray_obj (xarray.Dataset) – DataSet which is called by obj.EasyScience

add_coordinate(coordinate_name, coordinate_values, unit='')[source]#

Add a coordinate to the DataSet. This can be then be assigned to one or more DataArrays.

Parameters:
  • coordinate_name (str) – Name of the coordinate e.g. x

  • coordinate_values (Union[List[T_], numpy.ndarray]) – Points for the coordinates

  • unit (str) – Unit associated with the coordinate

Returns:

None

Return type:

None

add_variable(variable_name, variable_coordinates, variable_values, variable_sigma=None, unit='', auto_sigma=False)[source]#

Create a DataArray from known coordinates and data, assign it to the dataset under a given name. Variances can be calculated assuming gaussian distribution to 1 sigma.

Parameters:
  • variable_name (str) – Name of the DataArray which will be created and added to the dataset

  • variable_coordinates (str, List[str]) – List of coordinates used in the supplied data array.

  • variable_values (Union[numpy.ndarray, list]) – Numpy or list of data which will be assigned to the DataArray

  • variable_sigma (Union[numpy.ndarray, list]) – If the sigmas of the dataset are known, they can be supplied here.

  • unit (str) – Unit associated with the DataArray

  • auto_sigma (bool) – Should the sigma DataArray be automatically calculated assuming gaussian probability?

Returns:

None

Return type:

None

property core_object#

Get the core object associated to a DataSet. Note that this is called from a weakref. If the EasyScience obj is garbage collected, None will be returned.

Returns:

EasyScience object associated with the DataSet

Return type:

Any

property description: str#

Get a description of the DataSet

Returns:

Description of the DataSet

Return type:

str

fit(fitter, data_arrays, *args, dask='forbidden', fit_kwargs=None, fn_kwargs=None, vectorized=False, **kwargs)[source]#

Perform a fit on one or more DataArrays. This fit utilises a given fitter from EasyScience.fitting.Fitter, though there are a few differences to a standard EasyScience fit. In particular, key-word arguments to control the optimisation algorithm go in the fit_kwargs dictionary, fit function key-word arguments go in the fn_kwargs and given key-word arguments control the xarray.apply_ufunc function.

Parameters:
  • fitter (EasyScience.fitting.Fitter) – Fitting object which controls the fitting

  • args (Any) – Arguments to go to the fit function

  • dask (str) – Dask control string. See xarray.apply_ufunc documentation

  • fit_kwargs (dict) – Dictionary of key-word arguments to be supplied to the Fitting control

  • fn_kwargs (dict) – Dictionary of key-words to be supplied to the fit function

  • vectorized (bool) – Should the fit function be given dependents in a single object or split

  • kwargs (Any) – Key-word arguments for xarray.apply_ufunc. See xarray.apply_ufunc documentation

Returns:

Results of the fit

Return type:

List[FitResults]

generate_points(coordinates)[source]#
Return type:

DataArray

Generate an expanded DataArray of points which corresponds to broadcasted dimensions (all_x) which have been concatenated along the second axis (fit_dim).

x = [1, 2], y = [3, 4]
d = xr.DataArray()
d.EasyScience.add_coordinate('x', x)
d.EasyScience.add_coordinate('y', y)
points = d.EasyScience.generate_points(['x', 'y'])
print(points)
property name: str#

Get the common name of the DataSet.

Returns:

Common name of the DataSet

Return type:

str

remove_coordinate(coordinate_name)[source]#

Remove a coordinate from the DataSet. Note that this will not remove the coordinate from DataArrays which have already used the it!

Parameters:

coordinate_name (str) – Name of the coordinate to be removed

Returns:

None

Return type:

None

remove_variable(variable_name)[source]#

Remove a DataArray from the DataSet by supplied name.

Parameters:

variable_name (str) – Name of DataArray to be removed

Returns:

None

Return type:

None

sigma_attach(variable_label, sigma_values, label_prefix=None)[source]#

Attach an array of sigmas to the DataSet.

Parameters:
  • variable_label (str) – Name of the DataArray to perform the calculation on

  • sigma_values (Union[List[T_], numpy.ndarray, xarray.DataArray]) – Array of sigmas in list, numpy or DataArray form

  • label_prefix (str) – What prefix should be used to designate a sigma DataArray from a data DataArray

Returns:

None

Return type:

None

sigma_generator(variable_label, sigma_func=<function EasyScienceDatasetAccessor.<lambda>>, label_prefix=None)[source]#

Generate sigmas off of a DataArray based on a function.

Parameters:
  • variable_label (str) – Name of the DataArray to perform the calculation on

  • sigma_func (Callable) – Function to generate the sigmas. Must be of the form f(x) and return an array of the same shape as the input. Default sqrt(|x|)

  • label_prefix (str) – What prefix should be used to designate a sigma DataArray from a data DataArray

Returns:

None

Return type:

None

property url: str#

Get the url of the DataSet

Returns:

URL of the DataSet (empty if no URL)

Return type:

str