The SKIRT project
advanced radiative transfer for astrophysics
Functions
pts.utils.path Namespace Reference

Special paths related to PTS. More...

Functions

def absPath (inpath)
 This function returns the absolute canonical path corresponding to the given path. More...
 
def dataPath (object)
 This function returns the absolute path to the data subdirectory for the PTS package in which the given object is defined. More...
 
def projectParentPath ()
 This function returns the absolute path to the directory containing the SKIRT and PTS project directories as a pathlib.Path object. More...
 
def ptsPath ()
 This function returns the absolute path to the top-level directory of the pts repository as a pathlib.Path object. More...
 
def savePath (defFilePath, suffix, *outDirPath=None, outFileName=None, outFilePath=None)
 This function returns the absolute canonical path corresponding to the file path that will be used to save a result to file, such as a PDF plot or a PNG image. More...
 
def skirtPath ()
 This function returns the absolute path to the SKIRT executable built as part of the project structure including this PTS source file, or None if no executable is found. More...
 

Detailed Description

Special paths related to PTS.

This module allows retrieving some special paths related to PTS, such as for example the path to the pts repository.

Function Documentation

◆ absPath()

def pts.utils.path.absPath (   inpath)

This function returns the absolute canonical path corresponding to the given path.

The input path may be specified as a string or as a pathlib.Path object. If the input path is relative, it is interpreted relative to the current working directory. If it starts with a tilde, the tilde is expanded to the home directory of the current user. In all cases, the path is streamlined by removing and "." and ".." segments and following symbolic links.

◆ dataPath()

def pts.utils.path.dataPath (   object)

This function returns the absolute path to the data subdirectory for the PTS package in which the given object is defined.

◆ projectParentPath()

def pts.utils.path.projectParentPath ( )

This function returns the absolute path to the directory containing the SKIRT and PTS project directories as a pathlib.Path object.

In the canonical SKIRT/PTS developer directory structure, this is the grandparent of the pts repository.

◆ ptsPath()

def pts.utils.path.ptsPath ( )

This function returns the absolute path to the top-level directory of the pts repository as a pathlib.Path object.

◆ savePath()

def pts.utils.path.savePath (   defFilePath,
  suffix,
outDirPath = None,
  outFileName = None,
  outFilePath = None 
)

This function returns the absolute canonical path corresponding to the file path that will be used to save a result to file, such as a PDF plot or a PNG image.

The returned path is derived from the input arguments:

  • defFilePath: required argument; specifies the default save file path and is used in case the other arguments do not fully specify the path. This path is typically constructed by the immediate caller, e.g. a plot function.
  • outDirPath: optional argument; overrides the directory path in defFilePath.
  • outFileName: optional argument; overrides the filename portion of the path in defFilePath. It is valid for both outDirPath and outFileName to be specified, in which case defFilePath is ignored. However, in this case it may be more natural to use the outFilePath argument instead.
  • outFilePath: optional argument; overrides the complete path, which means that defFilePath, outDirPath and outFileName are ignored. The three optional arguments are typically (but not necessarily) supplied by the caller of the immediate caller.
  • suffix: required argument; string or sequence of strings listing the allowed suffixes for the returned path (including the leading "." in each suffix). If the path resulting from the above rules does not already has one of the specified suffixes, the suffix of the path will be replaced by the first (or only) specified suffix.

The three input paths may be specified as a string or as a pathlib.Path object. If the input path is relative, it is interpreted relative to the current working directory. If it starts with a tilde, the tilde is expanded to the home directory of the current user.

◆ skirtPath()

def pts.utils.path.skirtPath ( )

This function returns the absolute path to the SKIRT executable built as part of the project structure including this PTS source file, or None if no executable is found.

The function assumes that a SKIRT release version is built under a ~/SKIRT9 or SKIRT directory in the directory returned by the projectParent() function. The SKIRT9 directory is tried first.