예제 #1
0
def local_execute_example(interval, satellite, hirs2nc_delivery_id, skip_prepare=False, skip_execute=False, verbosity=2):

    setup_logging(verbosity)

    comp = setup_computation(satellite)

    # Get the required context...
    contexts =  comp.find_contexts(interval, satellite, hirs2nc_delivery_id)

    if len(contexts) != 0:
        LOG.info("Candidate contexts in interval...")
        for context in contexts:
            print("\t{}".format(context))

        try:
            if not skip_prepare:
                LOG.info("Running hirs2nc local_prepare()...")
                LOG.info("Preparing context... {}".format(contexts[0]))
                local_prepare(comp, contexts[0])
            if not skip_execute:
                LOG.info("Running hirs2nc local_execute()...")
                LOG.info("Running context... {}".format(contexts[0]))
                local_execute(comp, contexts[0])
        except Exception, err:
            LOG.error("{}".format(err))
            LOG.debug(traceback.format_exc())
def local_execute_example(interval, satellite, hirs2nc_delivery_id, hirs_avhrr_delivery_id,
                          hirs_csrb_daily_delivery_id, hirs_csrb_monthly_delivery_id,
                          hirs_ctp_orbital_delivery_id, hirs_ctp_daily_delivery_id,
                          skip_prepare=False, skip_execute=False, single=True, verbosity=2):

    setup_logging(verbosity)

    comp = setup_computation(satellite)
    #comp = hirs_ctp_daily.HIRS_CTP_DAILY()
    hirs_ctp_orbital_comp = hirs_ctp_orbital.HIRS_CTP_ORBITAL()

    # Get the required context...
    contexts = comp.find_contexts(interval, satellite, hirs2nc_delivery_id, hirs_avhrr_delivery_id,
                                  hirs_csrb_daily_delivery_id, hirs_csrb_monthly_delivery_id,
                                  hirs_ctp_orbital_delivery_id, hirs_ctp_daily_delivery_id)

    if len(contexts) != 0:
        LOG.info("Candidate contexts in interval...")
        for context in contexts:
            print("\t{}".format(context))

        if not single:

            for idx,context in enumerate(contexts):
                LOG.info('Current Dir: {} {}'.format(idx, os.getcwd()))
                try:
                    if not skip_prepare:
                        LOG.info("Running hirs_ctp_daily local_prepare()...")
                        LOG.info("Preparing context... {}".format(context))
                        local_prepare(comp, context, download_onlies=[hirs_ctp_orbital_comp])
                    if not skip_execute:
                        LOG.info("Running hirs_ctp_daily local_execute()...")
                        LOG.info("Running context... {}".format(context))
                        local_execute(comp, context, download_onlies=[hirs_ctp_orbital_comp])

                    if not skip_prepare:
                        shutil.move('inputs', 'inputs_{}'.format(idx))
                    if not skip_execute:
                        shutil.move('outputs', 'outputs_{}'.format(idx))

                except Exception, err:
                    LOG.error("{}".format(err))
                    LOG.debug(traceback.format_exc())

        else:

            LOG.info("Single context!")
            try:
                if not skip_prepare:
                    LOG.info("Running hirs_ctp_daily local_prepare()...")
                    LOG.info("Preparing context... {}".format(contexts[0]))
                    local_prepare(comp, contexts[0], download_onlies=[hirs_ctp_orbital_comp])
                if not skip_execute:
                    LOG.info("Running hirs_ctp_daily local_execute()...")
                    LOG.info("Running context... {}".format(contexts[0]))
                    local_execute(comp, contexts[0], download_onlies=[hirs_ctp_orbital_comp])
            except Exception, err:
                LOG.error("{}".format(err))
                LOG.debug(traceback.format_exc())
예제 #3
0
def print_contexts(interval, satellite, hirs2nc_delivery_id, verbosity=2):

    setup_logging(verbosity)

    comp = setup_computation(satellite)

    contexts = comp.find_contexts(interval, satellite, hirs2nc_delivery_id)
    for context in contexts:
        LOG.info(context)
def print_contexts(interval, satellite, hirs2nc_delivery_id, hirs_avhrr_delivery_id,
                   hirs_csrb_daily_delivery_id, hirs_csrb_monthly_delivery_id,
                   hirs_ctp_orbital_delivery_id, hirs_ctp_daily_delivery_id, verbosity=2):

    setup_logging(verbosity)
    
    comp = setup_computation(satellite)

    contexts = comp.find_contexts(interval, satellite, hirs2nc_delivery_id, hirs_avhrr_delivery_id,
                                  hirs_csrb_daily_delivery_id, hirs_csrb_monthly_delivery_id,
                                  hirs_ctp_orbital_delivery_id, hirs_ctp_daily_delivery_id)
    LOG.info('Printing contexts...')
    for context in contexts:
        LOG.info(context)
import calendar
import logging
from calendar import monthrange
from time import sleep

from flo.ui import safe_submit_order
from timeutil import TimeInterval, datetime, timedelta

import flo.sw.hirs_ctp_orbital as hirs_ctp_orbital
import flo.sw.hirs_ctp_daily as hirs_ctp_daily
from flo.sw.hirs2nc.utils import setup_logging

# every module should have a LOG object
LOG = logging.getLogger(__name__)

setup_logging(2)

# General information
hirs2nc_delivery_id = '20180410-1'
hirs_avhrr_delivery_id = '20180505-1'
hirs_csrb_daily_delivery_id = '20180714-1'
hirs_csrb_monthly_delivery_id = '20180516-1'
hirs_ctp_orbital_delivery_id = '20180730-1'
hirs_ctp_daily_delivery_id = '20180802-1'
wedge = timedelta(seconds=1.)
day = timedelta(days=1.)
hour = timedelta(hours=1.)

# Satellite specific information

#satellite = 'noaa-07'