Closed
Labels
feature requestRequest a new feature
Description
Description of the desired feature
It would be helpful if GMT had a way to retain information about the default colormaps for remote files during processing. For example, if the following code produced two images using the geo colormap. This feature would be helpful for PyGMT, where the remote data files are often read into memory before being passed to GMT, resulting in the loss of the default cpt information (xref GenericMappingTools/pygmt#499).
gmt grdimage @earth_relief -R0/10/0/10 -B -JM5c -png ex1
gmt begin ex2 png
gmt grdcut @earth_relief -R0/10/0/10 -JM5c -Gtest.nc
gmt grdimage test.nc -B
gmt end showAre you willing to help implement and maintain this feature? Yes
Metadata
Metadata
Assignees
Labels
feature requestRequest a new feature


Activity
PaulWessel commentedon Dec 29, 2021
One relatively simple implementation would be to add an attribute to the output netCDF file that holds the default CPT, if one is available. It could then be read and placed in the hidden GRID_HEADER structure and used to inform the default CPT choice if none is set via -C. This makes these assumptions:
I think (1) is reasonable, only very specific needs require a non-netCDF intermediate grid. As for (2), need feedback from @GenericMappingTools/pygmt-admin if this helpful, and perhaps @joa-quim could have similar needs in GMT.jl.
maxrjones commentedon Dec 29, 2021
Currently, PyGMT loads the variable attributes for netCDF grids but not the global attributes and uses grdinfo to access other attributes (registration, grid type).
joa-quim commentedon Dec 29, 2021
The SST L3 grids from the OceanColor color come with a cpt in global attribute called
palette. But silly is a 3x254 instead of a 255x3 array. We could use the same name for that attribute. If I would use it or not in GMT.jl I don't know right now.PaulWessel commentedon Dec 30, 2021
So the grid's z' attributes are read, so if I add palette it would be available to PyGMT then.
PaulWessel commentedon Dec 30, 2021
Since this would only be used when GMT grdcuts a subset off one of our remote grids and writes a netCDF grid, I think just adding CPT = "@earth_age.cpt" or similar is all we need to do.
Save any default CPT in hidden grid header
Save any default CPT for remote datasets in hidden grid header (#6178)
PaulWessel commentedon Jan 3, 2022
OK to close, @meghanrjones ?
maxrjones commentedon Jan 3, 2022
Yes