question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow the use of a separate file for shading (grdimage -I)

See original GitHub issue

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 option shading=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:

	-I Apply directional illumination. Append name of intensity grid file.
	   For a constant intensity (i.e., change the ambient light), append a value.
	   To derive intensities from <grd_z> instead, append +a<azim> [-45], +n<method> [t1], and +m<ambient> [0]
	   or use -I+d to accept the default values (see grdgradient for details).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
seismancommented, Oct 15, 2020

It seems that the upstream GMT PR https://github.com/GenericMappingTools/gmt/pull/4328 also fixes this issue.

Running @weiji14’s script above gives me a plot which looks correct (with the GMT master branch version: 6.2.0_8a4275f_2020.10.14):

image

But we need some more tests.

0reactions
weiji14commented, Nov 5, 2021

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 (https://github.com/GenericMappingTools/gmt/issues/5294) should be fixed with https://github.com/GenericMappingTools/gmt/pull/5947 and https://github.com/GenericMappingTools/gmt/pull/5948 (thanks Meghan and Paul!) and will be available in GMT 6.3.

I’ve opened a GMT conda-forge dev build at https://github.com/conda-forge/gmt-feedstock/pull/173 which will contain these patches, and allow us to test things easily using conda install -c conda-forge/label/dev gmt. So we should be able to close this issue once PyGMT bumps the minimum GMT version to 6.3, and the xfail is removed from the test below:

https://github.com/GenericMappingTools/pygmt/blob/5dc135b3d789c842c959c9abbdb505b07011a68e/pygmt/tests/test_grdimage.py#L120-L125

The test is currently XPASS at https://github.com/GenericMappingTools/pygmt/runs/4111894254?check_suite_focus=true#step:15:295 😁

Read more comments on GitHub >

github_iconTop Results From Across the Web

grdimage — GMT 6.0.0_r20460 documentation
grdimage reads one 2-D grid file and produces a gray-shaded (or colored) map by plotting rectangles centered on each grid node and assigning...
Read more >
grdimage · GMT - The Generic Mapping Tools
Reads one 2-D grid and produces a gray-shaded (or colored) map by plotting rectangles centered on each grid node and assigning them a...
Read more >
pygmt.Figure.grdimage
Project and plot grids or images. Reads a 2-D grid file and produces a gray-shaded (or colored) map by building a rectangular image...
Read more >
grdimage
Use extension .ppm for a Portable Pixel Map format. For GDAL-aware versions there are more choices: Use fname to select the image file...
Read more >
GRDIMAGE - Geophysics at Georgia Tech
grdimage reads one 2-D gridded file and produces a gray-shaded (or colored) ... The region option can be used to select a map...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found