Ejemplo n.º 1
0
 def test_gages_dam_attr(self):
     quick_data_dir = os.path.join(self.config_data.data_path["DB"],
                                   "quickdata")
     data_dir = os.path.join(quick_data_dir,
                             "conus-all_90-10_nan-0.0_00-1.0")
     df = GagesModel.load_datamodel(data_dir,
                                    data_source_file_name='data_source.txt',
                                    stat_file_name='Statistics.json',
                                    flow_file_name='flow.npy',
                                    forcing_file_name='forcing.npy',
                                    attr_file_name='attr.npy',
                                    f_dict_file_name='dictFactorize.json',
                                    var_dict_file_name='dictAttribute.json',
                                    t_s_dict_file_name='dictTimeSpace.json')
     # nid_input = NidModel()
     nid_input = NidModel(self.config_data.config_file)
     # nid_dir = os.path.join("/".join(self.config_data.data_path["DB"].split("/")[:-1]), "nid", "quickdata")
     nid_dir = os.path.join(
         "/".join(self.config_data.data_path["DB"].split("/")[:-1]), "nid",
         "test")
     save_nidinput(nid_input,
                   nid_dir,
                   nid_source_file_name='nid_source.txt',
                   nid_data_file_name='nid_data.shp')
     data_input = GagesDamDataModel(df, nid_input)
     serialize_json(data_input.gage_main_dam_purpose,
                    os.path.join(nid_dir, "dam_main_purpose_dict.json"))
Ejemplo n.º 2
0
                                include=True):
            diversions[i] = "yes"

    nid_gene_file = os.path.join(cfg.NID.NID_DIR, "test",
                                 "dam_main_purpose_dict.json")
    if not os.path.isfile(nid_gene_file):
        df = GagesModel.load_datamodel(cfg.CACHE.DATA_DIR,
                                       data_source_file_name='data_source.txt',
                                       stat_file_name='Statistics.json',
                                       flow_file_name='flow.npy',
                                       forcing_file_name='forcing.npy',
                                       attr_file_name='attr.npy',
                                       f_dict_file_name='dictFactorize.json',
                                       var_dict_file_name='dictAttribute.json',
                                       t_s_dict_file_name='dictTimeSpace.json')
        nid_input = NidModel(cfg)
        nid_dir = os.path.join(cfg.NID.NID_DIR, "test")
        save_nidinput(nid_input,
                      nid_dir,
                      nid_source_file_name='nid_source.txt',
                      nid_data_file_name='nid_data.shp')
        data_input = GagesDamDataModel(df, nid_input)
        serialize_json(data_input.gage_main_dam_purpose,
                       os.path.join(nid_dir, "dam_main_purpose_dict.json"))
    gage_main_dam_purpose = unserialize_json(nid_gene_file)
    gage_main_dam_purpose_lst = list(gage_main_dam_purpose.values())
    gage_main_dam_purpose_lst_merge = "".join(gage_main_dam_purpose_lst)
    gage_main_dam_purpose_unique = np.unique(
        list(gage_main_dam_purpose_lst_merge))
    # gage_main_dam_purpose_unique = np.unique(gage_main_dam_purpose_lst)
    purpose_regions = {}