Skip to content

Distance localization: let parameters without a grid be updated or left out - #185

Merged
KriFos1 merged 1 commit into
Python-Ensemble-Toolbox:mainfrom
patnr:distance-loc-unlocalized
Oct 28, 2026
Merged

KriFos1 merged 1 commit into
Python-Ensemble-Toolbox:mainfrom
patnr:distance-loc-unlocalized

Conversation

@patnr

@patnr patnr commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

Distance-based localization (distance_loc) could not be used on a state that holds scalars besides a field, e.g. state = ["permx", "sor", "vo"]:

  • A parameter with no localization entry gets an all-zero mask, sized from its prior's nx/ny/nz. A prior without a grid (Draw a prior without a grid as scalars, instead of dropping it #180) has none, so the analysis raised KeyError: 'nx'.
  • Even with a grid, such a parameter could only be frozen: an entry places a kernel on the field, so there was no way to have a scalar updated.

Change

  • A parameter without a grid is sized from its mean, as StateLayout.from_prior_info draws it (and has no inactive cells to drop).

  • A new unlocalized key lists parameters that every datum updates with weight one:

    [dataassim.localization]
    name        = "distance_loc"
    taper_func  = "gc"
    unlocalized = ["sor", "vo"]
    ...

    It must name parameters of the state; anything else is an error. A parameter that is neither in unlocalized nor in an entry keeps getting weight zero, as before.

Verified

  • Three new tests in tests/assimilation/test_distance_loc.py (gridless parameter without an entry, unlocalized parameters of both kinds, a misspelt name); all three fail without the change.
  • End to end, ES-MDA with distance localization runs on the MiniRes benchmark case of Add a benchmark of the update schemes on MiniRes twin experiments #184 (log-permeability field plus sor and vo), with Gaspari-Cohn tapers at the wells for the field and the two scalars unlocalized.
  • Full suite: 626 passed (with the minires extra). ruff clean.

🤖 Generated with Claude Code

…ft out

A state holding scalars besides a field could not use distance_loc. A
parameter with no localization entry gets a zero mask, sized from its
prior's nx/ny/nz, which a gridless prior does not have: KeyError 'nx'. And
there was no way to have such a parameter updated at all, since an entry
places a kernel on the field.

- A parameter without a grid is sized from its mean, as the prior draws it.
- `unlocalized = [...]` names parameters that every datum updates with
  weight one; it must name parameters of the state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KriFos1
KriFos1 merged commit 4fca540 into Python-Ensemble-Toolbox:main Oct 28, 2026
4 checks passed
@patnr
patnr deleted the distance-loc-unlocalized branch October 29, 2026 12:01
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