Skip to content
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

Adding cmocean colour maps #6284

Closed
remkos opened this issue Jan 31, 2022 · 10 comments · Fixed by #6446
Closed

Adding cmocean colour maps #6284

remkos opened this issue Jan 31, 2022 · 10 comments · Fixed by #6446
Labels
feature request Request a new feature

Comments

@remkos
Copy link
Contributor

remkos commented Jan 31, 2022

Description of the desired feature

I'm interested in adding the cmocean colour maps: https://matplotlib.org/cmocean/
For the paper in "Oceanography", see http:https://dx.doi.org/10.5670/oceanog.2016.66

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

@remkos remkos added the feature request Request a new feature label Jan 31, 2022
@PaulWessel
Copy link
Member

Seems useful. Maybe it is useful for you to look at our admin/build-scientific-colors-cpt.sh for converting their CPT into our master format (normalized 0/1 or -1/+1, depending on whether there is a hinge or not).
We may also wish to add a checker in the CI to tell us when there is a new release. @meghanrjones how is that working again?

@maxrjones
Copy link
Member

The scientific colour maps workflow checks for releases using their Zenodo archive. It doesn't look like cmocean is on Zenodo, but we could probably query https://github.com/matplotlib/cmocean for new releases.

@remkos
Copy link
Contributor Author

remkos commented Jan 31, 2022

Yes, @PaulWessel. I can either convert their RGB text files, or get the GMT4 formatted files from cpt-city and do the normalisation. I'll certainly look at your script. Thanks for the hint.

@meghanrjones : Yes, that would be a start, but most likely the updates would be in the python scripts, not in the underlying colour maps.

@remkos
Copy link
Contributor Author

remkos commented Feb 1, 2022

I'm getting well on my way with this. I'm now getting Kirsten's own CPT files from here: https://github.com/kthyng/cmocean-gmt
And I've more or less made a working script like the one @PaulWessel pointed out.
There are two names of colourmaps that we already have (gray and topo). What shall I do there?

  • Gray we can likely skip, as it is virtually the same as ours.
  • Topo is different. Maybe rename it topo-cmocean?

There are no foreground, background or NaN colours defined in these maps. Shall I leave them out in our own versions?

@PaulWessel
Copy link
Member

Great. As for the BNF, if they have none then do not add any - this means GMT supplies its default settings which is all we can do without adding new things.

While renaming to a non-conflicting name is fine, perhaps we should at least discuss what alternatives there are? I can think of this one:

  1. Contain sets of CPTs in groups or subdirectories, e.g., cmocean, matlab, matplotlib, gmt, fabio, cpt-city to allow the same named CPT to exist in different groups.
  2. Either user typical directory separators in -C, e.g., -Ccmocean/topo or (since these are not actually file names) some new syntax like -C[group:]master, where default group is gmt. Yet, for backwards compatibility we would probably need to put everything up to now into the gmt group as well as duplicate into the new groups.

I am just concerned how to handle 1000s CPT files eventually - we are not there yet but probably because we do not directly support cpt-city...

@remkos
Copy link
Contributor Author

remkos commented Feb 1, 2022

I think a directory structure is a wise, flexible, and workable solution. I'll just need to check how the -C option behaves when using a slash in the name. I think the slash is preferred above all else, as that becomes natural to me.
If -C already works without changes, I would opt to:

  • Store the GMT-originals in a subdirectory gmt of the directory share/cpt directory
  • Store the others we borrowed from other projects into respective subdirectories like cmocean, panoply, fabio
  • Link all those that we already have now from the share/cpt directory to the respective subdirectories mentioned above

@remkos
Copy link
Contributor Author

remkos commented Feb 2, 2022

Another few thoughts:

  • Putting a link in share/cpt is of course possible, but is not really practical from a maintenance point of view. It might not even transfer well to Windows, does it?
  • Probably we should add those "directories" to the names in the list that makecpt produces, then when the user selects a name without the directory, makecpt will pick the first one on the list that matches. E.g., -Ctopo will convert to -Cgmt/topo
  • This allows backward compatibility and forward flexibility to adopt a lot of new maps, and be clear about their origin.
  • I may need some help identifying which colourmaps came from where to put them in the right place.

@PaulWessel
Copy link
Member

Yes, I think we are talking about a handful of bytes so the duplication is OK and simplifies operations, including lack of symlinks (or done differently) on Windows.

Yes, I assume output form makecpt would be sorted per collection and maybe

gmt/abyss       : Black/dark blue to lightblue for bathymetry [R=-8000/0, C=RGB]
...
crameri/categorical : Color table particularly suitable for categorical data [C=RGB]

I think the gmt/ part is optional and if no directory given we default to gmt/ as you say.
I am less certain if we should hunt through all future directories looking for "topo" since then it becomes unclear which directory should be first in the list. If collections A and B both have a junk.cpt, what should -Cjunk return? I think it should probably be an error message saying no junk.cpt in collection gmt or something.

@remkos
Copy link
Contributor Author

remkos commented Mar 10, 2022

I got a lot further with this. There are just a few that I have not sorted out, see at the top of the list of
https://github.com/GenericMappingTools/gmt/blob/d7fa1f184acf82aa21da41f54161df684db5ff9e/src/gmt_cpt_masters.h

Where should those go?
Do you agree with the rest of the sorting?

@PaulWessel
Copy link
Member

I think these are basically cptcity:

cubhelix, dem1, dem4, elevation

These should be in the gmt list for sure: globe, mag, seis
But I think the rest can also be added to gmt to keep life simple.

remkos added a commit that referenced this issue Jun 8, 2022
* Introducing cmocean colormaps (#6284)

* Move Fabio Crameri's colormaps to subdirectory (#6284)

* Move matplotlib colormaps to subdirectory (#6284)

* gmt_is_cpt_master: return full name of cpt after matching master was found (#6284)

* Move gmt, google, gmt and panoply colormaps into subdirectories (#6284)

* Move last unsorted colormaps into subdirectories (#6284)

* Identify paired.cpt as categorical (#6284)

* Update GMT_App_M*.sh scripts and colormaps documentation in cookbook (#6284)

* Change permission on GMT_App_M_1e.sh

* Make gmt_is_cpt_master work for full file names (#6284)

* Renames cpt subdirectory from "crameri" to "SCM7" (#6284)

* Rename SCM7 to SCM (#6284)

* Add missing comma

* Update documentation for new color maps

Co-authored-by: Paul Wessel <[email protected]>
@maxrjones maxrjones added add-changelog Add PR to the changelog and removed add-changelog Add PR to the changelog labels Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants