Data handlers (data)

Contents

Data handlers (data)#

The general scheme is to use the following:

  • uv, xv -> samples (values) for u, x

  • u, xu -> averages of u and x*u

  • u[i] = <u**i>

  • xu[i] = <x * u**i>

  • xu[i, j] = <d^i x/d beta^i * u**j

Classes:

DataCallback()

Basic version of DataCallbackABC.

DataCallbackABC()

Base class for handling callbacks to adjust data.

DataCentralMoments(dxduave, *[, meta, ...])

Data class using cmomy.CentralMomentsData to handle central moments.

DataCentralMomentsVals(uv, xv[, ...])

Data object based on central co-moments array.

Functions:

factory_data_values(uv, xv, *, order[, ...])

Factory function to produce a DataCentralMomentsVals object.

class thermoextrap.data.DataCallback[source]#

Bases: DataCallbackABC

Basic version of DataCallbackABC.

Implemented to pass things through unchanged. Will be used for default construction

Methods:

check(data)

Perform any consistency checks between self and data.

deriv_args(data, *, deriv_args)

Adjust derivs args from data class.

resample(data, *, meta_kws, sampler, **kws)

Adjust create new object.

reduce(data, *, meta_kws, **kws)

Reduce along dimension.

asdict()

Convert object to dictionary.

assign(**kws)

Alias to new_like().

new_like(**kws)

Create a new object with optional parameters.

check(data)[source]#

Perform any consistency checks between self and data.

deriv_args(data, *, deriv_args)[source]#

Adjust derivs args from data class.

should return a tuple

resample(data, *, meta_kws, sampler, **kws)[source]#

Adjust create new object.

Should return new instance of class or self no change

reduce(data, *, meta_kws, **kws)[source]#

Reduce along dimension.

asdict()[source]#

Convert object to dictionary.

assign(**kws)[source]#

Alias to new_like().

new_like(**kws)[source]#

Create a new object with optional parameters.

Parameters:

**kwsattribute, value pairs.

class thermoextrap.data.DataCallbackABC[source]#

Bases: MyAttrsMixin

Base class for handling callbacks to adjust data.

For some cases, the default Data classes don’t quite cut it. For example, for volume extrapolation, extrap parameters need to be included in the derivatives. To handle this generally, the Data class include self.meta which performs these actions.

DataCallback can be subclassed to fine tune things.

Methods:

check(data)

Perform any consistency checks between self and data.

deriv_args(data, *, deriv_args)

Adjust derivs args from data class.

resample(data, *, meta_kws, sampler, **kws)

Adjust create new object.

reduce(data, *, meta_kws, **kws)

Reduce along dimension.

asdict()

Convert object to dictionary.

assign(**kws)

Alias to new_like().

new_like(**kws)

Create a new object with optional parameters.

abstractmethod check(data)[source]#

Perform any consistency checks between self and data.

abstractmethod deriv_args(data, *, deriv_args)[source]#

Adjust derivs args from data class.

should return a tuple

resample(data, *, meta_kws, sampler, **kws)[source]#

Adjust create new object.

Should return new instance of class or self no change

reduce(data, *, meta_kws, **kws)[source]#

Reduce along dimension.

asdict()[source]#

Convert object to dictionary.

assign(**kws)[source]#

Alias to new_like().

new_like(**kws)[source]#

Create a new object with optional parameters.

Parameters:

**kwsattribute, value pairs.

class thermoextrap.data.DataCentralMoments(dxduave, *, meta=None, umom_dim='umom', deriv_dim=None, xmom_dim='xmom', rec_dim='rec', central=False, x_is_u=None, use_cache=True)[source]#

Bases: DataCentralMomentsBase[DataT]

Data class using cmomy.CentralMomentsData to handle central moments.

Parameters:
  • meta (dict, optional) – extra meta data/parameters to be carried along with object and child objects. if ‘checker’ in meta, then perform a callback of the form meta[‘checker](self, meta) this can also be used to override things like deriv_args. Values passed through method resample_meta

  • umom_dim (str, default 'umom') – Name of dimension for moment of energy u.

  • deriv_dim (str, default None) – if deriv_dim is a string, then this is the name of the derivative dimension and xarray objects will have a derivative

  • xmom_dim (str, default 'xmom') – Name of dimension for moments of observable x.

  • rec_dim (hashable) – Name of dimension for ‘records’, i.e., multiple observations.

  • central (bool) – If True, Use central moments. Otherwise, use raw moments.

  • x_is_u (bool, default False) – if True, treat xv = uv and do adjust u/du accordingly

  • use_cache (bool) – If True (default), cache intermediate result. Speeds up calculations, but can lead to large objects.

Attributes:

dxduave

Wrapped cmomy.CentralMomentsData object.

central

Whether central or raw moments are used

deriv_args

Arguments to be passed to derivative function.

deriv_dim

Derivative dimension

du

Averages of du ** n.

du_selector

Selector for du_selector[n] = du ** n.

dxdu

Averages of form dx * dx ** n.

dxdu_selector

Selector for dxdu_selector[n] = dx * du ** n.

meta

Callback

order

Order of expansion.

rec_dim

Records dimension

u

Averages of form u ** n.

u_selector

Indexer for u_selector[n] = u ** n.

umom_dim

Energy moments dimension

values

Data underlying dxduave.

x_is_u

Whether observable x is same as energy u

xalpha

Whether X has explicit dependence on alpha.

xave

Averages of form observable x.

xave_selector

Selector for xave.

xmom_dim

Overvable moment dimension

xu

Averages of form x * u ** n.

xu_selector

Indexer for xu_select[n] = x * u ** n.

Methods:

reduce([dim, axis, meta_kws])

Reduce along axis.

resample(sampler[, dim, axis, rep_dim, ...])

Resample data.

from_raw(raw[, rec_dim, xmom_dim, umom_dim, ...])

Convert raw moments to data object.

from_vals(uv, xv, order[, xmom_dim, ...])

Create DataCentralMoments object from individual (unaveraged) samples.

from_data(data[, rec_dim, xmom_dim, ...])

Create DataCentralMoments object from data.

from_resample_vals(xv, uv, order, sampler[, ...])

Create DataCentralMoments object from unaveraged samples with resampling.

from_ave_raw(u, xu[, weight, rec_dim, ...])

Create object with <u**n>, <x * u**n> arrays.

from_ave_central(du, dxdu[, weight, xave, ...])

Constructor from central moments, with reduction along axis.

asdict()

Convert object to dictionary.

assign(**kws)

Alias to new_like().

cmom()

Central co-moments.

new_like(**kws)

Create a new object with optional parameters.

rmom()

Raw co-moments.

property dxduave#

Wrapped cmomy.CentralMomentsData object.

reduce(dim=MISSING, axis=MISSING, meta_kws=None, **kwargs)[source]#

Reduce along axis.

Parameters:
resample(sampler, dim=MISSING, axis=MISSING, rep_dim='rep', parallel=None, meta_kws=None, **kwargs)[source]#

Resample data.

Parameters:
  • sampler (int or array-like or mapping) – Passed through cmomy.resample.factory_sampler() to create an IndexSampler. Value can either be nrep (the number of replicates), freq (frequency array), a IndexSampler object, or a mapping of parameters. The mapping can have form of FactoryIndexSamplerKwargs. Allowable keys are freq, indices, ndat, nrep, nsamp, paired, rng, replace, shuffle.

  • dim (hashable) – Dimension to reduce/sample along.

  • axis (int) – Axis to reduce/sample along.

  • rep_dim (hashable) – Name of new ‘replicated’ dimension:

  • parallel (bool, optional) – If True, use parallel numba numba.njit or numba.guvectorized code if possible. If None, use a heuristic to determine if should attempt to use parallel method.

  • meta_kws (mapping, optional) – Parameters to self.meta.resample

classmethod from_raw(raw, rec_dim='rec', xmom_dim='xmom', umom_dim='umom', deriv_dim=None, central=False, x_is_u=False, meta=None, **kwargs)[source]#

Convert raw moments to data object.

The raw moments have the form raw[..., i, j] = weight if i = j = 0. Otherwise, raw[..., i, j] = <x ** i * u ** j>.

Parameters:
  • raw (array-like) – raw moments. The form of this array is such that The shape should be (..., 2, order+1)

  • rec_dim (hashable) – Name of dimension for ‘records’, i.e., multiple observations.

  • xmom_dim (str, default 'xmom') – Name of dimension for moments of observable x.

  • umom_dim (str, default 'umom') – Name of dimension for moment of energy u.

  • deriv_dim (str, default None) – if deriv_dim is a string, then this is the name of the derivative dimension and xarray objects will have a derivative

  • central (bool) – If True, Use central moments. Otherwise, use raw moments.

  • dims (hashable or sequence of hashable) – Dimension of resulting xarray.DataArray.

    • If len(dims) == self.ndim, then dims specifies all dimensions.

    • If len(dims) == self.val_ndim, dims = dims + mom_dims

    Default to ('dim_0', 'dim_1', ...)

  • attrs (mapping) – Attributes of output

  • coords (mapping) – Coordinates of output

  • name (hashable) – Name of output

  • indexes (Any) – indexes attribute. This is ignored.

  • template (DataArray) – If present, output will have attributes of template. Overrides other options.

  • meta (dict, optional) – extra meta data/parameters to be carried along with object and child objects. if ‘checker’ in meta, then perform a callback of the form meta[‘checker](self, meta) this can also be used to override things like deriv_args. Values passed through method resample_meta

  • x_is_u (bool, default False) – if True, treat xv = uv and do adjust u/du accordingly

  • **kwargs – Extra arguments to cmomy.wrap_raw()

Returns:

output (DataCentralMoments)

classmethod from_vals(uv, xv, order, xmom_dim='xmom', umom_dim='umom', rec_dim='rec', deriv_dim=None, central=False, weight=None, axis=MISSING, dim=MISSING, meta=None, x_is_u=False, **kwargs)[source]#

Create DataCentralMoments object from individual (unaveraged) samples.

Parameters:
  • xv (xarray.DataArray) – raw values of x (observable)

  • uv (xarray.DataArray) – raw values of u (energy)

  • order (int) – maximum order of moments/expansion to calculate

  • xmom_dim (str, default 'xmom') – Name of dimension for moments of observable x.

  • umom_dim (str, default 'umom') – Name of dimension for moment of energy u.

  • rec_dim (hashable) – Name of dimension for ‘records’, i.e., multiple observations.

  • deriv_dim (str, default None) – if deriv_dim is a string, then this is the name of the derivative dimension and xarray objects will have a derivative

  • central (bool) – If True, Use central moments. Otherwise, use raw moments.

  • weight (array-like or DataArray, optional) – optional weight array. Note that this array/xarray must be conformable to uv, xv

  • dim (hashable) – Dimension to reduce/sample along.

  • axis (int) – Axis to reduce/sample along.

  • dtype (dtype) – Optional dtype for output data.

  • meta (dict, optional) – extra meta data/parameters to be carried along with object and child objects. if ‘checker’ in meta, then perform a callback of the form meta[‘checker](self, meta) this can also be used to override things like deriv_args. Values passed through method resample_meta

  • x_is_u (bool, default False) – if True, treat xv = uv and do adjust u/du accordingly

  • **kwargs – Extra arguments to cmomy.wrap_reduce_vals()

Returns:

output (DataCentralMoments)

classmethod from_data(data, rec_dim='rec', xmom_dim='xmom', umom_dim='umom', deriv_dim=None, central=False, meta=None, x_is_u=False, **kwargs)[source]#

Create DataCentralMoments object from data.

data[…, i, j] = weight i = j = 0

= < x > i = 1 and j = 0 = < u > i = 0 and j = 1 = <(x - <x>)**i * (u - <u>)**j > otherwise

If pass in x_is_u = True, then treat data as a moments array for energy (i.e., using umom_dim). This is then converted to a comoments array using cmomy.convert.moments_to_comoments().

Parameters:
  • data (DataArray)

  • rec_dim (hashable) – Name of dimension for ‘records’, i.e., multiple observations.

  • xmom_dim (str, default 'xmom') – Name of dimension for moments of observable x.

  • umom_dim (str, default 'umom') – Name of dimension for moment of energy u.

  • deriv_dim (str, default None) – if deriv_dim is a string, then this is the name of the derivative dimension and xarray objects will have a derivative

  • central (bool) – If True, Use central moments. Otherwise, use raw moments.

  • dtype (dtype) – Optional dtype for output data.

  • meta (dict, optional) – extra meta data/parameters to be carried along with object and child objects. if ‘checker’ in meta, then perform a callback of the form meta[‘checker](self, meta) this can also be used to override things like deriv_args. Values passed through method resample_meta

  • x_is_u (bool, default False) – if True, treat xv = uv and do adjust u/du accordingly

  • **kwargs – Extra arguments to cmomy.wrap()

Returns:

output (DataCentralMoments)

classmethod from_resample_vals(xv, uv, order, sampler, weight=None, axis=MISSING, dim=MISSING, xmom_dim='xmom', umom_dim='umom', rep_dim='rep', deriv_dim=None, central=False, meta=None, meta_kws=None, x_is_u=False, parallel=None, **kwargs)[source]#

Create DataCentralMoments object from unaveraged samples with resampling.

Parameters:
  • xv (xarray.DataArray) – raw values of x (observable)

  • uv (xarray.DataArray) – raw values of u (energy)

  • order (int) – maximum order of moments/expansion to calculate

  • weight (array-like or DataArray, optional) – optional weight array. Note that this array/xarray must be conformable to uv, xv

  • axis (int) – Axis to reduce/sample along.

  • dim (hashable) – Dimension to reduce/sample along.

  • xmom_dim (str, default 'xmom') – Name of dimension for moments of observable x.

  • umom_dim (str, default 'umom') – Name of dimension for moment of energy u.

  • rep_dim (hashable) – Name of new ‘replicated’ dimension:

  • deriv_dim (str, default None) – if deriv_dim is a string, then this is the name of the derivative dimension and xarray objects will have a derivative

  • central (bool) – If True, Use central moments. Otherwise, use raw moments.

  • dtype (dtype) – Optional dtype for output data.

  • meta (dict, optional) – extra meta data/parameters to be carried along with object and child objects. if ‘checker’ in meta, then perform a callback of the form meta[‘checker](self, meta) this can also be used to override things like deriv_args. Values passed through method resample_meta

  • meta_kws (mapping, optional) – Optional parameters for meta.

  • x_is_u (bool, default False) – if True, treat xv = uv and do adjust u/du accordingly

  • **kwargs – Extra arguments to cmomy.wrap_resample_vals()

classmethod from_ave_raw(u, xu, weight=None, rec_dim='rec', xmom_dim='xmom', umom_dim='umom', deriv_dim=None, central=False, meta=None, x_is_u=False)[source]#

Create object with <u**n>, <x * u**n> arrays.

Parameters:
  • u (array-like) – u[n] = <u**n>.

  • xu (array_like) – xu[n] = <x * u**n>.

  • weight (array-like, optional) – sample weights

  • rec_dim (hashable) – Name of dimension for ‘records’, i.e., multiple observations.

  • xmom_dim (str, default 'xmom') – Name of dimension for moments of observable x.

  • umom_dim (str, default 'umom') – Name of dimension for moment of energy u.

  • deriv_dim (str, default None) – if deriv_dim is a string, then this is the name of the derivative dimension and xarray objects will have a derivative

  • central (bool) – If True, Use central moments. Otherwise, use raw moments.

  • mom (int or tuple of int) – Order or moments. If integer or length one tuple, then moments are for a single variable. If length 2 tuple, then comoments of two variables

  • dtype (dtype) – Optional dtype for output data.

  • dims (hashable or sequence of hashable) – Dimension of resulting xarray.DataArray.

    • If len(dims) == self.ndim, then dims specifies all dimensions.

    • If len(dims) == self.val_ndim, dims = dims + mom_dims

    Default to ('dim_0', 'dim_1', ...)

  • attrs (mapping) – Attributes of output

  • coords (mapping) – Coordinates of output

  • name (hashable) – Name of output

  • indexes (Any) – indexes attribute. This is ignored.

  • template (DataArray) – If present, output will have attributes of template. Overrides other options.

  • meta (dict, optional) – extra meta data/parameters to be carried along with object and child objects. if ‘checker’ in meta, then perform a callback of the form meta[‘checker](self, meta) this can also be used to override things like deriv_args. Values passed through method resample_meta

  • x_is_u (bool, default False) – if True, treat xv = uv and do adjust u/du accordingly

See also

cmomy.wrap_raw

classmethod from_ave_central(du, dxdu, weight=None, xave=None, uave=None, rec_dim='rec', xmom_dim='xmom', umom_dim='umom', deriv_dim=None, central=False, meta=None, x_is_u=False)[source]#

Constructor from central moments, with reduction along axis.

Parameters:
  • du (array-like) – du[0] = 1 or weight, du[1] = <u> or uave du[n] = <(u-<u>)**n>, n >= 2

  • dxdu (array-like) – dxdu[0] = <x> or xave, dxdu[n] = <(x-<x>) * (u - <u>)**n>, n >= 1

  • weight (array-like, optional) – sample weights

  • xave (array-like, optional) – if present, set dxdu[0] to xave

  • uave (array-like, optional) – if present, set du[0] to uave

  • rec_dim (hashable) – Name of dimension for ‘records’, i.e., multiple observations.

  • xmom_dim (str, default 'xmom') – Name of dimension for moments of observable x.

  • umom_dim (str, default 'umom') – Name of dimension for moment of energy u.

  • deriv_dim (str, default None) – if deriv_dim is a string, then this is the name of the derivative dimension and xarray objects will have a derivative

  • central (bool) – If True, Use central moments. Otherwise, use raw moments.

  • mom (int or tuple of int) – Order or moments. If integer or length one tuple, then moments are for a single variable. If length 2 tuple, then comoments of two variables

  • meta (dict, optional) – extra meta data/parameters to be carried along with object and child objects. if ‘checker’ in meta, then perform a callback of the form meta[‘checker](self, meta) this can also be used to override things like deriv_args. Values passed through method resample_meta

  • x_is_u (bool, default False) – if True, treat xv = uv and do adjust u/du accordingly

asdict()[source]#

Convert object to dictionary.

assign(**kws)[source]#

Alias to new_like().

central#

Whether central or raw moments are used

cmom()[source]#

Central co-moments.

property deriv_args#

Arguments to be passed to derivative function.

For example, derivs(*self.deriv_args).

deriv_dim#

Derivative dimension

du[source]#

Averages of du ** n.

du_selector[source]#

Selector for du_selector[n] = du ** n.

dxdu[source]#

Averages of form dx * dx ** n.

dxdu_selector[source]#

Selector for dxdu_selector[n] = dx * du ** n.

meta#

Callback

new_like(**kws)[source]#

Create a new object with optional parameters.

Parameters:

**kwsattribute, value pairs.

property order#

Order of expansion.

rec_dim#

Records dimension

rmom()[source]#

Raw co-moments.

u[source]#

Averages of form u ** n.

u_selector[source]#

Indexer for u_selector[n] = u ** n.

umom_dim#

Energy moments dimension

property values#

Data underlying dxduave.

x_is_u#

Whether observable x is same as energy u

property xalpha#

Whether X has explicit dependence on alpha.

That is, if self.deriv_dim is not None

xave[source]#

Averages of form observable x.

xave_selector[source]#

Selector for xave.

xmom_dim#

Overvable moment dimension

xu[source]#

Averages of form x * u ** n.

xu_selector[source]#

Indexer for xu_select[n] = x * u ** n.

class thermoextrap.data.DataCentralMomentsVals(uv, xv, resample_values=False, *, meta=None, umom_dim='umom', deriv_dim=None, xmom_dim='xmom', rec_dim='rec', central=False, x_is_u=None, use_cache=True, order=None, weight=None, from_vals_kws=NOTHING, dxduave=None)[source]#

Bases: DataCentralMomentsBase[DataT]

Data object based on central co-moments array.

Parameters:
  • meta (dict, optional) – extra meta data/parameters to be carried along with object and child objects. if ‘checker’ in meta, then perform a callback of the form meta[‘checker](self, meta) this can also be used to override things like deriv_args. Values passed through method resample_meta

  • umom_dim (str, default 'umom') – Name of dimension for moment of energy u.

  • deriv_dim (str, default None) – if deriv_dim is a string, then this is the name of the derivative dimension and xarray objects will have a derivative

  • xmom_dim (str, default 'xmom') – Name of dimension for moments of observable x.

  • rec_dim (hashable) – Name of dimension for ‘records’, i.e., multiple observations.

  • central (bool) – If True, Use central moments. Otherwise, use raw moments.

  • x_is_u (bool, default False) – if True, treat xv = uv and do adjust u/du accordingly

  • use_cache (bool) – If True (default), cache intermediate result. Speeds up calculations, but can lead to large objects.

