Skip to content

Commit 05023e5

Browse files
committed
field: timelabel respects scaling
1 parent 3298360 commit 05023e5

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/stagpy/dimensions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from .parfile import StagyyPar
1818
from .stagyydata import StagyyData
1919

20-
T = TypeVar("T", float, NDArray[np.float64])
20+
T = TypeVar("T", float, np.float64, NDArray[np.float64])
2121

2222

2323
def apply_factors(data: T, unit: str, scaling: Scaling) -> tuple[T, str]:

src/stagpy/field.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import numpy as np
1212
from mpl_toolkits.axes_grid1 import make_axes_locatable
1313

14+
from stagpy.dimensions import apply_factors
15+
1416
from . import _helpers, phyvars
1517
from .config import Config
1618
from .error import NotAvailableError
@@ -412,9 +414,13 @@ def cmd(conf: Config) -> None:
412414
plot_vec(axis, step, var[1], conf=conf)
413415
if conf.field.timelabel:
414416
time = step.timeinfo["t"]
417+
unit = ""
418+
if sdat.par.get("switches", "dimensional_units", True):
419+
time, unit = apply_factors(time, "s", conf.scaling)
420+
unit = " " + unit
415421
time_str = _helpers.scilabel(time)
416422
axes[0, 0].text(
417-
0.02, 1.02, f"$t={time_str}$", transform=axes[0, 0].transAxes
423+
0.02, 1.02, f"$t={time_str}${unit}", transform=axes[0, 0].transAxes
418424
)
419425
oname = "_".join(chain.from_iterable(vfig))
420426
plt.tight_layout(w_pad=3)

0 commit comments

Comments
 (0)