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.
nhi_chloride.py:42-45: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.