-
Notifications
You must be signed in to change notification settings - Fork 339
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
Add grdclip functionality to grdmath #6257
Comments
Because grdclip predates grdmath. But I agree we could add those features to grdmath via new operators, e.g., low replace CLIPL (-Sb) Since for backwards reasons we cannot remove grdclip we now would have to keep grdclip around but perhaps
|
That explains it; I was wondering why grdclip existed - all of this could(/should) be done in grdmath. I think your suggestions are good. |
|
I think pyGMT also are not able to wrap grdmath and gmtmath. But we did so in GMT/MEX but of course there we have the text command to work with. |
Wrapping is not a problem (Julia has it). The problem is to give it a friendly syntax. |
Just a question. With
|
That is correct, but that is what grdclip allows as well (-Sr and -Si are repeatable options in grdclip). |
Also, @anbj, note you could do what you wanted in grdmath in a different way:
Duplicate the stack, compare to 0 and get another grid that is 0 (false) for z < 0 and 1 (true) for z >= 0, then turn those 0s into NaNs, and multiply the 1 and NaN grid with your data, which turns things into what they were or NaN. |
Thanks. BTW, I had made a proposal (#4573) to improve |
Thanks for the reminder. It remains a tricky one and isn't super general. if your break values were computable it might be simpler (meaning clean multiples in the ranges rather than 3, 12, 22 etc. Let's say you want the slope values to be in three groups: 0-10,10-20,20-30 and azimuths in 8 groups.
But you are still up against the basic idea that this is a 2-D CPT where both azim and slope needs to be looked up from a 2-D CPT. Since we have no such thing it because a lot of scripting, like @joa-quim said. I imagine the simplest solution for the end user would a module like this
where -A is like in grdvector (so take slope and azim) and -D is the beast of a 2-D CPT. In creating the image we need both r and a to determine the rgb from your 2-D cpt somehow, and we may also allow -Iintens.grd. So most of this is like grdimage except
Looking at your color wheel, seems the hue is set via azimuth and then it is saturation changes with slope. Could you simulate this with turning your slope into the appropriate intensities and use grdimage? |
Thanks Paul, for this enlightening tour de force of RPN magic. Unfortunately, I never had an HP calculator. |
No, this would be very confusing to the people that know it exists and would not find the manual anymore. And besides, |
I agree with Joaquim. I also think that the functions of |
I understand that backward compatibility is/may be/is chosen to be important; but doesn't it create a plethora of technical debt? (That applies to all other work that is done in gmt as well - I'm surprised to see how often an 'old way of doing things' is preserved as an option, i.e. backwards compatibility). If people miss it, they need to consult the changelog and find out what happened. |
@weiji14 created a proof of concept for a PyGMT wrapper of grdmath in GenericMappingTools/pygmt#1527. I agree with @joa-quim about continuing to advertise grdclip, even if internally it is changed to a shortcut for new grdmath functionality. RPN is not easy for lots of people whereas grdclip is relatively simple. |
@PaulWessel, what do you think? Closing time? Let's get rid of it if it's not worth doing. |
Yes, please do. |
Why is the functionality in grdclip not included (or exclusively) in grdmath?
Today I had to do some calculations with grdmath and then set all cell values < 0 to NaN. To do this I had to:
Ideally, this should be possible to do with a single call to grdmath.
In my example only
-Sb
from grdclip was used, but all the options in grdclip could be included in grdmath.The text was updated successfully, but these errors were encountered: