ModelProps

Contents

ModelProps#

class ModelProps(name, desc, unit, scalar, _mesh, order='F', scales=('r', 't', 'p'))[source]#

Bases: ScaleProps

Immutable property bundle for a single PSI model quantity.

Extends ScaleProps with scalar/vector classification, staggered-grid mesh code, array ordering, and scale axis labels. Used for MAS and POT3D output fields. Instances are frozen (immutable) dataclass instances.

Parameters:
namestr

Canonical lower-case quantity identifier (e.g. 'br', 'vr'). Matches the filename prefix used in MAS and POT3D HDF output.

descstr

Human-readable description of the physical quantity.

unitUnit

Astropy unit whose scale factor converts one code unit of this quantity to physical unit. For example, MAS_b ≈ 2.2 Gauss.

scalarbool

True if the quantity is a scalar field (temperature, density, …); False if it is a component of a vector field (velocity, magnetic field, …).

_meshint

Integer mesh code encoding the stagger position on the three-dimensional grid. Each binary bit indicates whether the quantity is on the half mesh (1) or main mesh (0) along one coordinate axis.

orderstr, optional

Array memory layout: 'F' for Fortran (column-major, PSI default) or 'C' for C (row-major). Default is 'F'.

scalestuple[str, …], optional

Ordered names of the coordinate scale axes associated with this quantity. Default is ('r', 't', 'p').

Attributes:
meshMesh

Normalized mesh-stagger object for this quantity.

See also

ScaleProps

Base class for coordinate scale arrays without mesh or ordering.

get_mas_quantity_properties

Retrieve a ModelProps for a MAS quantity.

get_pot3d_quantity_properties

Retrieve a ModelProps for a POT3D quantity.

Notes

The arithmetic dunder methods (__mul__, __rmul__, __rtruediv__) delegate to unit, so value * props is equivalent to value * props.unit and returns an Quantity.

Examples

>>> from psi_io.models import ModelProps
>>> import astropy.units as u
>>> p = ModelProps('br', 'Radial B field', u.Gauss, False, 0b100)
>>> str(p)
'br'
>>> p.scalar
False
>>> p.mesh
Mesh(HALF, MAIN, MAIN)
>>> (2.5 * p).unit
Unit("G")

Properties

mesh

Normalized mesh-stagger object for this quantity.