Skip to content

Commit 54bd478

Browse files
committed
Geometry is a frozen dataclass
1 parent 4119d42 commit 54bd478

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/stagpy/step.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,32 @@
3030
from .stagyydata import StagyyData
3131

3232

33+
@dataclass(frozen=True)
3334
class Geometry:
3435
"""Geometry information.
3536
3637
It is deduced from the information in the header of binary field files
3738
output by StagYY.
3839
"""
3940

40-
def __init__(self, step: Step):
41-
self._step = step
41+
step: Step
4242

4343
@cached_property
4444
def _header(self) -> Mapping[str, Any]:
45-
hdr = self._step.fields._header
45+
hdr = self.step.fields._header
4646
if hdr is None:
47-
raise error.NoGeomError(self._step)
47+
raise error.NoGeomError(self.step)
4848
return hdr
4949

5050
def _scale_radius_mo(self, radius: NDArray) -> NDArray:
5151
"""Rescale radius for evolving MO runs."""
52-
if self._step.sdat.par.get("magma_oceans_in", "evolving_magma_oceans", False):
52+
if self.step.sdat.par.get("magma_oceans_in", "evolving_magma_oceans", False):
5353
return self._header["mo_thick_sol"] * (radius + self._header["mo_lambda"])
5454
return radius
5555

5656
@property
5757
def aspect_ratio(self) -> tuple[float, float]:
58-
return self._step.sdat.par.nml["geometry"]["aspect_ratio"]
58+
return self.step.sdat.par.nml["geometry"]["aspect_ratio"]
5959

6060
@cached_property
6161
def _ntot(self) -> tuple[int, int, int, int]:
@@ -104,7 +104,7 @@ def r_walls(self) -> NDArray:
104104
walls = rgeom[:, 0] + self.rcmb
105105
else:
106106
walls = self._header["e3_coord"] + self.rcmb
107-
walls = np.append(walls, self._step.rprofs.bounds[1])
107+
walls = np.append(walls, self.step.rprofs.bounds[1])
108108
return self._scale_radius_mo(walls)
109109

110110
@cached_property
@@ -114,7 +114,7 @@ def r_centers(self) -> NDArray:
114114
if rgeom is not None:
115115
walls = rgeom[:-1, 1] + self.rcmb
116116
else:
117-
walls = self._step.rprofs.centers
117+
walls = self.step.rprofs.centers
118118
return self._scale_radius_mo(walls)
119119

120120
@cached_property
@@ -200,7 +200,7 @@ def rcmb(self) -> float:
200200

201201
@cached_property
202202
def _shape(self) -> str:
203-
return self._step.sdat.par.nml["geometry"]["shape"].lower()
203+
return self.step.sdat.par.nml["geometry"]["shape"].lower()
204204

205205
@cached_property
206206
def curvilinear(self) -> bool:

0 commit comments

Comments
 (0)