Skip to content

Commit

Permalink
Removed unnecessary dictionaries from name function
Browse files Browse the repository at this point in the history
  • Loading branch information
fionaRust committed May 26, 2020
1 parent 66079d8 commit 0178eeb
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions lib/iris/fileformats/nimrod_load_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def name(cube, field):
"""Set the cube's name from the field.
Modifies the Nimrod object title based on other meta-data in the
Nimrod field and known use cases.
Adds "mean_of" or "standard_deviation_of_" to the cube name if appropriate.
"""
title_from_field_code = {
12: "air_pressure",
Expand All @@ -52,40 +53,26 @@ def name(cube, field):
58: "temperature",
61: "amount_of_precipitation",
63: "rate_of_precipitation",
29: "fog fraction",
101: "snow_melting_level_above_sea_level",
102: "rain_melted_level_above_sea_level",
155: "Visibility",
156: "Worst visibility in grid point",
161: "minimum_cloud_base_above_threshold",
172: "cloud_area_fraction_in_atmosphere",
218: "snowfall",
421: "precipitation type",
501: "vector_wind_shear",
508: "low_level_jet_u_component",
509: "low_level_jet_curvature",
514: "low_level_jet_v_component",
817: "wind_speed_of_gust",
821: "Probabilistic Gust Risk Analysis from Observations",
}
# threshold_value >= 0
title_from_field_code_and_threshold = {
29: "fog fraction",
161: "minimum_cloud_base_above_threshold",
}
# vertical_coord >= 0
title_from_field_code_and_vcoord = {
804: "wind speed",
806: "wind direction",
817: "wind_speed_of_gust",
821: "Probabilistic Gust Risk Analysis from Observations",
}
cube_title = title_from_field_code.get(field.field_code, field.title)
if field.threshold_value >= 0:
cube_title = title_from_field_code_and_threshold.get(
field.field_code, cube_title
)
if field.vertical_coord >= 0:
cube_title = title_from_field_code_and_vcoord.get(
field.field_code, cube_title
)

cube_title = title_from_field_code.get(field.field_code, field.title)
if field.ensemble_member == -98:
if not re.match("(?i)^.*(mean).*", cube_title):
cube_title = "mean_of_" + cube_title
Expand Down

0 comments on commit 0178eeb

Please sign in to comment.