Package fieldpy :: Package core :: Module extra_classes :: Class TimeSeries
[hide private]
[frames] | no frames]

Class TimeSeries

source code


A class to hold time series data. In self.data['time'] has to be the monotonically increasing times.

Instance Methods [hide private]
 
__init__(self)
Sets up the basic structure
source code
 
check(self)
Do integrity checks; should be invoked at the end of __init__ [NOT IMPLEMENTED]
source code
 
check_monotonically_inc_time(self)
Checks whether the times in self.data['time'] are monotonically increasing.
source code
 
check_constant_sampling_interval(self)
Checks whether sampling interval in self.data['time'] is constant.
source code
 
plot_ts(self, var_name=None, ax=None, fmt='-', **plot_kwargs)
Plots the time series data for var_name.
source code
 
plot_date(self, var_name=None, ax=None, fmt='-', **plot_kwargs)
Plots the time series data for var_name with plt.plot_date.
source code
 
time_filter_gauss(self, field, output_field, time_window=0.021)
Filters the self.data[field] with a weighted moving average filter.
source code
list of np.array
filter_and_resample(self, field, filter_window, new_sample_int, first_sample=None, modify_instance=False)
Filters and resamples a time signal with a running average in a given time intervall +/-filter_window/2.
source code
 
get_ind(self, times)
This is the index function you want to use.
source code
 
get_ind_as_slice(self, times)
This function takes two times and returns a slice object such that the slice includes start and end time.
source code
tuple
get_index_after(self, time)
get_index_after(t) returns the index at t or immediatly after t and the exact time corresponding to that index.
source code
tuple
get_index_before(self, time)
get_index_before(t) returns the index at t or immediately before t and the exact time corresponding to that index.
source code
tuple
get_index_nearest(self, time)
Get the index and time which is nearest to the time.
source code
 
cut_time_series(self, time_span)
This cut a piece of the timeseries out and modifies the data in place.
source code
 
integrate(self, field, start=None, end=None)
Integrates the field from start time to end time by a trapezoidal method.
source code

Inherited from Data: filter_by_freq, filter_low_pass, mask_if_true, mask_jumps, mask_jumps_one_dir, mask_value, pickle

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables [hide private]

Inherited from Data: data, md

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

Sets up the basic structure

Overrides: object.__init__
(inherited documentation)

check(self)

source code 

Do integrity checks; should be invoked at the end of __init__ [NOT IMPLEMENTED]

Overrides: Data.check
(inherited documentation)

check_monotonically_inc_time(self)

source code 

Checks whether the times in self.data['time'] are monotonically increasing. Raises an error if they are not.

check_constant_sampling_interval(self)

source code 

Checks whether sampling interval in self.data['time'] is constant. Raises an error if they are not.

plot_ts(self, var_name=None, ax=None, fmt='-', **plot_kwargs)

source code 

Plots the time series data for var_name.

Parameters:
  • var_name (string) - string of variable to be plotted
  • ax (axes object) - axes to be plotted into (default: make a new figure)
  • fmt (string) - format string to be passed to the plotter (default '-')
  • plot_kwargs - keywords arguments for plt.plot function

plot_date(self, var_name=None, ax=None, fmt='-', **plot_kwargs)

source code 

Plots the time series data for var_name with plt.plot_date.

Parameters:
  • var_name (string) - string of variable to be plotted
  • ax (axes object) - axes to be plotted into (default: make a new figure)
  • fmt (string) - format string to be passed to the plotter (default '-')
  • plot_kwargs - keywords arguments for plt.plot_date function

time_filter_gauss(self, field, output_field, time_window=0.021)

source code 

Filters the self.data[field] with a weighted moving average filter.

Appends or over-writes the field output_fild to self.data

Parameters:
  • field (string) - the name of the self.data field
  • output_field (string) - the name of the output field of self.data
  • time_window (float) - the filter window in units of self.data['time']

Note: I'm not sure how exactly the missing data are handled...

filter_and_resample(self, field, filter_window, new_sample_int, first_sample=None, modify_instance=False)

source code 

Filters and resamples a time signal with a running average in a given time intervall +/-filter_window/2. The filter has a PHASE SHIFT for a UN-equally sampled signal.

Parameters:
  • field - which field of self.data to use
  • filter_window - filter time interval
  • new_sample_int - the new sampling interval (in units of t)
  • first_sample - the time of the first sample in the resampled signal. If None (default) it is (approximatly) set to time[0]+filter_window
  • modify_instance - If true, self.data will only contain the new times and data
Returns: list of np.array
Returns [new_time, new_data]

get_ind(self, times)

source code 

This is the index function you want to use.

Parameters:
  • times - a list of times
Returns:
a list of indices nearest to the times

get_index_after(self, time)

source code 

get_index_after(t) returns the index at t or immediatly after t and the exact time corresponding to that index.

If there is no index afterwards, return (None, None).

Returns: tuple
tuple containing index and the time corresponing to that index

get_index_before(self, time)

source code 

get_index_before(t) returns the index at t or immediately before t and the exact time corresponding to that index.

If there is no index before, return (None, None).

Returns: tuple
tuple containing index and the time corresponing to that index

get_index_nearest(self, time)

source code 

Get the index and time which is nearest to the time.

Returns: tuple
tuple containing index and the time corresponing to that index

cut_time_series(self, time_span)

source code 

This cut a piece of the timeseries out and modifies the data in place.

Parameters:
  • time_span ()