Quantity

Quantity(self, name, unit, is_directional=False)

Quantity of data

Parameters

Name Type Description Default
name str Name of the quantity required
unit str Unit of the quantity required
is_directional bool Whether the quantity is directional (e.g. Wind Direction), by default False False

Examples

from modelskill import Quantity
wl = Quantity(name="Water Level", unit="meter")
wl
Quantity(name='Water Level', unit='meter')
wl.name
'Water Level'
'Water Level'
wl.unit
'meter'
wl.is_compatible(wl)
True
Quantity(name="Wind Direction", unit="degree", is_directional=True)
Quantity(name='Wind Direction', unit='degree', is_directional=True)

Methods

Name Description
from_cf_attrs Create a Quantity from a CF compliant attributes dictionary
from_mikeio_eum_name Create a Quantity from a name recognized by mikeio
from_mikeio_iteminfo Create a Quantity from mikeio ItemInfo
is_compatible Check if the quantity is compatible with another quantity

from_cf_attrs

Quantity.from_cf_attrs(attrs)

Create a Quantity from a CF compliant attributes dictionary

If units is “degree”, “degrees” or “Degree true”, the quantity is assumed to be directional. Based on https://codes.ecmwf.int/grib/param-db/ and https://cfconventions.org/Data/cf-standard-names/current/build/cf-standard-name-table.html

Parameters

Name Type Description Default
attrs Mapping[str, str] Attributes dictionary required

Examples

Quantity.from_cf_attrs({'long_name': 'Water Level', 'units': 'meter'})
Quantity(name='Water Level', unit='meter')
Quantity.from_cf_attrs({'long_name': 'Wind direction', 'units': 'degree'})
Quantity(name='Wind direction', unit='degree', is_directional=True)

from_mikeio_eum_name

Quantity.from_mikeio_eum_name(type_name)

Create a Quantity from a name recognized by mikeio

Parameters

Name Type Description Default
type_name str Name of the quantity required

Examples

Quantity.from_mikeio_eum_name("Water Level")
/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/modelskill/quantity.py:166: UserWarning:

unit='meter' was automatically set for type_name='Water Level'
Quantity(name='Water Level', unit='meter')

from_mikeio_iteminfo

Quantity.from_mikeio_iteminfo(iteminfo)

Create a Quantity from mikeio ItemInfo

If the unit is “degree”, the quantity is assumed to be directional.

is_compatible

Quantity.is_compatible(other)

Check if the quantity is compatible with another quantity

Examples

wl = Quantity(name="Water Level", unit="meter")
ws = Quantity(name="Wind Speed", unit="meter per second")
wl.is_compatible(ws)
False
uq = Quantity(name="Undefined", unit="Undefined")
wl.is_compatible(uq)
True