vslice

vslice#

_HdfData.vslice(
*args,
unit=None,
mesh=None,
order=None,
scales=True,
bounds_error=True,
)[source]#

Read data by physical coordinate value with linear interpolation.

Extends read() to accept physical coordinate values as positional arguments. A scalar, int, or Quantity argument for an axis locates the two nearest grid points and linearly interpolates to the target value. Only None and slice arguments are index-space and handled identically to read().

Attention

When reading/slicing data, the *args are always supplied in physical (e.g. \((r, \theta, \phi)\)) order. However, unless specified with the order argument, the sliced data array will be returned in storage order.

Note

Unlike read(), an int argument is treated as a physical coordinate value (in the axis’s native unit), not an array index. Use a slice to select by index.

Parameters:
*argsQuantityLike | slice | None

One argument per axis in physical (r, t, p) order. A Quantity, bare scalar, or int triggers interpolation to that coordinate value; None and slice are index-space and do not interpolate.

unitUnitLike | None, optional

Output unit. Default is None (code units).

meshMeshCodeType | None, optional

Target stagger mesh. Default is None.

orderArrayOrdering | None, optional

Transpose output if it differs from storage order. Default is None.

scalesbool, optional

If True (default), return coordinate slices alongside the data.

bounds_errorbool, optional

If True (default), raise ValueError when a physical value is outside the coordinate range.

Returns:
dataQuantity

Interpolated or sliced data array.

*scalesQuantity

Sliced scales (only returned when scales is True).

Raises:
ValueError

If bounds_error is True and a physical value falls outside the coordinate range.

Examples

>>> # Extract the r = 2.5 solar radii surface
>>> data, r, t, p = reader.vslice(2.5 * u.R_sun)