roms_tools.setup.utils.compute_in_situ_density

roms_tools.setup.utils.compute_in_situ_density#

roms_tools.setup.utils.compute_in_situ_density(temp: DataArray, salt: DataArray, depth: DataArray, lat: DataArray) DataArray#

Compute in-situ seawater density (kg/m³) via TEOS-10 (gsw).

Pressure is derived from depth via gsw.p_from_z and density is then computed with gsw.rho, both wrapped in apply_ufunc for dask compatibility. Like compute_potential_density(), this treats practical salinity as Absolute Salinity and in-situ temperature as Conservative Temperature – an approximation carried over from that function for consistency, sufficient for the µmol/kg -> mmol/m³ unit conversions that call this.

Parameters:
  • temp (xr.DataArray) – In-situ temperature (°C).

  • salt (xr.DataArray) – Practical salinity (PSU).

  • depth (xr.DataArray) – Depth (m), positive down.

  • lat (xr.DataArray) – Latitude (degrees north).

Returns:

xr.DataArray – In-situ density (kg/m³).