Skip to content

Silence seawater deprecation#239

Merged
pgierz merged 3 commits into
mainfrom
chore/silence-seawater-deprecation
May 12, 2026
Merged

Silence seawater deprecation#239
pgierz merged 3 commits into
mainfrom
chore/silence-seawater-deprecation

Conversation

@pgierz
Copy link
Copy Markdown
Member

@pgierz pgierz commented May 12, 2026

Summary

The seawater library prints a UserWarning: The seawater library is deprecated! Please use gsw instead. on every pyfesom2 import. This PR silences that warning at the only site that imports it (pyfesom2/climatology.py) and adds a prominent block comment explaining why a migration to gsw is not happening at this time.

Why not migrate to gsw?

  • seawater.ptmp expects Practical Salinity (PSS-78). gsw.pt0_from_t expects Absolute Salinity (g/kg).
  • gsw.SA_from_SP(SP, p, lon, lat) does a regionally varying lookup against a bundled atlas — a literal swap would silently change the numerics.
  • Climatology inputs here (PHC / WOA) are practical salinity, so reproducibility against legacy pyfesom2 output would break.

A real TEOS-10 migration is a scientific decision, not a mechanical refactor, and is deferred until that decision is made.

Compatibility check

Verified that seawater still runs on Python 3.13 + numpy 2.4.3 in a clean container (sw.ptmp returns sensible values), so silencing rather than removing is safe for the foreseeable future.

Test plan

  • python -c "import pyfesom2" no longer prints the seawater deprecation warning
  • pyfesom2.climatology.climatology(<phc_file>) still produces identical potential-temperature output Not a sensible test, nothing touches this code
  • CI green

The seawater library is deprecated in favor of gsw (TEOS-10) but a
literal swap is not safe: gsw expects Absolute Salinity (g/kg) while
this module receives Practical Salinity from PHC/WOA, and the SA<->SP
conversion is regionally varying. Until a deliberate scientific
decision is made on TEOS-10 migration, keep EOS-80 numerics and just
silence the import-time warning. Prominent comment block records why.

Verified seawater still works on Python 3.13 + numpy 2.4.x.
@JanStreffing
Copy link
Copy Markdown
Contributor

I've seen this one so many times :)
Ty!

@pgierz
Copy link
Copy Markdown
Member Author

pgierz commented May 12, 2026

I'm still going to get the tests to pass (they are unrelated to anything here, just some infra hiccups in conda I think)

It might be worthwhile to bump up the Pyfesom2 version number, what do you think @JanStreffing?

@pgierz pgierz merged commit 57157ec into main May 12, 2026
16 checks passed
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