pytroll / pytroll/pyresample

RuntimeWarning: invalid value encountered in divide x_2 = (-b__ - np.sqrt(discriminant)) / (2 * a__)

Open
#608 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
385
Forks
102
Avg merge
4d 2h
Merged PRs (30d)
9

Description

Code Sample, a minimal, complete, and verifiable piece of code

I have a temperature grib message and I want to resample it using cubic resampling. However, i get these warnings in the console. If i lower the radius value I no longer get the warnings but I get 0s in the interpolated data.

 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)

RuntimeWarning: invalid value encountered in divide   x_2 = (-b__ - np.sqrt(discriminant)) / (2 * a__)
import numpy as np
from pyproj import CRS
from pyresample.geometry import GridDefinition
from pyresample import create_area_def
from pyresample.bilinear import NumpyBilinearResampler
from pyresample import geometry


data = np.fromfunction(lambda y, x: y * x, (100, 100))
lons = np.fromfunction(lambda y, x: -180 + x * 3.6, (100, 100))
lats = np.fromfunction(lambda y, x: -90 + y * 1.8, (100, 100))


source_def = geometry.GridDefinition(lons=lons, lats=lats)

crs = CRS.from_epsg(3857)  # EPSG code for WGS 84 / Pseudo-Mercator
target_def = create_area_def('my_area',
        crs,
        1000, 1000,
        area_extent=[-180, -85, 180, 85],                
        units='degrees',
        description='Target grid in Mercator projection')


resampler = NumpyBilinearResampler(source_def, target_def, radius_of_influence=200000)
interpolated_data = resampler.resample(data)

Thank you!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied Python example and inspect NumpyBilinearResampler.resample where the RuntimeWarning appears during cubic or bilinear resampling. Compare the behavior with different radius_of_influence values and investigate the projection and grid definitions shown. Done means the warning's cause is addressed and interpolation no longer silently produces zeros for the reported case.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.