Base classes#
- class thermoextrap.core._attrs_utils.MyAttrsMixin[source]#
Bases:
object
Baseclass for adding some sugar to attrs.derived classes.
Methods:
asdict
()Convert object to dictionary.
new_like
(**kws)Create a new object with optional parameters.
assign
(**kws)Alias to
new_like()
.set_params
(**kws)Set parameters of self, and return self (for chaining).
- new_like(**kws)[source]#
Create a new object with optional parameters.
- Parameters:
**kws – attribute, value pairs.
- assign(**kws)[source]#
Alias to
new_like()
.
- class thermoextrap.models.PiecewiseMixin[source]#
Bases:
object
Provide methods for Piecewise state collection.
- class thermoextrap.models.SymDerivBase(func, args=None, expand=True, post_func=None)[source]#
Bases:
object
Base class for working with recursive derivatives in expansions.
- Parameters:
func (
Function
) – Function to differentiate. This should (most likely) be an instance ofthermoextrap.models.SymFuncBase
post_func (
str
orcallable()
) – Transformation of base function. For example, post_fuc = -sympy.log is equivalent to passing minus_log=True If a string, then apply the following standard functionsminus_log : post_func = -sympy.log
pow_i : post_func = lambda f: pow(f, i). E.g., pow_2 => pow(f, 2)
- class thermoextrap.models.SymFuncBase(beta)[source]#
Bases:
Function
Base class to define a sympy function for user defined deriatives.
See also
Methods:
Symbol arguments of function.
fdiff
([argindex])Derivative of function.
eval
(beta)Evaluate function.
- classmethod deriv_args()[source]#
Symbol arguments of function.
This is used by Data class to create a ‘lambdfied’ callable function.
See also
- fdiff(argindex=1)[source]#
Derivative of function. This will be used by
thermoextrap.models.SymDerivBase
.
- class thermoextrap.data.AbstractData(*, meta)[source]#
Bases:
MyAttrsMixin
Abstract class for data.
Attributes:
Callback
Whether central (True) or raw (False) moments are used.
Sequence of arguments to derivative calculation function.
Whether X has explicit dependence on alpha.
Methods:
asdict
()Convert object to dictionary.
assign
(**kws)Alias to
new_like()
.new_like
(**kws)Create a new object with optional parameters.
set_params
(**kws)Set parameters of self, and return self (for chaining).
- meta#
Callback
- abstract property central#
Whether central (True) or raw (False) moments are used.
- abstract property derivs_args#
Sequence of arguments to derivative calculation function.
- property xalpha#
Whether X has explicit dependence on alpha.
That is, if self.deriv_dim is not None
- assign(**kws)[source]#
Alias to
new_like()
.
- class thermoextrap.data.DataCentralMomentsBase(dxduave, *, meta, umom_dim='umom', xmom_dim='xmom', rec_dim='rec', deriv_dim=None, central=False, x_is_u=None)[source]#
Bases:
AbstractData
Data object based on central co-moments array.
- Parameters:
dxduave (
xCentralMoments
) – Central moments object.rec_dim (hashable, optional) – Name of dimension for ‘records’, i.e., multiple observations.
umom_dim (
str
, default'umom'
) – Name of dimension for moment of energy u.xmom_dim (
str
, default'xmom'
) – Name of dimension for moments of observable x.deriv_dim (
str
, defaultNone
) – if deriv_dim is a string, then this is the name of the derivative dimension and xarray objects will have a derivativecentral (
bool
) – If True, Use central moments. Otherwise, use raw moments.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 derivs_args. Values passed through method resample_metax_is_u (
bool
, defaultFalse
) – if True, treat xv = uv and do adjust u/du accordingly
Attributes:
cmomy.xCentralMoments
objectEnergy moment dimension
Overvable moment dimension
Records dimension
Derivative with respect to alpha dimension
Whether central or raw moments are used
Whether observable x is same as energy u
Order of expansion.
Data underlying
dxduave
.Averages of form
x * u ** n
.Averages of form
u ** n
.Averages of form observable
x
.Averages of form
dx * dx ** n
.Averages of
du ** n
.Indexer for
u_selector[n] = u ** n
.Indexer for
xu_select[n] = x * u ** n
.Selector for
xave
.Selector for
du_selector[n] = du ** n
.Selector for
dxdu_selector[n] = dx * du ** n
.Arguments to be passed to derivative function.
Callback
Whether X has explicit dependence on alpha.
Methods:
rmom
()Raw co-moments.
cmom
()Central co-moments.
asdict
()Convert object to dictionary.
assign
(**kws)Alias to
new_like()
.new_like
(**kws)Create a new object with optional parameters.
set_params
(**kws)Set parameters of self, and return self (for chaining).
- dxduave#
cmomy.xCentralMoments
object
- umom_dim#
Energy moment dimension
- xmom_dim#
Overvable moment dimension
- rec_dim#
Records dimension
- deriv_dim#
Derivative with respect to alpha dimension
- central#
Whether central or raw moments are used
- x_is_u#
Whether observable x is same as energy u
- property order#
Order of expansion.
- property derivs_args#
Arguments to be passed to derivative function.
For example,
derivs(*self.derivs_args)
.
- assign(**kws)[source]#
Alias to
new_like()
.
- meta#
Callback
- new_like(**kws)[source]#
Create a new object with optional parameters.
- Parameters:
**kws – attribute, value pairs.
- property xalpha#
Whether X has explicit dependence on alpha.
That is, if self.deriv_dim is not None
- class thermoextrap.data.DataValuesBase(uv, xv, order, *, meta, rec_dim='rec', umom_dim='umom', deriv_dim=None, skipna=False, chunk=None, compute=None, build_aves_kws=None, x_is_u=False)[source]#
Bases:
AbstractData
Base class to work with data based on values (non-cmomy).
- Parameters:
uv (
xarray.DataArray
) – raw values of u (energy)xv (
xarray.DataArray
) – raw values of x (observable)order (
int
) – maximum order of moments/expansion to calculaterec_dim (hashable, optional) – Name of dimension for ‘records’, i.e., multiple observations.
umom_dim (
str
, default'umom'
) – Name of dimension for moment of energy u.deriv_dim (
str
, defaultNone
) – if deriv_dim is a string, then this is the name of the derivative dimension and xarray objects will have a derivativechunk (
bool
, optional) – chunking of xarray objectscompute (
bool
, optional) – whether to perform compute step on xarray outputsmeta (
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 derivs_args. Values passed through method resample_metax_is_u (
bool
, defaultFalse
) – if True, treat xv = uv and do adjust u/du accordingly
Attributes:
Energy values
Obervable values
Expansion order
Records dimension
Energy moments dimension
Derivative dimension
Whether to skip NAN values
Whether to chunk the xarray objects
Whether to compute the chunked data
Arguments to building the averages
Whether the observable x is the same as energy u
Whether central (True) or raw (False) moments are used.
Sequence of arguments to derivative calculation function.
Callback
Whether X has explicit dependence on alpha.
Methods:
from_vals
(xv, uv, order[, rec_dim, ...])Constructor from arrays.
resample
([indices, nrep, rep_dim, chunk, ...])Resample object.
asdict
()Convert object to dictionary.
assign
(**kws)Alias to
new_like()
.new_like
(**kws)Create a new object with optional parameters.
set_params
(**kws)Set parameters of self, and return self (for chaining).
- uv#
Energy values
- xv#
Obervable values
- order#
Expansion order
- rec_dim#
Records dimension
- umom_dim#
Energy moments dimension
- deriv_dim#
Derivative dimension
- skipna#
Whether to skip NAN values
- chunk#
Whether to chunk the xarray objects
- compute#
Whether to compute the chunked data
- build_aves_kws#
Arguments to building the averages
- x_is_u#
Whether the observable x is the same as energy u
- classmethod from_vals(xv, uv, order, rec_dim='rec', umom_dim='umom', rep_dim='rep', deriv_dim=None, val_dims='val', skipna=False, chunk=None, compute=None, build_aves_kws=None, meta=None, x_is_u=False)[source]#
Constructor from arrays.
- Parameters:
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_xvorder (
int
) – maximum order of moments/expansion to calculaterec_dim (hashable, optional) – 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 ofstr
) – Names of extra dimensionsderiv_dim (
str
, defaultNone
) – if deriv_dim is a string, then this is the name of the derivative dimension and xarray objects will have a derivativechunk (
bool
, optional) – chunking of xarray objectsmeta (
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 derivs_args. Values passed through method resample_metax_is_u (
bool
, defaultFalse
) – if True, treat xv = uv and do adjust u/du accordingly
- property central#
Whether central (True) or raw (False) moments are used.
- resample(indices=None, nrep=None, rep_dim='rep', chunk=None, compute='None', meta_kws=None, rng=None)[source]#
Resample object.
- Parameters:
indices (array of
int
, optional) – Array of shape(nrep, size)
. If passed, create freq from indices. Seerandsamp_freq()
.nrep (
int
, optional) – Number of replicates. Create freq with this many replicates. Seerandsamp_freq()
rep_dim (hashable, optional) – Name of new ‘replicated’ dimension:
chunk (
bool
, optional) – chunking of xarray objectscompute (
bool
, optional) – whether to perform compute step on xarray outputsmeta_kws (mapping, optional) – Optional parameters for meta.
rng (
Generator
, optional) – Random number generator object. Defaults to result ofcmomy.random.default_rng()
.
- assign(**kws)[source]#
Alias to
new_like()
.
- abstract property derivs_args#
Sequence of arguments to derivative calculation function.
- meta#
Callback
- new_like(**kws)[source]#
Create a new object with optional parameters.
- Parameters:
**kws – attribute, value pairs.
- property xalpha#
Whether X has explicit dependence on alpha.
That is, if self.deriv_dim is not None