Example #1
0
 def __init__(self, params, calib_data, hourly_data, daily_data,
              monthly_data):
     self.logger = logging.getLogger('pywws.Tasks.RegularTasks')
     self.params = params
     self.calib_data = calib_data
     self.hourly_data = hourly_data
     self.daily_data = daily_data
     self.monthly_data = monthly_data
     # get directories
     self.work_dir = self.params.get('paths', 'work', '/tmp/weather')
     self.template_dir = self.params.get(
         'paths', 'templates', os.path.expanduser('~/weather/templates/'))
     self.graph_template_dir = self.params.get(
         'paths', 'graph_templates',
         os.path.expanduser('~/weather/graph_templates/'))
     # create calibration object
     self.calibrator = Calib(self.params)
     # create templater object
     self.templater = Template.Template(self.params, self.calib_data,
                                        self.hourly_data, self.daily_data,
                                        self.monthly_data)
     # create plotter objects
     self.plotter = Plot.GraphPlotter(self.params, self.calib_data,
                                      self.hourly_data, self.daily_data,
                                      self.monthly_data, self.work_dir)
     self.roseplotter = WindRose.RosePlotter(self.params, self.calib_data,
                                             self.hourly_data,
                                             self.daily_data,
                                             self.monthly_data,
                                             self.work_dir)
     # directory of service uploaders
     self.services = dict()
     # create a YoWindow object
     self.yowindow = YoWindow.YoWindow(self.calib_data)
     # get local time's offset from UTC, without DST
     now = self.calib_data.before(datetime.max)
     if not now:
         now = datetime.now()  # was kenmc utcnow
     time_offset = Local.utcoffset(now) - Local.dst(now)
     print "Time Offset = %s" % time_offset
     # get daytime end hour, in UTC
     self.day_end_hour = eval(params.get('config', 'day end hour', '21'))
     self.day_end_hour = (self.day_end_hour -
                          (time_offset.seconds / 3600)) % 24
     # convert config from underground/metoffice to new services
     for section in ('live', 'logged', 'hourly', '12 hourly', 'daily'):
         services = eval(self.params.get(section, 'services', '[]'))
         for svc in ('underground', 'metoffice'):
             if self.params.get(section, svc) == 'True':
                 if svc not in services:
                     services.append(svc)
             self.params._config.remove_option(section, svc)
         self.params.set(section, 'services', str(services))
     # create service uploader objects
     for section in ('live', 'logged', 'hourly', '12 hourly', 'daily'):
         for service in eval(self.params.get(section, 'services', '[]')):
             if service not in self.services:
                 self.services[service] = ToService(self.params,
                                                    self.calib_data,
                                                    service_name=service)
Example #2
0
    def __init__(self, params, calib_data, hourly_data, daily_data, monthly_data):
        self.logger = logging.getLogger('pywws.Tasks.RegularTasks')
        self.params = params
        self.calib_data = calib_data
        self.hourly_data = hourly_data
        self.daily_data = daily_data
        self.monthly_data = monthly_data
        # get directories
        self.work_dir = self.params.get('paths', 'work', '/tmp/weather')
        self.template_dir = self.params.get(
            'paths', 'templates', os.path.expanduser('~/weather/templates/'))
        self.graph_template_dir = self.params.get(
            'paths', 'graph_templates', os.path.expanduser('~/weather/graph_templates/'))
        # create calibration object
        self.calibrator = Calib(self.params)
        # create templater object
        self.templater = Template.Template(
            self.params, self.calib_data, self.hourly_data, self.daily_data,
            self.monthly_data)
        # create plotter objects
        self.plotter = Plot.GraphPlotter(
            self.params, self.calib_data, self.hourly_data, self.daily_data,
            self.monthly_data, self.work_dir)
        self.roseplotter = WindRose.RosePlotter(
            self.params, self.calib_data, self.hourly_data, self.daily_data,
            self.monthly_data, self.work_dir)
        # directory of service uploaders
        self.services = dict()
        # create a YoWindow object
        self.yowindow = YoWindow.YoWindow(self.calib_data)
        # get local time's offset from UTC, without DST
        now = self.calib_data.before(datetime.max)
        if not now:
            now = datetime.now() # was kenmc utcnow 
        time_offset = Local.utcoffset(now) - Local.dst(now)
	print "Time Offset = %s" % time_offset
        # get daytime end hour, in UTC
        self.day_end_hour = eval(params.get('config', 'day end hour', '21'))
        self.day_end_hour = (self.day_end_hour - (time_offset.seconds / 3600)) % 24
        # convert config from underground/metoffice to new services
        for section in ('live', 'logged', 'hourly', '12 hourly', 'daily'):
            services = eval(self.params.get(section, 'services', '[]'))
            for svc in ('underground', 'metoffice'):
                if self.params.get(section, svc) == 'True':
                    if svc not in services:
                        services.append(svc)
                self.params._config.remove_option(section, svc)
            self.params.set(section, 'services', str(services))
        # create service uploader objects
        for section in ('live', 'logged', 'hourly', '12 hourly', 'daily'):
            for service in eval(self.params.get(section, 'services', '[]')):
                if service not in self.services:
                    self.services[service] = ToService(
                        self.params, self.calib_data, service_name=service)
Example #3
0
def Process(params, raw_data, calib_data, hourly_data, daily_data,
            monthly_data):
    """Generate summaries from raw weather station data.

    The meteorological day end (typically 2100 or 0900 local time) is
    set in the preferences file ``weather.ini``. The default value is
    2100 (2200 during DST), following the historical convention for
    weather station readings.

    """
    logger = logging.getLogger('pywws.Process')
    logger.info('Generating summary data')
    # get time of last record
    last_raw = raw_data.before(datetime.max)
    if last_raw is None:
        raise IOError('No data found. Check data directory parameter.')
    # get local time's offset from UTC, without DST
    time_offset = Local.utcoffset(last_raw) - Local.dst(last_raw)
    # set daytime end hour, in UTC
    day_end_hour = eval(params.get('config', 'day end hour', '21'))
    day_end_hour = (day_end_hour - (time_offset.seconds / 3600)) % 24
    # divide 24 hours of UTC day into day and night
    daytime = []
    for i in range(24):
        daytime.append(True)
    night_hour = (21 - (time_offset.seconds / 3600)) % 24
    for i in range(12):
        daytime[night_hour] = False
        night_hour = (night_hour + 1) % 24
    # calibrate raw data
    start = calibrate_data(logger, params, raw_data, calib_data)
    # generate hourly data
    start = generate_hourly(logger, calib_data, hourly_data, start)
    # generate daily data
    start = generate_daily(logger, day_end_hour, daytime, calib_data,
                           hourly_data, daily_data, start)
    # generate monthly data
    generate_monthly(logger, day_end_hour, time_offset, daily_data,
                     monthly_data, start)
    return 0
Example #4
0
def Process(params, raw_data, calib_data, hourly_data, daily_data, monthly_data):
    """Generate summaries from raw weather station data.

    The meteorological day end (typically 2100 or 0900 local time) is
    set in the preferences file ``weather.ini``. The default value is
    2100 (2200 during DST), following the historical convention for
    weather station readings.

    """
    logger = logging.getLogger('pywws.Process')
    logger.info('Generating summary data')
    # get time of last record
    last_raw = raw_data.before(datetime.max)
    if last_raw is None:
        raise IOError('No data found. Check data directory parameter.')
    # get local time's offset from UTC, without DST
    time_offset = Local.utcoffset(last_raw) - Local.dst(last_raw)
    # set daytime end hour, in UTC
    day_end_hour = eval(params.get('config', 'day end hour', '21'))
    day_end_hour = (day_end_hour - (time_offset.seconds / 3600)) % 24
    # divide 24 hours of UTC day into day and night
    daytime = []
    for i in range(24):
        daytime.append(True)
    night_hour = (21 - (time_offset.seconds / 3600)) % 24
    for i in range(12):
        daytime[night_hour] = False
        night_hour = (night_hour + 1) % 24
    # calibrate raw data
    start = calibrate_data(logger, params, raw_data, calib_data)
    # generate hourly data
    start = generate_hourly(logger, calib_data, hourly_data, start)
    # generate daily data
    start = generate_daily(logger, day_end_hour, daytime,
                           calib_data, hourly_data, daily_data, start)
    # generate monthly data
    generate_monthly(logger, day_end_hour, time_offset,
                     daily_data, monthly_data, start)
    return 0