@@ -225,15 +225,19 @@ def at_step(self, istep: int) -> Series:
225225 return self ._tseries .loc [istep ] # type: ignore
226226
227227
228+ @dataclass (frozen = True )
228229class RprofsAveraged (step .Rprofs ):
229230 """Radial profiles time-averaged over a [`StepsView`][stagpy.stagyydata.StepsView].
230231
231232 The [`StepsView.rprofs_averaged`][stagpy.stagyydata.StepsView.rprofs_averaged]
232233 attribute is an instance of this class.
233234 """
234235
235- def __init__ (self , steps : StepsView ):
236- self .steps = steps .filter (rprofs = True )
236+ steps : StepsView
237+
238+ @cached_property
239+ def _steps_with_rprofs (self ) -> StepsView :
240+ return self .steps .filter (rprofs = True )
237241
238242 @cached_property
239243 def _cached_data (self ) -> dict [str , dt .Rprof ]:
@@ -245,7 +249,7 @@ def __getitem__(self, name: str) -> dt.Rprof:
245249 # - does not take into account time changing timestep.
246250 if name in self ._cached_data :
247251 return self ._cached_data [name ]
248- steps_iter = iter (self .steps )
252+ steps_iter = iter (self ._steps_with_rprofs )
249253 rpf = next (steps_iter ).rprofs [name ]
250254 rprof = np .copy (rpf .values )
251255 nprofs = 1
@@ -262,7 +266,7 @@ def stepstr(self) -> str:
262266
263267 @cached_property
264268 def _first_rprofs (self ) -> step .RprofsInstant :
265- first_step = next (iter (self .steps ))
269+ first_step = next (iter (self ._steps_with_rprofs ))
266270 return first_step .rprofs
267271
268272 @property
0 commit comments