def plot_kres_nom_nom_scatter(self, directory, ylim=None): plot_scatter(pjoin(directory, "k_res_nominal_scatter.pdf"), self.get_kres_nom_nom_musamples(), self.get_times_musamples(), xlbl="Time", ylbl="Nominal K Residual (" + str(int(self.get_musamples_total())) + " Samples)", title="", legend=self.get_mu_labels(), legend_loc="outside", solid_ylines=[0], fig_size=(12, 8), ylim=ylim) return 0
def plot_kres_nom_nom_scatter_monthlymean(self, directory, ylim=None): kres_nom_nom_monthlymean, months = self.get_kres_nom_nom_monthlymean() plot_scatter(pjoin(directory, "k_res_nominal_monthlymean.pdf"), kres_nom_nom_monthlymean, months, xlbl="Time", ylbl="Nominal K Residual (Monthly Mean)", title="", legend=self.get_mu_labels(), legend_loc="outside", solid_ylines=[0], fig_size=(12, 8), ylim=ylim, line="-") return 0
def plot_L1_harm_v_L2_harm_scatter(self, directory): plot_scatter(pjoin(directory, "L1_vs_L2_harmonised_scatter.pdf"), self.get_L1_harm_musamples(), self.get_L2_harm_musamples(), xlbl="Harmonised Sensor 2 Measurand", ylbl="Harmonised/Reference Sensor 1 Measurand (" + str(self.get_musamples_total()) + " Samples)", title="", yerr=None, xerr=None, legend=self.get_mu_labels(), legend_loc="outside", solid_ylines=[0], fig_size=(12, 8)) return 0
def plot_compare_calibration(self, directory, parameter_comparison, parameter_covariance_matrix_comparison, verbose=False): MatchUpSim = self.get_MatchUpSim(n_sim=20, verbose=verbose) measurand_1 = evaluate_measurand(MatchUpSim) MatchUpSim.a = parameter_comparison measurand_2, u_measurand_cov_2 = evaluate_measurand( MatchUpSim, parameter_covariance_matrix=parameter_covariance_matrix_comparison) measurand_diff = measurand_1 - measurand_2 # Just make one plot per sensor sensors = MatchUpSim.idx['sensors'] plotted_sensors = [] i_mu = 0 while set(plotted_sensors) != set(sensors): istart = MatchUpSim.idx['cNm'][i_mu] iend = MatchUpSim.idx['cNm'][i_mu + 1] pair = MatchUpSim.idx['Im'][i_mu] for i_pair, n_sensor in enumerate(pair): sensor_name = sensors[n_sensor] measurand_1_i = measurand_1[istart:iend, i_pair] measurand_diff_i = measurand_diff[istart:iend, i_pair] u_measurand_cov_2_i = u_measurand_cov_2[istart:iend, i_pair] path = pjoin(directory, "compare_calibration." + sensor_name + ".pdf") plot_scatter( path, measurand_diff_i, measurand_1_i, yerr=2 * u_measurand_cov_2_i, title="Sampled Radiance Residual - " + str(sensor_name), ylbl="Radiance Residual, $\Delta L = L_{Data} - L_{Est}$", xlbl="Data Radiance, $L_{DATA}$", dash_ylines=[0]) plotted_sensors.append(sensor_name) i_mu += 1
def plot_Y_x_binned_line(self, directory, Y, x, x_name, x_label, title, fname, ylim=None, mus=None): """ Output plot to given directory for the difference between data and estimated k against variable x :type directory: str :param directory: directory to write plots to :type MatchUpData: eopy.matchup.matchupIO.MatchUp :param MatchUpData: MatchUp data object to plot :type k_est: numpy.ndarray :param k_est: estimate of k to plot :type x: numpy.ndarray :param x: variable to plot against :type x_name: str :param x_name: name for file for x variable :type x_label: str :param x_label: label for plotting x variable :type mus: list :param mus: match-up series to plot for """ # 1. Preamble # a. Requried data # - Full range of x-variable MatchUpData = self.MatchUpData # 1. Initialise matchup_labels = self.get_mu_labels() matchup_fname_suffix = self.get_mu_fname_suffix() xmin = min(x) xmax = max(x) # b. Initialise data lists averages = [] stds = [] averages_x = [] if mus is None: mus = list(range(1, max(MatchUpData.idx['n_mu']) + 1)) # 2. Plot by match-up series for i, mu in enumerate(mus): # Indices and labels i1 = MatchUpData.idx["cNm"][mu - 1] i2 = MatchUpData.idx["cNm"][mu] sensor_2_name = MatchUpData.idx['sensors'][MatchUpData.idx['Im'][ mu - 1][1]] mu_fn = matchup_fname_suffix[mu - 1] # Bin by x for match-up series (match-up series data range) x_i = x[i1:i2] x_i_range = [min(x_i), max(x_i)] averages_i, stds_i, averages_x_i = bin(Y[i1:i2], x_i, bins=50, X_range=x_i_range) # Plot match-up series data fname_i = pjoin( directory, fname + "." + x_name + "_" + sensor_2_name + "_binned." + mu_fn + ".pdf") plot_scatter(fname_i, averages_i, averages_x_i, xlbl=x_label + " - " + sensor_2_name, ylbl=title + " (" + matchup_labels[i] + ")", title="", yerr=stds_i, xerr=None, txt=None, line='-', legend=None, solid_ylines=[0], ylim=ylim) # Bin by x for match-up series (all data range) averages_i, stds_i, averages_x_i = bin(Y[i1:i2], x_i, bins=50, X_range=[xmin, xmax]) averages.append(averages_i[~isnan(averages_i)]) stds.append(stds_i[~isnan(averages_i)]) averages_x.append(averages_x_i[~isnan(averages_i)]) # 3. Plot all match-up series together plot_scatter(pjoin(directory, fname + "." + x_name + "_sensor_2_binned.pdf"), averages, averages_x, xlbl=x_label + " - Sensor 2", ylbl=title, title="", yerr=stds, xerr=None, txt=None, line='-', legend=matchup_labels, legend_loc="outside", solid_ylines=[0], fig_size=(12, 8), ylim=ylim) return 0
def plot_Y_X_binned_line(self, directory, Y, title, fname, ylim=None, mus=None): MatchUpData = self.MatchUpData # 1. Initialise matchup_labels = self.get_mu_labels() matchup_fname_suffix = self.get_mu_fname_suffix() if mus is None: mus = list(range(1, max(MatchUpData.idx['n_mu']) + 1)) # 2. Plot by X by match-up series # Loop through X for cov in range(1, max(MatchUpData.idx['sensor_ms']) + 1): Xmin = self.get_Xmin(cov) Xmax = self.get_Xmax(cov) # Initialise data lists averages = [] stds = [] Xaverages = [] # Plot per match-up series for i, mu in enumerate(mus): # Indices and labels i1 = MatchUpData.idx["cNm"][mu - 1] i2 = MatchUpData.idx["cNm"][mu] sensor_2_name = MatchUpData.idx['sensors'][ MatchUpData.idx['Im'][mu - 1][1]] cov_name = self.get_X_name(cov, sensor_2_name) cov_label = "$" + self.get_X_label( cov, sensor_2_name) + "$ (Binned)" mu_fn = matchup_fname_suffix[mu - 1] # Plot if sensor 2 of given match-up series has an cov-th X sensor_2_m = MatchUpData.idx['sensor_ms'][MatchUpData.idx['Im'] [mu - 1][1]] if cov <= sensor_2_m: X = MatchUpData.getVariableData(cov, sensor_2_name, mu) # Bin data by match-up series limits averages_i, stds_i, Xaverages_i = bin( Y[i1:i2], X, bins=50, X_range=[min(X), max(X)]) # Plot match-up series fname_i = pjoin( directory, fname + "." + cov_name + "_" + sensor_2_name + "_binned." + mu_fn + ".pdf") plot_scatter(fname_i, averages_i, Xaverages_i, xlbl=cov_label + " - " + sensor_2_name, ylbl=title + " (" + matchup_labels[i] + ")", title="", yerr=stds_i, xerr=None, txt=None, line='-', legend=None, solid_ylines=[0], ylim=ylim) # Bin data by full limits averages_i, stds_i, Xaverages_i = bin(Y[i1:i2], X, bins=50, X_range=[Xmin, Xmax]) averages.append(averages_i[~isnan(averages_i)]) stds.append(stds_i[~isnan(averages_i)]) Xaverages.append(Xaverages_i[~isnan(averages_i)]) # Plot X for all match-up series plot_scatter(pjoin(directory, fname + "." + cov_name + "_sensor_2_binned.pdf"), averages, Xaverages, xlbl=cov_label + " - Sensor 2", ylbl=title, title="", yerr=stds, xerr=None, txt=None, line='-', legend=matchup_labels, legend_loc="outside", solid_ylines=[0], fig_size=(12, 8), ylim=ylim)