Quantity
modelskill.quantity.Quantity
dataclass
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:
>>> wl = Quantity(name="Water Level", unit="meter")
>>> wl
Quantity(name='Water Level', unit='meter')
>>> wl.name
'Water Level'
>>> wl.unit
'meter'
>>> wl.is_compatible(wl)
True
>>> ws = Quantity(name="Wind Direction", unit="degree", is_directional=True)
>>> ws
Quantity(name='Wind Direction', unit='degree', is_directional=True)
Source code in modelskill/quantity.py
10 11 12 13 14 15 16 17 18 19 20 21 22 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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
from_cf_attrs
staticmethod
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)
Source code in modelskill/quantity.py
from_mikeio_eum_name
staticmethod
Create a Quantity from a name recognized by mikeio
Parameters:
Name | Type | Description | Default |
---|---|---|---|
type_name |
str
|
Name of the quantity |
required |
Examples:
Source code in modelskill/quantity.py
from_mikeio_iteminfo
staticmethod
Create a Quantity from mikeio ItemInfo
If the unit is "degree", the quantity is assumed to be directional.
Source code in modelskill/quantity.py
is_compatible
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