@@ -519,25 +519,19 @@ class StagyyData:
519519
520520 """Generic lazy interface to StagYY output data."""
521521
522- def __init__ (self , path , nfields_max = 50 ):
522+ def __init__ (self , path ):
523523 """Initialization of instances:
524524
525525 Args:
526526 path (pathlike): path of the StagYY run. It can either be the path
527527 of the directory containing the par file, or the path of the
528528 par file. If the path given is a directory, the path of the par
529529 file is assumed to be path/par.
530- nfields_max (int): the maximum number of scalar fields that should
531- be kept in memory. Set to a value smaller than 6 if you want no
532- limit.
533530
534531 Attributes:
535532 steps (:class:`_Steps`): collection of time steps.
536533 snaps (:class:`_Snaps`): collection of snapshots.
537534 scales (:class:`_Scales`): dimensionful scaling factors.
538- nfields_max (int): the maximum number of scalar fields that should
539- be kept in memory. Set to a value smaller than 6 if you want no
540- limit.
541535 collected_fields (list of (int, str)): list of fields currently in
542536 memory, described by istep and field name.
543537 """
@@ -558,12 +552,11 @@ def __init__(self, path, nfields_max=50):
558552 self .refstate = _Refstate (self )
559553 self .steps = _Steps (self )
560554 self .snaps = _Snaps (self )
561- self .nfields_max = nfields_max
555+ self ._nfields_max = 50
562556 self .collected_fields = []
563557
564558 def __repr__ (self ):
565- return 'StagyyData({}, nfields_max={})' .format (
566- repr (self .path ), self .nfields_max )
559+ return 'StagyyData({})' .format (repr (self .path ))
567560
568561 def __str__ (self ):
569562 return 'StagyyData in {}' .format (self .path )
@@ -684,6 +677,24 @@ def walk(self):
684677 return self .steps [conf .core .timesteps ]
685678 return self .snaps [- 1 , ]
686679
680+ @property
681+ def nfields_max (self ):
682+ """Maximum number of scalar fields kept in memory.
683+
684+ Setting this to a value lower or equal to 5 raises a
685+ :class:`~stagpy.error.InvalidNfieldsError`. Set this to ``None`` if
686+ you do not want any limit on the number of scalar fields kept in
687+ memory. Defaults to 50.
688+ """
689+ return self ._nfields_max
690+
691+ @nfields_max .setter
692+ def nfields_max (self , nfields ):
693+ """Check nfields > 5 or None."""
694+ if nfields is not None and nfields <= 5 :
695+ raise error .InvalidNfieldsError (nfields )
696+ self ._nfields_max = nfields
697+
687698 def scale (self , data , unit ):
688699 """Scales quantity to obtain dimensionful quantity.
689700
0 commit comments