Ejemplo n.º 1
0
def save_datamodel(data_model, num_str=None, **kwargs):
    if num_str:
        dir_temp = os.path.join(
            data_model.data_source.data_config.data_path["Temp"], num_str)
    else:
        dir_temp = data_model.data_source.data_config.data_path["Temp"]
    if not os.path.isdir(dir_temp):
        os.makedirs(dir_temp)
    data_source_file = os.path.join(dir_temp, kwargs['data_source_file_name'])
    stat_file = os.path.join(dir_temp, kwargs['stat_file_name'])
    flow_file = os.path.join(dir_temp, kwargs['flow_file_name'])
    forcing_file = os.path.join(dir_temp, kwargs['forcing_file_name'])
    attr_file = os.path.join(dir_temp, kwargs['attr_file_name'])
    f_dict_file = os.path.join(dir_temp, kwargs['f_dict_file_name'])
    var_dict_file = os.path.join(dir_temp, kwargs['var_dict_file_name'])
    t_s_dict_file = os.path.join(dir_temp, kwargs['t_s_dict_file_name'])
    serialize_pickle(data_model.data_source, data_source_file)
    serialize_json(data_model.stat_dict, stat_file)
    serialize_numpy(data_model.data_flow, flow_file)
    serialize_numpy(data_model.data_forcing, forcing_file)
    serialize_numpy(data_model.data_attr, attr_file)
    # dictFactorize.json is the explanation of value of categorical variables
    serialize_json(data_model.f_dict, f_dict_file)
    serialize_json(data_model.var_dict, var_dict_file)
    serialize_json(data_model.t_s_dict, t_s_dict_file)
Ejemplo n.º 2
0
 def test_data_source_test(self):
     config_data = CamelsConfig(self.config_file)
     # 准备训练数据
     source_data = CamelsSource(
         config_data, config_data.model_dict["data"]["tRangeTest"])
     # 序列化保存对象
     serialize_pickle(source_data, self.data_source_test_file)
Ejemplo n.º 3
0
 def test_data_source(self):
     source_data = GagesSource(
         self.config_data,
         self.config_data.model_dict["data"]["tRangeTrain"],
         screen_basin_area_huc4=False)
     my_file = os.path.join(self.config_data.data_path["Temp"],
                            'data_source.txt')
     serialize_pickle(source_data, my_file)
Ejemplo n.º 4
0
def save_nidinput(nid_model, data_path, num_str=None, **kwargs):
    if num_str is not None:
        data_path = os.path.join(data_path, num_str)
    if not os.path.isdir(data_path):
        os.makedirs(data_path)
    nid_source_file = os.path.join(data_path, kwargs['nid_source_file_name'])
    nid_data_file = os.path.join(data_path, kwargs['nid_data_file_name'])
    serialize_pickle(nid_model.nid_source, nid_source_file)
    serialize_geopandas(nid_model.nid_data, nid_data_file)