Skip to content

Add new observation formulas - #34

Merged
mvertens merged 11 commits into
noresmfrom
feature/obs_formulas
Jul 28, 2026
Merged

Add new observation formulas#34
mvertens merged 11 commits into
noresmfrom
feature/obs_formulas

Conversation

@mvertens

@mvertens mvertens commented Jul 24, 2026

Copy link
Copy Markdown

Summary:

When ADF compares the model against observations, it needs the obs data for each variable — but that data isn't always sitting in the obs file ready to use. Sometimes the file has the ingredients but not the final field (it stores the two kinds of rain, PRECC and PRECL, but not total rain PRECT). Sometimes the variable is stored under a different name, or in different units than the model uses. Until now, ADF could only rename a variable and multiply it by a fixed
number, which wasn't enough to cover these cases.

This PR lets you write a short formula that tells ADF how to construct the observational variable from whatever the file actually contains. For example:

  • PRECT = PRECC + PRECL — add the pieces together
  • ALBEDO = (solar_mon − fsnt) / solar_mon — a genuine calculation
  • TGCLDLWP = TGCLDWP × 1000 — rename and convert units at once

What you put in a variable's settings

Two new settings do the work, and one existing setting now has a clearer, narrower role:

Setting What it's for When you use it
obs_var_name The name the variable is stored under in the obs file Only when the obs file stores the field directly but calls it something different from ADF (e.g. ADF's AODVIS is AOD_550 in the file). Skip it when the name already matches, and skip it for derived variables — there's no single stored field to point at.
obs_derivable_from (new) The list of input variables, named as they appear in the obs file, that the formula needs When the variable has to be built from other fields in the file
obs_derivation_formula (new) The formula itself, written in terms of those input names Alongside obs_derivable_from — the two go together

So it's an either/or: a variable that's stored directly may just need obs_var_name (if the name differs); a variable that's computed uses obs_derivable_from + obs_derivation_formula and leaves obs_var_name out
entirely. A quick example of the derived case:

ALBEDO:
  obs_file: "CERES_EBAF_Ed4.1_2001-2020.nc"
  obs_name: "CERES-EBAF"
  obs_derivable_from: ['solar_mon', 'fsnt']          # what's actually in the file
  obs_derivation_formula: "(solar_mon - fsnt) / solar_mon"

@mvertens
mvertens marked this pull request as draft July 24, 2026 09:45
@mvertens
mvertens marked this pull request as ready for review July 24, 2026 16:34
@mvertens
mvertens requested a review from TomasTorsvik July 24, 2026 16:34
@mvertens
mvertens marked this pull request as draft July 24, 2026 16:37
@mvertens
mvertens marked this pull request as ready for review July 24, 2026 16:37
@mvertens
mvertens requested a review from gold2718 July 27, 2026 07:29

@TomasTorsvik TomasTorsvik left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@mvertens - thanks for the OBS fix, looks fine to me. Is this update also shared with the NCAR version of ADF?

@mvertens

Copy link
Copy Markdown
Author

@TomasTorsvik - thanks for reviewing this.

We are up to date with the latest version of the NCAR repository. However, I have added a lot of new features that we want and that have not been shared with NCAR. At this point I have another PR that is currently in draft form that I will test once this PR is in. Then I'd for us to have the changes that @adagj will be bringing in that she is using. And at that point I'd like to do a PR back to NCAR.

@mvertens
mvertens merged commit 75f6144 into noresm Jul 28, 2026
9 checks passed
@mvertens
mvertens deleted the feature/obs_formulas branch July 28, 2026 08:38
@mvertens
mvertens removed the request for review from gold2718 July 28, 2026 08:38
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.

2 participants