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

grdmath SUB operator #916

Open
arleaman opened this issue Feb 16, 2021 · 3 comments · May be fixed by #1527
Open

grdmath SUB operator #916

arleaman opened this issue Feb 16, 2021 · 3 comments · May be fixed by #1527
Labels
feature request New feature wanted

Comments

@arleaman
Copy link
Contributor

grdmath SUB operator

I would like to use this feature to calculate residuals by finding the difference between two grid files.

Are you willing to help implement and maintain this feature? Yes, with guidance

@arleaman arleaman added the feature request New feature wanted label Feb 16, 2021
@welcome
Copy link

welcome bot commented Feb 16, 2021

👋 Thanks for opening your first issue here! Please make sure you filled out the template with as much detail as possible. You might also want to take a look at our contributing guidelines and code of conduct.

@weiji14
Copy link
Member

weiji14 commented Feb 17, 2021

Hi @arleaman, just need a bit more information on what your 'grids' are. Are they NetCDF files, xarray.DataArray/xarray.Dataset objects, or something else? This will help us to advice you a bit better.

About calculating residuals (using SUB), I would recommend doing it directly in xarray (see http:https://xarray.pydata.org/en/v0.16.2/computation.html#basic-array-math) using the minus '-' operator if possible, assuming that you are already familiar with xarray. Not to say we can't wrap a grdmath function in PyGMT, but the reverse polish notation of grdmath will make implementing this a bit tricky (though you are welcome to try).

@arleaman
Copy link
Contributor Author

Thanks @weiji14 - I am using NetCDF files for my grids and will look into performing calculations in xarray.

weiji14 added a commit that referenced this issue Sep 19, 2021
Initial commit for wrapping the grdmath function for #916
which is a "Raster calculator for grids (element by element)".
Original GMT `grdmath` documentation is at
https://docs.generic-mapping-tools.org/6.2/grdmath.html.
Implementation works by building and storing a computational
graph of the grid operations in a GrdMathCalc class object.
An output NetCDF grid or xarray.DataArray is produced
upon calling `.compute()` or by setting `outgrid=True`.
@weiji14 weiji14 linked a pull request Sep 19, 2021 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants