Skip to content

Online Lapse Rate Mean Calculation and refactor - #83

Open
jjguerrette wants to merge 8 commits into
JCSDA:developfrom
jjguerrette:feature/online_lapse_rate
Open

jjguerrette wants to merge 8 commits into
JCSDA:developfrom
jjguerrette:feature/online_lapse_rate

Conversation

@jjguerrette

Copy link
Copy Markdown

Description

We often have users ask for mean lapse rate files during their experiment periods. This is also a challenge for researchers setting up new regional domains where our sensors have not been assimilated before.

This PR adds an online mean option for mean temperature lapse rates used by bias-correction predictors, and consolidates the shared lapse-rate logic into a new LapseRateHelper used by both lapseRate and GMI cloudWaterContent.

Motivation / problem

Today, lapseRate (and GMI cloudWaterContent) require a precomputed tlapse text file of per-channel mean lapse rates. Those files can be generated for instruments that are assimilated operationally in GDAS from abias files acquired from NOMADS, NCEI, etc., but are often unavailable for a user’s time window for sensors that have not been assimilated before. This forces offline generation of mean files, and adds complexity to workflows, before VarBC can be configured.

What this PR does

  • Adds shared YAML options via LapseRateMeanParameters (flat under predictor options):
    • tlapse: <path> or online mean: true (exactly one required). tlapse has the same behavior as before via a new pathway.
    • optional save means: <path> to write computed/file means on the first fill
  • Introduces LapseRateHelper with a single public API, fillTlapchnAndMeans, that:
    • fills per-channel / per-location lapse rates (tlapchn) for the ObsSpace channels
    • fills per-channel means from either the offline file or an online ObsSpace mean
  • Caches means in an &ObsSpace-keyed map so all predictors sharing an ObsSpace reuse the same frozen means (first fill only), preserving consistency between NL/TL and across predictors. The frozen means are typical of the behavior that is used for file-sourced values in most workflows.
  • Refactors LapseRate and GMI CloudLiquidWater to use the helper; helper-only required GeoVaLs / hdiags are registered by the helper rather than duplicated by callers
  • Extends unit-test YAML to exercise both the existing tlapse path and the new online mean path

Issue(s) addressed

N/A

Dependencies

List the other PRs that this PR is dependent on:

  • None

Impact

Expected impact on downstream repositories:

  • No required config changes for existing experiments that already supply tlapse
  • New optional capability: configure online mean: true (and optionally save means) instead of providing a tlapse file
  • GMI cloudWaterContent now shares the same mean-lapse configuration contract as lapseRate

Checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have run the unit tests before creating the PR

Unit tests exercised by this change

YAML / ctests covering the shared helper and online-mean path:

Test YAML Result
test_ufo_amsua_crtm_bc_obsoperator test/testinput/unit_tests/predictors/amsua_crtm_bc.yaml (file tlapse + second obs with online mean: true) Passed
test_ufo_amsua_crtm_bc_tlad same amsua_crtm_bc.yaml Passed
test_ufo_gmi_qc_filters test/testinput/unit_tests/filters/gmi_qc_filters.yaml (file tlapse + second obs with online mean: true on lapseRate / cloudWaterContent; passedBenchmark: 624 for both) Passed

LapseRateHelper is reused in both the LapseRate and CloudLiquidWater
(for GMI) predictors. The public fillTlapchnAndMeans API supplies
both mean lapse rates (either from file or calculated online) and
the per-channel/-location lapse rates of the ObsSpace. Both the
offline and online mean paths store an &ObsSpace-keyed map
value only once per simulation, which retrieved by other callers in
with same &ObsSpace context. This provides bit-for-bit equivalence
with today's code as long as users always provide the same mean
lapse rate file to all applicable predictors per ObsSpace.
@jjguerrette jjguerrette changed the title Feature/online lapse rate Online Lapse Rate Mean Calculation and refactor Oct 13, 2026
@jjguerrette

Copy link
Copy Markdown
Author

@BenjaminRuston @ADCollard Other than for formatting cleanups and missing value checks, there have been few substantive changes to the code in several years. Any ideas on who could review?

@jjguerrette

Copy link
Copy Markdown
Author

@rajichidamb would you be willing to review?

@ADCollard

Copy link
Copy Markdown
Contributor

@jjguerrette This looks like it will be very useful. There are a lot of changes here, so it may take me a while, but I can review.

Comment thread src/ufo/predictors/CloudLiquidWater.cc Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this be tsavg?

@jjguerrette jjguerrette Oct 14, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch. I failed to update the missing check. It needs to target the new helper output (tlapchn_v, tlapchn_h) instead of tsavg5, ptau5, and tvp. Same for the other comments.

Comment thread src/ufo/predictors/CloudLiquidWater.cc Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nlevs does not appear to be declared

Comment thread src/ufo/predictors/CloudLiquidWater.cc Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

tvp does not appear to be declared.

Comment thread src/ufo/predictors/CloudLiquidWater.cc Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also ptau5

@jjguerrette

jjguerrette commented Oct 14, 2026 •

Copy link
Copy Markdown
Author

@ADCollard I confess to having built this in an older version (UFO 1.12.0), then attempting to port it forward to develop. Clearly I have made some errors, and need to attempt to build/debug this in develop. I'm not sure if I can do it easily, because we are still migrating from spack 1.9.x to 2.x.

@rajichidamb

Copy link
Copy Markdown
Contributor

Thanks @jjguerrette. I will also create a corresponding PR in JCSDA-internal so the change can be part of the develop branch and other partners can review the code.

@jjguerrette

jjguerrette commented Oct 14, 2026 •

Copy link
Copy Markdown
Author

Thank you @rajichidamb! I would like to fix the issues Andrew brought up, and get this branch up to date with develop. Are changes I push to jjguerrette:feature/online_lapse_rate visible in the JCSDA-internal PR, or is the source branch on my fork no longer the source of truth? Unfortunately I do not have internal access. Please relay any review responses to jj.guerrette@tomorrow.io or report them here.

Replace old local references to tsavg5, tvp, and ptau5 with tlapchn_v, tlapchn_h, and tlap (mean).
geovals.getAtLevel(pred, oops::Variable{"air_temperature"}, js);
tvp.push_back(pred);
}
nlevs = geovals.nlevs(oops::Variable{"air_pressure"});

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Another thing that changed from UFO 1.12 to develop is how nlevs is determined. 1.12 uses air_pressure (see this line) and develop removes that line entirely (3 weeks ago in this commit), which defaults back to using the air_temperature nlevs.

I did not write the science on this metric, and defer to other developers. If air_temperature is the correct source, then air_pressure can be removed from the required vars. @ADCollard @rajichidamb

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.

3 participants