Skip to content

Reading metadata from pluto.ini & definitions.h

plutoplot can read the PLUTO settings files if needed.

pluto.ini

Pluto_ini encapsulates the pluto.ini file, which is available from the simulation object (if pluto.ini is in the simulation directory). In Jupyter Notebooks the config will be displayed as a table. It is also possible to edit Pluto_ini and write it back to file.

Currently all values are strings and have to be converted to their respective datatype for use

This is subject to change, see Github Issue

Example

  • Access from simulation

    sim = pp.Simulation("path/to/simulation")
    
    sim.ini["Time"]["tstop"]
    sim.ini["Time","tstop"]
    sim.ini["Time/tstop"]
    

  • access directly from file and change values

    ini = pp.Pluto_ini("path/to/pluto.ini")
    
    ini["Time/tstop"] = "2.0"
    ini.write("path/to/pluto.ini")
    

Pluto_ini reference

plutoplot.metadata.Pluto_ini (OrderedDict)

PLUTO runtime initialization parameters pluto.ini

Parses and writes pluto.ini files. Access with dict-like interfaces: - ini["section"]["name"] - ini["section", "name"] - ini["section/name"]

Examples:

>>> ini = Pluto_ini(path)
>>> ini["Time"]["tstop"]

Section (OrderedDict)

Pluto_ini Section

Thin wrapper around :obj:OrderedDict, with some convenience functions.

Attributes; name (str): name of section

__init__(self, name, *args, **kwargs) special

Create Pluto_ini section

Parameters:

Name Type Description Default
name str

name of section

required
*args, **kwargs

passed to :obj:OrderedDict constructor

required
__str__(self) special

Output Section in pluto.ini format with aligned columns

__getitem__(self, key) special

ini[key] with multiple syntaxes:

  • ini["section"]
  • `ini["section","key"]
  • `ini["section/key"]

__init__(self, path) special

Load pluto.ini from file

Parameters:

Name Type Description Default
path Path

path to pluto.ini file

required

__setitem__(self, key, value) special

ini[key] = value For key syntax check __getitem__()

__str__(self) special

Convert to pluto.ini format, with columns aligned inside sections

parse(self, txt=None)

Parse pluto.ini file

Parameters:

Name Type Description Default
txt

obj:, optional): parse string instead of file

None

write(self, path=None)

Write pluto.ini to file.

If no path is given, the read file is overwritten

Parameters:

Name Type Description Default
path

obj:Path, optional): Path to write to

None

definitions.h

Definitions.h is available similarly as a Definitions_h-object, which is a OrderedDict. It is also available from the Simulation-object or can be read from a file.

The keys are handled case-insensitively for convenience.

Example

sim = pp.Simulation("path/to/simulation")

sim.definitions["cooling"]
# output example: NO
or
defs = pp.Definitions_h("path/to/definitions.h")

defs["physics"]
# output example: HD

Currently Definitions_h-files cannot be edited, see progress on this in Github Issue.

Definitions_h reference

plutoplot.metadata.Definitions_h (OrderedDict)

PLUTO compile time definitions from definitions.h

Todo

  • Implement file writing (sections need to stay as is)
  • Better string output

__init__(self, path) special

Load definitions.h from file

Parameters:

Name Type Description Default
path Path

path to definitions.h file

required

parse(self, txt=None)

Parse defintions.h

Parameters:

Name Type Description Default
txt

obj:, optional): parse string instead of file

None