devel:brewerpythonmodule
Differences
This shows you the differences between two versions of the page.
| devel:brewerpythonmodule [2015/10/22 10:32] – [measure] ajberjon | devel:brewerpythonmodule [2022/10/20 08:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Brewer Python | + | ====== Brewer Python |
| - | We describe here the functions and data structured implemented in brewer.py module. The last version of the python | + | We describe here the functions and data structured implemented in brewer.py |
| ===== Installation ===== | ===== Installation ===== | ||
| Line 20: | Line 20: | ||
| ===== Data structures ===== | ===== Data structures ===== | ||
| - | Functions from // | + | Functions from // |
| ==== 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 |
| ^ Field ^ Description ^ | ^ Field ^ Description ^ | ||
| Line 67: | Line 67: | ||
| ==== uv ==== | ==== uv ==== | ||
| - | Dictionary containing values of the UV Brewer measurements, | + | Dictionary containing values of the UV Brewer measurements, |
| ^ 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 |
| ^ 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 |
| ^ Field ^ Description ^ | ^ Field ^ Description ^ | ||
| Line 176: | Line 176: | ||
| ^ Function ^ Short Description ^ | ^ Function ^ Short Description ^ | ||
| ^ [[devel: | ^ [[devel: | ||
| - | ^ [[devel: | + | ^ [[devel: |
| + | ^ [[devel: | ||
| + | ^ [[devel: | ||
| ^ [[devel: | ^ [[devel: | ||
| + | ^ [[devel: | ||
| ^ [[devel: | ^ [[devel: | ||
| ^ [[devel: | ^ [[devel: | ||
| Line 210: | Line 213: | ||
| * //' | * //' | ||
| + | |||
| + | === airmass_calcl() === | ||
| + | |||
| + | This function applies [[devel: | ||
| + | |||
| + | * //' | ||
| + | * //' | ||
| + | |||
| + | **Example** | ||
| + | import datetime | ||
| + | import brewer | ||
| + | import brewerjson | ||
| + | | ||
| + | brewerid=185 | ||
| + | user=' | ||
| + | password=' | ||
| + | date1=datetime.date(2012, | ||
| + | date2=datetime.date(2012, | ||
| + | ds=brewerjson.getDataList(brewerid, | ||
| + | config=brewerjson.getDataList(brewerid, | ||
| + | ds=brewer.airmass_calcl(ds, | ||
| + | |||
| + | | ||
| === 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: | ||
| + | |||
| + | * //' | ||
| + | * //' | ||
| + | |||
| + | **Example** | ||
| + | import datetime | ||
| + | import brewer | ||
| + | import brewerjson | ||
| + | | ||
| + | brewerid=185 | ||
| + | user=' | ||
| + | password=' | ||
| + | date1=datetime.date(2012, | ||
| + | date2=datetime.date(2012, | ||
| + | sl=brewerjson.getDataList(brewerid, | ||
| + | config=brewerjson.getDataList(brewerid, | ||
| + | sl=brewer.instrumental_corl(sl, | ||
| + | |||
| Line 279: | Line 328: | ||
| This function returns the input //measure// dictionary, updating the following fields as described above: //' | This function returns the input //measure// dictionary, updating the following fields as described above: //' | ||
| + | |||
| + | === rayleigh_corl() === | ||
| + | |||
| + | This function applies [[devel: | ||
| + | |||
| + | * //' | ||
| + | * //' | ||
| + | |||
| + | **Example** | ||
| + | import datetime | ||
| + | import brewer | ||
| + | import brewerjson | ||
| + | | ||
| + | brewerid=185 | ||
| + | user=' | ||
| + | password=' | ||
| + | date1=datetime.date(2012, | ||
| + | date2=datetime.date(2012, | ||
| + | ds=brewerjson.getDataList(brewerid, | ||
| + | config=brewerjson.getDataList(brewerid, | ||
| + | | ||
| + | ds=brewer.airmass_calcl(ds, | ||
| + | ds=brewer.instrumental_corl(ds, | ||
| + | ds=brewer.rayleigh_corl(ds, | ||
| + | |||
| === o3_so2() === | === o3_so2() === | ||
| Line 390: | Line 464: | ||
| ^ [[devel: | ^ [[devel: | ||
| ^ [[devel: | ^ [[devel: | ||
| - | ^ [[devel: | + | ^ [[devel: |
| ^ [[devel: | ^ [[devel: | ||
| Line 435: | Line 509: | ||
| * //' | * //' | ||
| - | |||
| * //' | * //' | ||
| Line 443: | Line 516: | ||
| import brewerjson | import brewerjson | ||
| | | ||
| - | | + | brewerid=185 |
| - | params[' | + | user=' |
| - | | + | password=' |
| - | params[' | + | |
| - | params[' | + | ds=brewerjson.getDataList(brewerid, |
| - | | + | |
| - | | + | |
| - | ds = brewerjson.getdata(params) | + | |
| - | ds = brewerjson.formatDS(ds) | + | |
| | | ||
| dsf = brewer.temp_filter(ds, | dsf = brewer.temp_filter(ds, | ||
| Line 460: | Line 529: | ||
| * //' | * //' | ||
| - | |||
| * //' | * //' | ||
| Line 468: | Line 536: | ||
| import brewerjson | import brewerjson | ||
| | | ||
| - | | + | brewerid=185 |
| - | params[' | + | user=' |
| - | | + | password=' |
| - | params[' | + | |
| - | params[' | + | ds=brewerjson.getDataList(brewerid, |
| - | | + | |
| - | | + | |
| - | ds = brewerjson.getdata(params) | + | |
| - | ds = brewerjson.formatDS(ds) | + | |
| | | ||
| dsf=brewer.gmt_filter(ds, | dsf=brewer.gmt_filter(ds, | ||
| Line 485: | Line 549: | ||
| This function returns a filtered list of measurements removing outliers. It is considered as outliers all measurement which are more than //alpha// standard deviations away from the mean on either channel (//' | This function returns a filtered list of measurements removing outliers. It is considered as outliers all measurement which are more than //alpha// standard deviations away from the mean on either channel (//' | ||
| - | The function accepts two input parameters: | + | The function accepts two input parameters: |
| + | * //' | ||
| + | * //' | ||
| **Example** | **Example** | ||
| Line 492: | Line 558: | ||
| import brewerjson | import brewerjson | ||
| | | ||
| - | | + | brewerid=185 |
| - | params[' | + | user=' |
| - | | + | password=' |
| - | params[' | + | |
| - | params[' | + | ds=brewerjson.getDataList(brewerid, |
| - | | + | |
| - | | + | |
| - | ds = brewerjson.getdata(params) | + | |
| - | ds = brewerjson.formatDS(ds) | + | |
| | | ||
| dsf=brewer.outliers_filter(ds, | dsf=brewer.outliers_filter(ds, | ||
| + | |||
| + | === measure2summary() === | ||
| + | |||
| + | This function returns a list of averaged measurements to reproduce the brewer summaries from individual data, using //' | ||
| + | |||
| + | The function accepts only an input parameters: | ||
| + | * //' | ||
| + | |||
| + | **Example** | ||
| + | import datetime | ||
| + | import brewer | ||
| + | import brewerjson | ||
| + | | ||
| + | brewerid=185 | ||
| + | user=' | ||
| + | password=' | ||
| + | date1=datetime.date(2012, | ||
| + | ds=brewerjson.getDataList(brewerid, | ||
| + | | ||
| + | ds=brewer.airmass_calcl(ds, | ||
| + | ds=brewer.instrumental_corl(ds, | ||
| + | ds=brewer.rayleigh_corl(ds, | ||
| + | dss=brewer.measure2summary(ds) | ||
| + | |||
| + | |||
| + | |||
| + | === tempfit() === | ||
| + | |||
| + | This function does 8 linear regressions between instrumentally corrected measurements (//' | ||
| + | |||
| + | The function accepts two input parameters: | ||
| + | |||
| + | * //' | ||
| + | * //' | ||
| + | |||
| + | //tempfit// function returns a dictionary with 8 elements ' | ||
| + | |||
| + | * //' | ||
| + | * //' | ||
| + | * //' | ||
| + | * //' | ||
| + | * //' | ||
| + | * //' | ||
| + | |||
| + | **Example** | ||
| + | import datetime | ||
| + | import brewer | ||
| + | import brewerjson | ||
| + | | ||
| + | brewerid=185 | ||
| + | user=' | ||
| + | password=' | ||
| + | date1=datetime.date(2012, | ||
| + | date2=datetime.date(2012, | ||
| + | sl=brewerjson.getDataList(brewerid, | ||
| + | config=brewerjson.getDataList(brewerid, | ||
| + | | ||
| + | sl=brewer.instrumental_corl(sl, | ||
| + | fit=brewer.tempfit(sl, | ||
| + | |||
| + | |||
| + | === tempanalysis() === | ||
| + | |||
| + | This function calculate new temperature coefficients or apply the temperature coefficients passed as function parameters. It calculate data for ' | ||
| + | |||
| + | * //' | ||
| + | * //' | ||
| + | * //' | ||
| + | * //' | ||
| + | * //' | ||
| + | * //' | ||
| + | * //' | ||
| + | * //' | ||
| + | |||
| + | Each element old, new and zero is a dictionary which includes: | ||
| + | * //' | ||
| + | * //' | ||
| + | * //' | ||
| + | * //' | ||
| + | * //' | ||
| + | * //' | ||
| + | * //' | ||
| + | * //' | ||
| + | * //' | ||
| + | * //' | ||
| + | |||
| + | The function accepts four input parameters: | ||
| + | * //' | ||
| + | * //' | ||
| + | * //' | ||
| + | * //' | ||
| + | |||
| + | **Example** | ||
| + | import datetime | ||
| + | import brewer | ||
| + | import brewerjson | ||
| + | | ||
| + | brewerid=185 | ||
| + | user=' | ||
| + | password=' | ||
| + | date1=datetime.date(2012, | ||
| + | date2=datetime.date(2012, | ||
| + | sl=brewerjson.getDataList(brewerid, | ||
| + | config=brewerjson.getDataList(brewerid, | ||
| + | | ||
| + | ta=tempanalysis(sl, | ||
| + | ta.keys() | ||
| ==== Astronomical ==== | ==== Astronomical ==== | ||
| Line 739: | Line 908: | ||
| ^ Function ^ Short Description ^ | ^ Function ^ Short Description ^ | ||
| ^ [[devel: | ^ [[devel: | ||
| + | ^ [[devel: | ||
| + | ^ [[devel: | ||
| === wsum() === | === wsum() === | ||
| - | This function computes the weighted | + | This function computes the sum of products over two lists. Both input lists should have the same length: |
| \begin{displaymath} | \begin{displaymath} | ||
| Line 750: | Line 920: | ||
| **Example** | **Example** | ||
| + | import brewer | ||
| + | f=[1,2] | ||
| + | w=[2,3] | ||
| brewer.wsum(f, | brewer.wsum(f, | ||
| Line 756: | 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: | ||
| + | * //' | ||
| + | * //' | ||
| + | * //' | ||
| + | |||
| + | **Example** | ||
| + | |||
| + | import brewer | ||
| + | brewer.weeknum(datetime.date(2015, | ||
| + | |||
| + | === weektodate() === | ||
| + | |||
| + | This returns a tuple with the first and last days of acertain week. | ||
| + | |||
| + | The function accepts four input parameters: | ||
| + | * //' | ||
| + | * //' | ||
| + | * //' | ||
| + | * //' | ||
| + | |||
| + | **Example** | ||
| + | |||
| + | import brewer | ||
| + | brewer.weektodate(2, | ||
devel/brewerpythonmodule.1445509932.txt.gz · Last modified: 2015/10/22 10:32 by ajberjon