Time series plotting example

This example shows how easy it is to plot BayEOS Server series using the matplotlib package. The first step is to import all necessary python packages. In addition to our previous examples we need the matplotlib package and the appropriate magic to show the plot inline.


In [1]:
%matplotlib inline
import datetime as dt
import numpy as np
import bayeos.cli as bayeos
import matplotlib.pyplot as plt

Let's connect to our server and change our current folder to Alle Messungen/Micrometeorology Dept/AWS Ecological Botanical Garden/AWS EBG Data start May 08, 1997/Lufttemperatur & Feuchte


In [2]:
bayeos.connect('guest@bayeos')
bayeos.cd(36076)


Open connection to http://bayeos.bayceer.uni-bayreuth.de/BayEOS-Server/XMLServlet as user gast
Alle Messungen/Micrometeorology Dept/AWS Ecological Botanical Garden/AWS EBG Data start May 08, 1997/Lufttemperatur & Feuchte
14294     |..
2718      |Lufttemperatur 02 m Höhe (HMP45)                  |messung_massendaten |1997-05-08 06:00:00 |2014-08-26 14:30:00 
2717      |Relative Luftfeuchte 02 m Höhe (HMP45)            |messung_massendaten |1997-05-08 06:00:00 |2014-08-26 14:30:00 

Fetch the data of the current folder by calling the getSeries() function.


In [3]:
data = bayeos.getSeries(aggfunc='avg',aggint='month',interval='this year')


Fetching data of series:[2718, 2717]
Rows fetched:8

Access the first column by it's name.


In [4]:
d = data['Lufttemperatur 02 m Höhe (HMP45)']

Create the dateTime values based on the transfered values.


In [5]:
i = [dt.datetime.fromtimestamp(t) for t in data['dateTime']]

Plot the data inline


In [6]:
plt.figure(figsize=[16,9])
plt.plot(i,d)


Out[6]:
[<matplotlib.lines.Line2D at 0x6faf0b8>]

In [7]:
bayeos.disconnect()


Close connection
Out[7]:
True

In [7]: