Local free energy of lnPi (lnpienergy)#
Functions:
|
Find boundary region for masks |
|
Find regions where boundaries overlap |
|
Find position and value of extrema of masked data. |
|
Merge labels where free energy energy barrier < efac. |
Classes:
|
Analysis of local free energy \(w = \beta f = - \ln \Pi\). |
|
Calculate the transition free energies for a |
|
Stripped down version of |
- lnpy.lnpienergy.find_boundaries(masks, mode='thick', connectivity=None, **kws)[source]#
Find boundary region for masks
See also
- lnpy.lnpienergy.find_boundaries_overlap(masks, *, boundaries=None, flag_none=True, mode='thick', connectivity=None, method='exact')[source]#
Find regions where boundaries overlap
- Parameters:
masks (sequence of
Noneorndarrayofbool) – Masks using “image” convention. Where masks[i] is True, values are included for sample i.boundaries (
listofndarrayofbool, optional) – If supplied, use these areas as boundaries. Otherwise, calculate boundaries using find_boundariesflag_none (
bool, defaultTrue) – if True, replace overlap with None if no overlap between regionsconnectivity (
int, optional) – Defaults tomasks[0].ndimmethod (
str,{'approx', 'exact'}) –approx : consider regions where boundaries overlap and in one of the two region
exact : consider regions where boundaries overlap
- Returns:
overlap (
dictofndarrayofbool) – overlap[i, j] = region of overlap between boundaries and masks in regions i and j
See also
- lnpy.lnpienergy.find_masked_extrema(data, masks, convention='image', extrema='max', fill_val=nan, fill_arg=None, unravel=True)[source]#
Find position and value of extrema of masked data.
- Parameters:
data (
ndarray) – input data to considermasks (sequence of
Noneorndarrayofbool) – Masking arrays.convention (
stringorbool) – Convention for mask. Allowable values are:- ‘image’ or TrueTrue values included, False values excluded.
This is the normal convention in
scipy.ndimage.
- ‘masked’ or False: False values are included, True values are excluded.
This is the convention in
numpy.ma
extrema (
{'max','min}) – Type of extrema to calculatefill_val (scalar, default
nan) – Value to fill for out_arg for empty maskfill_arg (scalar, optional) – Value to fill for out_val for empty mask
unravel (
bool, defaultTrue) – If True, unravel flat index to multi dimensional index.
- Returns:
- lnpy.lnpienergy.merge_regions(w_tran, w_min, masks, nfeature_max=None, efac=1.0, force=True, convention='image', warn=True)[source]#
Merge labels where free energy energy barrier < efac.
The scaled free energy \(w = \beta f = - \ln \Pi ` is analyzed. Anywhere where :math:\)Delta w = text{w_tran} - text{w_min} < text{efac}` will be merged into a single phase. Here,
w_transis the transition energy between phases (i.e., the minimum value of lnPi` between regions`) andw_minis the minimum energy (the maximum lnPi) for a phase.- Parameters:
w_tran (
ndarray) – Shape of array is(n, n), wherenis the number of unique regions/phases.This is the transitional free energy ()
w_min (
ndarray) – Shape of array is(n, 1).masks (sequence of
Noneorndarrayofbool) – Masking arrays.nfeature_max (
int) – maximum number of features/phases to allowefac (
float, default0.5) – Energy difference to merge on. Whenw_trans[i, j] - w_min[i] < efac, phasesiandjwill be merged together.force (
bool, defaultTrue) – if True, then keep going until nfeature <= nfeature_max even if min_val > efac.convention (
stringorbool) – Convention for mask. Allowable values are:- ‘image’ or TrueTrue values included, False values excluded.
This is the normal convention in
scipy.ndimage.
- ‘masked’ or False: False values are included, True values are excluded.
This is the convention in
numpy.ma
- Returns:
- class lnpy.lnpienergy.wFreeEnergy(data, masks, convention='image', connectivity=None, index=None)[source]#
Bases:
objectAnalysis of local free energy \(w = \beta f = - \ln \Pi\).
- Parameters:
data (
ndarray) – lnPi datamasks (sequence of
Noneorndarrayofbool) – Masking arrays.convention (
stringorbool) – Convention for mask. Allowable values are:- ‘image’ or TrueTrue values included, False values excluded.
This is the normal convention in
scipy.ndimage.
- ‘masked’ or False: False values are included, True values are excluded.
This is the convention in
numpy.ma
connectivity (
int, optional) – Defaults tomasks[0].ndimindex (sequence of
int, optional) – Optional index to apply to phases. Not yet fully supported.
Notes
this class uses the ‘image’ convention for masks. That is where mask == True indicates locations in the phase/region, and mask == False indicates locations not in the phase/region. This is opposite the convention used in
numpy.ma.Attributes:
Number of features/regions/phases
Minimum value of w (max lnPi) in each phase/region.
Locations of the minimum of w in each phase/region
Minimum value of w (max lnPi) in the boundary between phases.
Location of w_tran
Transition energy
delta_w[i, j] = w_tran[i, j] - w_min[i].Methods:
from_labels(data, labels[, connectivity, ...])Create wFreeEnergy from labels
merge_regions([nfeature_max, efac, force, ...])Merge labels where free energy energy barrier < efac.
- property nfeature#
Number of features/regions/phases
- classmethod from_labels(data, labels, connectivity=None, features=None, include_boundary=False, **kwargs)[source]#
Create wFreeEnergy from labels
- Parameters:
data (
ndarray) – lnPi datalabels (
ndarrayofint) – Each unique value i in labels indicates a mask. That islabels == iis a mask for feature i.connectivity (
int, optional) – Defaults tomasks[0].ndimfeatures (sequence of
int) – If specified, extract only those locations wherelabels == featurefor all valuesfeature in features. That is, select a subset of unique label values.include_boundary (
bool) – if True, include boundary regions in output mask**kwargs – Extra arguments to
labels_to_masks()
- Returns:
out (
wFreeEnergy)
See also
- property w_min#
Minimum value of w (max lnPi) in each phase/region.
- property w_argmin#
Locations of the minimum of w in each phase/region
- property w_tran#
Minimum value of w (max lnPi) in the boundary between phases.
w_tran[i, j] is the transition energy between phases i and j.
- property w_argtran#
Location of w_tran
- merge_regions(nfeature_max=None, efac=1.0, force=True, convention='image', warn=True)[source]#
Merge labels where free energy energy barrier < efac.
Interface to
merge_regions()- Parameters:
nfeature_max (
int) – maximum number of features/phases to allowefac (
float, default0.5) – Energy difference to merge on. Whenw_trans[i, j] - w_min[i] < efac, phasesiandjwill be merged together.force (
bool, defaultTrue) – if True, then keep going until nfeature <= nfeature_max even if min_val > efac.{mask_convention}
- Returns:
- class lnpy.lnpienergy.wFreeEnergyCollection(parent)[source]#
Bases:
objectCalculate the transition free energies for a
lnpy.lnpiseries.lnPiCollection.\(w(N) = \beta f(N) = - \ln \Pi(N)\)
- Parameters:
parent (
lnPiCollection)
Notes
An instance of
wFreeEnergyCollectionis normally created from the accessorlnpy.lnpiseries.lnPiCollection.wfe()Attributes:
Minimum energy (maximum lnPi) for a given region/phase
Minimum energy (maximum lnPi) at boundary between phases
Location of
w_minLocation of
w_tranSeries representation of dw = w_tran - w_min
Methods:
get_dwx(idx[, idx_nebr])Helper function to get the change in energy from phase idx to idx_nebr.
get_dw(idx[, idx_nebr])Series version of
get_dwx()- property w_min#
Minimum energy (maximum lnPi) for a given region/phase
- property w_tran#
Minimum energy (maximum lnPi) at boundary between phases
- property dw#
Series representation of dw = w_tran - w_min
- get_dwx(idx, idx_nebr=None)[source]#
Helper function to get the change in energy from phase idx to idx_nebr.
- Parameters:
- Returns:
dw (
DataArray) – Transition energy from idx to idx_nebr - if only phase idx exists, dw = np.inf - if idx does not exists, dw = 0.0 (no barrier between idx and anything else) - else min of transition for idx to idx_nebr
- class lnpy.lnpienergy.wFreeEnergyPhases(parent)[source]#
Bases:
wFreeEnergyCollectionStripped down version of
wFreeEnergyCollectionfor single phase grouping.This should be used for a collection of lnPi that is at a single state point, with multiple phases.
- Parameters:
parent (
lnPiCollection)
Notes
This is accessed through
lnpy.lnpiseries.lnPiCollection.wfe_phasesAttributes:
Location of
w_minLocation of
w_tranMinimum energy (maximum lnPi) for a given region/phase
Minimum energy (maximum lnPi) at boundary between phases
Series representation of delta_w
Methods:
get_dwx(idx[, idx_nebr])Helper function to get the change in energy from phase idx to idx_nebr.
get_dw(idx[, idx_nebr])Series version of
get_dwx()- get_dwx(idx, idx_nebr=None)[source]#
Helper function to get the change in energy from phase idx to idx_nebr.
- Parameters:
- Returns:
dw (
DataArray) – Transition energy from idx to idx_nebr - if only phase idx exists, dw = np.inf - if idx does not exists, dw = 0.0 (no barrier between idx and anything else) - else min of transition for idx to idx_nebr
- property w_min#
Minimum energy (maximum lnPi) for a given region/phase
- property w_tran#
Minimum energy (maximum lnPi) at boundary between phases
- property dw#
Series representation of delta_w