Skip to content

Commit 963ce0c

Browse files
committed
parfile: get rid of PAR_DEFAULT, impl wrapped in StagyyPar
1 parent e7856b9 commit 963ce0c

File tree

8 files changed

+127
-733
lines changed

8 files changed

+127
-733
lines changed

docs/sources/apiref/parfile.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,3 @@ parfile
33

44
.. automodule:: stagpy.parfile
55
:members:
6-
7-
.. data:: PAR_DEFAULT
8-
9-
Defaut value of all the StagYY input parameters used to fill missing
10-
entries by :func:`readpar`. It is a :class:`f90nml.namelist.Namelist`.

stagpy/_step.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,14 @@ def __init__(self, header: Dict[str, Any], step: Step):
5858

5959
def _scale_radius_mo(self, radius: ndarray) -> ndarray:
6060
"""Rescale radius for evolving MO runs."""
61-
if self._step.sdat.par["magma_oceans_in"]["evolving_magma_oceans"]:
61+
if self._step.sdat.par.get("magma_oceans_in", "evolving_magma_oceans", False):
6262
return self._header["mo_thick_sol"] * (radius + self._header["mo_lambda"])
6363
return radius
6464

65+
@property
66+
def aspect_ratio(self) -> tuple[float, float]:
67+
return self._step.sdat.par.nml["geometry"]["aspect_ratio"]
68+
6569
@cached_property
6670
def nttot(self) -> int:
6771
"""Number of grid point along the x/theta direction."""
@@ -127,10 +131,10 @@ def t_walls(self) -> ndarray:
127131
elif self.curvilinear:
128132
# should take theta_position/theta_center into account
129133
tmin = 0
130-
tmax = min(np.pi, self._step.sdat.par["geometry"]["aspect_ratio"][0])
134+
tmax = min(np.pi, self.aspect_ratio[0])
131135
else:
132136
tmin = 0
133-
tmax = self._step.sdat.par["geometry"]["aspect_ratio"][0]
137+
tmax = self.aspect_ratio[0]
134138
return np.linspace(tmin, tmax, self.nttot + 1)
135139
# twoD YZ
136140
center = np.pi / 2 if self.curvilinear else 0
@@ -150,12 +154,10 @@ def p_walls(self) -> ndarray:
150154
pmin, pmax = -3 * np.pi / 4, 3 * np.pi / 4
151155
elif self.curvilinear:
152156
pmin = 0
153-
pmax = min(
154-
2 * np.pi, self._step.sdat.par["geometry"]["aspect_ratio"][1]
155-
)
157+
pmax = min(2 * np.pi, self.aspect_ratio[1])
156158
else:
157159
pmin = 0
158-
pmax = self._step.sdat.par["geometry"]["aspect_ratio"][1]
160+
pmax = self.aspect_ratio[1]
159161
return np.linspace(pmin, pmax, self.nptot + 1)
160162
# twoD YZ
161163
d_p = (self.t_walls[1] - self.t_walls[0]) / 2
@@ -198,7 +200,7 @@ def y_centers(self) -> ndarray:
198200

199201
def _init_shape(self) -> None:
200202
"""Determine shape of geometry."""
201-
shape = self._step.sdat.par["geometry"]["shape"].lower()
203+
shape = self._step.sdat.par.nml["geometry"]["shape"].lower()
202204
aspect = self._header["aspect"]
203205
if self._header["rcmb"] >= 0:
204206
# curvilinear
@@ -556,13 +558,13 @@ def bounds(self) -> Tuple[float, float]:
556558
try:
557559
rcmb = step.geom.rcmb
558560
except error.NoGeomError:
559-
rcmb = step.sdat.par["geometry"]["r_cmb"]
560-
if step.sdat.par["geometry"]["shape"].lower() == "cartesian":
561+
rcmb = step.sdat.par.get("geometry", "r_cmb", 3480e3)
562+
if step.sdat.par.nml["geometry"]["shape"].lower() == "cartesian":
561563
rcmb = 0
562564
rbot = max(rcmb, 0)
563565
thickness = (
564566
step.sdat.scales.length
565-
if step.sdat.par["switches"]["dimensional_units"]
567+
if step.sdat.par.get("switches", "dimensional_units", True)
566568
else 1
567569
)
568570
return rbot, rbot + thickness

stagpy/field.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ def plot_scalar(
217217
else:
218218
fig = axis.get_figure() # type: ignore
219219

220-
if step.sdat.par["magma_oceans_in"]["evolving_magma_oceans"]:
221-
rcmb = step.sdat.par["geometry"]["r_cmb"]
220+
if step.sdat.par.get("magma_oceans_in", "evolving_magma_oceans", False):
221+
rcmb = step.sdat.par.nml["geometry"]["r_cmb"]
222222
xmax = rcmb + 1
223223
ymax = xmax
224224
xmin = -xmax

0 commit comments

Comments
 (0)