Skip to content

Commit 1f9a173

Browse files
committed
add read_parameters_dat config option
1 parent f67fbd6 commit 1f9a173

File tree

8 files changed

+20
-12
lines changed

8 files changed

+20
-12
lines changed

stagpy/commands.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
from shutil import get_terminal_size
1010
from textwrap import TextWrapper, indent
1111

12-
from . import __version__, phyvars, stagyydata
12+
from . import __version__, phyvars
1313
from ._helpers import baredoc, walk
1414
from .config import CONFIG_LOCAL, Config
15+
from .stagyydata import _sdat_from_conf
1516

1617
if typing.TYPE_CHECKING:
1718
from typing import Callable, Iterable, Mapping, Optional, Sequence, Union
@@ -23,7 +24,7 @@
2324

2425
def info_cmd(conf: Config) -> None:
2526
"""Print basic information about StagYY run."""
26-
sdat = stagyydata.StagyyData(conf.core.path)
27+
sdat = _sdat_from_conf(conf.core)
2728
lsnap = sdat.snaps[-1]
2829
lstep = sdat.steps[-1]
2930
print(f"StagYY run in {sdat.path}")

stagpy/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class Core(Section):
3838
path: Path = path_entry(
3939
path=".", cli_short="p", doc="path of StagYY run directory or par file"
4040
)
41+
read_parameters_dat: bool = switch_opt(True, None, "enable reading parameters.dat")
4142
outname: str = entry(val="stagpy", cli_short="n", doc="output file name prefix")
4243
shortname: bool = switch_opt(False, None, "output file name is only prefix")
4344
timesteps: Sequence[Union[int, slice]] = _indices.entry(

stagpy/field.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from . import _helpers, phyvars
1515
from .config import Config
1616
from .error import NotAvailableError
17-
from .stagyydata import StagyyData
17+
from .stagyydata import _sdat_from_conf
1818

1919
if typing.TYPE_CHECKING:
2020
from typing import Any, Iterable, Optional, Union
@@ -362,7 +362,7 @@ def _findminmax(view: StepsView, sovs: Iterable[str]) -> dict[str, tuple[float,
362362

363363
def cmd(conf: Config) -> None:
364364
"""Implementation of field subcommand."""
365-
sdat = StagyyData(conf.core.path)
365+
sdat = _sdat_from_conf(conf.core)
366366
view = _helpers.walk(sdat, conf)
367367
# no more than two fields in a subplot
368368
lovs = [[slov[:2] for slov in plov] for plov in conf.field.plot]

stagpy/plates.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from ._helpers import saveplot
1616
from .config import Config
1717
from .datatypes import Field
18-
from .stagyydata import StagyyData
18+
from .stagyydata import _sdat_from_conf
1919

2020
if typing.TYPE_CHECKING:
2121
from typing import Optional, Sequence, TextIO, Union
@@ -399,7 +399,7 @@ def plot_scalar_field(
399399

400400
def cmd(conf: Config) -> None:
401401
"""Implementation of plates subcommand."""
402-
sdat = StagyyData(conf.core.path)
402+
sdat = _sdat_from_conf(conf.core)
403403
view = _helpers.walk(sdat, conf)
404404

405405
isurf = _isurf(next(iter(view)))

stagpy/refstate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from . import _helpers
1010
from .config import Config
1111
from .phyvars import REFSTATE
12-
from .stagyydata import StagyyData
12+
from .stagyydata import StagyyData, _sdat_from_conf
1313

1414

1515
def plot_ref(sdat: StagyyData, var: str, conf: Optional[Config] = None) -> None:
@@ -45,7 +45,7 @@ def plot_ref(sdat: StagyyData, var: str, conf: Optional[Config] = None) -> None:
4545

4646
def cmd(conf: Config) -> None:
4747
"""Implementation of refstate subcommand."""
48-
sdat = StagyyData(conf.core.path)
48+
sdat = _sdat_from_conf(conf.core)
4949

5050
for var in conf.refstate.plot:
5151
plot_ref(sdat, var, conf)

stagpy/rprof.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from . import _helpers
1010
from .config import Config
11-
from .stagyydata import StagyyData
11+
from .stagyydata import _sdat_from_conf
1212

1313
if typing.TYPE_CHECKING:
1414
from typing import Optional, Sequence
@@ -94,7 +94,7 @@ def plot_grid(step: Step, conf: Optional[Config] = None) -> None:
9494

9595
def cmd(conf: Config) -> None:
9696
"""Implementation of rprof subcommand."""
97-
sdat = StagyyData(conf.core.path)
97+
sdat = _sdat_from_conf(conf.core)
9898
view = _helpers.walk(sdat, conf)
9999

100100
if conf.rprof.grid:

stagpy/stagyydata.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
from numpy.typing import NDArray
4040
from pandas import DataFrame, Series
4141

42+
from .config import Core
43+
4244
StepIndex = Union[int, slice]
4345

4446

@@ -643,6 +645,10 @@ def __eq__(self, other: object) -> bool:
643645
return all(s1 is s2 for s1, s2 in zip_longest(self, other))
644646

645647

648+
def _sdat_from_conf(core: Core) -> StagyyData:
649+
return StagyyData(core.path, core.read_parameters_dat)
650+
651+
646652
class StagyyData:
647653
"""Generic lazy interface to StagYY output data.
648654

stagpy/time_series.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from . import _helpers
1313
from .config import Config
1414
from .error import InvalidTimeFractionError
15-
from .stagyydata import StagyyData
15+
from .stagyydata import StagyyData, _sdat_from_conf
1616

1717
if typing.TYPE_CHECKING:
1818
from typing import Optional, Sequence
@@ -124,7 +124,7 @@ def compstat(
124124

125125
def cmd(conf: Config) -> None:
126126
"""Implementation of time subcommand."""
127-
sdat = StagyyData(conf.core.path)
127+
sdat = _sdat_from_conf(conf.core)
128128
if sdat.tseries is None:
129129
return
130130

0 commit comments

Comments
 (0)