Skip to content

Commit 7d8dd9a

Browse files
Update src/CSET/operators/plot.py
Co-authored-by: James Frost <james.frost@metoffice.gov.uk>
1 parent 8da9518 commit 7d8dd9a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/CSET/operators/plot.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -959,11 +959,11 @@ def _convert_precipitation_units_callback(cube: iris.cube.Cube):
959959
if cube.long_name == "surface_microphysical_rainfall_rate":
960960
if cube.units == "kg m-2 s-1":
961961
logging.info("Converting precipitation units from kg m-2 s-1 to mm hr-1")
962-
# manually convert from kg m-2 s-1 to mm hr-1 assuming 1kg water = 1l water = 1dm^3 water
963-
cube.data = cube.data * 3600.0
964-
965-
# update the units
966-
cube.units = "mm hr-1"
962+
# Convert from kg m-2 s-1 to mm s-1 assuming 1kg water = 1l water = 1dm^3 water.
963+
# This is a 1:1 conversion, so we just change the units.
964+
cube.units = "mm s-1"
965+
# Convert the units to per hour.
966+
cube.convert_units("mm hr-1")
967967
else:
968968
logging.warning(
969969
"Precipitation units are not in 'kg m-2 s-1', skipping conversion"

0 commit comments

Comments
 (0)