User Tools

Site Tools


devel:brewerpythonmodule

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
devel:brewerpythonmodule [2015/10/22 12:31]
ajberjon [Control]
devel:brewerpythonmodule [2022/10/20 08:00] (current)
Line 1: Line 1:
-====== Brewer Python ​Module ​======+====== Brewer Python ​Library ​======
  
-We describe here the functions and data structured implemented in brewer.py module. The last version of the python ​module ​is available from [[http://​rbcce.aemet.es/​svn/​python/​libbrewer/​|rbcce subversion repository]].+We describe here the functions and data structured implemented in brewer.py ​library. A Python library to the Eubrewnet database can be found in the [[ http://​eubrewnet.aemet.es/​dokuwiki/​doku.php?​id=devel:​brewerjsonpythonmodule | brewerjson ​module ​]]. The last version of the brewer ​python ​library ​is available from [[http://​rbcce.aemet.es/​svn/​python/​libbrewer/​|rbcce subversion repository]].
  
 ===== Installation ===== ===== Installation =====
Line 20: Line 20:
 ===== Data structures ===== ===== Data structures =====
  
-Functions from //​brewer.py//​ module use four different data structures for both input and output. These structures are python dictionaries:​ //​measure//,​ //uv//, //hg//, //config// and //bdaily//.+Functions from //​brewer.py//​ module use four different data structures for both input and output. These structures are python dictionaries:​ //​measure//,​ //uv//, //hg//, //config// and //bdaily//. These structures can be generated by using [[http://​eubrewnet.aemet.es/​dokuwiki/​doku.php?​id=devel:​brewerjsonpythonmodule|brewerjson module]].
  
 ==== measure ==== ==== measure ====
-Dictionary containing values of the DS and SL Brewer measurements. Some of the dictionary fields will be used as input to the calculations of the library functions, and others will be used as the output. The values came from B files or Eubrewnet database through its JSON interface. It contains the following fields:+Dictionary containing values of the DS and SL Brewer measurements. Some of the dictionary fields will be used as input to the calculations of the library functions, and others will be used as the output. The values ​can came from B files or from Eubrewnet database through its JSON interface ​by using [[http://​eubrewnet.aemet.es/​dokuwiki/​doku.php?​id=devel:​brewerjsonpythonmodule|brewerjson module]]. It contains the following fields:
  
 ^ Field ^ Description ^ ^ Field ^ Description ^
Line 67: Line 67:
 ==== uv ==== ==== uv ====
  
-Dictionary containing values of the UV Brewer measurements,​ including uv, ux, and ua. Some of the dictionary fields will be used as input to the calculations of the library functions, and others will be used as the output. The values came from B files or Eubrewnet database through its JSON interface. It contains the following fields:+Dictionary containing values of the UV Brewer measurements,​ including uv, ux, and ua. Some of the dictionary fields will be used as input to the calculations of the library functions, and others will be used as the output. The values ​can came from B files or from Eubrewnet database through its JSON interface ​by using [[http://​eubrewnet.aemet.es/​dokuwiki/​doku.php?​id=devel:​brewerjsonpythonmodule|brewerjson module]]. It contains the following fields:
  
 ^ Field ^ Description ^ ^ Field ^ Description ^
Line 102: Line 102:
  
 ==== hg ==== ==== hg ====
-Dictionary containing values of HG Brewer calibration. The values came from B files or Eubrewnet database through its JSON interface. It contains the following fields:+Dictionary containing values of HG Brewer calibration. The values ​can came from B files or from Eubrewnet database through its JSON interface ​by using [[http://​eubrewnet.aemet.es/​dokuwiki/​doku.php?​id=devel:​brewerjsonpythonmodule|brewerjson module]]. It contains the following fields:
  
 ^ Field ^ Description ^ ^ Field ^ Description ^
Line 109: Line 109:
  
 ==== config ==== ==== config ====
-Dictionary containing values of brewer settings. The values came from B files, ICF or Eubrewnet database through its JSON interface. It contains the following fields:+Dictionary containing values of brewer settings. The values ​can came from B files, ​from ICF or from Eubrewnet database through its JSON interface ​by using [[http://​eubrewnet.aemet.es/​dokuwiki/​doku.php?​id=devel:​brewerjsonpythonmodule|brewerjson module]]. It contains the following fields:
  
 ^ Field ^ Description ^ ^ Field ^ Description ^
Line 176: Line 176:
 ^ Function ^ Short Description ^ ^ Function ^ Short Description ^
 ^ [[devel:​brewerpythonmodule#​airmass_calc| airmass_calc()]] | Calculates sun position and air mass (rayleigh and ozone) for brewer individual measurements. ^ ^ [[devel:​brewerpythonmodule#​airmass_calc| airmass_calc()]] | Calculates sun position and air mass (rayleigh and ozone) for brewer individual measurements. ^
-^ [[devel:​brewerpythonmodule#​instrumental_cor|instrumental_cor()]] | Applies instrumental corrections (darkcount, deadtime, temperature,​ filter attenuation) to brewer individual ​raw measurements. ^+^ [[devel:​brewerpythonmodule#​airmass_calcl| airmass_calcl()]] | Calculates sun position and air mass (rayleigh and ozone) for a list of brewer measurements. ^ 
 +^ [[devel:​brewerpythonmodule#​instrumental_cor|instrumental_cor()]] | Applies instrumental corrections (darkcount, deadtime, temperature,​ filter attenuation) to brewer individual ​measurements. ^ 
 +^ [[devel:​brewerpythonmodule#​instrumental_corl|instrumental_corl()]] | Applies instrumental corrections (darkcount, deadtime, temperature,​ filter attenuation) to a list of brewer ​measurements. ^
 ^ [[devel:​brewerpythonmodule#​rayleigh_cor|rayleigh_cor()]] | Applies Rayleigh corrections to brewer instrumentally corrected individual measurements. ^ ^ [[devel:​brewerpythonmodule#​rayleigh_cor|rayleigh_cor()]] | Applies Rayleigh corrections to brewer instrumentally corrected individual measurements. ^
 +^ [[devel:​brewerpythonmodule#​rayleigh_corl|rayleigh_corl()]] | Applies Rayleigh corrections to a list of brewer instrumentally corrected measurements. ^
 ^ [[devel:​brewerpythonmodule#​o3_so2|o3_so2()]] | Calculates $O_3$ and $SO_2$ from the brewer corrected individual measurements. ^ ^ [[devel:​brewerpythonmodule#​o3_so2|o3_so2()]] | Calculates $O_3$ and $SO_2$ from the brewer corrected individual measurements. ^
 ^ [[devel:​brewerpythonmodule#​o3_so2_sl|o3_so2_sl()]] | Calculates Standard Lamp correction for $O_3$ and $SO_2$. ^ ^ [[devel:​brewerpythonmodule#​o3_so2_sl|o3_so2_sl()]] | Calculates Standard Lamp correction for $O_3$ and $SO_2$. ^
Line 210: Line 213:
   * //'​airmass_rayleigh'//​. This is defined as the Rayleigh air mass, and is  calculated as the output of //​brewer_airmass()//,​ using //'​zenith_angle'//​ and a height of 5km as input.   * //'​airmass_rayleigh'//​. This is defined as the Rayleigh air mass, and is  calculated as the output of //​brewer_airmass()//,​ using //'​zenith_angle'//​ and a height of 5km as input.
  
 +
 +=== airmass_calcl() ===
 +
 +This function applies [[devel:​brewerpythonmodule#​airmass_calc| airmass_calc()]] to a list of brewer measuremments. It accepts two input parameters: //'​measure'//​ and //'​config'//​.
 +
 +  * //'​measure'//​ is a list of measurements ds, sl, etc.
 +  * //'​config'//​ is a list of dictionaries with brewer configurations.
 +
 +**Example**
 +    import datetime
 +    import brewer
 +    import brewerjson
 +    ​
 +    brewerid=185
 +    user='​user'​
 +    password='​password'​
 +    date1=datetime.date(2012,​2,​7)
 +    date2=datetime.date(2012,​2,​8)
 +    ds=brewerjson.getDataList(brewerid,​user,​password,"​DS",​date1,​date2)
 +    config=brewerjson.getDataList(brewerid,​user,​password,"​ConfigbyDate",​date1,​date2)
 +    ds=brewer.airmass_calcl(ds,​config)
 +
 +  ​
  
 === instrumental_cor() === === instrumental_cor() ===
Line 245: Line 271:
     * $double\_ratio1 = \sum_{i} measure\_w_i * w\_so2_{i+1} $     * $double\_ratio1 = \sum_{i} measure\_w_i * w\_so2_{i+1} $
     * $double\_ratio2 = \sum_{i} measure\_w_i * w\_o3_{i+1} $     * $double\_ratio2 = \sum_{i} measure\_w_i * w\_o3_{i+1} $
 +
 +
 +=== instrumental_corl() ===
 +
 +This function applies [[devel:​brewerpythonmodule#​instrumental_cor()| instrumental_cor()]] to a list of brewer measuremments. It accepts two input parameters: //'​measure'//​ and //'​config'//​.
 +
 +  * //'​measure'//​ is a list of measurements ds, sl, etc.
 +  * //'​config'//​ is a list of dictionaries with brewer configurations.
 +
 +**Example**
 +    import datetime
 +    import brewer
 +    import brewerjson
 +    ​
 +    brewerid=185
 +    user='​user'​
 +    password='​password'​
 +    date1=datetime.date(2012,​2,​7)
 +    date2=datetime.date(2012,​2,​8)
 +    sl=brewerjson.getDataList(brewerid,​user,​password,"​SL",​date1,​date2)
 +    config=brewerjson.getDataList(brewerid,​user,​password,"​ConfigbyDate",​date1,​date2)
 +    sl=brewer.instrumental_corl(sl,​config)
 +
  
  
Line 279: Line 328:
  
 This function returns the input //measure// dictionary, updating the following fields as described above: //'​measure_w1'//,​ //'​measure_w2'//,​ //'​measure_w3'//,​ //'​measure_w4'//,​ //'​measure_w5'//,​ //'​single_ratio1'//,​ //'​single_ratio2'//,​ //'​single_ratio3'//,​ //'​single_ratio4'//,​ //'​double_ratio1'//​ and //'​double_ratio2'//​. This function returns the input //measure// dictionary, updating the following fields as described above: //'​measure_w1'//,​ //'​measure_w2'//,​ //'​measure_w3'//,​ //'​measure_w4'//,​ //'​measure_w5'//,​ //'​single_ratio1'//,​ //'​single_ratio2'//,​ //'​single_ratio3'//,​ //'​single_ratio4'//,​ //'​double_ratio1'//​ and //'​double_ratio2'//​.
 +
 +=== rayleigh_corl() ===
 +
 +This function applies [[devel:​brewerpythonmodule#​irayleigh_corl()| rayleigh_corl()]] to a list of brewer instrumentally corrected measurements. It accepts two input parameters: //'​measure'//​ and //'​config'//​.
 +
 +  * //'​measure'//​ is a list of measurements ds, sl, etc.
 +  * //'​config'//​ is a list of dictionaries with brewer configurations.
 +
 +**Example**
 +    import datetime
 +    import brewer
 +    import brewerjson
 +  ​
 +    brewerid=185
 +    user='​user'​
 +    password='​password'​
 +    date1=datetime.date(2012,​2,​7)
 +    date2=datetime.date(2012,​2,​8)
 +    ds=brewerjson.getDataList(brewerid,​user,​password,"​DS",​date1,​date2)
 +    config=brewerjson.getDataList(brewerid,​user,​password,"​ConfigbyDate",​date1,​date2)
 +    ​
 +    ds=brewer.airmass_calcl(ds,​config)
 +    ds=brewer.instrumental_corl(ds,​config)
 +    ds=brewer.rayleigh_corl(ds,​config)
 +
  
 === o3_so2() === === o3_so2() ===
Line 442: Line 516:
     import brewerjson     import brewerjson
     ​     ​
-    ​ds=brewerjson.getDataList(185,'​user'​,'​password'​,"​getDS",​datetime.date(2012,​2,​7)) ​  ​+    ​brewerid=185 
 +    user='​user'​ 
 +    password='​password'​ 
 +    date1=datetime.date(2012,​2,​7) 
 +    ds=brewerjson.getDataList(brewerid,​user,​password,"​DS",​date1) 
 +    ​
     dsf = brewer.temp_filter(ds,​[20])     dsf = brewer.temp_filter(ds,​[20])
  
Line 457: Line 536:
     import brewerjson     import brewerjson
     ​     ​
-    ​ds=brewerjson.getDataList(185,'​user'​,'​password'​,"​getDS",​datetime.date(2012,​2,​7))+    ​brewerid=185 
 +    user='​user'​ 
 +    password='​password'​ 
 +    date1=datetime.date(2012,​2,​7) 
 +    ds=brewerjson.getDataList(brewerid,​user,​password,"​DS",​date1) 
 +    ​
     dsf=brewer.gmt_filter(ds,​[datetime.datetime(2012,​ 2, 7, 12, 0, 0),​datetime.datetime(2012,​ 2, 7, 15, 0, 0)])     dsf=brewer.gmt_filter(ds,​[datetime.datetime(2012,​ 2, 7, 12, 0, 0),​datetime.datetime(2012,​ 2, 7, 15, 0, 0)])
  
Line 474: Line 558:
     import brewerjson     import brewerjson
     ​     ​
-    ​ds=brewerjson.getDataList(185,'​user'​,'​password'​,"​getDS",​datetime.date(2012,​2,​7))+    ​brewerid=185 
 +    user='​user'​ 
 +    password='​password'​ 
 +    date1=datetime.date(2012,​2,​7) 
 +    ds=brewerjson.getDataList(brewerid,​user,​password,"​DS",​date1) 
 +    ​
     dsf=brewer.outliers_filter(ds,​3)     dsf=brewer.outliers_filter(ds,​3)
  
Line 489: Line 578:
     import brewerjson     import brewerjson
     ​     ​
-    ​ds=brewerjson.getDataList(185,'​user'​,'​password'​,"​getDS",​datetime.date(2012,​2,​7),​datetime.date(2012,​2,​9)+    ​brewerid=185 
-    ​config=brewerjson.getDataList(185,'user','password',"getConfigsbyDate",datetime.date(2012,​2,​7),​datetime.date(2012,​2,​9))+    user='​user'​ 
 +    password='​password'​ 
 +    date1=datetime.date(2012,​2,​7) 
 +    ​ds=brewerjson.getDataList(brewerid,​user,​password,"​DS",date1)
     ​     ​
     ds=brewer.airmass_calcl(ds,​config)     ds=brewer.airmass_calcl(ds,​config)
Line 522: Line 614:
     import brewerjson     import brewerjson
     ​     ​
-    ​sl=brewerjson.getDataList(185,'​user'​,'​password',​"​getSL"​,​datetime.date(2012,​2,​7)+    ​brewerid=185 
-    ​config=brewerjson.getDataList(185,'user','password',"getConfigsbyDate",datetime.date(2012,2,7))+    user='​user'​ 
 +    password='​password'​ 
 +    date1=datetime.date(2012,2,7) 
 +    date2=datetime.date(2012,​2,​8
 +    ​sl=brewerjson.getDataList(brewerid,​user,​password,"​SL",date1,​date2) 
 +    config=brewerjson.getDataList(brewerid,user,password,"​ConfigbyDate",​date1,​date2)
     ​     ​
     sl=brewer.instrumental_corl(sl,​config)     sl=brewer.instrumental_corl(sl,​config)
Line 531: Line 628:
 === tempanalysis() === === tempanalysis() ===
  
-This function calculate new temperature coefficients or apply the temperature coefficients passed as function ​parameter. It calculate data for '​old',​ '​zero'​ and '​new'​ temperature coefficients. The output of the //​tempanalysis()//​ function is a dictionary which includes:+This function calculate new temperature coefficients or apply the temperature coefficients passed as function ​parameters. It calculate data for '​old',​ '​zero'​ and '​new'​ temperature coefficients. The output of the //​tempanalysis()//​ function is a dictionary which includes:
  
- that has three elements referred to data with different TC: old, new and zero. The function also gives the following parameters: 
   * //'​old'//​ is a dictionay with data from temperature fit when old temperature coefficients are applied   * //'​old'//​ is a dictionay with data from temperature fit when old temperature coefficients are applied
   * //'​zero'//​ is a dictionay with data from temperature fit when zero temperature coefficients are applied   * //'​zero'//​ is a dictionay with data from temperature fit when zero temperature coefficients are applied
Line 566: Line 662:
     import brewerjson     import brewerjson
     ​     ​
-    ​sl=brewerjson.getDataList(185,'​user'​,'​password'​,"​getSL",​datetime.date(2012,​2,​7),datetime.date(2012,​2,​20)+    ​brewerid=185 
-    ​config=brewerjson.getDataList(185,'user','password',"getConfigsbyDate",datetime.date(2012,2,​7),​datetime.date(2012,​2,​20)+    user='​user'​ 
-    ​ta=tempanalysis(sl,config,[],0)+    password='​password'​ 
 +    date1=datetime.date(2012,​2,​7) 
 +    date2=datetime.date(2012,​2,​8
 +    ​sl=brewerjson.getDataList(brewerid,​user,​password,"​SL",date1,date2
 +    ​config=brewerjson.getDataList(brewerid,user,​password,"​ConfigbyDate"​,date1,date2)
     ​     ​
 +    ta=tempanalysis(sl,​config,​[],​0)
     ta.keys()     ta.keys()
  
Line 807: Line 908:
 ^ Function ^ Short Description ^ ^ Function ^ Short Description ^
 ^ [[devel:​brewerpythonmodule#​wsum|wsum()]] | Returns the weighted sum from all measurements on a list. ^ ^ [[devel:​brewerpythonmodule#​wsum|wsum()]] | Returns the weighted sum from all measurements on a list. ^
 +^ [[devel:​brewerpythonmodule#​weeknum|weeknum()]] | Returns the weighted sum from all measurements on a list. ^ 
 +^ [[devel:​brewerpythonmodule#​weektodate|weektodate()]] | Returns the weighted sum from all measurements on a list. ^
  
 === wsum() === === wsum() ===
  
-This function computes the weighted ​sum from all measurements on a list. Both input lists, measurements and weights, ​should have the same length:+This function computes the sum of products over two lists. Both input lists should have the same length:
  
 \begin{displaymath} \begin{displaymath}
Line 818: Line 920:
  
 **Example** **Example**
 +    import brewer
 +    f=[1,2]
 +    w=[2,3]
     brewer.wsum(f,​w)     brewer.wsum(f,​w)
  
Line 824: Line 929:
 The //wsum()// function returns a //float// with the weighted sum value. The //wsum()// function returns a //float// with the weighted sum value.
  
 +=== weeknum() ===
 +
 +This function calculate the week number of year. It is based in the matlab function of the same name.
 +
 +The function accepts three input parameters: ​
 +  * //'​d'//​ is a date
 +  * //'​w'//​ is an integer repressenting the week start value (Sunday:1, Monday:2, Tuesday:3, Wednesday:​4,​ Thursday:5, Friday:6, Saturday:7)
 +  * //'​e'//​ is a bool to use or not use European standard
 +
 +**Example**
 +
 +    import brewer
 +    brewer.weeknum(datetime.date(2015,​1,​5),​1,​False)
 +
 +=== weektodate() ===
 +
 +This returns a tuple with the first and last days of acertain week.
 +
 +The function accepts four input parameters: ​
 +  * //'​n'//​ is an integer representing the week number
 +  * //'​yrs'//​ is an integer representing the year
 +  * //'​w'//​ is an integer repressenting the week start value (Sunday:1, Monday:2, Tuesday:3, Wednesday:​4,​ Thursday:5, Friday:6, Saturday:7)
 +  * //'​e'//​ is a bool to use or not use European standar
 +
 +**Example**
 +
 +    import brewer
 +    brewer.weektodate(2,​2015,​1,​False)
  
devel/brewerpythonmodule.1445517096.txt.gz · Last modified: 2015/10/22 12:31 by ajberjon