|
9 | 9 | from __future__ import annotations |
10 | 10 |
|
11 | 11 | import typing |
| 12 | +from abc import ABC, abstractmethod |
12 | 13 | from collections import abc |
13 | 14 | from functools import cached_property |
14 | 15 | from itertools import chain |
@@ -449,16 +450,47 @@ def __iter__(self) -> NoReturn: |
449 | 450 | raise TypeError("tracers collection is not iterable") |
450 | 451 |
|
451 | 452 |
|
452 | | -class Rprofs: |
453 | | - """Radial profiles data structure. |
454 | | -
|
455 | | - The `Step.rprofs` attribute is an instance of this class. |
| 453 | +class Rprofs(ABC): |
| 454 | + """Radial profiles. |
456 | 455 |
|
457 | 456 | `Rprofs` implements the getitem mechanism. Keys are profile names |
458 | 457 | defined in `stagpy.phyvars.RPROF[_EXTRA]`. Items are |
459 | 458 | [`Rprof`][stagpy.datatypes.Rprof] instances. |
460 | 459 | """ |
461 | 460 |
|
| 461 | + @abstractmethod |
| 462 | + def __getitem__(self, name: str) -> Rprof: ... |
| 463 | + |
| 464 | + @property |
| 465 | + @abstractmethod |
| 466 | + def stepstr(self) -> str: |
| 467 | + """String representation of steps indices.""" |
| 468 | + |
| 469 | + @property |
| 470 | + @abstractmethod |
| 471 | + def centers(self) -> NDArray: |
| 472 | + """Radial position of cell centers.""" |
| 473 | + |
| 474 | + @property |
| 475 | + @abstractmethod |
| 476 | + def walls(self) -> NDArray: |
| 477 | + """Radial position of cell walls.""" |
| 478 | + |
| 479 | + @property |
| 480 | + @abstractmethod |
| 481 | + def bounds(self) -> tuple[float, float]: |
| 482 | + """Radial or vertical position of boundaries. |
| 483 | +
|
| 484 | + Radial/vertical positions of boundaries of the domain. |
| 485 | + """ |
| 486 | + |
| 487 | + |
| 488 | +class RprofsInstant(Rprofs): |
| 489 | + """Radial profiles at a given step. |
| 490 | +
|
| 491 | + The `Step.rprofs` attribute is an instance of this class. |
| 492 | + """ |
| 493 | + |
462 | 494 | def __init__(self, step: Step): |
463 | 495 | self.step = step |
464 | 496 | self._cached_extra: dict[str, Rprof] = {} |
@@ -595,7 +627,7 @@ def __init__(self, istep: int, sdat: StagyyData): |
595 | 627 | self, phyvars.SFIELD, {}, phyvars.SFIELD_FILES, phyvars.SFIELD_FILES_H5 |
596 | 628 | ) |
597 | 629 | self.tracers = Tracers(self) |
598 | | - self.rprofs = Rprofs(self) |
| 630 | + self.rprofs = RprofsInstant(self) |
599 | 631 |
|
600 | 632 | def __repr__(self) -> str: |
601 | 633 | if self.isnap is not None: |
|
0 commit comments