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

Fails to resample RSS in native format #2368

Closed
jdaniel006 opened this issue Jan 25, 2023 · 11 comments
Closed

Fails to resample RSS in native format #2368

jdaniel006 opened this issue Jan 25, 2023 · 11 comments
Assignees
Labels

Comments

@jdaniel006
Copy link

jdaniel006 commented Jan 25, 2023

Describe the bug
Loading a scene with seviri_l1b_native from a native Meteosat RSS file and then trying to resample it, fails with exception ValueError: Latitude values can not contain inf values.

It was not happening with older versions on another workstation.

To Reproduce

# Your code here
from satpy.scene import Scene
from satpy.resample import get_area_def
from satpy import find_files_and_readers
from datetime import datetime
import glob
import warnings

fnames=["tempRSS/MSG3-SEVI-MSG15-0100-NA-20230125105009.689000000Z-NA.nat"] #Use a local file
scn=Scene(reader='seviri_l1b_native', filenames=fnames)

composite = 'natural_color'
scn.load([composite])
scn.show(composite) # So far, so good

local_scn = scn.resample("eurol") # Boom! 

Expected behavior
satpy v0.39 should behave as v0.31, which used to work (lots of warnings, but it produced correct results).

Actual results
Text output of actual results or error messages including full tracebacks if applicable.

/home/meteo/.conda/envs/pytroll/lib/python3.10/site-packages/pyresample/spherical.py:300: RuntimeWarning: invalid value encountered in divide
  cart = self.cart / norm
/home/meteo/.conda/envs/pytroll/lib/python3.10/site-packages/pyresample/spherical.py:34: RuntimeWarning: invalid value encountered in remainder
  return (val + mod) % (2 * mod) - mod
/home/meteo/.conda/envs/pytroll/lib/python3.10/site-packages/pyresample/spherical.py:547: RuntimeWarning: invalid value encountered in cos
  self.cvertices = np.array([np.cos(self.lat) * np.cos(self.lon),
/home/meteo/.conda/envs/pytroll/lib/python3.10/site-packages/pyresample/spherical.py:548: RuntimeWarning: invalid value encountered in cos
  np.cos(self.lat) * np.sin(self.lon),
/home/meteo/.conda/envs/pytroll/lib/python3.10/site-packages/pyresample/spherical.py:549: RuntimeWarning: invalid value encountered in sin
  np.sin(self.lat)]).T * radius
Traceback (most recent call last):
  File "/home/meteo/.conda/envs/pytroll/lib/python3.10/site-packages/satpy/scene.py", line 901, in _reduce_data
    (slice_x, slice_y), source_area = reductions[key]
KeyError/home/meteo/.conda/envs/pytroll/lib/python3.10/site-packages/pyproj/crs/crs.py:1296: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems
  proj = self._crs.to_proj4(version=version)
: Area ID: msg_seviri_rss_3km
Description: MSG SEVIRI Rapid Scanning Service area definition with 3 km resolution
Projection: {'a': '6378169', 'h': '35785831', 'lon_0': '9.5', 'no_defs': 'None', 'proj': 'geos', 'rf': '295.488065897014', 'type': 'crs', 'units': 'm', 'x_0': '0', 'y_0': '0'}
Number of columns: 3712
Number of rows: 1392
Area extent: (5567248.0742, 5570248.4773, -5570248.4773, 1393687.2705)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/meteo/.conda/envs/pytroll/lib/python3.10/site-packages/satpy/scene.py", line 954, in resample
    self._resampled_scene(new_scn, destination, resampler=resampler,
  File "/home/meteo/.conda/envs/pytroll/lib/python3.10/site-packages/satpy/scene.py", line 865, in _resampled_scene
    dataset, source_area = self._reduce_data(dataset, source_area, destination_area,
  File "/home/meteo/.conda/envs/pytroll/lib/python3.10/site-packages/satpy/scene.py", line 908, in _reduce_data
    slice_x, slice_y = source_area.get_area_slices(
  File "/home/meteo/.conda/envs/pytroll/lib/python3.10/site-packages/pyresample/geometry.py", line 2616, in get_area_slices
    intersection = data_boundary.contour_poly.intersection(
  File "/home/meteo/.conda/envs/pytroll/lib/python3.10/site-packages/pyresample/spherical.py", line 713, in intersection
    return self._bool_oper(other, -1)
  File "/home/meteo/.conda/envs/pytroll/lib/python3.10/site-packages/pyresample/spherical.py", line 649, in _bool_oper
    arcs1 = [edge for edge in self.aedges()]
  File "/home/meteo/.conda/envs/pytroll/lib/python3.10/site-packages/pyresample/spherical.py", line 649, in <listcomp>
    arcs1 = [edge for edge in self.aedges()]
  File "/home/meteo/.conda/envs/pytroll/lib/python3.10/site-packages/pyresample/spherical.py", line 571, in aedges
    yield Arc(SCoordinate(lon_start, lat_start),
  File "/home/meteo/.conda/envs/pytroll/lib/python3.10/site-packages/pyresample/spherical.py", line 131, in __init__
    lon, lat = _check_lon_lat(lon, lat)
  File "/home/meteo/.conda/envs/pytroll/lib/python3.10/site-packages/pyresample/spherical.py", line 119, in _check_lon_lat
    _check_lat_validity(lat)
  File "/home/meteo/.conda/envs/pytroll/lib/python3.10/site-packages/pyresample/spherical.py", line 109, in _check_lat_validity
    raise ValueError("Latitude values can not contain inf values.")
ValueError: Latitude values can not contain inf values.

Screenshots
N/A

Environment Info:

  • OS: openSUSE (as a VM guest)
  • python 3.10.8
  • Satpy Version: 0.39.0
  • PyResample Version: 1.26.0.post0
  • Readers and writers dependencies (when relevant): [run from satpy.utils import check_satpy; check_satpy()]
    seviri_l1b_native: ok

Additional context
Mostly clean install under conda environment. Not tested with old versions in new computer (solving environment takes forever) UPDATE: finally checked and older version in newer machine works.

@TAlonglong
Copy link
Collaborator

TAlonglong commented Jan 26, 2023

I had a look. I downloaded /MSG3-SEVI-MSG15-0100-NA-20230125104916.184000000Z-NA.nat ( not exact time match, but I guess that does not mater)

I reproduced your error with satpy=0.39.0 and pyresample=1.26.0.post0

I did downgrade pyresample like this conda install -c conda-forge --override-channels pyresample=1.25.1 to the previous version, and as far as I can see this version of pyresample works.

So something happened with pyresample between 1.25.1 and 1.26.0.post0, but I need some of the pyresample developers to suggest a cause for this.

@TAlonglong
Copy link
Collaborator

I also tested pyresample 1.26.0 which gives the same error as shown by the user.

@TAlonglong
Copy link
Collaborator

I need to add my tests are under python 3.9

@jdaniel006
Copy link
Author

And the downgrade to pyresample=1.25.1 is a workaround at the moment. Python 3.10 for me.

@mraspaud
Copy link
Member

@jdaniel006 thanks for reporting this!
This seems to be a regression in pyresample according to the findings of @TAlonglong. I'll try reproducing it with a minimal example.

@mraspaud
Copy link
Member

Oh, it's the spherical stuff... @ghiggi do you have an idea?

@mraspaud
Copy link
Member

@jdaniel006 I pushed a PR to pyresample, do you want to check it locally to see if it fixes your problem?

@ghiggi
Copy link
Contributor

ghiggi commented Jan 26, 2023

Hi Martin. I guess you already identified the cause ;)

@jdaniel006
Copy link
Author

@mraspaud With pleasure!

Checked the PR and the resample runs perfectly. I have had some problems with our custom area but I guess it's because of my limited github expertise.

Thank you.

@mraspaud
Copy link
Member

Perfect, thanks for checking!

@mraspaud mraspaud self-assigned this Jan 26, 2023
@mraspaud mraspaud added the bug label Jan 26, 2023
@mraspaud
Copy link
Member

mraspaud commented Feb 7, 2023

Fixed in pytroll/pyresample#493

@mraspaud mraspaud closed this as completed Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants