Props

Contents

Props#

class Props(name, desc, unit, ndim, scalar, _mesh=None)[source]#

Bases: object

Immutable property bundle for a single PSI model quantity.

Associates a quantity name with its human-readable description, physical unit, dimensionality, scalar/vector classification, and staggered-grid mesh code. 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.

unitu.Unit

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

ndimint

Number of spatial dimensions of the output array (3 for MAS/POT3D fields, 1 for coordinate scale arrays).

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, optional

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. None for coordinate scale arrays that carry no stagger information (e.g. the radial scale 'r').

Attributes:
meshtuple[Mesh, …] or None

Normalized mesh-stagger tuple for this quantity.

Notes

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

Examples

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

Properties

mesh

Normalized mesh-stagger tuple for this quantity.