The SKIRT project
advanced radiative transfer for astrophysics
Public Member Functions | Private Attributes | List of all members
pts.simulation.simulation.Simulation Class Reference

An instance of the Simulation class represents all input and output files related to a single performed SKIRT simulation. More...

Public Member Functions

def __init__ (self, prefix="", *skiFilePath=None, inDirPath=None, outDirPath="", process=None)
 The constructor accepts the following arguments: More...
 
def __getattr__ (self, attrname)
 This function allows invoking any SkiFile function directly on a simulation object. More...
 
def inDirPath (self)
 This function returns the absolute path to the input directory of the simulation, or None if it is unknown. More...
 
def inFilePath (self, name)
 This function returns the absolute path for a simulation input file, given the file's name, or None if the input directory path is unknown. More...
 
def instruments (self)
 This function returns a list of Instrument instances for each of the instruments in the simulation, in their order of appearance in the ski file. More...
 
def isRunning (self)
 This function returns True if the simulation instance has been created from an asynchronous Skirt.execute() invocation (with "wait=False") and the asynchronous process is still executing. More...
 
def logFilePath (self)
 This function returns the absolute path for the simulation log file. More...
 
def logFilePaths (self)
 This function returns a list of absolute filepaths for all log files produced by the simulation, including the master log file and any log files produced by parallel (MPI) processes. More...
 
def outDirPath (self)
 This function returns the absolute path to the output directory of the simulation. More...
 
def outFilePath (self, partialname)
 This function returns the absolute path for a simulation output file, given the file's partial name (the partial name does not include the prefix and the subsequent underscore). More...
 
def parameters (self)
 This function returns a SkiFile object representing the parameter file for this simulation. More...
 
def prefix (self)
 This function returns the prefix for the simulation, which is used for all output file names. More...
 
def probes (self, probeType=None, formType=None)
 This function returns a list of Probe instances for each of the probes in the simulation, in their order of appearance in the ski file. More...
 
def skiFilePath (self)
 This function returns the absolute file path of the input ski file for which the simulation was performed (not the parameters.xml file generated by SKIRT), or None if it is unknown. More...
 
def status (self)
 This function returns the status of the simulation, based on its process completion state (if available) and the contents of its log file, as one of the following strings: More...
 

Private Attributes

 _inDirPath
 
 _outDirPath
 
 _parameters
 
 _prefix
 
 _process
 
 _running
 
 _skiFilePath
 

Detailed Description

An instance of the Simulation class represents all input and output files related to a single performed SKIRT simulation.

To create an instance of the class, one specifies the name of the ski file (used as prefix for all output filenames) plus directory paths for the input and output files. The methods of the class allow retrieving all kinds of information about the simulation results.

The code in this class uses ad-hoc knowledge about SKIRT's data formats and naming schemes; for example:

Constructor & Destructor Documentation

◆ __init__()

def pts.simulation.simulation.Simulation.__init__ (   self,
  prefix = "",
skiFilePath = None,
  inDirPath = None,
  outDirPath = "",
  process = None 
)

The constructor accepts the following arguments:

  • prefix: the name of the ski file for which the simulation was performed (without the directory path and without the .ski filename extension) and which has been used as a prefix for all output file names. If the prefix argument is empty or missing, the skiFilePath argument must be provided so that the prefix can be automatically derived from the (stem of the name of) the specified ski file.
  • skiFilePath: the path of the input ski file for which the simulation was performed (not the parameters.xml file generated by SKIRT). This argument is optional, but if it is omitted, the prefix argument must be present and non-empty.
  • inDirPath: the input path of the simulation. If there were no input files for the simulation, or if access to the input files is not needed, this argument may be omitted.
  • outDirPath: the output path of the simulation. If this argument is missing, the output path is taken to be the current working directory.
  • process: optional subprocess.Popen object that can be queried for completion of a simulation. If the argument is not provided, the completion status is derived from the log file. This argument is provided by the Skirt object when it creates a Simulation instance for a simulation that is being performed in asynchronous mode.

All paths described above are interpreted as described for the pts.utils.absPath() function.

Member Function Documentation

◆ __getattr__()

def pts.simulation.simulation.Simulation.__getattr__ (   self,
  attrname 
)

This function allows invoking any SkiFile function directly on a simulation object.

For example, self.instrumentNames() is automatically translated to self.parameters().instrumentNames().

◆ inDirPath()

def pts.simulation.simulation.Simulation.inDirPath (   self)

This function returns the absolute path to the input directory of the simulation, or None if it is unknown.

◆ inFilePath()

def pts.simulation.simulation.Simulation.inFilePath (   self,
  name 
)

This function returns the absolute path for a simulation input file, given the file's name, or None if the input directory path is unknown.

◆ instruments()

def pts.simulation.simulation.Simulation.instruments (   self)

This function returns a list of Instrument instances for each of the instruments in the simulation, in their order of appearance in the ski file.

◆ isRunning()

def pts.simulation.simulation.Simulation.isRunning (   self)

This function returns True if the simulation instance has been created from an asynchronous Skirt.execute() invocation (with "wait=False") and the asynchronous process is still executing.

Otherwise, the function returns False. Note that this is not always exactly the same as the result of "status() == 'Running'".

◆ logFilePath()

def pts.simulation.simulation.Simulation.logFilePath (   self)

This function returns the absolute path for the simulation log file.

◆ logFilePaths()

def pts.simulation.simulation.Simulation.logFilePaths (   self)

This function returns a list of absolute filepaths for all log files produced by the simulation, including the master log file and any log files produced by parallel (MPI) processes.

The list includes only paths for log files that actually exist, and the paths are listed in order of process rank.

◆ outDirPath()

def pts.simulation.simulation.Simulation.outDirPath (   self)

This function returns the absolute path to the output directory of the simulation.

◆ outFilePath()

def pts.simulation.simulation.Simulation.outFilePath (   self,
  partialname 
)

This function returns the absolute path for a simulation output file, given the file's partial name (the partial name does not include the prefix and the subsequent underscore).

◆ parameters()

def pts.simulation.simulation.Simulation.parameters (   self)

This function returns a SkiFile object representing the parameter file for this simulation.

◆ prefix()

def pts.simulation.simulation.Simulation.prefix (   self)

This function returns the prefix for the simulation, which is used for all output file names.

◆ probes()

def pts.simulation.simulation.Simulation.probes (   self,
  probeType = None,
  formType = None 
)

This function returns a list of Probe instances for each of the probes in the simulation, in their order of appearance in the ski file.

The list can be limited to probes of the specified type(s) and/or with the specified assocated form type(s).

◆ skiFilePath()

def pts.simulation.simulation.Simulation.skiFilePath (   self)

This function returns the absolute file path of the input ski file for which the simulation was performed (not the parameters.xml file generated by SKIRT), or None if it is unknown.

◆ status()

def pts.simulation.simulation.Simulation.status (   self)

This function returns the status of the simulation, based on its process completion state (if available) and the contents of its log file, as one of the following strings:

  • 'NotStarted': the simulation has not (yet) been started.
  • 'Running': the simulation is still running, or at least it seems to be so (for example, the simulation crashed without logging an error message and the Simulation was constructed without a process object).
  • 'Crashed': the simulation ended with a fatal error.
  • 'Finished': the simulation completed properly.

The documentation for this class was generated from the following file: