def point_comparisons_at_outlets(hdf_folder="/home/huziy/skynet3_rech1/hdf_store"): start_year = 1979 end_year = 1981 sim_name_to_file_name = { # "CRCM5-R": "/skynet3_rech1/huziy/hdf_store/quebec_0.1_crcm5-r_spinup.hdf", # "CRCM5-HCD-R": "/skynet3_rech1/huziy/hdf_store/quebec_0.1_crcm5-hcd-r_spinup2.hdf", "CRCM5-HCD-RL": "/skynet3_rech1/huziy/hdf_store/quebec_0.1_crcm5-hcd-rl_spinup.hdf", "CRCM5-HCD-RL-INTFL": "/skynet3_rech1/huziy/hdf_store/quebec_0.1_crcm5-hcd-rl-intfl_do_not_discard_small.hdf", # "SANI=10000, ignore THFC": # "/skynet3_rech1/huziy/hdf_store/quebec_0.1_crcm5-hcd-rl-intfl_sani-10000_not_care_about_thfc.hdf", # "CRCM5-HCD-RL-ERA075": "/skynet3_rech1/huziy/hdf_store/quebec_0.1_crcm5-hcd-rl-intfl_spinup_ecoclimap_era075.hdf", "SANI=10000": "/skynet3_rech1/huziy/hdf_store/quebec_0.1_crcm5-hcd-rl-intfl_sani-10000.hdf" # "CRCM5-HCD-RL-ECOCLIMAP": "/skynet3_rech1/huziy/hdf_store/quebec_0.1_crcm5-hcd-rl-intfl_spinup_ecoclimap.hdf" } path0 = os.path.join(hdf_folder, list(sim_name_to_file_name.items())[0][1]) path1 = os.path.join(hdf_folder, list(sim_name_to_file_name.items())[1][1]) flow_directions = analysis.get_array_from_file(path=path0, var_name=infovar.HDF_FLOW_DIRECTIONS_NAME) lake_fraction = analysis.get_array_from_file(path=path0, var_name=infovar.HDF_LAKE_FRACTION_NAME) slope = analysis.get_array_from_file(path=path1, var_name=infovar.HDF_SLOPE_NAME) lons2d, lats2d, _ = analysis.get_basemap_from_hdf(file_path=path0) cell_manager = CellManager(flow_directions, lons2d=lons2d, lats2d=lats2d) mp_list = cell_manager.get_model_points_of_outlets(lower_accumulation_index_limit=10) assert len(mp_list) > 0 # Get the accumulation indices so that the most important outlets can be identified acc_ind_list = [np.sum(cell_manager.get_mask_of_upstream_cells_connected_with_by_indices(mp.ix, mp.jy)) for mp in mp_list] for mp, acc_ind in zip(mp_list, acc_ind_list): mp.acc_index = acc_ind mp_list.sort(key=lambda x: x.acc_index) # do not take global lake cells into consideration, and discard points with slopes 0 or less mp_list = [mp for mp in mp_list if lake_fraction[mp.ix, mp.jy] < 0.6 and slope[mp.ix, mp.jy] >= 0] mp_list = mp_list[-12:] # get 12 most important outlets print("The following outlets were chosen for analysis") pattern = "({0}, {1}): acc_index = {2} cells; fldr = {3}; lake_fraction = {4}" for mp in mp_list: print(pattern.format(mp.ix, mp.jy, mp.acc_index, cell_manager.flow_directions[mp.ix, mp.jy], lake_fraction[mp.ix, mp.jy])) draw_model_comparison(model_points=mp_list, sim_name_to_file_name=sim_name_to_file_name, hdf_folder=hdf_folder, start_year=start_year, end_year=end_year, cell_manager=cell_manager)