-
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
Allow the use of a separate file for shading (grdimage -I) #618
Comments
Hi @MarkWieczorek, I agree that this will be a useful feature. Do you have an example for this/a map illustration? Even just the pure GMT command will do (best if we can access the data too). |
Well, here is what it should look like (Earth geoid with topography illumination). Sorry for the rainbow colormap, this is a few years old: I could look through my files, but the scripts will most likely be for gmt 5, and the grd files are pretty big. The only peculiarity with specifying a |
I was thinking more along the lines of a GMT Remote Data-Set (i.e. the |
Here is something for a different image
In essence, if you are creating an image with grdimage, you just add the option |
Cool, thanks for the example. This sounds very similar to the Lines 433 to 444 in d3e131a
I'll take a closer look over the weekend (getting late for me here), but you're more than welcome to open up a Pull Request to speed up the process 😄. |
I don't test it, but I believe you can already use Of course, there are more things to do:
|
I'll test (1) monday, but (2) is what I really want! |
Yes, (2) is definitely a missing feature! |
I can confirm that this works, here's a very minimal working example: import pygmt
fig = pygmt.Figure()
fig.grdimage(grid="@earth_relief_01d_g", shading="@earth_relief_01d_g+d")
fig.savefig("shading_with_intensfile.png")
fig.show() However, shading an
Agree with both points, we can better document |
It seems that the upstream GMT PR GenericMappingTools/gmt#4328 also fixes this issue. Running @weiji14's script above gives me a plot which looks correct (with the GMT master branch But we need some more tests. |
I finally got around to testing this, and grdimage with shading works fine for me as long as I specify a pre-existing filename. For my pipeline, a hack solution is to save an xarray DataArray as a netcdf file, and then to use this filename with the shading option. Obviously, it would be better if we could just specify the xarray DataArray directly in the shading option. |
@MarkWieczorek I've implemented the requested feature in #750 and it seems working well (I only did a few simple tests and eye-checking the images). It would be good if you can test it and give some feedbacks. |
The feature request has been implemented in #750 and now merged in master. Now However, the grdimage shading with a xarray.DataArray has known upstream bugs (see #750 (comment), #750 (comment), and GenericMappingTools/gmt#5294). I'm reopening this issue to better track the upstream bug. |
The last bits of the upstream CPT stretching issue (GenericMappingTools/gmt#5294) should be fixed with GenericMappingTools/gmt#5947 and GenericMappingTools/gmt#5948 (thanks Meghan and Paul!) and will be available in GMT 6.3. I've opened a GMT conda-forge dev build at conda-forge/gmt-feedstock#173 which will contain these patches, and allow us to test things easily using pygmt/pygmt/tests/test_grdimage.py Lines 120 to 125 in 5dc135b
The test is currently XPASS at https://github.com/GenericMappingTools/pygmt/runs/4111894254?check_suite_focus=true#step:15:295 😁 |
The gmt command grdimage has an option
-I
that adds shading to another image by modulating the intensity. Historically, (up until gmt v5), this command has only taken as an option another grd filename. One common use of this feature was to plot something like a gravity, the geoid, or magnetic field in color, and then apply shading using a topography file to provide geologic context.Since gmt 5, there has been the option of using the input grd file along with grdgradient to automatically generate an intensity file that would be used with the
-I
command. I believe that pygmt only accepts the optionshading=True
which automatically generates such an intensity file using gmt defined default illumination angle parameters.I am asking that pygmt fully implement the
grdimage -I
option. This is the only feature that I am currently missing in pygmt, and which is forcing me to use both gmt and pygmt separately to generate publication quality images for journal articles.For reference, here is the relevant part of the
gmt grdimage
man page:The text was updated successfully, but these errors were encountered: