Skip to content

Retain information about default colormaps for remote files #6167

Closed

Description

@maxrjones

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 show

ex1:
ex1

ex2:
ex2

Are you willing to help implement and maintain this feature? Yes

Activity

  1. added
    feature request
    on Dec 29, 2021
  2. PaulWessel commented on Dec 29, 2021

    @PaulWessel
    Contributor

    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:

    1. The user is not specifying a non-netCDF output grid format
    2. PyGMT can access the attributes of a netCDF grid when read into an Xarray.

    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.

  3. maxrjones commented on Dec 29, 2021

    @maxrjones
    MemberAuthor

    Currently, PyGMT loads the variable attributes for netCDF grids but not the global attributes and uses grdinfo to access other attributes (registration, grid type).

  4. joa-quim commented on Dec 29, 2021

    @joa-quim
    Member

    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.

  5. PaulWessel commented on Dec 30, 2021

    @PaulWessel
    Contributor

    So the grid's z' attributes are read, so if I add palette it would be available to PyGMT then.

  6. PaulWessel commented on Dec 30, 2021

    @PaulWessel
    Contributor

    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.

    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.

  7. PaulWessel commented on Jan 3, 2022

    @PaulWessel
    Contributor

    OK to close, @meghanrjones ?

  8. maxrjones commented on Jan 3, 2022

    @maxrjones
    MemberAuthor

    Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions