PyFoam.Basics.SpreadsheetData module¶
Data that can go into a spreadsheet (title line and rectangular data)
-
class
PyFoam.Basics.SpreadsheetData.
SpreadsheetData
(timeName=None, validData=None, validMatchRegexp=False, csvName=None, txtName=None, excelName=None, data=None, names=None, isSampleFile=False, skip_header=0, stripCharacters=None, replaceFirstLine=None, title=None)[source]¶ Bases:
object
Collects data that could go into a spreadsheet. The focus of this class is on storing all the data at once
-
__call__
(t, name=None, time=None, invalidExtend=False, noInterpolation=False)[source]¶ ‘Evaluate’ the data at a specific time by linear interpolation :param t: the time at which the data should be evaluated :param name: name of the data column to be evaluated. Assumes that that column is ordered in ascending order. If unspecified a dictionary with the values from all columns is returned :param time: name of the time column. If none is given then the first column is assumed :param invalidExtend: if t is out of the valid range then use the smallest or the biggest value. If False use nan :param noInterpolation: if t doesn’t exactly fit a data-point return ‘nan’
-
__dict__
= mappingproxy({'addTimes': <function SpreadsheetData.addTimes>, '__init__': <function SpreadsheetData.__init__>, 'append': <function SpreadsheetData.append>, 'writeCSV': <function SpreadsheetData.writeCSV>, '__module__': 'PyFoam.Basics.SpreadsheetData', 'rename': <function SpreadsheetData.rename>, 'validName': <function SpreadsheetData.validName>, 'resample': <function SpreadsheetData.resample>, 'size': <function SpreadsheetData.size>, 'timeName': <function SpreadsheetData.timeName>, 'tRange': <function SpreadsheetData.tRange>, 'names': <function SpreadsheetData.names>, '__call__': <function SpreadsheetData.__call__>, 'recalcData': <function SpreadsheetData.recalcData>, '__weakref__': <attribute '__weakref__' of 'SpreadsheetData' objects>, '__doc__': '\n Collects data that could go into a spreadsheet. The focus of this class is on\n storing all the data at once\n ', 'compare': <function SpreadsheetData.compare>, '__add__': <function SpreadsheetData.__add__>, '__dict__': <attribute '__dict__' of 'SpreadsheetData' objects>, 'getSeries': <function SpreadsheetData.getSeries>, 'getData': <function SpreadsheetData.getData>, 'metrics': <function SpreadsheetData.metrics>, 'join': <function SpreadsheetData.join>})¶
-
__init__
(timeName=None, validData=None, validMatchRegexp=False, csvName=None, txtName=None, excelName=None, data=None, names=None, isSampleFile=False, skip_header=0, stripCharacters=None, replaceFirstLine=None, title=None)[source]¶ Either this is constructed from a file or from the data and the column headers
Parameters: - timeName – the data colum that is to be considered the time in this file
- validData – names of the valid data columns (all others should be discarded)
- validMatchRegexp – Should the validData be interpreted as regular expressions
- csvName – name of the CSV-file the data should be constructed from,
- txtName – name of a file the data should be constructed from,
- excelName – name of a Excel-file the data should be constructed from (uses the first sheet in the file),
- data – the actual data to use
- names – the names for the column header
- isSampleFile – file produced by sample/set. Field names are determined from the filename
- stripCharacters – String with characters that should be removed before reading
- replaceFirstLine – String with a line that should replace the first line (usually to replace the header)
- title – a name that is used to make unique heades names
-
__module__
= 'PyFoam.Basics.SpreadsheetData'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
addTimes
(times, time=None, interpolate=False, invalidExtend=False)[source]¶ Extend the data so that all new times are represented (add rows if they are not there) :param time: the name of the column with the time :param times: the times that shoild be there :param interpolate: interpolate the data in new rows. Otherwise insert ‘nan’ :param invalidExtend: if t is out of the valid range then use the smallest or the biggest value. If False use nan
-
append
(name, data, allowDuplicates=False)[source]¶ Add another column to the data. Assumes that the number of rows is right :param name: the name of the column :param data: the actual data :param allowDuplicates: If the name already exists make it unique by appending _1, _2 ...
-
compare
(other, name, otherName=None, time=None, common=False, minTime=None, maxTime=None)[source]¶ Compare this data-set with another. The time-points of this dataset are used as a reference. Returns a dictionary with a number of norms: maximum absolute difference, average absolute difference on all timepoints, average absolute difference weighted by time :param other: the other data-set :param name: name of the data column to be evaluated. Assumes that that column is ordered in ascending order :param time: name of the time column. If none is given then the first column is assumed :param common: cut off the parts where not both data sets are defined :param minTime: first time which should be compared :param maxTime: last time to compare
-
getData
(reindex=True)[source]¶ Return a dictionary of the data in the DataFrame format of pandas :param: drop duplicate times (setting it to False might break certain Pandas-operations)
-
getSeries
(reindex=True)[source]¶ Return a dictionary of the data-columns in the Series format of pandas :param: drop duplicate times (setting it to False might break certain Pandas-operations)
-
join
(other, time=None, prefix=None)[source]¶ Join this object with another. Assume that they have the same amount of rows and that they have one column that designates the time and is called the same and has the same values :param other: the other array :param time: name of the time. If None the first column is used :param prefix: String that is added to the other names. If none is given then the title is used
-
metrics
(name, time=None, minTime=None, maxTime=None)[source]¶ Calculates the metrics for a data set. Returns a dictionary with a number of norms: minimum, maximum, average, average weighted by time :param name: name of the data column to be evaluated. Assumes that that column is ordered in ascending order :param time: name of the time column. If none is given then the first column is assumed :param minTime: first time to take metrics from :param maxTime: latest time to take matrics from
-
recalcData
(name, expr, create=False)[source]¶ Recalc or add a column to the data :param name: the colum (must exist if it is not created. Otherwise it must not exist) :param expr: the expression to calculate. All present column names are usable as variables. There is also a variable data for subscripting if the data is not a valid variable name. If the column is not create then there is also a variable this that is an alias for the name :param create: whether a new data item should be created
-
rename
(f, renameTime=False)[source]¶ Rename all the columns according to a function. Time only if specified
-
resample
(other, name, otherName=None, time=None, invalidExtend=False, extendData=False, noInterpolation=False)[source]¶ Calculate values from another dataset at the same times as in this data-set :param other: the other data-set :param name: name of the data column to be evaluated. Assumes that that column is ordered in ascending order :param time: name of the time column. If none is given then the first column is assumed :param invalidExtend: see __call__ :param extendData: if the time range of x is bigger than the range then extend the range before resampling :param noInterpolation: if t doesn’t exactly fit a data-point return ‘nan’
-