Exemplo n.º 1
0
    def __init__(self):
        """
        Initialises the object

        :return: nothing
        """
        from collections import OrderedDict

        self.bmimodels = OrderedDict()
        self.currenttimestep = 0
        self.exchanges = []
        self.comp_sep = "@"
        self.wrtodisk = False
        if os.getenv("wflow_bmi_combined_writetodisk",'False') in 'True':
            self.wrtodisk = True

        self.loggingmode = logging.ERROR
        logstr = os.getenv('wflow_bmi_loglevel', 'ERROR')
        if logstr in 'ERROR':
            self.loggingmode = logging.ERROR
        if logstr in 'WARNING':
            self.loggingmode = logging.WARNING
        if logstr in 'INFO':
            self.loggingmode = logging.INFO
        if logstr in 'DEBUG':
            self.loggingmode = logging.DEBUG

        self.bmilogger = setlogger('wflow_bmi_combined.log','wflow_bmi_combined_logging',thelevel=self.loggingmode)
        self.bmilogger.info("__init__: wflow_bmi_combined object initialised.")
        if self.wrtodisk:
            self.bmilogger.warn('Will write all bmi set- and get- grids to disk!...')
Exemplo n.º 2
0
    def __init__(self):
        """
        Initialises the object

        :return: nothing
        """
        from collections import OrderedDict

        self.bmimodels = OrderedDict()
        self.currenttimestep = 0
        self.exchanges = []
        self.indices_from = []
        self.indices_to = []
        self.comp_sep = "@"
        self.wrtodisk = False
        if os.getenv("wflow_bmi_combined_writetodisk",'False') in 'True':
            self.wrtodisk = True

        self.loggingmode = logging.ERROR
        logstr = os.getenv('wflow_bmi_loglevel', 'ERROR')
        if logstr in 'ERROR':
            self.loggingmode = logging.ERROR
        if logstr in 'WARNING':
            self.loggingmode = logging.WARNING
        if logstr in 'INFO':
            self.loggingmode = logging.INFO
        if logstr in 'DEBUG':
            self.loggingmode = logging.DEBUG

        self.bmilogger = setlogger('wflow_bmi_combined.log','wflow_bmi_combined_logging',thelevel=self.loggingmode)
        self.bmilogger.info("__init__: wflow_bmi_combined object initialised.")
        if self.wrtodisk:
            self.bmilogger.warn('Will write all bmi set- and get- grids to disk!...')
    def __init__(self):
        """
        Initialises the object

        :return: nothing
        """
        from collections import OrderedDict

        self.bmimodels = OrderedDict()
        self.currenttimestep = 0
        self.exchanges = []
        self.comp_sep = "@"
        self.wrtodisk = False
        if os.getenv("wflow_bmi_combined_writetodisk", "False") in "True":
            self.wrtodisk = True

        self.loggingmode = logging.ERROR
        logstr = os.getenv("wflow_bmi_loglevel", "ERROR")
        if logstr in "ERROR":
            self.loggingmode = logging.ERROR
        if logstr in "WARNING":
            self.loggingmode = logging.WARNING
        if logstr in "INFO":
            self.loggingmode = logging.INFO
        if logstr in "DEBUG":
            self.loggingmode = logging.DEBUG

        self.bmilogger = setlogger(
            "wflow_bmi_combined.log",
            "wflow_bmi_combined_logging",
            thelevel=self.loggingmode,
        )
        self.bmilogger.info("__init__: wflow_bmi_combined object initialised.")
        if self.wrtodisk:
            self.bmilogger.warn("Will write all bmi set- and get- grids to disk!...")
Exemplo n.º 4
0
def main(argv=None):
    """
    Perform command line execution of the model.
    """

    configfile = "bmirunner.ini"

    if argv is None:
        argv = sys.argv[1:]
        if len(argv) == 0:
            usage()
            return
    ########################################################################
    ## Process command-line options                                        #
    ########################################################################
    try:
        opts, args = getopt.getopt(argv, "c:l:")
    except getopt.error as msg:
        usage(msg)

    loglevel = logging.WARN
    for o, a in opts:
        if o == "-c":
            configfile = a
        if o == "-l":
            exec("loglevel = logging." + a)

    combilogger = pcrut.setlogger("bmi2runner.log",
                                  "bmi2runner_logging",
                                  thelevel=loglevel)

    # Construct object and initilize the models
    combilogger.info("Starting combined bmi object")
    bmiobj = wfbmi.wflowbmi_csdms()

    bmiobj.initialize_config(configfile, loglevel=loglevel)
    bmiobj.initialize_model()

    # Get and set start and end times
    start = bmiobj.get_start_time()
    end = bmiobj.get_end_time()
    bmiobj.set_start_time(start)
    bmiobj.set_end_time(end)

    # Update models (if necessary) to start time
    bmiobj.update_to_start_time(start)

    # Number of steps to run models
    ts = bmiobj.get_time_step()
    steps = int((end - start) / ts + 1)

    cts = bmiobj.currenttimestep
    # Loop over the time duration
    while cts < steps:
        combilogger.info("time is: " + str(bmiobj.get_current_time()))
        bmiobj.update()
        cts = bmiobj.currenttimestep

    bmiobj.finalize()
    combilogger.info("Finishing run")
Exemplo n.º 5
0
    def __init__(self,log=None):
        """
        Initialises the object

        :return: nothing
        """
        self.currenttimestep = 0
        self.name = "undefined"
        self.myModel = None

        self.dynModel = None

        self.loggingmode = logging.ERROR
        logstr = os.getenv('wflow_bmi_loglevel', 'ERROR')
        self.wrtodisk = False

        if os.getenv("wflow_bmi_writetodisk",'False') in 'True':
            self.wrtodisk = True

        if logstr in 'ERROR':
            self.loggingmode = logging.ERROR
        if logstr in 'WARNING':
            self.loggingmode = logging.WARNING
        if logstr in 'INFO':
            self.loggingmode = logging.INFO
        if logstr in 'DEBUG':
            self.loggingmode = logging.DEBUG

        self.bmilogger = setlogger('wflow_bmi.log','wflow_bmi_logging',thelevel=self.loggingmode)
        self.bmilogger.info("__init__: wflow_bmi object initialised.")
        if self.wrtodisk:
            self.bmilogger.warn('Will write all bmi set and get grids to disk!...')
Exemplo n.º 6
0
    def __init__(self):
        """
        Initialises the object

        :return: nothing
        """
        self.currenttimestep = 0
        self.name = "undefined"
        self.myModel = None

        self.dynModel = None

        self.loggingmode = logging.ERROR
        logstr = os.getenv('wflow_bmi_loglevel', 'ERROR')
        self.wrtodisk = False

        if os.getenv("wflow_bmi_writedisk", 'False') in 'True':
            self.wrtodisk = True

        if logstr in 'ERROR':
            self.loggingmode = logging.ERROR
        if logstr in 'WARNING':
            self.loggingmode = logging.WARNING
        if logstr in 'INFO':
            self.loggingmode = logging.INFO
        if logstr in 'DEBUG':
            self.loggingmode = logging.DEBUG

        self.bmilogger = setlogger('wflow_bmi.log',
                                   'wflow_bmi_logging',
                                   thelevel=self.loggingmode)
        self.bmilogger.info("__init__: wflow_bmi object initialised.")
Exemplo n.º 7
0
    def __init__(self, log=None):
        """
        Initialises the object

        :return: nothing
        """
        self.currenttimestep = 0
        self.name = "undefined"
        self.myModel = None

        self.dynModel = None

        self.loggingmode = logging.ERROR
        logstr = os.getenv("wflow_bmi_loglevel", "ERROR")
        self.wrtodisk = False

        if os.getenv("wflow_bmi_writetodisk", "False") in "True":
            self.wrtodisk = True

        if logstr in "ERROR":
            self.loggingmode = logging.ERROR
        if logstr in "WARNING":
            self.loggingmode = logging.WARNING
        if logstr in "INFO":
            self.loggingmode = logging.INFO
        if logstr in "DEBUG":
            self.loggingmode = logging.DEBUG

        self.bmilogger = setlogger("wflow_bmi.log",
                                   "wflow_bmi_logging",
                                   thelevel=self.loggingmode)
        self.bmilogger.info("__init__: wflow_bmi object initialised.")
        if self.wrtodisk:
            self.bmilogger.warning(
                "Will write all bmi set and get grids to disk!...")
Exemplo n.º 8
0
    def __init__(self):
        """
        Initialises the object

        :return: nothing
        """
        from collections import OrderedDict

        self.bmimodels = OrderedDict()
        self.currenttimestep = 0
        self.exchanges = []
        self.comp_sep = "@"
        self.wrtodisk = False
        if os.getenv("wflow_bmi_combined_writetodisk", "False") in "True":
            self.wrtodisk = True

        self.loggingmode = logging.ERROR
        logstr = os.getenv("wflow_bmi_loglevel", "ERROR")
        if logstr in "ERROR":
            self.loggingmode = logging.ERROR
        if logstr in "WARNING":
            self.loggingmode = logging.WARNING
        if logstr in "INFO":
            self.loggingmode = logging.INFO
        if logstr in "DEBUG":
            self.loggingmode = logging.DEBUG

        self.bmilogger = setlogger(
            "wflow_bmi_combined.log",
            "wflow_bmi_combined_logging",
            thelevel=self.loggingmode,
        )
        self.bmilogger.info("__init__: wflow_bmi_combined object initialised.")
        if self.wrtodisk:
            self.bmilogger.warning("Will write all bmi set- and get- grids to disk!...")
Exemplo n.º 9
0
    def __init__(self):
        """

        :return:
        """
        self.loggingmode = logging.ERROR
        logstr = os.getenv('wflow_bmi_loglevel', 'ERROR')

        if logstr in 'ERROR':
            self.loggingmode = logging.ERROR
        if logstr in 'WARNING':
            self.loggingmode = logging.WARNING
        if logstr in 'INFO':
            self.loggingmode = logging.INFO
        if logstr in 'DEBUG':
            self.loggingmode = logging.DEBUG

        """ If set to True all set and get grids are writtesn to disk for debugging """
        self.wrtodisk = False

        self.bmilogger = setlogger('wflow_bmi.log','wflow_bmi_logging',thelevel=self.loggingmode)
        self.bmilogger.info("__init__: wflow_bmi object initialised.")
Exemplo n.º 10
0
    def __init__(self):
        """

        :return:
        """
        self.loggingmode = logging.ERROR
        logstr = os.getenv('wflow_bmi_loglevel', 'ERROR')

        if logstr in 'ERROR':
            self.loggingmode = logging.ERROR
        if logstr in 'WARNING':
            self.loggingmode = logging.WARNING
        if logstr in 'INFO':
            self.loggingmode = logging.INFO
        if logstr in 'DEBUG':
            self.loggingmode = logging.DEBUG

        """ If set to True all set and get grids are writtesn to disk for debugging """
        self.wrtodisk = False

        self.bmilogger = setlogger('wflow_bmi.log','wflow_bmi_logging',thelevel=self.loggingmode)
        self.bmilogger.info("__init__: wflow_bmi object initialised.")
Exemplo n.º 11
0
    def __init__(self):
        """

        :return:
        """
        self.loggingmode = logging.ERROR
        logstr = os.getenv("wflow_bmi_loglevel", "ERROR")

        if logstr in "ERROR":
            self.loggingmode = logging.ERROR
        if logstr in "WARNING":
            self.loggingmode = logging.WARNING
        if logstr in "INFO":
            self.loggingmode = logging.INFO
        if logstr in "DEBUG":
            self.loggingmode = logging.DEBUG
        """ If set to True all set and get grids are written to disk for debugging """
        self.wrtodisk = False

        self.bmilogger = setlogger("wflow_bmi.log",
                                   "wflow_bmi_logging",
                                   thelevel=self.loggingmode)
        self.bmilogger.info("__init__: wflow_bmi object initialised.")
Exemplo n.º 12
0
    for o, a in opts:
        if o == '-h': usage()
        if o == '-O': outputdir = a
        if o == '-D': thedem = a
        if o == '-M': xymetres = true
        if o == '-x': lat = int(a)
        if o == '-y': lon = int(a)
        if o == '-S': startday = int(a)
        if o == '-E': endday = int(a)
        if o == '-T': calc_interval = int(a)
        if o == '-l': exec "thelevel = logging." + a
        if o == '-s': shour = int(a)
        if o == '-e': ehour = int(a)


    logger = pcr.setlogger("wflow_prepare_rad.log","wflow_prepare_rad",thelevel=loglevel)
    if not os.path.exists(thedem):
        logger.error("Cannot find dem: " + thedem + " exiting.")
        sys.exit(1)
    if not os.path.exists(outputdir):
        os.mkdir(outputdir)

    logger.debug("Reading dem: " " thedem")
    setclone(thedem)
    dem = readmap(thedem)

    logger.debug("Calculating slope and aspect...")
    if xymetres:
        LAT = spatial(scalar(lat))
        LON= spatial(scalar(lon))
        Slope = max(0.00001,slope(dem))
Exemplo n.º 13
0
            return
    ########################################################################
    ## Process command-line options                                        #
    ########################################################################
    try:
        opts, args = getopt.getopt(argv, 'c:l:')
    except getopt.error, msg:
        usage(msg)

    loglevel = logging.WARN
    for o, a in opts:
        if o == '-c': configfile = a
        if o == '-l': exec "loglevel = logging." + a

    combilogger = pcrut.setlogger("bmi2runner.log",
                                  "bmi2runner_logging",
                                  thelevel=loglevel)

    # Construct object and initilize the models
    combilogger.info("Starting combined bmi object")
    bmiobj = wfbmi.wflowbmi_csdms()

    bmiobj.initialize_config(configfile, loglevel=loglevel)
    bmiobj.initialize_model()

    # Get and set start and end times
    start = bmiobj.get_start_time()
    end = bmiobj.get_end_time()
    bmiobj.set_start_time(start)
    bmiobj.set_end_time(end)
Exemplo n.º 14
0
def main(argv=None):
    """
    Perform command line execution of the model.
    """

    if argv is None:
        argv = sys.argv[1:]
        if len(argv) == 0:
            usage()
            return

    try:
        opts, args = getopt.getopt(argv, "hD:Mx:y:l:O:S:E:T:s:e:")
    except getopt.error as msg:
        usage(msg)

    thedem = "mydem.map"
    xymetres = False
    lat = 52
    lon = 10
    loglevel = logging.DEBUG
    outputdir = "output_rad"
    startday = 1
    endday = 2
    calc_interval = 60
    shour = 1
    ehour = 23

    for o, a in opts:
        if o == "-h":
            usage()
        if o == "-O":
            outputdir = a
        if o == "-D":
            thedem = a
        if o == "-M":
            xymetres = true
        if o == "-x":
            lat = int(a)
        if o == "-y":
            lon = int(a)
        if o == "-S":
            startday = int(a)
        if o == "-E":
            endday = int(a)
        if o == "-T":
            calc_interval = int(a)
        if o == "-l":
            exec("thelevel = logging." + a)
        if o == "-s":
            shour = int(a)
        if o == "-e":
            ehour = int(a)

    logger = pcr.setlogger(
        "wflow_prepare_rad.log", "wflow_prepare_rad", thelevel=loglevel
    )
    if not os.path.exists(thedem):
        logger.error("Cannot find dem: " + thedem + " exiting.")
        sys.exit(1)
    if not os.path.exists(outputdir):
        os.mkdir(outputdir)

    logger.debug("Reading dem: " " thedem")
    setclone(thedem)
    dem = readmap(thedem)

    logger.debug("Calculating slope and aspect...")
    if xymetres:
        LAT = spatial(scalar(lat))
        LON = spatial(scalar(lon))
        Slope = max(0.00001, slope(dem))
        DEMxyUnits = dem
    else:
        LAT = ycoordinate(boolean(dem))
        LON = xcoordinate(boolean(dem))
        Slope = slope(dem)
        xl, yl, reallength = pcr.detRealCellLength(dem * 0.0, 0)
        Slope = max(0.00001, Slope * celllength() / reallength)
        DEMxyUnits = dem * celllength() / reallength

    # Get slope in degrees
    Slope = scalar(atan(Slope))
    Aspect = cover(scalar(aspect(dem)), 0.0)

    GenRadMaps(
        outputdir,
        LAT,
        LON,
        Slope,
        Aspect,
        dem,
        DEMxyUnits,
        logger,
        start=startday,
        end=endday,
        interval=calc_interval,
        shour=shour,
        ehour=ehour,
    )
Exemplo n.º 15
0
def main(argv=None):
    """
    Perform command line execution of the model.
    """

    if argv is None:
        argv = sys.argv[1:]
        if len(argv) == 0:
            usage()
            return

    try:
        opts, args = getopt.getopt(argv, "hD:Mx:y:l:O:S:E:T:s:e:")
    except getopt.error as msg:
        usage(msg)

    thedem = "mydem.map"
    xymetres = False
    lat = 52
    lon = 10
    loglevel = logging.DEBUG
    outputdir = "output_rad"
    startday = 1
    endday = 2
    calc_interval = 60
    shour = 1
    ehour = 23

    for o, a in opts:
        if o == "-h":
            usage()
        if o == "-O":
            outputdir = a
        if o == "-D":
            thedem = a
        if o == "-M":
            xymetres = true
        if o == "-x":
            lat = int(a)
        if o == "-y":
            lon = int(a)
        if o == "-S":
            startday = int(a)
        if o == "-E":
            endday = int(a)
        if o == "-T":
            calc_interval = int(a)
        if o == "-l":
            exec("thelevel = logging." + a)
        if o == "-s":
            shour = int(a)
        if o == "-e":
            ehour = int(a)

    logger = pcr.setlogger("wflow_prepare_rad.log",
                           "wflow_prepare_rad",
                           thelevel=loglevel)
    if not os.path.exists(thedem):
        logger.error("Cannot find dem: " + thedem + " exiting.")
        sys.exit(1)
    if not os.path.exists(outputdir):
        os.mkdir(outputdir)

    logger.debug("Reading dem: " " thedem")
    setclone(thedem)
    dem = readmap(thedem)

    logger.debug("Calculating slope and aspect...")
    if xymetres:
        LAT = spatial(scalar(lat))
        LON = spatial(scalar(lon))
        Slope = max(0.00001, slope(dem))
        DEMxyUnits = dem
    else:
        LAT = ycoordinate(boolean(dem))
        LON = xcoordinate(boolean(dem))
        Slope = slope(dem)
        xl, yl, reallength = pcr.detRealCellLength(dem * 0.0, 0)
        Slope = max(0.00001, Slope * celllength() / reallength)
        DEMxyUnits = dem * celllength() / reallength

    # Get slope in degrees
    Slope = scalar(atan(Slope))
    Aspect = cover(scalar(aspect(dem)), 0.0)

    GenRadMaps(
        outputdir,
        LAT,
        LON,
        Slope,
        Aspect,
        dem,
        DEMxyUnits,
        logger,
        start=startday,
        end=endday,
        interval=calc_interval,
        shour=shour,
        ehour=ehour,
    )
Exemplo n.º 16
0
            return
    ########################################################################
    ## Process command-line options                                        #
    ########################################################################
    try:
        opts, args = getopt.getopt(argv, 'c:l:')
    except getopt.error, msg:
        usage(msg)

    loglevel = logging.WARN
    for o, a in opts:
        if o == '-c': configfile = a
        if o == '-l': exec "loglevel = logging." + a

    combilogger = pcrut.setlogger('bmi2runner.log',
                                  'bmi2runner_logging',
                                  thelevel=loglevel)
    # Construct object and initilize the models
    combilogger.info('Starting combined bmi object')
    bmiobj = bmi.wflowbmi_csdms()
    bmiobj.initialize_config(configfile, loglevel=loglevel)
    bmiobj.initialize_model()
    start = bmiobj.get_start_time()
    end = bmiobj.get_end_time()
    bmiobj.set_start_time(start)
    bmiobj.set_end_time(end)
    # Get time for the loop

    ts = bmiobj.get_time_step()
    curtime = bmiobj.get_current_time()
    # Loop over the time duration
Exemplo n.º 17
0
            return
    ########################################################################
    ## Process command-line options                                        #
    ########################################################################
    try:
        opts, args = getopt.getopt(argv, 'c:l:')
    except getopt.error, msg:
        usage(msg)

    loglevel=logging.WARN
    for o, a in opts:
        if o == '-c': configfile = a
        if o == '-l': exec "loglevel = logging." + a


    combilogger = pcrut.setlogger('bmi2runner.log','bmi2runner_logging',thelevel=loglevel)
    # Construct object and initilize the models
    combilogger.info('Starting combined bmi object')
    bmiobj = bmi.wflowbmi_csdms()
    bmiobj.initialize_config(configfile,loglevel=loglevel)
    bmiobj.initialize_model()
    start = bmiobj.get_start_time()
    end = bmiobj.get_end_time()
    bmiobj.set_start_time(start)
    bmiobj.set_end_time(end)
    # Get time for the loop

    ts = bmiobj.get_time_step()
    curtime = bmiobj.get_current_time()
    # Loop over the time duration