def test_forecast_data_temp_test(self): sim_config_data = self.sim_config_data sim_source_data = GagesSource( sim_config_data, sim_config_data.model_dict["data"]["tRangeTest"]) sim_df = DataModel(sim_source_data) save_datamodel(sim_df, "1", data_source_file_name='test_data_source.txt', stat_file_name='test_Statistics.json', flow_file_name='test_flow', forcing_file_name='test_forcing', attr_file_name='test_attr', f_dict_file_name='test_dictFactorize.json', var_dict_file_name='test_dictAttribute.json', t_s_dict_file_name='test_dictTimeSpace.json') config_data = self.config_data source_data = GagesSource(config_data, config_data.model_dict["data"]["tRangeTest"]) df = DataModel(source_data) save_datamodel(df, "2", data_source_file_name='test_data_source.txt', stat_file_name='test_Statistics.json', flow_file_name='test_flow', forcing_file_name='test_forcing', attr_file_name='test_attr', f_dict_file_name='test_dictFactorize.json', var_dict_file_name='test_dictAttribute.json', t_s_dict_file_name='test_dictTimeSpace.json')
def test_trans_all_forcing_file_to_camels(self): data_source_dump = os.path.join(self.config_data.data_path["Temp"], 'data_source.txt') source_data = unserialize_pickle(data_source_dump) output_dir = os.path.join(self.config_data.data_path["DB"], "basin_mean_forcing", "daymet") if not os.path.isdir(output_dir): os.mkdir(output_dir) region_names = [ region_temp.split("_")[-1] for region_temp in source_data.all_configs['regions'] ] # forcing data file generated is named as "allref", so rename the "all" region_names = ["allref" if r == "all" else r for r in region_names] year_start = int(source_data.t_range[0].split("-")[0]) year_end = int(source_data.t_range[1].split("-")[0]) years = np.arange(year_start, year_end) assert (all(x < y for x, y in zip(source_data.gage_dict['STAID'], source_data.gage_dict['STAID'][1:]))) config_dir = definitions.CONFIG_DIR for i in range(len(region_names)): config_file_i = os.path.join( config_dir, "transdata/config_exp" + str(i + 1) + ".ini") subdir_i = "transdata/exp" + str(i + 1) config_data_i = GagesConfig.set_subdir(config_file_i, subdir_i) source_data_i = GagesSource( config_data_i, config_data_i.model_dict["data"]["tRangeTrain"], screen_basin_area_huc4=False) for year in years: trans_daymet_to_camels(source_data.all_configs["forcing_dir"], output_dir, source_data_i.gage_dict, region_names[i], year)
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)
def test_check_streamflow_data(self): source_data = GagesSource( self.config_data, self.config_data.model_dict["data"]["tRangeTrain"], screen_basin_area_huc4=False) t_range_list = hydro_time.t_range_days(["1990-01-01", "2010-01-01"]) # data_temp = source_data.read_usge_gage("01", '01052500', t_range_list) data_temp = source_data.read_usge_gage("08", '08013000', t_range_list) print(data_temp) print(np.argwhere(np.isnan(data_temp)))
def test_data_temp_explore(self): config_data_1 = self.config_data source_data_1 = GagesSource( config_data_1, config_data_1.model_dict["data"]["tRangeTrain"]) df1 = DataModel(source_data_1) save_datamodel(df1, data_source_file_name='data_source.txt', stat_file_name='Statistics.json', flow_file_name='flow', forcing_file_name='forcing', attr_file_name='attr', f_dict_file_name='dictFactorize.json', var_dict_file_name='dictAttribute.json', t_s_dict_file_name='dictTimeSpace.json')
def test_data_temp_test_explore(self): config_data_test = self.config_data source_data_test = GagesSource( config_data_test, config_data_test.model_dict["data"]["tRangeTest"]) df_test = DataModel(source_data_test) save_datamodel(df_test, data_source_file_name='test_data_source.txt', stat_file_name='test_Statistics.json', flow_file_name='test_flow', forcing_file_name='test_forcing', attr_file_name='test_attr', f_dict_file_name='test_dictFactorize.json', var_dict_file_name='test_dictAttribute.json', t_s_dict_file_name='test_dictTimeSpace.json')