def load_and_plot_diffs(varl, case_ctrl, case_other, start_time, end_time, pressure_coords=True, relative=False, cbar_orient='vertical', asp_ratio=2, subfig_size=3, ncol=None, ylim=None, yscale='log', norm=None ): if ylim is None: ylim = [1e3, 100] cases_dict = get_averaged_fields.get_levlat_cases(cases, varl, start_time, end_time, pressure_adjust=pressure_coords) _nv = len(varl) if ncol is None: if _nv > 3: ncol = 2 else: ncol = 1 # noinspection PyUnresolvedReferences nrow = int(np.ceil(_nv / ncol)) figsize = [subfig_size * ncol * asp_ratio, subfig_size * nrow] # noinspection PyTypeChecker fig, axs = plt.subplots(nrow, ncol, figsize=figsize, sharex=True, sharey=True) for ax, var in zip(axs.flat, varl): plot_levlat_diff(var, case_ctrl, case_other, cases_dict, cbar_orientation=cbar_orient, relative=relative, ylim=ylim, yscale=yscale, ax=ax, norm=norm) return axs
def load_and_plot_diff_mm(varl,to_case,from_cases,startyear, endyear, avg_over_lev=avg_over_lev, pmin=pmin,nr_cols=2, pressure_adjust=pressure_adjust, p_level=None, relative=False, width=6., height=2.3): cases = [to_case] + from_cases maps_dic = get_averaged_fields.get_maps_cases(cases,varl,startyear, endyear, avg_over_lev=avg_over_lev, pmin=pmin, pressure_adjust=pressure_adjust, p_level=p_level) nr_rows = int(np.ceil(len(varl)/nr_cols)) nr_cols = len(from_cases) fig, axs = subplots_map(nr_rows, nr_cols, figsize=[width*nr_cols,height*nr_rows]) for i, var in enumerate(varl): if len(varl) == 1: saxs = axs else: saxs = axs[i,:] plot_map_diff_only(var, [to_case,*from_cases], maps_dic, relative=relative, cbar_equal=True, cbar_loc='side', tight_layout=False, inverse_diff=True, axs=saxs) #for from_case,i in zip(from_cases,range(nr_cols)): # sax = axs[:,i] # plot_diff(maps_dic, varl, [from_case,to_case],nr_cols=nr_cols, relative=relative, width=width, axs=sax) subp_insert_abc(axs, pos_y=0.1) return axs
def plot_diff(maps_dic, varl, cases, nr_cols=2, relative=False, width=5., axs=None): #fig, axs = subplots_map(int(np.ceil(len(varl)/2)), 2, figsize=[10,4*len(varl)]) if axs is None: nr_rows = int(np.ceil(len(varl) / nr_cols)) print(nr_rows) fig, axs = subplots_map(nr_rows, nr_cols, figsize=[width * nr_cols, 2.5 * nr_rows ]) #7*nr_cols,3*nr_rows]) for var, ax in zip(varl, axs.flatten()): plot_map_diff_2case(var, cases[0], cases[1], maps_dic, relative=relative, ax=ax, cmap_diff='RdBu_r')
def load_and_plot_diff_mm(varl, to_case, from_cases, startyear, endyear, avg_over_lev=avg_over_lev, pmin=pmin, nr_cols=2, pressure_adjust=pressure_adjust, p_level=None, relative=False, width=6.): cases = [to_case] + from_cases maps_dic = get_averaged_fields.get_maps_cases( cases, varl, startyear, endyear, avg_over_lev=avg_over_lev, pmin=pmin, pressure_adjust=pressure_adjust, p_level=p_level) nr_rows = int(np.ceil(len(varl) / nr_cols)) nr_cols = len(from_cases) fig, axs = subplots_map(nr_rows, nr_cols, figsize=[width * nr_cols, 2.5 * nr_rows]) for from_case, i in zip(from_cases, range(nr_cols)): sax = axs[:, i] plot_diff(maps_dic, varl, [from_case, to_case], nr_cols=nr_cols, relative=relative, width=width, axs=sax) return
width = 4.7 asp_rat = 0.48 relative = True cases = [to_case] + from_cases maps_dic = get_averaged_fields.get_maps_cases(cases, varl, startyear, endyear, avg_over_lev=avg_over_lev, pmin=pmin, time_mask=period, pressure_adjust=pressure_adjust, p_level=p_level) nr_cols = len(from_cases) nr_rows = int(np.ceil(len(varl))) fig, axs = subplots_map(nr_rows, nr_cols, figsize=[width * nr_cols, asp_rat * width * nr_rows]) for i, var in enumerate(varl): saxs = axs[i, :] plot_map_diff_only(var, [to_case, *from_cases], maps_dic, relative=(var in varl_rel), cbar_equal=True, kwargs_diff={}, axs=saxs, cmap_diff='RdBu_r', cbar_loc='side', tight_layout=False, inverse_diff=True)
width = 4.7 asp_rat = 0.48 relative = True cases = [to_case] + from_cases maps_dic = get_averaged_fields.get_maps_cases(cases, varl, startyear, endyear, avg_over_lev=avg_over_lev, pmin=pmin, pressure_adjust=pressure_adjust, p_level=p_level) nr_cols = len(from_cases) nr_rows = int(np.ceil(len(varl))) fig, axs = subplots_map(nr_rows, nr_cols, figsize=[width * nr_cols, asp_rat * width * nr_rows]) for i, var in enumerate(varl): saxs = axs[i, :] plot_map_diff_only(var, [to_case, *from_cases], maps_dic, relative=(var in varl_rel), cbar_equal=True, kwargs_diff={}, axs=saxs, cmap_diff='RdBu_r', cbar_loc='side', tight_layout=False, inverse_diff=True)