Skip to content

Commit

Permalink
Fixed syntax error in verif output with elev_gradient
Browse files Browse the repository at this point in the history
  • Loading branch information
tnipen committed Jan 16, 2025
1 parent 1434835 commit 96465b8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
4 changes: 2 additions & 2 deletions bris/outputs/verif.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ def _add_forecast(self, times: list, ensemble_member: int, pred: np.array):

if self.elev_gradient is not None:
interpolated_altitudes = gridpp.bilinear(
self.igrid, self.opoints, self.igrid.get_altitudes()
self.igrid, self.opoints, self.igrid.get_elevs()
)
daltitude = self.opoints.get_elevs() - interpolated_altitudes
interpolated_pred += self.elev_gradient * delev
interpolated_pred += self.elev_gradient * daltitude
interpolated_pred = interpolated_pred[
:, :, None
] # Add in variable dimension
Expand Down
36 changes: 19 additions & 17 deletions tests/test_outputs_verif.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,26 @@ def test_1():
pm = PredictMetadata(variables, lats, lons, altitudes, leadtimes, num_members, field_shape)
ofilename = "otest.nc"
workdir = "verif_workdir"
output = Verif(
pm,
workdir,
ofilename,
"2t",
sources,
"K",
thresholds=thresholds,
quantile_levels=quantile_levels,
)

frt = 1672552800
times = frt + leadtimes
for member in range(num_members):
pred = np.random.rand(*pm.shape)
output.add_forecast(times, member, pred)

output.finalize()
for elev_gradient in [None, 0]:
output = Verif(
pm,
workdir,
ofilename,
"2t",
sources,
"K",
thresholds=thresholds,
quantile_levels=quantile_levels,
elev_gradient=elev_gradient,
)

times = frt + leadtimes
for member in range(num_members):
pred = np.random.rand(*pm.shape)
output.add_forecast(times, member, pred)

output.finalize()


if __name__ == "__main__":
Expand Down

0 comments on commit 96465b8

Please sign in to comment.