Automaticly use the default CPT for each remote data set?

I made this map. I expected/wanted that for the map above the default cpt of the earth_faa grid would be used without specifying it (instead of the one of the previous grid, geo in this case). Shouldn’t this be the default behavior?

gmt begin earth_defaultCPT png 
    gmt grdimage @earth_relief_30m_g 
    gmt grdimage @earth_faa_30m_g     -Yh -V
gmt end

The first grdimage sets the current figure default CPT (i.e., geo) and since no change it uses that for other commands (your second grdimage) also, unless you change it. We cannot really know if the user make a special CPT earlier and meant that to be the default. So our options are:

  1. Require you to add -Cfaa on the second grdimage
  2. Change the code so that when a remote data grid and no -C we default to the data sets CPT and not what may have been set as default CPT in this session.

I am sympathetic to option 2. Comments?

I also like option two

I think we could use:

-C: use session cpt

No -C: use grid cpt

But I think this could break some scripts.

I don’t think this is a good idea and it likely will break many old existing scripts. Take earth_relief as an example, people who only study a small region usually make their own CPT, so their codes may like:

gmt begin map
gmt makecpt -Cxxx -Tx/x
gmt grdimage @earth_relief_01m -Rx/x/x/x
gmt end show

Maybe we could do it the other way.

-C: grid CPT (if exists).
No -C: session CPT

That should work for @seisman too?

The current grdimage -C documentation says:

If no argument is given to -C then under modern mode we select the current CPT.

When a module requires a CPT (e.g., grdimage not given -C or plot given -C with no name) then we read this hidden CPT (if it exists).

So, both (-C without a CPT or -C is not given) are well documented and are widely used. Any changes will likely break many existing scripts.

Back to the original post, plotting each dataset in subplots should fix the problem because in subplot mode, each panel has its own “current” CPT.

my 5 cents: please don’t fix something that is not broken.

With subplot I can make my map with. I think I can live with that.

gmt begin earth_defaultCPT png
    gmt subplot begin 2x1 -Ff5c -B+n
        gmt grdimage @earth_relief_30m_g  -c
        gmt grdimage @earth_faa_30m_g     -c
    gmt subplot end
gmt end

Could it be possible to assign different default values to -C ?

Instead of just « hidden » (-C without option), you could say
-Cgeo
-Chot

similar to how you parameter makecpt.

Then if “.cpt” extension is specified (one could even think if default name doesn’t exist), then you try to read said file.

Sensible?

It would also reduce the use of makecpt -H in modern session I believe.

-C master already works

Whaaaaaaaaaaat?! :exploding_head: