Feature #640

Supporting Date/Time as Range of makecpt

Added by Edith over 5 years ago. Updated about 1 year ago.

Status:ClosedStart date:2014-11-15
Priority:NormalDue date:
Assignee:Paul% Done:


Target version:Candidate for next minor release


I would be most pleased if you would consider in one of the next GMT releases a fix that makecpt can support date/time as Range (-T) as asked/answered in User-Forum makecpt with time? on 11/11/14.

Thank you in advance,


#1 Updated by Florian over 5 years ago

  • Description updated (diff)

#2 Updated by Remko over 5 years ago

  • Assignee set to Remko
  • Target version set to Candidate for next minor release
  • Start date changed from 2014-11-11 to 2014-11-15

To be considered for implementation in 5.2.x, but after the release this month.

#3 Updated by Paul over 5 years ago

  • Status changed from New to Feedback
This is doable but will involve the machinery normally used for axis annotations. For example, running
makecpt -T2010T/2014T/3o

should mean 3-month intervals which have different number of days, just like when -Ba3o is used. Basically, we will then support the same increments as in -B, such as days, weeks, Gregorian weeks, months, etc.
I see the following changes to be involved:
  1. No longer use atof to parse min/max/inc since these could be dates, so use GMT_scanf as elsewhere.
  2. From these, build a coordinate array as is done in basemap plotting. Normally, these will be equidistant but not for time, necessarily.
  3. Set -f0T when min and max contains the "T" used to indicate date-time string so that the i/o machinery will work.
  4. Write date-time strings into the output cpt files (well, if -fo0t is used then relative time is written).
  5. Parsing of CPT files needs to use GMT_scanf since there may be date-strings.

#4 Updated by Paul over 2 years ago

  • Status changed from Feedback to Resolved
  • Assignee changed from Remko to Paul
  • % Done changed from 0 to 100

After reimplementing the parsing of -T in modules like makecpt and gmtmath we can now accept things like -T2017/2018/1o and get an uneven but monthly interval. This now carries through to CPT files which can now use an absolute time axis. As an example, see

gmt makecpt -T2017T/2018T/1o -Cjet > t.cpt

which is part of a new test script (tests/makecpt/timecpt.sh). In r19803

#5 Updated by Paul over 2 years ago

  • Status changed from Resolved to Closed

Closing this as implemented.

#6 Updated by Jeremy over 1 year ago

Hi, I just downloaded gmt-5.4.5-darwin-x86_64.dmg and get the following from the test command above:

gmt makecpt -T2017T/2018T/1o -Cjet > t.cpt
makecpt: Syntax error -T option: Must specify z_min/z_max[/z_inc[+n]]
makecpt: Syntax error -T option: Give z_min < z_max
makecpt: Syntax error -T option: For interpolation, give z_inc > 0

what am I missing?

#7 Updated by Joaquim over 1 year ago

what am I missing?

Need to use the developing version. Then

makecpt -T2017T/2018T/1o -Cjet
2017-01-01T00:00:00 0/0/170.48 2017-02-01T00:00:00 0/0/170.48
2017-02-01T00:00:00 0/0/253.25 2017-03-01T00:00:00 0/0/253.25
2017-03-01T00:00:00 0/80.692/255 2017-04-01T00:00:00 0/80.692/255
2017-04-01T00:00:00 0/165.92/255 2017-05-01T00:00:00 0/165.92/255
2017-05-01T00:00:00 0/251.16/255 2017-06-01T00:00:00 0/251.16/255
2017-06-01T00:00:00 81.39/255/173.61 2017-07-01T00:00:00 81.39/255/173.61
2017-07-01T00:00:00 166.62/255/88.377 2017-08-01T00:00:00 166.62/255/88.377
2017-08-01T00:00:00 253.25/255/1.7466 2017-09-01T00:00:00 253.25/255/1.7466
2017-09-01T00:00:00 255/171.51/0 2017-10-01T00:00:00 255/171.51/0
2017-10-01T00:00:00 255/86.281/0 2017-11-01T00:00:00 255/86.281/0
2017-11-01T00:00:00 255/1.0479/0 2017-12-01T00:00:00 255/1.0479/0
2017-12-01T00:00:00 170.48/0/0 2018-01-01T00:00:00 170.48/0/0
B black
F white
N 127.5

#8 Updated by Paul over 1 year ago

You need to use GMT 6 for this and build from source.

#9 Updated by Jeremy about 1 year ago

Hi. I finally built from source and tried this and it works nicely, except that when I use psscale to plot the scalebar, the default annotations that result are not datetime strings, but rather numbers that I cannot decipher. Are there some changes that need to be propagated to psscale? Will create custom annotations for now, thanks.

#10 Updated by Paul about 1 year ago

Thanks, confirm that plotting of these is not working as intended. Please use GitHub to report bugs though since this site will go away.

Also available in: Atom PDF