polaris.tasks.ocean.horiz_press_grad.reconstruction.linear_slope

polaris.tasks.ocean.horiz_press_grad.reconstruction.linear_slope(values: DataArray, pressure_mid: DataArray) → DataArray[source]

The slope of the mean-preserving linear reconstruction, per layer.

A centred difference of the layer means with respect to mid-layer pressure, one-sided in the shallowest and deepest valid layer of each column. Exact for a profile linear in pressure on an arbitrary grid; second-order accurate otherwise.

The one-sided branches are not an edge case here. The deepest valid layer is a partial cell in both columns and carries the whole signal for the bathymetry_step configuration, so the one-sided branch is exercised exactly where the interesting behaviour is.

Parameters:
  • values (xarray.DataArray) – Layer-mean conservative temperature or absolute salinity, with nVertLevels last. Invalid layers are NaN.

  • pressure_mid (xarray.DataArray) – Mid-layer sea gauge pressure in Pa, on the same points.

Returns:

slope (xarray.DataArray) – The slope per Pa, NaN in invalid layers and zero in a column with only one valid layer.