-
Notifications
You must be signed in to change notification settings - Fork 224
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
Passing xarray.DataArray to grdfilter gives incorrect results #859
Comments
@PaulWessel It looks like a GMT bug. Please see if you can fix it when you have time. |
To keep it as simple as possible, can you demonstrate the same mismatch with -Fg300 or even better, -Fb300 ? |
CLI:
Python:
the output is even worse:
|
How would you do the equivalent of
in python, and does it differ then too (trying to make as small test as possible) |
import pygmt
grid = pygmt.grdcut("@earth_relief_01d_p", region=[0, 10, 0, 10])
print(grid.data.max(), grid.data.min())
result = pygmt.grdfilter(grid, filter='b300', distance='4')
print(result.data.max(), result.data.min()) output:
|
Ping @PaulWessel just in case you forget it. |
Was starting to look using my new M1 laptop but first have to install miniconda and that got me this far: bash ~/Downloads/Miniconda3-py39_4.9.2-MacOSX-x86_64.sh Some googling talks about condo running in emulation mode but not sure about miniconda. I guess this is all work in progress. Not sure how to proceed. Perhaps just not do this on laptop but do it on the old Mac Pro Intel... |
Hi @seisman, is this still failing after the last API fixes today/yesterday? |
It's still failing. |
Odd, I just stepped through the whole grdfilter example above (the 10x10 case) and I got the same result as CLI. Sure you rebuilt etc? |
I think I'm using the latest GMT version ( What happens if you just run the examples, not in Xcode debugging. |
Same result with release build or xbuild. |
This is my output:
Can you show your output of |
|
The PyGMT version doesn't make sense:
Did you update your pygmt to the latest (using |
OK, I had done git pull but not make install. Now done this morning and still works
I also followed this in xcode and the temporary files that pygmt makes (the grid, etc) match that of CLI. |
Can @meghanrjones or @weiji14 check if it works for you (you need to build the latest GMT dev). |
I can check it out. |
I'm getting the same results as @seisman. I do not understand why pygmt.show_versions shows v0.3.2 for me:
While @PaulWessel's has 0.3.1:
If that's not the issue, perhaps it would be worth trying to sync the dependencies since it seems that @seisman and I are using later xarray versions. |
I do not understand either, but cannot see how this can be a bug in GMT if it steps through and does all the right things? |
The version difference is due to a known limitation of setuptools_scm (#912). |
I just created a new conda environment and install the package versions @PaulWessel is using. I still have the same problem. @PaulWessel Your PyGMT version Could you please follow the instructions below:
and then check |
OK:
git pull (lots of updates).
I assume the only thing that changed here is pyGMT and that the shared GMT lib stayed the same? So perhaps this is an issue in how the gmt info call is done? Can you check the intermediate grid in /tmp? |
Good to know that we're on the same page. I think the old version you were using ( I just switched to that PR, and it works for me. So, it fails for "GMT_IN|GMT_IS_REFERENCE", but works for "GMT_IN". |
Which step is failing? the filtering or the hidden grdinfo on the temp file? |
The
|
OK, and this is with GMT_IN, and with REFERENCE it works OK? Not sure why grdinfo would return NaN in the limits since the grid clearly has non-NaN values. |
No, PyGMT is using The min and max values are not obtained from the grdinfo call. So any NaN values in data can cause:
|
Sorry, I wrote it backwards but meant what you wrote above (!). |
Description of the problem
Here is the result from GMT CLI. From the output, we can know the min and max of the filtered grid, -6147.49072266 and 5164.06005859.
This is how we do the same thing in Python:
The output is:
Obviously, passing xarray.DataArray to grdfilter gives incorrect results.
It's still unclear to me if this is a PyGMT bug or an upstream GMT bug.
Note: the tests in
test_grdfilter.py
is testing the "wrong" results. We need to update the tests after figuring out the reason.The text was updated successfully, but these errors were encountered: