PyFoam.RunDictionary.SampleDirectory module

Working with a directory of samples

class PyFoam.RunDictionary.SampleDirectory.SampleData(fName, name, line, index, coord, data, note='', scale=(1, 1), offset=(0, 0))[source]

Bases: object

Data from a sample-set

__call__(scaleX=1.0, scaleData=1, offsetData=0, offsetX=0)[source]

Return the data as SpreadsheetData-object

__dict__ = mappingproxy({'__weakref__': <attribute '__weakref__' of 'SampleData' objects>, '__init__': <function SampleData.__init__>, '__doc__': 'Data from a sample-set', 'isVector': <function SampleData.isVector>, '__module__': 'PyFoam.RunDictionary.SampleDirectory', 'line': <function SampleData.line>, 'domain': <function SampleData.domain>, '__repr__': <function SampleData.__repr__>, 'component': <function SampleData.component>, '__dict__': <attribute '__dict__' of 'SampleData' objects>, 'range': <function SampleData.range>, '__call__': <function SampleData.__call__>, 'time': <function SampleData.time>})
__init__(fName, name, line, index, coord, data, note='', scale=(1, 1), offset=(0, 0))[source]
Parameters:
  • fName – Name of the file
  • name – Name of the value
  • index – Index of the data in the file
  • coord – Values that identify the data (the location)
  • data – The actual data
  • scale – pair of factors with which the data is scaled when being plotted
  • offset – pair of offsets
__module__ = 'PyFoam.RunDictionary.SampleDirectory'
__repr__()[source]
__weakref__

list of weak references to the object (if defined)

component(component=None)[source]

Return the data as a number of single scalars. :param component: If None for vectors the absolute value is taken. else the number of the component

domain()[source]

Range of the data domain

isVector()[source]

Is this vector or scalar data?

line()[source]

Get the line of the sample

range(component=None)[source]

Range of the data

time()[source]

Get the time of the sample (as a string)

class PyFoam.RunDictionary.SampleDirectory.SampleDirectory(case, dirName='samples', postfixes=[], prefixes=[], valueNames=None, linePattern=None, namesFromFirstLine=False, needsExtension=True)[source]

Bases: object

A directory of sampled times

__contains__(time)[source]
__dict__ = mappingproxy({'__weakref__': <attribute '__weakref__' of 'SampleDirectory' objects>, '__init__': <function SampleDirectory.__init__>, '__doc__': 'A directory of sampled times', '__module__': 'PyFoam.RunDictionary.SampleDirectory', 'values': <function SampleDirectory.values>, 'lines': <function SampleDirectory.lines>, '__iter__': <function SampleDirectory.__iter__>, '__getitem__': <function SampleDirectory.__getitem__>, '__len__': <function SampleDirectory.__len__>, '__contains__': <function SampleDirectory.__contains__>, 'getData': <function SampleDirectory.getData>, '__dict__': <attribute '__dict__' of 'SampleDirectory' objects>})
__getitem__(time)[source]
__init__(case, dirName='samples', postfixes=[], prefixes=[], valueNames=None, linePattern=None, namesFromFirstLine=False, needsExtension=True)[source]
Parameters:
  • case – The case directory
  • dirName – Name of the directory with the samples
  • postfixes – list of possible extensions to a field name of the form

name_postfix to help splitting such field names. :param prefixes: list of possible extensions to a field name of the form prefix_name to help splitting such field names :param valueNames: List of value names. If specified then the classes do not try to determine the names automatically :param linePattern: Regular expression to determine the name of the line from the filename. The first group in the expression is the name. If unset the linename is determined automatically :param needsExtension: whether a file needs an extension

__iter__()[source]
__len__()[source]
__module__ = 'PyFoam.RunDictionary.SampleDirectory'
__weakref__

list of weak references to the object (if defined)

getData(line=None, value=None, time=None, note='', scale=(1, 1), offset=(0, 0))[source]

Get Sample sets :param line: name of the line. All if unspecified :param value: name of the sampled value. All if unspecified :param time: times for which the samples are to be got. All if unspecified :param note: A short annotation (for plots) :param scale: pair of factors with which the data is scaled when being plotted :param offset: pair of offsets

lines()[source]

Returns all the found sample lines

values()[source]

Returns all the found sampled values

class PyFoam.RunDictionary.SampleDirectory.SampleTime(sDir, time, postfixes=[], prefixes=[], valueNames=None, namesFromFirstLine=False, linePattern=None, needsExtension=True)[source]

Bases: object

A directory with one sampled time

__dict__ = mappingproxy({'__weakref__': <attribute '__weakref__' of 'SampleTime' objects>, '__init__': <function SampleTime.__init__>, '__doc__': 'A directory with one sampled time', '__module__': 'PyFoam.RunDictionary.SampleDirectory', 'determineIndex': <function SampleTime.determineIndex>, '__getitem__': <function SampleTime.__getitem__>, '__dict__': <attribute '__dict__' of 'SampleTime' objects>, 'extractLine': <function SampleTime.extractLine>, 'extractValues': <function SampleTime.extractValues>})
__getitem__(key)[source]

Get the data for a value on a specific line :param key: A tuple with the line-name and the value-name :returns: A SampleData-object

__init__(sDir, time, postfixes=[], prefixes=[], valueNames=None, namesFromFirstLine=False, linePattern=None, needsExtension=True)[source]
Parameters:
  • sDir – The sample-dir
  • time – the timename
  • postfixes – list of possible extensions to a field name of the form

name_postfix to help splitting such field names. :param prefixes: list of possible extensions to a field name of the form prefix_name to help splitting such field names

__module__ = 'PyFoam.RunDictionary.SampleDirectory'
__weakref__

list of weak references to the object (if defined)

determineIndex(fName, vName, data)[source]

Determines the index of the data from the filename and a dataset :param fName: name of the file :param vName: Name of the quantity :param data: A list with the data :returns: A tuple of a boolean (whether the data is supposed to be a vector or a scalar) and an integer (the index of the data set - or the first component of the vector

extractLine(fName)[source]

Extract the name of the line from a filename

extractValues(fName)[source]

Extracts the names of the contained Values from a filename