odys.parameters.vectorize¶
Internal implementation detail. Most users do not need this page directly.
vectorize builds a typed collection of arrays from the same-named fields of a sequence of entities, so a quantity carries the same name in the domain and in the model.
Generic vectorization of entity fields into typed arrays.
EntityArrays
¶
Bases: BaseModel
Base of the typed array collections: frozen, holding xr.DataArray fields.
Source code in src/odys/parameters/vectorize.py
14 15 16 17 | |
vectorize(arrays_type, models, coordinates)
¶
Build one array per field of arrays_type from the same-named field of every model.
Each field of arrays_type is an xr.DataArray named exactly like a field
of the models, so a quantity carries the same name in the domain and in the
model. The models are labelled by coordinates, in order. An unset optional
field (None) becomes NaN, so optional numeric fields give float arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arrays_type
|
type[ArraysT]
|
The typed collection of arrays to build, such as |
required |
models
|
Sequence[BaseModel]
|
The entities (or value objects such as batteries) to read, one per label. |
required |
coordinates
|
Coordinates
|
The labels of the models along their dimension. |
required |
Returns:
| Type | Description |
|---|---|
ArraysT
|
An instance of |
Raises:
| Type | Description |
|---|---|
OdysError
|
If there are no models, a model lacks a field of |
Source code in src/odys/parameters/vectorize.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |