Skip to content

field_bundle

FieldBundle

Field Bundle wraps a nD array (3D + n Data Dimensions) into a complex indexing scheme that allows a dual name-based and index-based access to the underlying memory. It is paired with the FieldBundleType which provides a way to type hint parameters for stencils in the gtscript.

WARNING: The present implementation only allows for 4D array.

name = bundle_name instance-attribute

quantity property

shape property

__init__(bundle_name, quantity, mapping=None, register_type=False)

Initialize a bundle from a nD quantity.

Dev note: current implementation limits to 4D inputs.

Parameters:

Name Type Description Default
bundle_name str

name of the bundle, accessible via name.

required
quantity Quantity

data inputs as a nD array.

required
mapping _FieldBundleIndexer | None

sparse dict of [name, index] to be able to call tracers by name.

None
register_type bool

boolean to register the type as part of initialization.

False

map(index, name)

Map a single index to name

groupby(name)

Not implemented

index(name)

Get index from name.

extend_3D_quantity_factory(quantity_factory, extra_dims) staticmethod

Create a nD quantity factory from a cartesian 3D factory.

Parameters:

Name Type Description Default
quantity_factory QuantityFactory

Cartesian 3D factory.

required
extra_dims dict[str, int]

dict of [name, size] of the data dimensions to add.

required

MarkupFieldBundleType dataclass

Markup a field bundle to delay specialization.

Properties

name: name of the future type to look into the registrar.

name instance-attribute

__init__(name)

FieldBundleType

Field Bundle Types to help with static sizing of Data Dimensions.

Methods:

Name Description
register

Register a type by sizing its data dimensions

T

access any registered types for type hinting.

register(name, data_dims, dtype=Float) classmethod

Register a name type by name by giving the size of its data dimensions.

The same type cannot be registered twice and will error out.

Parameters:

Name Type Description Default
name str

Type name, to be re-used with T.

required
data_dims tuple[int]

tuple of int giving size of each data dimensions.

required
dtype

Inner data type, defaults to Float.

Float

T(name, do_markup=True) classmethod

Get registered type.

Dev note: The markup feature is to allow early parsing (at file import) to go ahead - while we will resolve the full type when calling the stencil.

Parameters:

Name Type Description Default
name str

name of the type as registered via register

required
do_markup bool

if name not registered, markup for a future specialization at stencil call time

True