data_workflow/wrfprworkflow.py
def run_wrfpr_workflow(threddspath):
    """
    The controller for running the workflow to download and process data
    """
    wrksppath = os.path.join(
        os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'tethysapp', 'ffgs', 'workspaces', 'app_workspace')

    # enable logging to track the progress of the workflow and for debugging
    logpath = os.path.join(threddspath, 'workflow.log')
    logging.basicConfig(filename=logpath, filemode='w', level=logging.INFO, format='%(message)s')
    logging.info('Workflow initiated on ' + datetime.datetime.utcnow().strftime("%D at %R"))

    # start the workflow by setting the environment
    timestamp, redundant = setenvironment(threddspath, wrksppath)

    # if this has already been done for the most recent forecast, abort the workflow
    if redundant:
        logging.info('\nWorkflow aborted on ' + datetime.datetime.utcnow().strftime("%D at %R"))
        return 'Workflow Aborted: already run for most recent data'

    # run the workflow
    region = 'hispaniola'
    model = 'wrfpr'
    logging.info('\nBeginning to process ' + region + ' on ' + datetime.datetime.utcnow().strftime("%D at %R"))

    # download each forecast model, convert them to netcdfs and tiffs
    succeeded = download_wrfpr(threddspath, timestamp, region)
    if not succeeded:
        return 'Workflow Aborted- Downloading Errors Occurred'
    wrfpr_tiffs(threddspath, wrksppath, timestamp, region)
    resample(wrksppath, region)
    # the geoprocessing functions
    zonal_statistics(wrksppath, timestamp, region, model)
    nc_georeference(threddspath, timestamp, region, model)
    # generate color scales and ncml aggregation files
    new_ncml_wrfpr(threddspath, timestamp, region)
    new_colorscales(wrksppath, region, model)
    # cleanup the workspace by removing old files
    cleanup(threddspath, timestamp, region, model)

    logging.info('\nAll regions and models finished- writing the timestamp used on this run to a txt file')
    with open(os.path.join(threddspath, 'wrfpr_timestamp.txt'), 'w') as file:
        file.write(timestamp)

    logging.info('WRF-PR Workflow completed successfully on ' + datetime.datetime.utcnow().strftime("%D at %R"))
    logging.info('If there are other model workflows to be processed, they will follow.\n\n\n')

    return 'WRF-PR Workflow Completed- Normal Finish'

    The controller for running the workflow to download and process data
    
The controller for running the workflow to download and process data
The controller for running the workflow to download and process data
def run_wrfpr_workflow(threddspath):
    wrksppath = os.path.join(
        os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'tethysapp', 'ffgs', 'workspaces', 'app_workspace')
    logpath = os.path.join(threddspath, 'workflow.log')
    logging.basicConfig(filename=logpath, filemode='w', level=logging.INFO, format='%(message)s')
    logging.info('Workflow initiated on ' + datetime.datetime.utcnow().strftime("%D at %R"))
    timestamp, redundant = setenvironment(threddspath, wrksppath)
    if redundant:
        logging.info('\nWorkflow aborted on ' + datetime.datetime.utcnow().strftime("%D at %R"))
        return 'Workflow Aborted: already run for most recent data'
    region = 'hispaniola'
    model = 'wrfpr'
    logging.info('\nBeginning to process ' + region + ' on ' + datetime.datetime.utcnow().strftime("%D at %R"))
    succeeded = download_wrfpr(threddspath, timestamp, region)
    if not succeeded:
        return 'Workflow Aborted- Downloading Errors Occurred'
    wrfpr_tiffs(threddspath, wrksppath, timestamp, region)
    resample(wrksppath, region)
    zonal_statistics(wrksppath, timestamp, region, model)
    nc_georeference(threddspath, timestamp, region, model)
    new_ncml_wrfpr(threddspath, timestamp, region)
    new_colorscales(wrksppath, region, model)
    cleanup(threddspath, timestamp, region, model)
    logging.info('\nAll regions and models finished- writing the timestamp used on this run to a txt file')
    with open(os.path.join(threddspath, 'wrfpr_timestamp.txt'), 'w') as file:
        file.write(timestamp)
    logging.info('WRF-PR Workflow completed successfully on ' + datetime.datetime.utcnow().strftime("%D at %R"))
    logging.info('If there are other model workflows to be processed, they will follow.\n\n\n')
    return 'WRF-PR Workflow Completed- Normal Finish'
def run_wrfpr_workflow ( threddspath ) : wrksppath = os . path . join ( os . path . dirname ( os . path . dirname ( os . path . abspath ( __file__ ) ) ) , 'tethysapp' , 'ffgs' , 'workspaces' , 'app_workspace' ) logpath = os . path . join ( threddspath , 'workflow.log' ) logging . basicConfig ( filename = logpath , filemode = 'w' , level = logging . INFO , format = '%(message)s' ) logging . info ( 'Workflow initiated on ' + datetime . datetime . utcnow ( ) . strftime ( "%D at %R" ) ) timestamp , redundant = setenvironment ( threddspath , wrksppath ) if redundant : logging . info ( '\nWorkflow aborted on ' + datetime . datetime . utcnow ( ) . strftime ( "%D at %R" ) ) return 'Workflow Aborted: already run for most recent data' region = 'hispaniola' model = 'wrfpr' logging . info ( '\nBeginning to process ' + region + ' on ' + datetime . datetime . utcnow ( ) . strftime ( "%D at %R" ) ) succeeded = download_wrfpr ( threddspath , timestamp , region ) if not succeeded : return 'Workflow Aborted- Downloading Errors Occurred' wrfpr_tiffs ( threddspath , wrksppath , timestamp , region ) resample ( wrksppath , region ) zonal_statistics ( wrksppath , timestamp , region , model ) nc_georeference ( threddspath , timestamp , region , model ) new_ncml_wrfpr ( threddspath , timestamp , region ) new_colorscales ( wrksppath , region , model ) cleanup ( threddspath , timestamp , region , model ) logging . info ( '\nAll regions and models finished- writing the timestamp used on this run to a txt file' ) with open ( os . path . join ( threddspath , 'wrfpr_timestamp.txt' ) , 'w' ) as file : file . write ( timestamp ) logging . info ( 'WRF-PR Workflow completed successfully on ' + datetime . datetime . utcnow ( ) . strftime ( "%D at %R" ) ) logging . info ( 'If there are other model workflows to be processed, they will follow.\n\n\n' ) return 'WRF-PR Workflow Completed- Normal Finish'
The controller for running the workflow to download and process data
The controller for running the workflow to download and process data
"""
    The controller for running the workflow to download and process data
    """ # enable logging to track the progress of the workflow and for debugging # start the workflow by setting the environment # if this has already been done for the most recent forecast, abort the workflow # run the workflow # download each forecast model, convert them to netcdfs and tiffs # the geoprocessing functions # generate color scales and ncml aggregation files # cleanup the workspace by removing old files
threddspath