Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Aaron Hopkinson <aaron.hopkinson@metoffice.gov.uk> <arh89@users.noreply.github.com>
Alice Lake <alice.lake@metoffice.gov.uk> <69578135+mo-AliceLake@users.noreply.github.com>
Andrew Creswick <andrew.creswick@metoffice.gov.uk> AndrewCreswick <andrew.creswick@metoffice.gov.uk>
Alice Lake <alice.lake@metoffice.gov.uk> <69578135+mo-AliceLake@users.noreply.github.com>
Anna Booton <anna.booton@metoffice.gov.uk> <anna.booton@metoffice.gov.uk>
Expand Down
23 changes: 16 additions & 7 deletions improver/cli/wind_downscaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,27 +85,35 @@ def process(
"associated height level has been provided. These units "
"will have no effect."
)

# Attempt to iterate over the wind data by 'realization', and apply corrections to each member.
# If the cube has no realization coordinate (e.g. deterministic model data), treat the entire cube as a single member.
try:
wind_speed_iterator = wind_speed.slices_over("realization")
except CoordinateNotFoundError:
wind_speed_iterator = [wind_speed]
wind_speed_list = iris.cube.CubeList()
for wind_speed_slice in wind_speed_iterator:
result = wind_downscaling.RoughnessCorrection(
silhouette_roughness,
sigma,
target_orography,
standard_orography,
model_resolution,
z0_cube=vegetative_roughness,
model_silhouette_roughness_cube=silhouette_roughness,
model_orog_stddev_cube=sigma,
target_orog_cube=target_orography,
model_orog_cube=standard_orography,
model_res=model_resolution,
model_z0_cube=vegetative_roughness,
height_levels_cube=None,
)(wind_speed_slice)
wind_speed_list.append(result)

wind_speed = wind_speed_list.merge_cube()

# Check whether 'realization' exists as a non-dimension coordinate.
# If so, reinsert it as a proper dimension axis so the cube has the expected shape.
non_dim_coords = [x.name() for x in wind_speed.coords(dim_coords=False)]
if "realization" in non_dim_coords:
wind_speed = iris.util.new_axis(wind_speed, "realization")

# If a specific output height is requested, use apply_extraction to select
# the corresponding height level from the processed wind cube.
if output_height_level is not None:
constraints = {"height": output_height_level}
units = {"height": output_height_level_units}
Expand All @@ -121,4 +129,5 @@ def process(
)
)
wind_speed = single_level

return wind_speed
Loading