Attributes:

uv

Stored energy values

xv

Stored observable values

weight

Stored weights

from_vals_kws

Optional parameters to cmomy.wrap_reduce_vals()

resample_values

If True, resample uv and xv.

dxduave

Wrapped cmomy.CentralMomentsData object.

order

Order of expansion.

central

Whether central or raw moments are used

deriv_args

Arguments to be passed to derivative function.

deriv_dim

Derivative dimension

du

Averages of du ** n.

du_selector

Selector for du_selector[n] = du ** n.

dxdu

Averages of form dx * dx ** n.

dxdu_selector

Selector for dxdu_selector[n] = dx * du ** n.

meta

Callback

rec_dim

Records dimension

u

Averages of form u ** n.

u_selector

Indexer for u_selector[n] = u ** n.

umom_dim

Energy moments dimension

values

Data underlying dxduave.

x_is_u

Whether observable x is same as energy u

xalpha

Whether X has explicit dependence on alpha.

xave

Averages of form observable x.

xave_selector

Selector for xave.

xmom_dim

Overvable moment dimension

xu

Averages of form x * u ** n.

xu_selector

Indexer for xu_select[n] = x * u ** n.

Methods:

from_vals(xv, uv, order[, weight, rec_dim, ...])

Constructor from arrays.

resample(sampler[, dim, axis, rep_dim, ...])

Resample data.

asdict()

Convert object to dictionary.

assign(**kws)

Alias to new_like().

cmom()

Central co-moments.

new_like(**kws)

Create a new object with optional parameters.

rmom()

Raw co-moments.

uv#

Stored energy values

xv#

Stored observable values

weight#

Stored weights

from_vals_kws#

Optional parameters to cmomy.wrap_reduce_vals()

resample_values#

If True, resample uv and xv. Otherwise resample during construction of dxduave.

property dxduave#

Wrapped cmomy.CentralMomentsData object.

property order#

Order of expansion.

classmethod from_vals(xv, uv, order, weight=None, rec_dim='rec', umom_dim='umom', xmom_dim='xmom', deriv_dim=None, central=False, from_vals_kws=None, resample_values=False, meta=None, x_is_u=False)[source]#

Constructor from arrays.

Parameters:
  • xv (xarray.DataArray) – raw values of x (observable)

  • uv (xarray.DataArray) – raw values of u (energy)

  • order (int) – maximum order of moments/expansion to calculate

  • xmom_dim (str, default 'xmom') – Name of dimension for moments of observable x.

  • umom_dim (str, default 'umom') – Name of dimension for moment of energy u.

  • rec_dim (hashable) – Name of dimension for ‘records’, i.e., multiple observations.

  • deriv_dim (str, default None) – if deriv_dim is a string, then this is the name of the derivative dimension and xarray objects will have a derivative

  • central (bool) – If True, Use central moments. Otherwise, use raw moments.

  • weight (array-like or DataArray, optional) – optional weight array. Note that this array/xarray must be conformable to uv, xv

  • val_shape (tuple) – Shape of values part of data. That is, the non-moment dimensions.

  • dtype (dtype) – Optional dtype for output data.

  • dims (hashable or sequence of hashable) – Dimension of resulting xarray.DataArray.

    • If len(dims) == self.ndim, then dims specifies all dimensions.

    • If len(dims) == self.val_ndim, dims = dims + mom_dims

    Default to ('dim_0', 'dim_1', ...)

  • attrs (mapping) – Attributes of output

  • coords (mapping) – Coordinates of output

  • name (hashable) – Name of output

  • indexes (Any) – indexes attribute. This is ignored.

  • template (DataArray) – If present, output will have attributes of template. Overrides other options.

  • meta (dict, optional) – extra meta data/parameters to be carried along with object and child objects. if ‘checker’ in meta, then perform a callback of the form meta[‘checker](self, meta) this can also be used to override things like deriv_args. Values passed through method resample_meta

  • x_is_u (bool, default False) – if True, treat xv = uv and do adjust u/du accordingly

Returns:

output (DataCentralMomentsVals)

