From 5ae4380f0f91c7681061385d3c1f450ef65388fc Mon Sep 17 00:00:00 2001 From: David Shean Date: Mon, 25 Nov 2024 12:14:36 -0800 Subject: [PATCH] csm_camera: Update annotation units (#66) The units of the csm camera statistics were given in meters rather than degrees. This PR also updates the plots to use a degree symbol. --- asp_plot/csm_camera.py | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/asp_plot/csm_camera.py b/asp_plot/csm_camera.py index 344d7a7..eac2e25 100644 --- a/asp_plot/csm_camera.py +++ b/asp_plot/csm_camera.py @@ -215,7 +215,7 @@ def format_stat_value(value): return f"{value:.2e}" if abs(value) < 0.01 else f"{value:.2f}" -def plot_stats_text(ax, mean, std): +def plot_stats_text(ax, mean, std, unit='m'): """ Plots a text annotation on the given axis displaying the mean and standard deviation of a value. @@ -223,11 +223,12 @@ def plot_stats_text(ax, mean, std): ax (matplotlib.axes.Axes): The axis on which to plot the text annotation. mean (float): The mean value to display. std (float): The standard deviation value to display. + unit (str): Unit to use for display. Default is 'm' Returns: None """ - stats_text = f"{format_stat_value(mean)} ± {format_stat_value(std)} m" + stats_text = f"{format_stat_value(mean)} ± {format_stat_value(std)} {unit}" ax.text( 0.05, 0.1, @@ -433,7 +434,7 @@ def csm_camera_summary_plot( cbar2 = plt.colorbar( sm2, ax=ax, extend=extend, orientation="vertical", aspect=30, pad=0.05 ) - cbar2.set_label("Diff Magnitude (deg)", fontsize=9) + cbar2.set_label("Diff Magnitude (°)", fontsize=9) cbar2.ax.tick_params(labelsize=9) # Camera 1 line plots @@ -448,7 +449,7 @@ def csm_camera_summary_plot( lw=1, label="X position (easting)", ) - plot_stats_text(ax1, cam1_x_position_diff_mean, cam1_x_position_diff_std) + plot_stats_text(ax1, cam1_x_position_diff_mean, cam1_x_position_diff_std, unit='m') ax2 = axes[0, 2] ax2.plot( frame_cam1, @@ -457,7 +458,7 @@ def csm_camera_summary_plot( lw=1, label="Y position (northing)", ) - plot_stats_text(ax2, cam1_y_position_diff_mean, cam1_y_position_diff_std) + plot_stats_text(ax2, cam1_y_position_diff_mean, cam1_y_position_diff_std, unit='m') ax3 = axes[0, 3] ax3.plot( frame_cam1, @@ -466,7 +467,7 @@ def csm_camera_summary_plot( lw=1, label="Z position (altitude)", ) - plot_stats_text(ax3, cam1_z_position_diff_mean, cam1_z_position_diff_std) + plot_stats_text(ax3, cam1_z_position_diff_mean, cam1_z_position_diff_std, unit='m') # Share y-axis for position diff plots min_val_position_diff = min( @@ -524,7 +525,7 @@ def csm_camera_summary_plot( linestyle="--", label="Original Roll", ) - plot_stats_text(ax1_r, cam1_roll_diff_mean, cam1_roll_diff_std) + plot_stats_text(ax1_r, cam1_roll_diff_mean, cam1_roll_diff_std, unit='°') ax2 = axes[1, 2] ax2.plot(frame_cam1, gdf_cam1.pitch_diff, c="#FFA500", lw=1, label="Pitch Diff") @@ -537,7 +538,7 @@ def csm_camera_summary_plot( linestyle="--", label="Original Pitch", ) - plot_stats_text(ax2_r, cam1_pitch_diff_mean, cam1_pitch_diff_std) + plot_stats_text(ax2_r, cam1_pitch_diff_mean, cam1_pitch_diff_std, unit='°') ax3 = axes[1, 3] ax3.plot(frame_cam1, gdf_cam1.yaw_diff, c="#FFB347", lw=1, label="Yaw Diff") @@ -550,7 +551,7 @@ def csm_camera_summary_plot( linestyle="--", label="Original Yaw", ) - plot_stats_text(ax3_r, cam1_yaw_diff_mean, cam1_yaw_diff_std) + plot_stats_text(ax3_r, cam1_yaw_diff_mean, cam1_yaw_diff_std, unit='°') # Share y-axis for angular diff plots min_val_angle_diff = min( @@ -583,10 +584,10 @@ def csm_camera_summary_plot( ax.set_xticklabels(xtick_labels) else: ax.set_xlabel("Position Sample", fontsize=9) - ax.set_ylabel("Original $-$ Optimized (deg)", fontsize=9) + ax.set_ylabel("Original $-$ Optimized (°)", fontsize=9) if shared_scales: ax.set_ylim(min_val_angle_diff, max_val_angle_diff) - ax_r.set_ylabel("Original (deg)", fontsize=9) + ax_r.set_ylabel("Original (°)", fontsize=9) if log_scale_angles: ax.set_yscale("symlog") ax.grid(True, linestyle=":", linewidth=0.5, alpha=0.8, color="gray") @@ -646,7 +647,7 @@ def csm_camera_summary_plot( cbar2 = plt.colorbar( sm2, ax=ax, extend=extend, orientation="vertical", aspect=30, pad=0.05 ) - cbar2.set_label("Diff Magnitude (deg)", fontsize=9) + cbar2.set_label("Diff Magnitude (°)", fontsize=9) cbar2.ax.tick_params(labelsize=9) frame_cam2 = np.arange(gdf_cam2.shape[0]) @@ -660,7 +661,7 @@ def csm_camera_summary_plot( lw=1, label="X position (easting)", ) - plot_stats_text(ax1, cam2_x_position_diff_mean, cam2_x_position_diff_std) + plot_stats_text(ax1, cam2_x_position_diff_mean, cam2_x_position_diff_std, unit='m') ax2 = axes[2, 2] ax2.plot( frame_cam2, @@ -669,7 +670,7 @@ def csm_camera_summary_plot( lw=1, label="Y position (northing)", ) - plot_stats_text(ax2, cam2_y_position_diff_mean, cam2_y_position_diff_std) + plot_stats_text(ax2, cam2_y_position_diff_mean, cam2_y_position_diff_std, unit='m') ax3 = axes[2, 3] ax3.plot( frame_cam2, @@ -678,7 +679,7 @@ def csm_camera_summary_plot( lw=1, label="Z position (altitude)", ) - plot_stats_text(ax3, cam2_z_position_diff_mean, cam2_z_position_diff_std) + plot_stats_text(ax3, cam2_z_position_diff_mean, cam2_z_position_diff_std, unit='m') # Share y-axis for position diff plots min_val_position_diff = min( @@ -738,7 +739,7 @@ def csm_camera_summary_plot( linestyle="--", label="Original Roll", ) - plot_stats_text(ax1_r, cam2_roll_diff_mean, cam2_roll_diff_std) + plot_stats_text(ax1_r, cam2_roll_diff_mean, cam2_roll_diff_std, unit='°') ax2 = axes[3, 2] ax2.plot(frame_cam2, gdf_cam2.pitch_diff, c="#FFA500", lw=1, label="Pitch Diff") @@ -751,7 +752,7 @@ def csm_camera_summary_plot( linestyle="--", label="Original Pitch", ) - plot_stats_text(ax2_r, cam2_pitch_diff_mean, cam2_pitch_diff_std) + plot_stats_text(ax2_r, cam2_pitch_diff_mean, cam2_pitch_diff_std, unit='°') ax3 = axes[3, 3] ax3.plot(frame_cam2, gdf_cam2.yaw_diff, c="#FFB347", lw=1, label="Yaw Diff") @@ -764,7 +765,7 @@ def csm_camera_summary_plot( linestyle="--", label="Original Yaw", ) - plot_stats_text(ax3_r, cam2_yaw_diff_mean, cam2_yaw_diff_std) + plot_stats_text(ax3_r, cam2_yaw_diff_mean, cam2_yaw_diff_std, unit='°') # Share y-axis for angular diff plots min_val_angle_diff = min( @@ -799,10 +800,10 @@ def csm_camera_summary_plot( ax.set_xticklabels(xtick_labels) else: ax.set_xlabel("Position Sample", fontsize=9) - ax.set_ylabel("Original $-$ Optimized (deg)", fontsize=9) + ax.set_ylabel("Original $-$ Optimized (°)", fontsize=9) if shared_scales: ax.set_ylim(min_val_angle_diff, max_val_angle_diff) - ax_r.set_ylabel("Original (deg)", fontsize=9) + ax_r.set_ylabel("Original (°)", fontsize=9) if log_scale_angles: ax.set_yscale("symlog") ax.grid(True, linestyle=":", linewidth=0.5, alpha=0.8, color="gray")