# Path: wfcommon/formula/base.py
# class LastFormula(object):
#     '''
#     Keeps last sample value.
#     '''
# 
#     def __init__(self, index):
#         self.index = index
# 
#     index = None
#     last = None
# 
#     def append(self, sample):
#         value = sample[self.index]
#         if value is not None:
#             self.last = value
# 
#     def value(self):
#         return self.last
# 
# Path: wfcommon/formula/base.py
# class SumFormula(object):
#     '''
#     Sum.
#     '''
# 
#     def __init__(self, index):
#         self.index = index
# 
#     index = None
#     sum = 0
#     empty = True
# 
#     def append(self, sample):
#         value = sample[self.index]
#         if value is not None:
#             self.empty = False
#             self.sum = self.sum + value
# 
#     def value(self):
#         if self.empty:
#             return None
#         else:
#             return self.sum
# 
# Path: wfcommon/formula/base.py
# class MinFormula(object):
#     '''
#     Minimum.
#     '''
# 
#     def __init__(self, index):
#         self.index = index
# 
#     index = None
#     min = sys.maxint
# 
#     def append(self, sample):
#         value = sample[self.index]
#         if value is not None:
#             self.min = min(self.min, value)
# 
#     def value(self):
#         if self.min == sys.maxint:
#             return None
#         else:
#             return self.min
# 
# Path: wfcommon/formula/base.py
# class MaxFormula(object):
#     '''
#     Maximum.
#     '''
# 
#     def __init__(self, index):
#         self.index = index
# 
#     index = None
#     max = -sys.maxint
# 
#     def append(self, sample):
#         value = sample[self.index]
#         if value is not None:
#             self.max = max(self.max, value)
# 
#     def value(self):
#         if self.max == -sys.maxint:
#             return None
#         else:
#             return self.max
# 
# Path: wfcommon/units.py
# def MpsToKmh(value):
#     return value * 3.6 if value != None else None


import math
import logging
import sys
import time
import wfcommon.database
from wfcommon.formula.base import LastFormula
from wfcommon.formula.base import SumFormula
from wfcommon.formula.base import MinFormula
from wfcommon.formula.base import MaxFormula
    from wfrender.datasource.accumulator import AccumulatorDatasource
    from datasource.accumulator import AccumulatorDatasource
from wfcommon.units import MpsToKmh
                     'min_pressure' : MinFormula('pressure'),
                     'max_gust' : MaxFormula('wind_gust'),
                     'rain_fall' : SumFormula('rain') } }

                # Accumulator for monthly data
                self.accuM = AccumulatorDatasource()
                self.accuM.slice = 'month'
                self.accuM.span = 1
                self.accuM.storage = self.storage
                self.accuM.caching = True
                self.accuM.formulas = {'data': {
                     'max_temp' : MaxFormula('temp'),
                     'min_temp' : MinFormula('temp'),
                     'max_hum' : MaxFormula('hum'),
                     'min_hum' : MinFormula('hum'),
                     'max_pressure' : MaxFormula('pressure'),
                     'min_pressure' : MinFormula('pressure'),
                     'max_gust' : MaxFormula('wind_gust'),
                     'rain_fall' : SumFormula('rain') } }

                # Accumulator for daily and current data
                self.accuD = AccumulatorDatasource()
                self.accuD.slice = 'day'
                self.accuD.span = 1
                self.accuD.storage = self.storage
                self.accuD.caching = True
                self.accuD.formulas = {
                     'data': {
                         'max_temp' : MaxFormula('temp'),
                         'min_temp' : MinFormula('temp'),

# Path: wfcommon/formula/base.py
# class LastFormula(object):
#     '''
#     Keeps last sample value.
#     '''
# 
#     def __init__(self, index):
#         self.index = index
# 
#     index = None
#     last = None
# 
#     def append(self, sample):
#         value = sample[self.index]
#         if value is not None:
#             self.last = value
# 
#     def value(self):
#         return self.last
# 
# Path: wfcommon/formula/base.py
# class SumFormula(object):
#     '''
#     Sum.
#     '''
# 
#     def __init__(self, index):
#         self.index = index
# 
#     index = None
#     sum = 0
#     empty = True
# 
#     def append(self, sample):
#         value = sample[self.index]
#         if value is not None:
#             self.empty = False
#             self.sum = self.sum + value
# 
#     def value(self):
#         if self.empty:
#             return None
#         else:
#             return self.sum
# 
# Path: wfcommon/formula/base.py
# class MinFormula(object):
#     '''
#     Minimum.
#     '''
# 
#     def __init__(self, index):
#         self.index = index
# 
#     index = None
#     min = sys.maxint
# 
#     def append(self, sample):
#         value = sample[self.index]
#         if value is not None:
#             self.min = min(self.min, value)
# 
#     def value(self):
#         if self.min == sys.maxint:
#             return None
#         else:
#             return self.min
# 
# Path: wfcommon/formula/base.py
# class MaxFormula(object):
#     '''
#     Maximum.
#     '''
# 
#     def __init__(self, index):
#         self.index = index
# 
#     index = None
#     max = -sys.maxint
# 
#     def append(self, sample):
#         value = sample[self.index]
#         if value is not None:
#             self.max = max(self.max, value)
# 
#     def value(self):
#         if self.max == -sys.maxint:
#             return None
#         else:
#             return self.max
# 
# Path: wfcommon/units.py
# def MpsToKmh(value):
#     return value * 3.6 if value != None else None


# Path: wfrender/renderer/meteoclimatic.py
import math
import logging
import sys
import time
import wfcommon.database
from wfcommon.formula.base import LastFormula
from wfcommon.formula.base import SumFormula
from wfcommon.formula.base import MinFormula
from wfcommon.formula.base import MaxFormula
    from wfrender.datasource.accumulator import AccumulatorDatasource
    from datasource.accumulator import AccumulatorDatasource
from wfcommon.units import MpsToKmh

                     'min_pressure' : MinFormula('pressure'),
                     'max_gust' : MaxFormula('wind_gust'),
                     'rain_fall' : SumFormula('rain') } }

                # Accumulator for monthly data
                self.accuM = AccumulatorDatasource()
                self.accuM.slice = 'month'
                self.accuM.span = 1
                self.accuM.storage = self.storage
                self.accuM.caching = True
                self.accuM.formulas = {'data': {
                     'max_temp' : MaxFormula('temp'),
                     'min_temp' : MinFormula('temp'),
                     'max_hum' : MaxFormula('hum'),
                     'min_hum' : MinFormula('hum'),
                     'max_pressure' : MaxFormula('pressure'),
                     'min_pressure' : MinFormula('pressure'),
                     'max_gust' : MaxFormula('wind_gust'),
                     'rain_fall' : SumFormula('rain') } }

                # Accumulator for daily and current data
                self.accuD = AccumulatorDatasource()
                self.accuD.slice = 'day'
                self.accuD.span = 1
                self.accuD.storage = self.storage
                self.accuD.caching = True
                self.accuD.formulas = {
                     'data': {
                         'max_temp' : MaxFormula('temp'),
                         'min_temp' : MinFormula('temp'),

                         'max_hum' : MaxFormula('hum'),