resample(sampler, dim=MISSING, axis=MISSING, rep_dim='rep', parallel=None, meta_kws=None, resample_values=None, **kwargs)[source]#

Resample data.

Parameters:
  • sampler (int or array-like or mapping) – Passed through cmomy.resample.factory_sampler() to create an IndexSampler. Value can either be nrep (the number of replicates), freq (frequency array), a IndexSampler object, or a mapping of parameters. The mapping can have form of FactoryIndexSamplerKwargs. Allowable keys are freq, indices, ndat, nrep, nsamp, paired, rng, replace, shuffle.

  • dim (hashable) – Dimension to reduce/sample along.

  • axis (int) – Axis to reduce/sample along.

  • rep_dim (hashable) – Name of new ‘replicated’ dimension:

  • parallel (bool, optional) – If True, use parallel numba numba.njit or numba.guvectorized code if possible. If None, use a heuristic to determine if should attempt to use parallel method.

  • meta_kws (mapping, optional) – Optional parameters for meta.

  • resample_values (bool) – If True, resample xv and uv. If False, resample dxduave (see cmomy.wrap_resample_vals()) and leave xv and uv unchanged.

  • **kwargs – Keyword arguments to cmomy.wrap_resample_vals()

Notes

resample_values defaults to self.resample_values.

asdict()[source]#

Convert object to dictionary.

assign(**kws)[source]#

Alias to new_like().

central#

Whether central or raw moments are used

cmom()[source]#

Central co-moments.

property deriv_args#

Arguments to be passed to derivative function.

For example, derivs(*self.deriv_args).

deriv_dim#

Derivative dimension

du[source]#

Averages of du ** n.

du_selector[source]#

Selector for du_selector[n] = du ** n.

dxdu[source]#

Averages of form dx * dx ** n.

dxdu_selector[source]#

Selector for dxdu_selector[n] = dx * du ** n.

meta#

Callback

new_like(**kws)[source]#

Create a new object with optional parameters.

Parameters:

**kwsattribute, value pairs.

rec_dim#

Records dimension

rmom()[source]#

Raw co-moments.

u[source]#

Averages of form u ** n.

u_selector[source]#

Indexer for u_selector[n] = u ** n.

umom_dim#

Energy moments dimension

property values#

Data underlying dxduave.

x_is_u#

Whether observable x is same as energy u

property xalpha#

Whether X has explicit dependence on alpha.

That is, if self.deriv_dim is not None

xave[source]#

Averages of form observable x.

xave_selector[source]#

Selector for xave.

xmom_dim#

Overvable moment dimension

xu[source]#

Averages of form x * u ** n.

xu_selector[source]#

Indexer for xu_select[n] = x * u ** n.

thermoextrap.data.factory_data_values(uv, xv, *, order, central=False, xalpha=False, rec_dim='rec', umom_dim='umom', xmom_dim='xmom', val_dims='val', rep_dim='rep', deriv_dim=None, x_is_u=False, resample_values=True, **kws)[source]#

Factory function to produce a DataCentralMomentsVals object.

Parameters:
  • order (int) – Highest moment <x * u ** order>. For the case x_is_u, highest order is <u ** (order+1)>

  • uv (array-like) – raw values of u (energy) if not DataArray, wrap with xrwrap_uv

  • xv (xarray.DataArray) – raw values of x (observable) if not DataArray, wrap with xrwrap_xv

  • central (bool) – If True, Use central moments. Otherwise, use raw moments.

  • xalpha (bool, default False) – Flag whether u depends on variable alpha.

  • rec_dim (hashable) – Name of dimension for ‘records’, i.e., multiple observations.

  • umom_dim (str, default 'umom') – Name of dimension for moment of energy u.

  • val_dims (str or sequence of str) – Names of extra dimensions

  • rep_dim (hashable) – Name of new ‘replicated’ dimension:

  • deriv_dim (str, default None) – if deriv_dim is a string, then this is the name of the derivative dimension and xarray objects will have a derivative

  • x_is_u (bool, default False) – if True, treat xv = uv and do adjust u/du accordingly

  • resample_values (bool) – If True, resample xv and uv. If False, resample dxduave (see cmomy.wrap_resample_vals()) and leave xv and uv unchanged.

  • **kws – Extra arguments passed to constructor

Returns:

output (DataCentralMomentsVals)