Skip to content

Commit

Permalink
pad press variable (#1148)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinElms authored Apr 26, 2024
1 parent 91303ff commit d74633c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions data/calculated_parser/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ def density(depth, latitude, temperature, salinity) -> np.ndarray:

press = __calc_pressure(depth, latitude)

if salinity.shape != press.shape:
# Need to pad press so it can broadcast against temperature and salinity.
# eg. if using GIOPS and salinity has shape (3, 50, 3, 12) then press has
# shape (50, 3). This logic pads press to give shape (1, 50, 3, 1).
for ax, val in enumerate(salinity.shape):
if ax > press.ndim - 1 or press.shape[ax] != val:
press = np.expand_dims(press, axis=ax)

density = gsw.density.rho(salinity, temperature, press)
return np.array(density)

Expand Down

0 comments on commit d74633c

Please sign in to comment.