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 derivatives.
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, umom_dim='umom', deriv_dim=None, x_is_u=False)[source]#
Bases:
MyAttrsMixin
Abstract class for data.
Attributes:
Callback
Energy moments dimension
Derivative dimension
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.
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
- umom_dim#
Energy moments dimension
- deriv_dim#
Derivative dimension
- x_is_u#
Whether the observable x is the same as energy u
- 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', deriv_dim=None, xmom_dim='xmom', rec_dim='rec', central=False, x_is_u=None, use_cache=True)[source]#
Bases:
AbstractData
Data object based on central co-moments array.
- Parameters:
dxduave (
CentralMomentsData
) – Central moments object.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.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 accordinglyuse_cache (
bool
) – IfTrue
(default), cache intermediate result. Speeds up calculations, but can lead to large objects.
Attributes:
cmomy.CentralMomentsData
objectOvervable moment dimension
Records 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.
Derivative dimension
Callback
Energy moments dimension
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.CentralMomentsData
object
- xmom_dim#
Overvable moment dimension
- rec_dim#
Records 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()
.
- deriv_dim#
Derivative dimension
- meta#
Callback
- new_like(**kws)[source]#
Create a new object with optional parameters.
- Parameters:
**kws – attribute, value pairs.
- umom_dim#
Energy moments dimension
- 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, umom_dim='umom', deriv_dim=None, x_is_u=False, rec_dim='rec')[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) – Name of dimension for ‘records’, i.e., multiple observations.
umom_dim (
str
, default'umom'
) – Name of dimension for moment of energy u.x_is_u (
bool
, defaultFalse
) – if True, treat xv = uv and do adjust u/du accordinglyderiv_dim (
str
, defaultNone
) – if deriv_dim is a string, then this is the name of the derivative dimension and xarray objects will have a derivativemeta (
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_meta
Attributes:
Energy values
Obervable values
Expansion order
Records dimension
Whether central (True) or raw (False) moments are used.
Derivative dimension
Sequence of arguments to derivative calculation function.
Callback
Energy moments dimension
Whether the observable x is the same as energy u
Whether X has explicit dependence on alpha.
Methods:
from_vals
(uv, xv, *, order[, rec_dim, ...])Constructor from arrays.
resample
(sampler, *[, rep_dim, meta_kws])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
- classmethod from_vals(uv, xv, *, order, rec_dim='rec', umom_dim='umom', deriv_dim=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) – 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 derivativemeta (
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(sampler, *, rep_dim='rep', meta_kws=None)[source]#
Resample object.
- Parameters:
sampler (
int
or array-like orIndexSampler
or mapping) – Passed throughresample.factory_sampler()
to create anIndexSampler
. Value can either benrep
(the number of replicates),freq
(frequency array), aIndexSampler
object, or a mapping of parameters. The mapping can have form ofFactoryIndexSamplerKwargs
. Allowable keys arefreq
,indices
,ndat
,nrep
,nsamp
,paired
,rng
,replace
,shuffle
.rep_dim (hashable) – Name of new ‘replicated’ dimension:
meta_kws (mapping, optional) – Optional parameters for meta.
- assign(**kws)[source]#
Alias to
new_like()
.
- deriv_dim#
Derivative dimension
- 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.
- umom_dim#
Energy moments dimension
- x_is_u#
Whether the observable x is the same as energy u
- property xalpha#
Whether X has explicit dependence on alpha.
That is, if self.deriv_dim is not None