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
-
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’
-