GeoStat-Framework / PyKrige

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

Issue when running execute for universal kriging 3d #223

Closed ivan-marroquin closed 2 years ago

ivan-marroquin commented 2 years ago

Hi,

Many thanks for such great package!

I am using PyKrige 1.6.1 and noticed the following error message when executing universal kriging 3d:

The produced error message is as follows: residual_predict, residual_variance= model.execute(style= 'points', xpoints= coor_test[:,0], ypoints= coor_test[:,1], zpoints= coor_test[:,2], File "C:\Temp\Python_3.8.10\lib\site-packages\pykrige\uk3d.py", line 1072, in execute if spec.ndim != 1:

Checking the Python code, I noticed the 'spec' is used to go through the list of arrays defined in specified drift arrays parameter of execute object. Since the execute object expects to have a list of arrays, the command 'spec.ndim' produces the error message. I also noticed that there is another checking using: spec.shape[0] != xpts.size, which I am sure it will produce another error.

My workaround was to uncomment Python line commands from 1072 - 1083.

Kind regards,

Ivan

MuellerSeb commented 2 years ago

Would you mind creating a PR to fix this? There we could discuss further on what was happening.

MuellerSeb commented 2 years ago

I guess you only need to add brackets ([...]) around your specified_drift_arrays and convert them to numpy arrays. I assume you are using only one array for the specified drift, but that has to be supplied as a list with that one numpy array as only element:

residual_predict, residual_variance = model.execute(
    style='points', 
    xpoints= coor_test[:,0],
    ypoints= coor_test[:,1],
    zpoints= coor_test[:,2],
    specified_drift_arrays=[np.asarray(spec)],
)

This is also stated in the doc-string of that method.