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

Catch or fix pyproj UserWarning when loading an AreaDefinition from a netCDF/CF file #550

Open
TomLav opened this issue Oct 16, 2023 · 1 comment

Comments

@TomLav
Copy link
Contributor

TomLav commented Oct 16, 2023

What's the problem:

pyresample's load_cf_area() forwards a UserWarning from pyproj:
UserWarning: You will likely lose important projection information when converting to a PROJ string from another format.

Severity:

Low. It is annoying to get the warning, but we know where it comes from.

Where does it come from:
The warning is triggered because we call pyproj's CRS.to_dict():

crs_dict = crs.to_dict()

We use CRS.to_dict() to test the type of the projection, not to do any math / transformation with it.

Solutions:
Two solutions:

  1. Keep using to_dict() but catch the UserWarning (as done elsewhere in pyresample);
  2. Access the parameters in another, more CRS-friendly way, that will not trigger a warning.
@djhoese
Copy link
Member

djhoese commented Oct 16, 2023

It looks like 2 main properties are looked at:

  1. Is this a geostationary projection?
  2. Get satellite height

For geostationary check, I added a helper method a while back to the AreaDefinition that covers this:

@property
def is_geostationary(self):
"""Whether this area is in a geostationary satellite projection or not."""
coord_operation = self.crs.coordinate_operation
if coord_operation is None:
return False
return 'geostationary' in coord_operation.method_name.lower()

Extracting that as a utility function would make sense.

For geostationary height there is already a utility function for that:

def get_geostationary_height(geos_area_crs):
"""Get the height parameter from a geostationary CRS."""
params = geos_area_crs.coordinate_operation.params
h_param = [p for p in params if 'satellite height' in p.name.lower()][0]
return h_param.value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants