Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Geostationary coord_system #5745

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
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
12 changes: 11 additions & 1 deletion lib/iris/analysis/_regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ def interpolate(data):
return data

def _check_units(self, coord):
from iris.coord_systems import GeogCS, RotatedGeogCS
from iris.coord_systems import GeogCS, Geostationary, RotatedGeogCS

if coord.coord_system is None:
# No restriction on units.
Expand All @@ -842,6 +842,16 @@ def _check_units(self, coord):
"Expected 'degrees' got {!r}.".format(coord.units)
)
raise ValueError(msg)
elif isinstance(
coord.coord_system,
Geostationary,
):
if coord.units != "radians":
msg = (
"Unsupported units for coordinate system. "
"Expected 'radians' got {!r}.".format(coord.units)
)
raise ValueError(msg)
else:
# Units for other coord systems must be equal to metres.
if coord.units != "m":
Expand Down
6 changes: 6 additions & 0 deletions lib/iris/fileformats/_nc_load_rules/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ def action_provides_coordinate(engine, dimcoord_fact):
coord_type = "projection_x"
elif hh.is_projection_y_coordinate(engine, var_name):
coord_type = "projection_y"
elif hh.is_projection_x_angular_coordinate(engine, var_name):
coord_type = "projection_x_angular"
elif hh.is_projection_y_angular_coordinate(engine, var_name):
coord_type = "projection_y_angular"

if coord_type is None:
# Not identified as a specific known coord_type.
Expand Down Expand Up @@ -274,6 +278,8 @@ def action_provides_coordinate(engine, dimcoord_fact):
),
"projection_x": ("projected", hh.CF_VALUE_STD_NAME_PROJ_X),
"projection_y": ("projected", hh.CF_VALUE_STD_NAME_PROJ_Y),
"projection_x_angular": ("projected", hh.CF_VALUE_STD_NAME_PROJ_X_ANGULAR),
"projection_y_angular": ("projected", hh.CF_VALUE_STD_NAME_PROJ_Y_ANGULAR),
"time": (None, None),
"time_period": (None, None),
"miscellaneous": (None, None),
Expand Down
22 changes: 22 additions & 0 deletions lib/iris/fileformats/_nc_load_rules/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@
CF_VALUE_STD_NAME_GRID_LON = "grid_longitude"
CF_VALUE_STD_NAME_PROJ_X = "projection_x_coordinate"
CF_VALUE_STD_NAME_PROJ_Y = "projection_y_coordinate"
CF_VALUE_STD_NAME_PROJ_X_ANGULAR = "projection_x_angular_coordinate"
CF_VALUE_STD_NAME_PROJ_Y_ANGULAR = "projection_y_angular_coordinate"


################################################################################
Expand Down Expand Up @@ -1413,6 +1415,16 @@ def is_projection_x_coordinate(engine, cf_name):
return attr_name == CF_VALUE_STD_NAME_PROJ_X


################################################################################
def is_projection_x_angular_coordinate(engine, cf_name):
"""Determine whether the CF coordinate variable is a projection_x_angular_coordinate variable."""
cf_var = engine.cf_var.cf_group[cf_name]
attr_name = getattr(cf_var, CF_ATTR_STD_NAME, None) or getattr(
cf_var, CF_ATTR_LONG_NAME, None
)
return attr_name == CF_VALUE_STD_NAME_PROJ_X_ANGULAR


################################################################################
def is_projection_y_coordinate(engine, cf_name):
"""Determine whether the CF coordinate variable is a projection_y_coordinate variable."""
Expand All @@ -1423,6 +1435,16 @@ def is_projection_y_coordinate(engine, cf_name):
return attr_name == CF_VALUE_STD_NAME_PROJ_Y


################################################################################
def is_projection_y_angular_coordinate(engine, cf_name):
"""Determine whether the CF coordinate variable is a projection_y_angular_coordinate variable."""
cf_var = engine.cf_var.cf_group[cf_name]
attr_name = getattr(cf_var, CF_ATTR_STD_NAME, None) or getattr(
cf_var, CF_ATTR_LONG_NAME, None
)
return attr_name == CF_VALUE_STD_NAME_PROJ_Y_ANGULAR


################################################################################
def is_time(engine, cf_name):
"""Determine whether the CF coordinate variable is a time variable.
Expand Down
3 changes: 3 additions & 0 deletions lib/iris/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ def _can_draw_map(coords):
["latitude", "longitude"],
["grid_latitude", "grid_longitude"],
["projection_y_coordinate", "projection_x_coordinate"],
["projection_y_angular_coordinate", "projection_x_angular_coordinate"],
]
return std_names in valid_std_names

Expand Down Expand Up @@ -797,6 +798,8 @@ def _draw_1d_from_points(draw_method_name, arg_func, *args, **kwargs):
if draw_method_name == "plot" and u_object.standard_name not in (
"projection_x_coordinate",
"projection_y_coordinate",
"projection_x_angular_coordinate",
"projection_y_angular_coordinate",
):
u = _shift_plot_sections(u_object, u, v)

Expand Down
2 changes: 2 additions & 0 deletions lib/iris/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,14 @@ def guess_coord_axis(coord):
"longitude",
"grid_longitude",
"projection_x_coordinate",
"projection_x_angular_coordinate",
):
axis = "X"
elif coord.standard_name in (
"latitude",
"grid_latitude",
"projection_y_coordinate",
"projection_y_angular_coordinate",
):
axis = "Y"
elif coord.units.is_convertible("hPa") or coord.attributes.get("positive") in (
Expand Down
Loading