|
5 | 5 | be computed from other variables. |
6 | 6 | """ |
7 | 7 |
|
8 | | -from collections import namedtuple |
| 8 | +from __future__ import annotations |
9 | 9 | from operator import attrgetter |
10 | 10 | from types import MappingProxyType |
| 11 | +from typing import NamedTuple, TYPE_CHECKING |
11 | 12 |
|
12 | 13 | from . import processing |
13 | 14 |
|
14 | | -Varf = namedtuple('Varf', ['description', 'dim']) |
| 15 | +if TYPE_CHECKING: |
| 16 | + from typing import Union, Callable, Tuple |
| 17 | + from numpy import ndarray |
| 18 | + from ._step import Step |
| 19 | + from .stagyydata import StagyyData |
| 20 | + |
| 21 | + |
| 22 | +class Varf(NamedTuple): |
| 23 | + """Metadata of scalar fields. |
| 24 | +
|
| 25 | + Attributes: |
| 26 | + description: short description of the variable if it is output by |
| 27 | + StagYY, function to compute it otherwise. |
| 28 | + dim: dimension used to :func:`~stagpy.stagyydata.StagyyData.scale` to |
| 29 | + dimensional values. |
| 30 | + """ |
| 31 | + |
| 32 | + description: Union[str, Callable[[Step], ndarray]] |
| 33 | + dim: str |
| 34 | + |
| 35 | + |
15 | 36 | FIELD = MappingProxyType({ |
16 | 37 | 'T': Varf('Temperature', 'K'), |
17 | 38 | 'v1': Varf('x Velocity', 'm/s'), |
|
129 | 150 | 'CrustThickness': ['crust'], |
130 | 151 | }) |
131 | 152 |
|
132 | | -Varr = namedtuple('Varr', ['description', 'kind', 'dim']) |
| 153 | + |
| 154 | +class Varr(NamedTuple): |
| 155 | + """Metadata of radial profiles. |
| 156 | +
|
| 157 | + Attributes: |
| 158 | + description: short description of the variable if it is output by |
| 159 | + StagYY, function to compute it otherwise. |
| 160 | + kind: shorter description to group similar variables under the same |
| 161 | + label. |
| 162 | + dim: dimension used to :func:`~stagpy.stagyydata.StagyyData.scale` to |
| 163 | + dimensional values. |
| 164 | + """ |
| 165 | + |
| 166 | + description: Union[str, Callable[[Step], Tuple[ndarray, ndarray]]] |
| 167 | + kind: str |
| 168 | + dim: str |
| 169 | + |
| 170 | + |
133 | 171 | RPROF = MappingProxyType({ |
134 | 172 | 'r': Varr('Radial coordinate', 'Radius', 'm'), |
135 | 173 | 'Tmean': Varr('Temperature', 'Temperature', 'K'), |
|
212 | 250 | 'advth': Varr(processing.advth, 'Heat Flux', 'W/m2'), |
213 | 251 | }) |
214 | 252 |
|
215 | | -Vart = namedtuple('Vart', ['description', 'kind', 'dim']) |
| 253 | + |
| 254 | +class Vart(NamedTuple): |
| 255 | + """Metadata of time series. |
| 256 | +
|
| 257 | + Attributes: |
| 258 | + description: short description of the variable if it is output by |
| 259 | + StagYY, function to compute it otherwise. |
| 260 | + kind: shorter description to group similar variables under the same |
| 261 | + label. |
| 262 | + dim: dimension used to :func:`~stagpy.stagyydata.StagyyData.scale` to |
| 263 | + dimensional values. |
| 264 | + """ |
| 265 | + |
| 266 | + description: Union[str, Callable[[StagyyData], Tuple[ndarray, ndarray]]] |
| 267 | + kind: str |
| 268 | + dim: str |
| 269 | + |
| 270 | + |
216 | 271 | TIME = MappingProxyType({ |
217 | 272 | 't': Vart('Time', 'Time', 's'), |
218 | 273 | 'ftop': Vart('Heat flux at top', 'Heat flux', 'W/m2'), |
|
0 commit comments