Making an animation with non-standard clock format

I have a shiptrack (in NMEA) which I have formatted like this:

$ head long-lat-time.gmt
010:56.48643 78:06.99576 2009-05-09T204347.13
010:56.47279 78:06.99634 2009-05-09T204348.13
010:56.45915 78:06.99693 2009-05-09T204349.13
010:56.44551 78:06.99752 2009-05-09T204350.13
010:56.43190 78:06.99816 2009-05-09T204351.13
010:56.41830 78:06.99890 2009-05-09T204352.13
010:56.40475 78:06.99976 2009-05-09T204353.13
010:56.39106 78:07.00070 2009-05-09T204354.13
010:56.37716 78:07.00161 2009-05-09T204355.13
010:56.36329 78:07.00245 2009-05-09T204356.13

I would like to do an animation showing the ships progress/position through time.

The clock format as seen above is --FORMAT_CLOCK_IN=hhmmss.xx; I do however see that there does not seem to be a template for decimal seconds in FORMAT_CLOCK_IN (but there is one for FORMAT_CLOCK_OUT).

The following script produces an animation, but the movement through time (by events) is having problems understanding the time (I think) (animation,bad):

start=2009-05-09T20:43:47
stop=2009-05-09T21:56:22

gmt math -o0 -T${start}/${stop}/1m T = times.txt

cat<<eof > main.sh
gmt begin
gmt coast -Ggray -JM15c -R5/15/77.5/79
gmt plot -Wthick long-lat-time.gmt
gmt events -Sc0.02c -Gred --MAP_ANNOT_OBLIQUE=30 -B0 long-lat-time.gmt -T\${MOVIE_COL0} --FORMAT_CLOCK_IN=hhmmss.xx

gmt end
eof

time gmt movie main.sh -Ncruise -C19cx16cx100 -Fmp4 -Ttimes.txt -V -Z -Pf+jTC+ac0 -Lc0+jBL -D12 --FORMAT_CLOCK_MAP=hhmmss.xx

rm times.txt main.sh

If I reformat the clock-string in the shiptrack file, it works fine (animation, good):

$ head long-lat-time.gmt 
010:56.48643 78:06.99576 2009-05-09T20:43:47
010:56.47279 78:06.99634 2009-05-09T20:43:48
010:56.45915 78:06.99693 2009-05-09T20:43:49
010:56.44551 78:06.99752 2009-05-09T20:43:50
010:56.43190 78:06.99816 2009-05-09T20:43:51
010:56.41830 78:06.99890 2009-05-09T20:43:52
010:56.40475 78:06.99976 2009-05-09T20:43:53
010:56.39106 78:07.00070 2009-05-09T20:43:54
010:56.37716 78:07.00161 2009-05-09T20:43:55
010:56.36329 78:07.00245 2009-05-09T20:43:56

I’m attaching the long-lat-time file used below.

long-lat-time.gmt.zip (46.6 KB)

To change long-lat-time.gmt (insert : and remove decimal second) in order to make a good animation, use:

$ sed -i -e "s/.\{38\}/&:/" -e "s/.\{41\}/&:/" -e 's/.\{3\}$//' long-lat-time.gmt

And remove –FORMAT_CLOCK_IN=hhmmss.xx.

Am I using the wrong gmt.conf parameter? Or doesn’t gmt understand decimal seconds?

Please try to add --FORMAT_CLOCK_IN=hhmmss.xx to your movie call since it is movie that reads times.txt and passes things to events.

Added —FORMAT_CLOCK_OUT=hhmmss.xx, but same result unfortunately. But, the format in times.txt (created by sample1d) is in the standard format (hh:mm:ss), so I would not think this was necessary?

Edit: Wrote —FORMAT_CLOCK_OUT=hhmmss.xx, but meant —FORMAT_CLOCK_IN=hhmmss.xx, and sample1d but meant gmt math. Fixed.

Yes, you are right - I forgot that file was made by gmt math.
Since events is not doing the plotting (it is passing the baton to plot), the problem is that plot is not seeing the FORMAT_CLOCK_IN setting. Please try this

after the gmt begin in your main, add

gmt set FORMAT_CLOCK_IN hhmmss.xx

and then remove it from the commands. Now plot will find it.

Still no luck; still as in ‘bad’.

My script as of now:

start=2009-05-09T20:43:47
stop=2009-05-09T21:56:22

gmt math -o0 -T${start}/${stop}/1m T = times.txt

cat<<eof > main.sh
gmt begin
gmt set FORMAT_CLOCK_IN hhmmss.xx

gmt coast -Ggray -JM15c -R5/15/77.5/79
gmt plot -Wthick long-lat-time.gmt
gmt events -Sc0.02c -Gred --MAP_ANNOT_OBLIQUE=30 -B0 long-lat-time.gmt -T\${MOVIE_COL0}

gmt end
eof

time gmt movie main.sh -Ncruise -C19cx16cx100 -Fmp4 -Ttimes.txt -V -Z -Pf+jTC+ac0 -Lc0+jBL -D12 --FORMAT_CLOCK_MAP=hhmmss

rm times.txt main.sh

Maybe the problem is that you cannot have two time formats at the same time, i.e., you are passing ISO time via -T to psevents but you are trying to read non-ISO times from a file in the same module. COuld you use TIME_FORMAT_OUT im gmt math to make the times.txt in the same format as your data time?

Tried that as well, but no result. Seems though as if this is not necessary. I could mix these and get a good result when manipulating the input data;

I think it’s maybe the problem is the (missing) delimiter between hh mm and ss. If I insert a : in my clock field (204347.13 -> 20:43:47.13) it works fine - even when not giving the proper FORMAT_CLOCK_IN=hh:mm:ss.xx. Maybe gmt just discards the decimal? If I change the delimiter to e.g. -, I get the bad result again.

So:

Nothing else changed except:

  • gmt set FORMAT_CLOCK_IN hh-mm-ss.xx with records of type 2009-05-09T20-43-47.13 gives bad result
  • (No custom clock format OR FORMAT_CLOCK_IN hh:mm:ss.xx) and 2009-05-09T20:43:47.13 give good results.

The only difference being the delimiter used in the clock field (long-lat-time.gmt) and corresponding FORMAT_CLOCK_IN.

I guess there is no way you can make a failing simple plot with this data (i.e., not a movie)? If you can, great - please post a GitHub issue. if not, please make the tiniest movie you can that fails (e.g., just a few lines of data) and post that so I can try to reproduce and debug it.

Will do, Paul. Thanks.