From a7e4aa8e6e057fcb634e2769348993050d9381e6 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Fri, 6 Dec 2024 22:30:48 +0000 Subject: [PATCH] Per #3024, tweak laplace MSE computation --- src/libcode/vx_statistics/met_stats.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libcode/vx_statistics/met_stats.cc b/src/libcode/vx_statistics/met_stats.cc index d82205a81..d13f789e4 100644 --- a/src/libcode/vx_statistics/met_stats.cc +++ b/src/libcode/vx_statistics/met_stats.cc @@ -3820,7 +3820,6 @@ void GRADInfo::set(int grad_dx, int grad_dy, wgt = wgt_na[i]/wgt_sum; // Gradient sums - // JHG, I suspect this implementation may be very wrong! fgbar += wgt * (fabs(fgx_na[i]) + fabs(fgy_na[i])); ogbar += wgt * (fabs(ogx_na[i]) + fabs(ogy_na[i])); mgbar += wgt * (max(fabs(fgx_na[i]), fabs(ogx_na[i])) + @@ -3829,6 +3828,11 @@ void GRADInfo::set(int grad_dx, int grad_dy, fabs(fgy_na[i] - ogy_na[i])); // Gradient vector magnitude + // Reference: + // Ebert-Uphoff, I.: An Investigation of Metrics to Evaluate the Sharpness in + // AI-Generated Meteorology Imagery + // Draft version, Jan 26, 2024 + double fmag = square_root(fgx_na[i] * fgx_na[i] + fgy_na[i] * fgy_na[i]); double omag = square_root(ogx_na[i] * ogx_na[i] + ogy_na[i] * ogy_na[i]); @@ -3836,8 +3840,7 @@ void GRADInfo::set(int grad_dx, int grad_dy, fgmag += wgt * fmag; ogmag += wgt * omag; mag_mse += wgt * (fmag - omag)*(fmag - omag); - // TODO: confirm the algorithm for laplace_rmse - double diff = (fgx_na[i] + fgy_na[i]) - (ogx_na[i] - ogy_na[i]); + double diff = (fgx_na[i] + fgy_na[i]) - (ogx_na[i] + ogy_na[i]); lap_mse += wgt * (diff * diff); total++; }