Skip to content

gt4py_utils

make_storage_data(data, shape=None, origin=origin, *, backend, dtype=Float, mask=None, start=(0, 0, 0), dummy=None, axis=2, max_dim=3, read_only=True)

Create a new gt4py storage from the given data.

Parameters:

Name Type Description Default
data NDArray

Data array for new storage

required
shape tuple[int, ...] | None

Shape of the new storage. Number of indices should be equal to number of unmasked axes

None
origin tuple[int, ...]

Default origin for gt4py stencil calls

origin
backend Backend

current backend in use

required
dtype DTypeLike

Data type

Float
mask tuple[bool, ...] | None

Tuple indicating the axes used when initializing the storage. True indicates a masked axis, False is a used axis.

None
start tuple[int, ...]

Starting points for slices in data copies

(0, 0, 0)
dummy tuple[int, ...] | None

Dummy axes

None
axis int

Axis for 2D to 3D arrays

2
max_dim int

Number of cartesian dimensions. Those will be index-aligned, while additional "data" dimensions are considered "en block".

3
read_only bool

?

True

Returns:

Type Description
NDArray

Field[..., dtype]: New storage

Example
ptop = utils.make_storage_data(top_p, q4_1.shape)
Example
ws3 = utils.make_storage_data(ws3[:, :, -1], shape, origin=(0, 0, 0))
Example
data_dict[names[i]] = make_storage_data(
       data[:, :, :, i],
       shape,
       origin=origin,
       start=start,
       dummy=dummy,
       axis=axis,
   )

make_storage_from_shape(shape, origin=origin, *, backend, dtype=Float, mask=None)

Create a new gt4py storage of a given shape filled with zeros.

Parameters:

Name Type Description Default
shape tuple[int, ...]

Shape of the new storage

required
origin tuple[int, ...]

Default origin for gt4py stencil calls

origin
dtype DTypeLike

Data type

Float
mask tuple[bool, ...] | None

Tuple indicating the axes used when initializing the storage

None
backend Backend

gt4py backend to use when making the storage

required

Returns:

Type Description
NDArray

Field[..., dtype]: New storage

Example
utmp = utils.make_storage_from_shape(ua.shape)
Example
qx = utils.make_storage_from_shape(
       qin.shape, origin=(grid().is_, grid().jsd, kstart)
   )
Example
q_out = utils.make_storage_from_shape(q_in.shape, origin)

run_once(f)

Python trick to enforce function is only called once

split_cartesian_into_storages(var)

Provided a storage of dims [I_DIM, J_DIM, CARTESIAN_DIM] or [I_INTERFACE_DIM, J_INTERFACE_DIM, CARTESIAN_DIM]. Split it into separate 2D storages for each cartesian dimension, and return these in a list.