Skip to content

Comments

Bugfix for new plot "ObsFit (Active Observations Only)"#42

Open
dschoenach wants to merge 1 commit intoHirlam:masterfrom
dschoenach:patch-1
Open

Bugfix for new plot "ObsFit (Active Observations Only)"#42
dschoenach wants to merge 1 commit intoHirlam:masterfrom
dschoenach:patch-1

Conversation

@dschoenach
Copy link
Contributor

Misbehaviour discovered by Reima and should now work as intended.

Misbehaviour discovered by Reima and should now work as intended.
Copilot AI review requested due to automatic review settings February 17, 2026 13:24
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the data post-processing for the new timeseries plot “ObsFit (Active Observations Only)” so that RMS metrics are computed correctly from per-observation departures after filtering to active observations.

Changes:

  • Add a local .rms() helper to compute RMS with NA-safe handling (returns NA_real_ when a group has no non-NA values).
  • Simplify the post-processing by removing an intermediate, redundant grouping step and computing group summaries in a single data.table aggregation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 47 to 53
dt <- dt[, .(
# total number of obs in this group
nobs_total = .N,
fg_rms_total = sqrt(sum((fg_dep - mean(fg_dep, na.rm=TRUE))^2, na.rm=TRUE) / sum(!is.na(fg_dep))),
an_rms_total = sqrt(sum((an_dep - mean(an_dep, na.rm=TRUE))^2, na.rm=TRUE) / sum(!is.na(an_dep))),
fg_rms_total = .rms(fg_dep),
an_rms_total = .rms(an_dep),
fg_bias_total = mean(fg_dep, na.rm=TRUE),
an_bias_total = mean(an_dep, na.rm=TRUE)
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated RMS/bias aggregation for the new "ObsFit (Active Observations Only)" plot isn’t covered by tests. Consider adding a testthat case that feeds a small synthetic dataset through .obsFitActiveObsDataPostProcessingFunction and asserts: (1) only rows with an "active" status are included, (2) fg_rms_total/an_rms_total match the intended RMS formula, and (3) all-NA groups return NA_real_ instead of propagating unexpected values.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant