|
5 | 5 | be computed from other variables. |
6 | 6 | """ |
7 | 7 |
|
| 8 | +from __future__ import annotations |
8 | 9 | from operator import attrgetter |
9 | 10 | from types import MappingProxyType |
| 11 | +import typing |
10 | 12 |
|
11 | 13 | from . import processing |
12 | 14 | from .datatypes import Varf, Varr, Vart |
13 | 15 |
|
| 16 | +if typing.TYPE_CHECKING: |
| 17 | + from typing import Mapping, Callable, List |
| 18 | + from .datatypes import Field, Rprof, Tseries |
| 19 | + from ._step import Step |
| 20 | + from .stagyydata import StagyyData, _Scales |
14 | 21 |
|
15 | | -FIELD = MappingProxyType({ |
| 22 | + |
| 23 | +FIELD: Mapping[str, Varf] = MappingProxyType({ |
16 | 24 | 'T': Varf('Temperature', 'K'), |
17 | 25 | 'v1': Varf('x Velocity', 'm/s'), |
18 | 26 | 'v2': Varf('y Velocity', 'm/s'), |
|
44 | 52 | 'prim': Varf('Primordial layer', '1'), |
45 | 53 | }) |
46 | 54 |
|
47 | | -FIELD_EXTRA = MappingProxyType({ |
| 55 | +FIELD_EXTRA: Mapping[str, Callable[[Step], Field]] = MappingProxyType({ |
48 | 56 | 'stream': processing.stream_function, |
49 | 57 | }) |
50 | 58 |
|
51 | | -FIELD_FILES = MappingProxyType({ |
| 59 | +FIELD_FILES: Mapping[str, List[str]] = MappingProxyType({ |
52 | 60 | 't': ['T'], |
53 | 61 | 'vp': ['v1', 'v2', 'v3', 'p'], |
54 | 62 | 'c': ['c'], |
|
66 | 74 | 'prm': ['prim'], |
67 | 75 | }) |
68 | 76 |
|
69 | | -FIELD_FILES_H5 = MappingProxyType({ |
| 77 | +FIELD_FILES_H5: Mapping[str, List[str]] = MappingProxyType({ |
70 | 78 | 'Temperature': ['T'], |
71 | 79 | 'Velocity': ['v1', 'v2', 'v3'], |
72 | 80 | 'Dynamic_Pressure': ['p'], |
|
92 | 100 | 'Primordial': ['prim'], |
93 | 101 | }) |
94 | 102 |
|
95 | | -SFIELD = MappingProxyType({ |
| 103 | +SFIELD: Mapping[str, Varf] = MappingProxyType({ |
96 | 104 | 'topo_top': Varf('Topography at top', 'm'), |
97 | 105 | 'topo_bot': Varf('Topography at bottom', 'm'), |
98 | 106 | 'geoid_top': Varf('Geoid at top', 'm'), |
|
106 | 114 | 'crust': Varf('Crustal thickness', 'm'), |
107 | 115 | }) |
108 | 116 |
|
109 | | -SFIELD_FILES = MappingProxyType({ |
| 117 | +SFIELD_FILES: Mapping[str, List[str]] = MappingProxyType({ |
110 | 118 | 'cs': ['topo_bot', 'topo_top'], |
111 | 119 | 'g': ['geoid_bot', 'geoid_top'], |
112 | 120 | 'csg': ['topo_g_bot', 'topo_g_top'], |
|
115 | 123 | 'cr': ['crust'], |
116 | 124 | }) |
117 | 125 |
|
118 | | -SFIELD_FILES_H5 = MappingProxyType({ |
| 126 | +SFIELD_FILES_H5: Mapping[str, List[str]] = MappingProxyType({ |
119 | 127 | 'BottomTopography': ['topo_bot'], |
120 | 128 | 'SurfaceTopography': ['topo_top'], |
121 | 129 | 'BottomGeoid': ['geoid_bot'], |
|
130 | 138 | }) |
131 | 139 |
|
132 | 140 |
|
133 | | -RPROF = MappingProxyType({ |
| 141 | +RPROF: Mapping[str, Varr] = MappingProxyType({ |
134 | 142 | 'r': Varr('Radial coordinate', 'Radius', 'm'), |
135 | 143 | 'Tmean': Varr('Temperature', 'Temperature', 'K'), |
136 | 144 | 'Tmin': Varr('Min temperature', 'Temperature', 'K'), |
|
199 | 207 | 'advasc': Varr('Upward advection', 'Heat flux', 'W/m2'), |
200 | 208 | }) |
201 | 209 |
|
202 | | -RPROF_EXTRA = MappingProxyType({ |
| 210 | +RPROF_EXTRA: Mapping[str, Callable[[Step], Rprof]] = MappingProxyType({ |
203 | 211 | 'dr': processing.delta_r, |
204 | 212 | 'diff': processing.diff_prof, |
205 | 213 | 'diffs': processing.diffs_prof, |
|
213 | 221 | }) |
214 | 222 |
|
215 | 223 |
|
216 | | -TIME = MappingProxyType({ |
| 224 | +TIME: Mapping[str, Vart] = MappingProxyType({ |
217 | 225 | 't': Vart('Time', 'Time', 's'), |
218 | 226 | 'ftop': Vart('Heat flux at top', 'Heat flux', 'W/m2'), |
219 | 227 | 'fbot': Vart('Heat flux at bottom', 'Heat flux', 'W/m2'), |
|
245 | 253 | 'botT_val': Vart('Temperature at bottom', 'Temperature', 'K'), |
246 | 254 | }) |
247 | 255 |
|
248 | | -TIME_EXTRA = MappingProxyType({ |
| 256 | +TIME_EXTRA: Mapping[str, Callable[[StagyyData], Tseries]] = MappingProxyType({ |
249 | 257 | 'dt': processing.dtime, |
250 | 258 | 'dTdt': processing.dt_dt, |
251 | 259 | 'ebalance': processing.ebalance, |
252 | 260 | 'mobility': processing.mobility, |
253 | 261 | }) |
254 | 262 |
|
255 | | -REFSTATE = MappingProxyType({ |
| 263 | +REFSTATE: Mapping[str, Varr] = MappingProxyType({ |
256 | 264 | 'z': Varr('z position', 'z position', 'm'), |
257 | 265 | 'T': Varr('Temperature', 'Temperature', 'K'), |
258 | 266 | 'rho': Varr('Density', 'Density', 'kg/m3'), |
|
263 | 271 | 'grav': Varr('Gravity', 'Gravity', 'm/s2'), |
264 | 272 | }) |
265 | 273 |
|
266 | | -SCALES = MappingProxyType({ |
| 274 | +SCALES: Mapping[str, Callable[[_Scales], float]] = MappingProxyType({ |
267 | 275 | 'm': attrgetter('length'), |
268 | 276 | 'kg/m3': attrgetter('density'), |
269 | 277 | 'K': attrgetter('temperature'), |
|
0 commit comments