User Tools

Site Tools


devel:brewerjsonpythonmodule

This is an old revision of the document!


Brewer JSON Python Module

The Brewer JSON Python Module provides the functions to connect to the RBCC-E database and to download data of the different Brewer equipments.

We describe here the functions implemented in brewerjson.py module. The last version of the python module is available from rbcce subversion repository.

Installation

Brewer JSON library can be imported from python code adding the path to brewerjson.py module to the Python path (list of directories Python goes through to search for modules and files):

import sys
sys.path.append("/home/to/module/")

By default the sys.path variable includes the current directory, so if brewerjson.py is in the same directory as the Python script, the module can be directly imported.

Alternatively, you can download brewer.py file to the standard location for third-party Python modules. This location varies by platform and by how you built/installed Python itself. Typical locations are shown in the following table:

Platform Standard installation location
Windows C:\PythonXY\Lib\site-packages
Unix /usr/local/lib/pythonX.Y/site-packages

Functions

The functions of this module are:

Field Description
getDataList() Retrieve a list of dictionaries with data from RBCC-E between two dates
getdata() Retrieve raw data from RBCC-E database

getDataList()

This function retrieve a list of dictionaries with data of the registered brewers at the RBCC-E database. Arguments are berwerid, user, password, function, date1 and date2. If date2 is omitted the function returns only data of the day data1.

The returned dictionaries structures depend on the function argument value:

function Dictionaries
'getDS' measure
'getSL' measure
'getConfigsbyDate'' config

Example

  import brewerjson
  import datetime
  
  d1=datetime.date(2014,10,01)
  d2=datetime.date(2014,10,02)
  data=brewerjson.getDataList(37,'user,'password','getDS',d1,d2)

getdata()

This function retrieves brewer data using the interface described in the access functions Section. This function accepts only an argument params which is a dictionary. Mandatory elements in params are: user, password, berwerid and function. Other elements should be provided depending on the selected function. The function element refers to the different functions described in the access functions Section.

Example

  import brewerjson
  import datetime
  
  params['user']='user'
  params['password']='password'
  params['function']='getDS'
  params['brewerid']=37
  params['date']=datetime.date(2014,10,01)'
  data=brewerjson.getdata(params)

In this example we retrieve data from the url: http://rbcce.aemet.es/eubrewnet/getdata/getDS?brewerid=037&date=2014-10-01

This function returns different data structures depending on function parameter.

devel/brewerjsonpythonmodule.1445508781.txt.gz · Last modified: 2015/10/22 10:13 by ajberjon