polyfemos.front.sohplot.datacontainer.DataContainer

class polyfemos.front.sohplot.datacontainer.DataContainer(track_datalen=False, remove_identicals=False)[source]

Bases: object

A class to handle timeseries data consisting of DataPoint instances.

The class has __setitem__ and __getitem__ methods so it works like dictionary on that part.

Public Methods

__init__(track_datalen=False, remove_identicals=False)[source]
Parameters
  • track_datalen (bool, optional) – Defaults to False, If True, the amount of datapoints, nans, etc., is monitored.

  • remove_identicals (bool, optional) – defaults to False. If True, values with identical x and y values are removed.

add2info(str_)[source]
Parameters

str_ (str) – A notes appended to self.__info list

add_identical_removal_info()[source]

Adds original datapoint and nan amounts and identical datapoint information to self.__info.

append(dp)[source]

If self.remove_identicals is True, the datapoint is not included if it has identical x and y values as one of the already added datapoints.

Parameters

value (DataPoint) – Addends DataPoint instance to self.datapoints

count_nans()[source]
Return type

int

Returns

A count of nan values in self.datapoints list

decimate()[source]

Decimates self.datapoints list by removing datapoints so that the after decimation, the amount of datapoints in the list is not over decimation_limit, which is set to 10000.

Bokeh can plot 10000 datapoints with relative ease but more datapoints than that will result in slow plotting.

get_info()[source]
Return type

list

Returns

A list containing the info notes

get_ys_wo_nans(force=False)[source]
Parameters

force (bool, optional) – defaults to False, if True the returned list is recalculated in every case.

Return type

list

Returns

A list containing y values of DataPoint instances excluding nan values

outlier_removal(outlierremfunc)[source]

Applies advanced outlier removal to datapoints attribute. Changes y values of outlying datapoints into nan, while simultaneously creating dataset self.outlier_datapoints, which contains the outliers.

Some functions for removing outliers are in outlierremover.

Parameters

outlierremfunc (func) – a function to remove outliers, arguments of the outlierremfunc has to be predefined, except the actual data.

remove_irrationals(irlims=None)[source]

If DataPoint instance’s y value is not within the interval (including both ends) defined by irlims, the y is set to nan in place.

Parameters

irlims (list) – lower and upper limit for irrational values

sort()[source]

Sorts self.datapoints comparing timestamp values

Special Methods

__len__()[source]
Return type

int

Returns

length of self.datapoints