Skip to content

[nhi_chloride] sea override runs before the horizontal fill, so coastal land cells can inherit 18000 mg/l #63

Description

@bdestombe

nhi_chloride.py:42-45:

da.values[0] = xr.where(ds["northsea"] == 1, SEA_CHLORIDE_MG_L, da.values[0])

for ilay in range(da.layer.size):
    da.values[ilay] = nlmod.resample.fillnan_da(ds=ds, da=da.isel(layer=ilay), method="nearest")

The sea override is applied before the nearest-neighbour gap fill. Any top-layer land cell that is NaN after interpolation (typically outside the NHI source extent) is then filled from its nearest valid neighbour — which, along the coast, is frequently a sea cell now holding 18000 mg/l. Those land cells start the transport model at full sea-water chloride.

Reversing the order (fill first, then apply the sea override) would confine 18000 mg/l to actual sea cells. Whether that is the desired schematisation is a modelling decision, hence an issue rather than a patch.

Found while writing the nhflotools test suite; deliberately not pinned by a test, since a test would entrench whichever behaviour is currently in place.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions