Skip to content

field

Plot scalar and vector fields.

valid_field_var

valid_field_var(var: str) -> bool

Whether a field variable is defined.

Parameters:

Name Type Description Default
var str

the variable name to be checked.

required

Returns:

Type Description
bool

whether the var is defined in either FIELD or FIELD_EXTRA.

get_meshes_fld

get_meshes_fld(
    conf: Config, step: Step, var: str, walls: bool = False
) -> tuple[
    NDArray[np.float64],
    NDArray[np.float64],
    NDArray[np.float64],
    Varf,
]

Return scalar field along with coordinates meshes.

Only works properly in 2D geometry and 3D cartesian.

Parameters:

Name Type Description Default
conf Config

configuration.

required
step Step

a Step of a StagyyData instance.

required
var str

scalar field name.

required
walls bool

consider the walls as the relevant mesh.

False

Returns:

Name Type Description
xmesh NDArray[float64]

x position

ymesh NDArray[float64]

y position

fld NDArray[float64]

field values

meta Varf

metadata

get_meshes_vec

get_meshes_vec(
    conf: Config, step: Step, var: str
) -> tuple[
    NDArray[np.float64],
    NDArray[np.float64],
    NDArray[np.float64],
    NDArray[np.float64],
]

Return vector field components along with coordinates meshes.

Only works properly in 2D geometry and 3D cartesian.

Parameters:

Name Type Description Default
conf Config

configuration.

required
step Step

a Step of a StagyyData instance.

required
var str

vector field name.

required

Returns:

Name Type Description
xmesh NDArray[float64]

x position

ymesh NDArray[float64]

y position

fldx NDArray[float64]

x component

fldy NDArray[float64]

y component

plot_scalar

plot_scalar(
    step: Step,
    var: str,
    field: NDArray[float64] | None = None,
    axis: Axes | None = None,
    conf: Config | None = None,
    **extra: Any
) -> tuple[Figure, Axes, QuadMesh, Colorbar | None]

Plot scalar field.

Parameters:

Name Type Description Default
step Step

a Step of a StagyyData instance.

required
var str

the scalar field name.

required
field NDArray[float64] | None

if not None, it is plotted instead of step.fields[var]. This is useful to plot a masked or rescaled array.

None
axis Axes | None

the matplotlib.axes.Axes object where the field should be plotted. If set to None, a new figure with one subplot is created.

None
conf Config | None

configuration.

None
extra Any

options that will be passed on to matplotlib.axes.Axes.pcolormesh.

{}

Returns:

Name Type Description
fig Figure

matplotlib figure

axes Axes

matplotlib axes

surf QuadMesh

surface returned by pcolormesh

cbar Colorbar | None

colorbar

plot_iso

plot_iso(
    axis: Axes,
    step: Step,
    var: str,
    field: NDArray[float64] | None = None,
    conf: Config | None = None,
    **extra: Any
) -> None

Plot isocontours of scalar field.

Parameters:

Name Type Description Default
axis Axes

the matplotlib.axes.Axes of an existing matplotlib figure where the isocontours should be plotted.

required
step Step

a Step of a StagyyData instance.

required
var str

the scalar field name.

required
field NDArray[float64] | None

if not None, it is plotted instead of step.fields[var]. This is useful to plot a masked or rescaled array.

None
conf Config | None

configuration.

None
extra Any

options that will be passed on to Axes.contour.

{}

plot_vec

plot_vec(
    axis: Axes,
    step: Step,
    var: str,
    conf: Config | None = None,
) -> None

Plot vector field.

Parameters:

Name Type Description Default
axis Axes

the :class:matplotlib.axes.Axes of an existing matplotlib figure where the vector field should be plotted.

required
step Step

a Step of a StagyyData instance.

required
var str

the vector field name.

required
conf Config | None

configuration.

None

cmd

cmd(conf: Config) -> None

Plot scalar and vector fields.

This is the implementation of the field subcommand.