Get Simulation Parameters¶
The cactus_parfile
module provides a class
Parfile
representing Cactus simulation parameters, and a
function load_parfile()
to parse Cactus parameter files.
Usage example:
>>>p = load_parfile("doomed.par")
>>>p.coordbase.dx
'6.4'
>>>cb = p.coordbase
>>>float(cb.xmax) / float(cb.dx)
80.0
>>>p['coordbase']['dx'] # alternative access
'6.4'
>>>'CoordBase' in p
True
>>>'hobbit' in cb
False
>>>print p.coordbase
coordbase::domainsize = "minmax"
coordbase::dx = 6.4
coordbase::xmax = 512
>>>print p.active_thorns()
set(['symbase', 'coordbase'])
- class postcactus.cactus_parfile.Parfile¶
This class represents Cactus simulation parameters. It provides Thorn objects which represent the parameters of a single Cactus thorn. The thorns can be obtained in a dictionary-like way, or more pythonic as attributes. Besides the thorn parameters, it also contains a list of active thorns.
- active_thorns()¶
Returns the list of active thorns.
- has_key(key)¶
Test if a given thorn is available.
- class postcactus.cactus_parfile.Thorn(tname)¶
This class represents the parameters of a given Cactus thorn. The parameters can be accessed by name in a dictionary like way, or as object attributes.
- has_key(key)¶
Test if given parameter is available
- postcactus.cactus_parfile.load_parfile(path, parse_varlists=True, guess_types=False)¶
Load and parse a Cactus parameter file given by path. If guess_types True, the function will try to guess the type of the parameters and bring them into canonic form, e.g. 0.0001 will become a float, no or false will become a bool. This can go wrong, e.g. a string parameter set to “yes” would be read as bool. This function knows about some parameters representing lists of Cactus grid functions, and tries to bring them in canonic form, unless parse_varlists is False. If unparsable content is encountered, a warning is printed.
Note
This does not know anything about default values.
Warning
Cactus might parse parameter files slightly different in some corner cases.
- Parameters
path (string) – Location of the parfile.
parse_varlists (bool) – Whether to bring known variable list parameters into canonical form.
guess_Types (bool) – Whether to guess parameter types and convert into canonical form.
- Returns
The extracted parameters
- Return type