-
Notifications
You must be signed in to change notification settings - Fork 229
Return values of gmt.info #147
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
Comments
Hi @seisman, sorry I missed this issue. I think we can leave it the way it is for now. I'll leave this open so we know to come back to it if the need arises. |
I also agree with that |
Yep. Those should be very low in our list of things to wrap. |
tl;dr After reading the above discussion, I would like to work on more fully wrapping Motivation In my use case, I want to easily see the min/max z-values of a DEM so that I can choose my colorbar limits. 1. No specified region With import gmt
print(gmt.grdinfo(GRIDFILE).strip())
or (with import xarray
print(xarray.open_dataset(GRIDFILE).z.actual_range)
These are about equal effort (and 2. Specified region of interest For viewing the min/maz z-values within a specified import gmt
print(gmt.grdinfo(GRIDFILE, R='{}/{}/{}/{}'.format(*REGION)).strip())
vs. import xarray
z = xarray.open_dataset(GRIDFILE).sel(lon=slice(*REGION[0:2]), lat=slice(*REGION[2:4])).z.values
print(z.min(), z.max())
Plus print(gmt.grdinfo(GRIDFILE, region=REGION).strip()) and (with more work) could perhaps output a dictionary? Please let me know if this is a worthwhile effort and I'll make a PR for |
This issue is opened to further discuss the #106 (comment) about
gmt.info
.IMHO, returning the output makes more sense than printing it. It's easy for users to print it via
print(gmt.info())
if they need.As far as I know, the outputs of
gmt info
can be divided into following types when different options are used:Type 1
I think this type is useless in most cases. We can leave it as it is.
Type 2
We can convert this type to a list/array.
Type 3
-Rw/e/s/n
is useless for Python. Should be convert to a list/array.Type 4
Useless. Should be convert to a list/array.
Types 5
gmt info -Ib
reports the bounding box polygon for the data files, which is usually used in furtherfig.plot()
. So it may make more sense to return it as two arraysx
andy
. A much general way is to return it as a ndarray, so users can access the first column viaoutput[:,0]
and the ith column viaoutput[:,i-1]
.If
-Af|s
option is used, the output becomes more complicated, e.g.:In such cases, we can return the output as a ndarray.
Conclusion
What we can do with the
gmt.info
outputs:The text was updated successfully, but these errors were encountered: