GeoStat-Framework / PyKrige

Kriging Toolkit for Python
https://pykrige.readthedocs.io
BSD 3-Clause "New" or "Revised" License
765 stars 189 forks source link

ValueError #135

Closed victortm closed 4 years ago

victortm commented 4 years ago

Hi,

I'm trying to get a variogram using pykrige.ok.OrdinaryKriging function but I'm getting the next error:

image

I'm passing float values and longitude/latitude coordinates in decimal degrees.

I don't know if it could be related to this issue but I've found something that doesn't make so much sense to me in the documentation:

image

When longitude has West component, the result is negative, so is out of that [0,360] longitude range specified in the doc. Feel free to correct me if I'm wrong.

Thanks in advance and best regards

MuellerSeb commented 4 years ago

Could you provide a minimal example to reproduce the error?

victortm commented 4 years ago

Of course.

There you have some samples I'm working with:

image

Ignore ID parameter.

And this is how I'm calling the function:

image

MuellerSeb commented 4 years ago

In your example all data is in the same location. So the bining of the data for the variogram estimation results in degenerate Intervals. I get the same error with:

from pykrige import OrdinaryKriging as OK
lon = [-3.1, -3.1, -3.1]
lat = [40.0, 40.0, 40.0]
val = [1.1, 1.2, 1.3]
kr = OK(lon, lat, val, coordinates_type="geographic")
Traceback (most recent call last):

  File "test.py", line 6, in <module>
    kr = OK(lon, lat, val, coordinates_type="geographic")

  File "/usr/local/lib/python3.6/dist-packages/pykrige/ok.py", line 253, in __init__
    weight, self.coordinates_type)

  File "/usr/local/lib/python3.6/dist-packages/pykrige/core.py", line 482, in _initialize_variogram_model
    variogram_function, weight)

  File "/usr/local/lib/python3.6/dist-packages/pykrige/core.py", line 580, in _calculate_variogram_model
    args=(lags, semivariance, variogram_function, weight))

  File "/usr/local/lib/python3.6/dist-packages/scipy/optimize/_lsq/least_squares.py", line 786, in least_squares
    raise ValueError("`x0` is infeasible.")

ValueError: `x0` is infeasible.

Your data-locations need to be pairwise different!

victortm commented 4 years ago

Thanks, now works!

MuellerSeb commented 4 years ago

Solved.