예제 #1
0
def main():
    """FUNCTION TESTS"""
    cur_path = UtilClass.current_path(lambda: 0)
    SEIMS_path = os.path.abspath(cur_path + '../../..')
    model_paths = ModelPaths(SEIMS_path, 'dianbu2', 'demo_dianbu2_model')
    prep_cfg = write_preprocess_config_file(model_paths, 'preprocess.ini')
    postp_cfg = write_postprocess_config_file(model_paths, 'postprocess.ini')
예제 #2
0
    def __init__(self, root_dir):
        """Create workspace directories for outputs.
        Args:
            root_dir: Root directory
        """
        if not os.path.isdir(root_dir):
            try:
                os.makedirs(root_dir)
            except Exception:  # failed of any types
                root_dir = UtilClass.current_path(
                    lambda: 0) + os.sep + "FuzzySlpPos"
                os.mkdir(root_dir)
        self.root_dir = root_dir

        self.pre_dir = self.root_dir + os.sep + "PreDir"
        self.param_dir = self.root_dir + os.sep + "Params"
        self.log_dir = self.root_dir + os.sep + "Log"
        self.output_dir = self.root_dir + os.sep + "FuzzySlpPos"
        self.typloc_dir = self.root_dir + os.sep + "TypLoc"
        self.conf_dir = self.root_dir + os.sep + "Config"

        UtilClass.mkdir(self.pre_dir)
        UtilClass.mkdir(self.param_dir)
        UtilClass.mkdir(self.output_dir)
        UtilClass.mkdir(self.log_dir)
        UtilClass.mkdir(self.typloc_dir)
        UtilClass.mkdir(self.conf_dir)
예제 #3
0
def main():
    """FUNCTION TESTS"""
    cur_path = UtilClass.current_path(lambda: 0)
    SEIMS_path = os.path.abspath(cur_path + '../../..')
    model_paths = ModelPaths(SEIMS_path, 'dianbu2', 'demo_dianbu2_model')
    prep_cfg = write_preprocess_config_file(model_paths, 'preprocess.ini')
    postp_cfg = write_postprocess_config_file(model_paths, 'postprocess.ini')
예제 #4
0
def main():
    cur_path = UtilClass.current_path(lambda: 0)
    SEIMS_path = os.path.abspath(cur_path + '../../..')
    model_paths = ModelPaths(SEIMS_path, 'dianbu2', 'demo_dianbu2_model')

    scenario_id = 0
    seims_obj = MainSEIMS(model_paths.bin_dir, model_paths.model_dir, scenario_id=scenario_id)
    seims_obj.run()
예제 #5
0
def main():
    cur_path = UtilClass.current_path(lambda: 0)
    SEIMS_path = os.path.abspath(cur_path + '../../..')
    model_paths = ModelPaths(SEIMS_path, 'dianbu2', 'demo_dianbu2_model')
    seims_cfg = write_preprocess_config_file(model_paths, 'preprocess.ini')

    SpatialDelineation.workflow(seims_cfg)  # Spatial delineation by TauDEM
    ImportMongodbClass.workflow(seims_cfg)  # Import to MongoDB database
예제 #6
0
def main():
    cur_path = UtilClass.current_path(lambda: 0)
    SEIMS_path = os.path.abspath(cur_path + '../../..')
    model_paths = ModelPaths(SEIMS_path, 'dianbu2', 'demo_dianbu2_model')

    # hydrograph, e.g. discharge
    scenario_id = 0
    post_cfg = write_postprocess_config_file(model_paths, 'postprocess.ini', scenario_id)
    TimeSeriesPlots(post_cfg).generate_plots()
예제 #7
0
def main():
    """FUNCTION TESTS"""
    cur_path = UtilClass.current_path(lambda: 0)
    SEIMS_path = os.path.abspath(cur_path + '../../..')
    # More demo data could be added in the future.
    for wtsd_name, model_name in list(DEMO_MODELS.items()):
        model_paths = ModelPaths(SEIMS_path, wtsd_name, model_name)
        prep_cfg = write_preprocess_config_file(model_paths, 'preprocess.ini')
        postp_cfg = write_postprocess_config_file(model_paths,
                                                  'postprocess.ini')
def main():
    cur_path = UtilClass.current_path(lambda: 0)
    SEIMS_path = os.path.abspath(cur_path + '../../..')
    model_paths = ModelPaths(SEIMS_path, 'dianbu2', 'demo_dianbu2_model')

    # hydrograph, e.g. discharge
    scenario_id = 0
    post_cfg = write_postprocess_config_file(model_paths, 'postprocess.ini',
                                             scenario_id)
    TimeSeriesPlots(post_cfg).generate_plots()
def main():
    cur_path = UtilClass.current_path(lambda: 0)
    SEIMS_path = os.path.abspath(cur_path + '../../..')
    model_paths = ModelPaths(SEIMS_path, 'dianbu2', 'demo_dianbu2_model')

    scenario_id = 0
    seims_obj = MainSEIMS(model_paths.bin_dir,
                          model_paths.model_dir,
                          scenario_id=scenario_id)
    seims_obj.run()
예제 #10
0
def main():
    wtsd_name = get_watershed_name(
        'Specify watershed name to run auto-calibration.')
    if wtsd_name not in list(DEMO_MODELS.keys()):
        print('%s is not one of the available demo watershed: %s' %
              (wtsd_name, ','.join(list(DEMO_MODELS.keys()))))
        exit(-1)

    cur_path = UtilClass.current_path(lambda: 0)
    SEIMS_path = os.path.abspath(cur_path + '../../..')
    model_paths = ModelPaths(SEIMS_path, wtsd_name, DEMO_MODELS[wtsd_name])

    cali_cfg = write_calibration_config_file(model_paths, 'calibration.ini')
    cali_nsga2.main(cali_cfg)
예제 #11
0
def main():
    wtsd_name = get_watershed_name('Specify watershed name to run preprocess.')
    if wtsd_name not in list(DEMO_MODELS.keys()):
        print('%s is not one of the available demo watershed: %s' %
              (wtsd_name, ','.join(list(DEMO_MODELS.keys()))))
        exit(-1)
    cur_path = UtilClass.current_path(lambda: 0)
    SEIMS_path = os.path.abspath(cur_path + '../../..')

    model_paths = ModelPaths(SEIMS_path, wtsd_name, DEMO_MODELS[wtsd_name])
    seims_cfg = write_preprocess_config_file(model_paths, 'preprocess.ini')

    SpatialDelineation.workflow(seims_cfg)  # Spatial delineation by TauDEM
    ImportMongodbClass.workflow(seims_cfg)  # Import to MongoDB database
예제 #12
0
def main():
    wtsd_name = get_watershed_name(
        'Specify watershed name to run SEIMS-based model.')
    if wtsd_name not in list(DEMO_MODELS.keys()):
        print('%s is not one of the available demo watershed: %s' %
              (wtsd_name, ','.join(list(DEMO_MODELS.keys()))))
        exit(-1)
    cur_path = UtilClass.current_path(lambda: 0)
    SEIMS_path = os.path.abspath(cur_path + '../../..')
    model_paths = ModelPaths(SEIMS_path, wtsd_name, DEMO_MODELS[wtsd_name])

    scenario_id = 0
    seims_obj = MainSEIMS(model_paths.bin_dir,
                          model_paths.model_dir,
                          scenario_id=scenario_id)
    seims_obj.run()
예제 #13
0
def main():
    wtsd_name = get_watershed_name(
        'Specify watershed name to run SEIMS-based model.')
    if wtsd_name not in list(DEMO_MODELS.keys()):
        print('%s is not one of the available demo watershed: %s' %
              (wtsd_name, ','.join(list(DEMO_MODELS.keys()))))
        exit(-1)
    cur_path = UtilClass.current_path(lambda: 0)
    SEIMS_path = os.path.abspath(cur_path + '../../..')
    model_paths = ModelPaths(SEIMS_path, wtsd_name, DEMO_MODELS[wtsd_name])

    runmodel_cfg = write_runmodel_config_file(model_paths, 'runmodel.ini')

    seims_obj = MainSEIMS(args_dict=runmodel_cfg.ConfigDict)
    seims_obj.run()
    for l in seims_obj.runlogs:
        print(l)
예제 #14
0
def main():
    wtsd_name = get_watershed_name(
        'Specify watershed name to run postprocess.')
    if wtsd_name not in list(DEMO_MODELS.keys()):
        print('%s is not one of the available demo watershed: %s' %
              (wtsd_name, ','.join(list(DEMO_MODELS.keys()))))
        exit(-1)

    cur_path = UtilClass.current_path(lambda: 0)
    SEIMS_path = os.path.abspath(cur_path + '../../..')
    model_paths = ModelPaths(SEIMS_path, wtsd_name, DEMO_MODELS[wtsd_name])

    # hydrograph, e.g. discharge
    scenario_id = 0
    calibration_id = -1
    post_cfg = write_postprocess_config_file(model_paths, 'postprocess.ini',
                                             scenario_id, calibration_id)
    TimeSeriesPlots(post_cfg).generate_plots()
예제 #15
0
def main():
    """Main workflow."""
    cur_path = UtilClass.current_path()
    print cur_path
    workspace = cur_path + os.sep + 'workspace'
    bin_dir = os.path.abspath(os.path.join(cur_path, '../bin'))
    print bin_dir
    demo_data_path = os.path.abspath(
        os.path.join(cur_path, '../data/demo_data'))
    print demo_data_path
    org_ini_name = 'Jamaica_demo.ini'
    dem_name = 'Jamaica_dem.tif'

    fuzslppos_cfg = write_autofuzslppos_config_file(org_ini_name, bin_dir,
                                                    workspace, demo_data_path,
                                                    dem_name)

    pre_processing(fuzslppos_cfg)
    extract_typical_location(fuzslppos_cfg)
    fuzzy_inference(fuzslppos_cfg)
예제 #16
0
def main():
    wtsd_name = get_watershed_name(
        'Specify watershed name to run parameters sensitivity analysis.')
    if wtsd_name not in list(DEMO_MODELS.keys()):
        print('%s is not one of the available demo watershed: %s' %
              (wtsd_name, ','.join(list(DEMO_MODELS.keys()))))
        exit(-1)

    cur_path = UtilClass.current_path(lambda: 0)
    SEIMS_path = os.path.abspath(cur_path + '../../..')
    model_paths = ModelPaths(SEIMS_path, wtsd_name, DEMO_MODELS[wtsd_name])

    psa_cfg = write_sensitivity_config_file(model_paths,
                                            'sensitivity_analysis.ini')
    print('### START TO PARAMETERS SENSITIVITY ANALYSIS ###')
    start_t = time.time()
    saobj = Sensitivity(psa_cfg)
    saobj.run()
    saobj.plot()
    print('### END OF PARAMETERS SENSITIVITY ANALYSIS ###')
    print('Running time: %.2fs' % (time.time() - start_t))
예제 #17
0
def main():
    wtsd_name = get_watershed_name(
        'Specify watershed name to run scenario analysis.')
    if wtsd_name not in list(DEMO_MODELS.keys()):
        print('%s is not one of the available demo watershed: %s' %
              (wtsd_name, ','.join(list(DEMO_MODELS.keys()))))
        exit(-1)

    cur_path = UtilClass.current_path(lambda: 0)
    SEIMS_path = os.path.abspath(cur_path + '../../..')
    model_paths = ModelPaths(SEIMS_path, wtsd_name, DEMO_MODELS[wtsd_name])

    cf = write_scenario_analysis_config_file(model_paths,
                                             'scenario_analysis.ini')
    base_cfg = SAConfig(cf)  # type: SAConfig
    if base_cfg.bmps_cfg_unit == BMPS_CFG_UNITS[3]:  # SLPPOS
        cfg = SASlpPosConfig(cf)
    elif base_cfg.bmps_cfg_unit == BMPS_CFG_UNITS[2]:  # CONNFIELD
        cfg = SAConnFieldConfig(cf)
    else:  # Common spatial units, e.g., HRU and EXPLICITHRU
        cfg = SACommUnitConfig(cf)
    cfg.construct_indexes_units_gene()

    sce = SUScenario(cfg)

    scoop_log('### START TO SCENARIOS OPTIMIZING ###')
    start_t = time.time()

    fpop, fstats = sa_nsga2.main(sce)
    fpop.sort(key=lambda x: x.fitness.values)
    scoop_log(fstats)
    with open(cfg.opt.logbookfile, 'w', encoding='utf-8') as f:
        # In case of 'TypeError: write() argument 1 must be unicode, not str' in Python2.7
        #   when using unicode_literals, please use '%s' to concatenate string!
        f.write('%s' % fstats.__str__())

    end_t = time.time()
    scoop_log('Running time: %.2fs' % (end_t - start_t))