Skip to content

Commit

Permalink
Per #3024, tweak laplace MSE computation
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnHalleyGotway committed Dec 6, 2024
1 parent 32591e0 commit a7e4aa8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/libcode/vx_statistics/met_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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])) +
Expand All @@ -3829,15 +3828,19 @@ 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]);

// Gradient vector sums
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++;
}
Expand Down

0 comments on commit a7e4aa8

Please sign in to comment.