The cli.getSeries()
series function is without a doubt the most important package function. It is the core function to get data out of the BayEOS-Server. An active connection is necessary to call the function. Let's open a connection to our BayEOS Server by reusing the guest alias of our CLI Example.
In [1]:
from bayeos import cli as bayeos
bayeos.connect('guest@bayeos')
Out[1]:
A first look at the function definition showed, that there are several ways to call the function. The easiest approach is to navigate into a folder with data series and call the getSeries()
function with it's default arguments. This will produce a numpy array with channel columns and rows of data from yesterday until todoay for all series in your current folder.
In [2]:
bayeos.cd(36076)
In [3]:
data = bayeos.getSeries()
Let's check the type of our data variable.
In [4]:
type(data)
Out[4]:
Each numpy array contains metainformation in a property called dtype. It's up to you to reuse these properties during the analysis of your data.
In [5]:
data.dtype
Out[5]:
The first column of our data array contains values as integer. These values represent the time of observation in seconds since January 1, 1970, 00:00:00 GMT. Further columns represent the series values as Floats. You can produce python dateTime
typed values out of the first column values with the following statement:
In [6]:
import datetime as dt
dateCol = [dt.datetime.fromtimestamp(t) for t in data['dateTime']]
Series can be selected by id or a list of ids.
In [7]:
data = bayeos.getSeries(2718)
In [8]:
data = bayeos.getSeries([2718,2717])
You can filter the series values by a start and/or until value. Both parameters must fullfill the following restrictions:
Here are examples showing the different possibilities to call the function:
In [9]:
data = bayeos.getSeries([2718,2717],start='yesterday')
In [10]:
data = bayeos.getSeries([2718,2717],start='yesterday',until='today')
In [11]:
date = bayeos.getSeries([2718,2717],start='2014-08-01 00:00',until='2014-08-07 00:00')
There are several fixed time intervals defined to pick a time period:
You can use the interval name and ommit the start end until parameter to filter the data:
In [12]:
data = bayeos.getSeries([2718,2717],interval="last week")
Server side aggregated series values can be accessed by calling the getSeries()
function with aggFunc and aggInt parameters:
In [13]:
data = bayeos.getSeries([2718,2717],interval="last week",aggfunc="avg",aggint="day")
The available functions can be determined at runtime:
In [14]:
print("Aggregation functions:" + str([x for x in bayeos.getAggFunc()]))
print("Aggregation intervals:" + str([x for x in bayeos.getAggInt()]))
If set for aggegarated values, additional count columns will be added to the output array.
In [15]:
data = bayeos.getSeries([2718,2717],interval="last week",aggfunc="avg",aggint="day",csFlag=True)
If set for non aggregated values, status flag column (range(10)) will be added for each value column.
In [16]:
data = bayeos.getSeries([2718,2717],interval="last week",csFlag=True)
In [17]:
data.dtype
Out[17]: