Exemple #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())
def local_execute_example(granule, platform, hirs_version, collo_version, csrb_version, ctp_version,
                          tpw_version, skip_prepare=False, skip_execute=False):
    comp_dict = { 
        'granule': granule
        'sat': platform, 
        'hirs_version': hirs_version, 
        'collo_version': collo_version, 
        'csrb_version': csrb_version,
        'ctp_version': ctp_version,
        'tpw_version': tpw_version}

    try:
        if not skip_prepare:
            LOG.info("Running local prepare...")
            local_prepare(comp, comp_dict, download_only=[HIRS_TPW_DAILY()])
        if not skip_execute:
            LOG.info("Running local execute...")
            local_execute(comp, comp_dict)
    except Exception, err:
        LOG.error("{}".format(err))
        LOG.info(traceback.format_exc())