Legacy lnPi array routines (maskedlnpi_legacy)#

Classes:

MaskedlnPiLegacy([data, lnz, state_kws, ...])

Class to store masked version of \(\ln\Pi(N)\).

class lnPi.maskedlnpi_legacy.MaskedlnPiLegacy(data=None, lnz=None, state_kws=None, extra_kws=None, **kwargs)[source]#

Bases: MaskedArray, AccessorMixin

Class to store masked version of \(\ln\Pi(N)\). shape is (N0,N1,…) where Ni is the span of each dimension)

Constructor

Parameters:
  • data (array-like) – data for lnPi

  • lnz (array-like, optional) – if None, set lnz=np.zeros(data.ndim)

  • state_kws (dict, optional) – dictionary of state values, such as volume and beta. These parameters will be pushed to self.xge coordinates.

  • extra_kws (dict, optional) – this defines extra parameters to pass along. Note that for potential energy calculations, extra_kws should contain PE (total potential energy for each N vector).

  • zeromax (bool, default False) – if True, shift lnPi = lnPi - lnPi.max()

  • pad (bool, default False) – if True, pad masked region by interpolation

  • **kwargs – Extra arguments to numpy.ma.MaskedArray e.g., mask=…

Attributes:

optinfo

All extra properties

state_kws

State specific parameters

extra_kws

All extra parameters

edge_distance_matrix

Matrix of distance from upper bound

Methods:

pad([axes, ffill, bfill, limit, inplace])

Pad nan values in underlying data to values

zeromax([inplace])

Shift so that lnpi.max() == 0

adjust([zeromax, pad, inplace])

Do multiple adjustments in one go

reweight(lnz[, zeromax, pad])

Get lnpi at new lnz

smooth([sigma, mode, truncate, inplace])

Apply gaussian filter smoothing to data

copy_shallow([mask])

Create shallow copy

or_mask(mask, **kwargs)

New object with logical or of self.mask and mask

and_mask(mask, **kwargs)

New object with logical and of self.mask and mask

from_table(path, lnz[, state_kws, sep, ...])

Create lnPi object from text file table with columns [n_0,...,n_ndim, lnpi]

from_dataarray(da[, state_as_attrs])

Create a lnPi object from xarray.DataArray

list_from_masks(masks[, convention])

Create list of lnpis corresponding to masks[i]

list_from_labels(labels[, features, ...])

Create list of lnpis corresponding to labels

property optinfo#

All extra properties

property state_kws#

State specific parameters

property extra_kws#

All extra parameters

edge_distance_matrix[source]#

Matrix of distance from upper bound

pad(axes=None, ffill=True, bfill=False, limit=None, inplace=False)[source]#

Pad nan values in underlying data to values

Parameters:
  • ffill (bool, default True) – do forward filling

  • bfill (bool, default False) – do back filling

  • limit (int, default None) – The maximum number of consecutive NaN values to forward fill. In other words, if there is a gap with more than this number of consecutive NaNs, it will only be partially filled. Must be greater than 0 or None for no limit.

  • inplace (bool, default False)

Returns:

out (object) – padded object

zeromax(inplace=False)[source]#

Shift so that lnpi.max() == 0

adjust(zeromax=False, pad=False, inplace=False)[source]#

Do multiple adjustments in one go

reweight(lnz, zeromax=False, pad=False)[source]#

Get lnpi at new lnz

Parameters:
Returns:

object

smooth(sigma=4, mode='nearest', truncate=4, inplace=False, **kwargs)[source]#

Apply gaussian filter smoothing to data

Parameters:
  • inplace (bool, default False) – if True, do inplace modification.

  • mode (str, default 'nearest') – Arguments to gaussian_filter

  • truncate (int, default 4) – Argument to gaussian_filter

  • **kwargs – Extra arguments to gaussian_filter.

See also

gaussian_filter

copy_shallow(mask=None, **kwargs)[source]#

Create shallow copy

Parameters:

mask (optional) – if specified, new object has this mask otherwise, at least copy old mask

or_mask(mask, **kwargs)[source]#

New object with logical or of self.mask and mask

and_mask(mask, **kwargs)[source]#

New object with logical and of self.mask and mask

classmethod from_table(path, lnz, state_kws=None, sep='\\s+', names=None, csv_kws=None, **kwargs)[source]#

Create lnPi object from text file table with columns [n_0,…,n_ndim, lnpi]

Parameters:
  • path (path-like) – file object to be read

  • lnz (array-like) – beta*(chemical potential) for each component

  • state_kws (dict, optional) – define state variables, like volume, beta

  • sep (string, optional) – separator for file read

  • names (sequence of str)

  • csv_kws (dict, optional) – optional arguments to pandas.read_csv

  • **kwargs – Passed to lnPi constructor

classmethod from_dataarray(da, state_as_attrs=None, **kwargs)[source]#

Create a lnPi object from xarray.DataArray

list_from_masks(masks, convention='image')[source]#

Create list of lnpis corresponding to masks[i]

Parameters:
  • masks (list) – masks[i] is the mask for lnpi index i.

  • convention (str or bool) – convention of input masks

Returns:

lnpis (list) – list of lnpis corresponding to each mask

list_from_labels(labels, features=None, include_boundary=False, check_features=True, **kwargs)[source]#

Create list of lnpis corresponding to labels