User Tools

Site Tools


devel:brewerjsonpythonmodule

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

devel:brewerjsonpythonmodule [2016/05/18 19:56]
ajberjon
devel:brewerjsonpythonmodule [2022/10/20 08:00]
Line 1: Line 1:
-====== 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 [[http://​rbcce.aemet.es/​svn/​python/​libbrewerjson/​|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 ^ 
-^ [[devel:​brewerjsonpythonmodule#​getDataList|getDataList()]] | Retrieve a list of dictionaries with data from RBCC-E between two dates. ^ 
-^ [[devel:​brewerjsonpythonmodule#​writejson|writejson()]] | Write list of dictionaries (measures, config,..) to file. ^ 
-^ [[devel:​brewerjsonpythonmodule#​readjson|readjson()]] | Read list of dictionaries (measures, config,..) from file. ^ 
- 
-=== getDataList() === 
- 
-This function retrieve a list of [[http://​rbcce.aemet.es/​dokuwiki/​doku.php?​id=devel:​brewerpythonmodule#​data_structures|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'​ | [[http://​rbcce.aemet.es/​dokuwiki/​doku.php?​id=devel:​brewerpythonmodule#​measure|measure]] ^ 
-^ '​getSL'​ | [[http://​rbcce.aemet.es/​dokuwiki/​doku.php?​id=devel:​brewerpythonmodule#​measure|measure]] ^ 
-^ '​getConfigsbyDate''​ | [[http://​rbcce.aemet.es/​dokuwiki/​doku.php?​id=devel:​brewerpythonmodule#​config|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 [[codes:​accessfunctions|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 [[codes:​accessfunctions|access functions Section]]. 
- 
-**Example** 
-    import brewerjson 
-    import datetime 
-    ​ 
-    params={} 
-    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. 
- 
- 
- 
-=== formatConfig() === 
- 
-This function returns a [[ http://​rbcce.aemet.es/​dokuwiki/​doku.php?​id=devel:​brewerpythonmodule#​config | config ]] dictionary from the JSON interface output of the Eubrewnet database. 
- 
-**Example** 
-    import brewerjson 
-    import datetime 
-    ​ 
-    params={} 
-    params['​user'​]='​user'​ 
-    params['​password'​]='​password'​ 
-    params['​function'​]='​getConfigsbyDate'​ 
-    params['​brewerid'​]=37 
-    params['​date'​]=datetime.date(2014,​10,​01) 
-    data=brewerjson.getdata(params) 
-    config = brewerjson.formatConfig(data) 
- 
- 
-=== formatDS() === 
- 
-This function returns a [[ http://​rbcce.aemet.es/​dokuwiki/​doku.php?​id=devel:​brewerpythonmodule#​measure | measure ]] dictionary from the JSON interface output of the Eubrewnet database. 
- 
-**Example** 
-    import brewerjson 
-    import datetime 
-    ​ 
-    params={} 
-    params['​user'​]='​user'​ 
-    params['​password'​]='​password'​ 
-    params['​function'​]='​getDS'​ 
-    params['​brewerid'​]=37 
-    params['​date'​]=datetime.date(2014,​10,​01) 
-    data=brewerjson.getdata(params) 
-    ds = brewerjson.formatDS(data) 
- 
- 
-=== formatUV() === 
- 
-This function returns a [[ http://​rbcce.aemet.es/​dokuwiki/​doku.php?​id=devel:​brewerpythonmodule#​uv | uv ]] dictionary from the JSON interface output of the Eubrewnet database. 
- 
-**Example** 
-    import brewerjson 
-    import datetime 
-    ​ 
-    params={} 
-    params['​user'​]='​user'​ 
-    params['​password'​]='​password'​ 
-    params['​function'​]='​getUV'​ 
-    params['​brewerid'​]=37 
-    params['​date'​]=datetime.date(2014,​10,​01) 
-    data=brewerjson.getdata(params) 
-    uv = brewerjson.formatUV(data) 
- 
-=== formatUVR() === 
- 
-This function returns a [[ http://​rbcce.aemet.es/​dokuwiki/​doku.php?​id=devel:​brewerpythonmodule#​uvr | uvr ]] dictionary from the JSON interface output of the Eubrewnet database. 
- 
-**Example** 
-    import brewerjson 
-    import datetime 
-    ​ 
-    params={} 
-    params['​user'​]='​user'​ 
-    params['​password'​]='​password'​ 
-    params['​function'​]='​getUVR'​ 
-    params['​brewerid'​]=37 
-    params['​date'​]=datetime.date(2014,​10,​01) 
-    data=brewerjson.getdata(params) 
-    uvr = brewerjson.formatUVR(data) 
- 
  
devel/brewerjsonpythonmodule.txt ยท Last modified: 2022/10/20 08:00 (external edit)