hainegroup / oceanspy

A Python package to facilitate ocean model data analysis and visualization.
https://oceanspy.readthedocs.io
MIT License
98 stars 32 forks source link

Choice of `THETA` and `SALT` for temp incompatible with density calculation #316

Closed Mikejmnez closed 1 year ago

Mikejmnez commented 1 year ago
fig= plt.figure(figsize=(15, 6), facecolor='w')
ax = od_surv.plot.vertical_section(
    varName="THETA",
    plotType="contourf",
    levels=np.linspace(-1,10,100),
    contourName="Sigma0",
    meanAxes="time",
    robust=True,
    cmap="RdBu_r",
)

The snippet above aims to make a vertical section of THETA (temperature) along a particular survey, while overlapping density contours. I get the following error :

error

The problem is that oceanspy uses Temp and S by default, as the variable name by choice for temperature and salinity, respectively. You can see this, for example, inside the TSdiagram plot function (lines 180 of plot.py)

# Check and extract T and S
varList = ["Temp", "S"]
od = _add_missing_variables(od, varList)

I didn't have that problem when running the notebook during Ocean Sciences Meeting, because the intake catalog for LLC4320 renamed T as Temp, as it should be. I changed the intake catalog entry for LLC4320 to match that of, and therefore be consistent with, the catalog entry for ECCO data. See PR #282.

Solution

Make all variable names for temperature and salinity (an others?) consistent with the way oceanspy uses them (on intake catalog).

renskegelderloos commented 1 year ago

THETA and SALT are diagnostics (output from the diagnostics package), while Temp and S are state variables. THETA and SALT are often (but not necessarily) time averages. We need to check this, but it may be worth keeping both or think through the consequences of changing them to Temp and S.

Mikejmnez commented 1 year ago

That makes sense!

ThomasHaine commented 1 year ago

Following discussion: fix catalog to return LLC4320 variables to "Temp" and "S". Users who insist on computing density with "THETA" and "SALT" (which may be time-averages, like in ECCO), can call the density function directly.