I’m trying to make my first GMT movie. I got it somewhat to work but I’m struggling plotting symbols for several events with the same timestamp. So far only the first occurence of a timestamp is plotted.
My data is structured like in the following table and currently only the bold lines are plotted. Every data point is a position report of an aircraft.
lon(deg) |
lat(deg) |
alt(ft) |
time(unix) |
7.010317 |
50.582544 |
7225 |
1685577600 |
7.127455 |
50.881577 |
950 |
1685577600 |
7.39751 |
50.697968 |
4350 |
1685577600 |
8.04669 |
50.258057 |
2300 |
1685577600 |
7.018601 |
50.584991 |
7150 |
1685577605 |
7.12326 |
50.884575 |
1125 |
1685577605 |
7.390755 |
50.701401 |
4200 |
1685577605 |
8.042787 |
50.256042 |
2325 |
1685577605 |
7.026552 |
50.587326 |
7075 |
1685577610 |
7.119215 |
50.887573 |
1325 |
1685577610 |
7.384594 |
50.70488 |
4100 |
1685577610 |
8.038874 |
50.253979 |
2325 |
1685577610 |
7.034647 |
50.589752 |
7025 |
1685577615 |
7.114612 |
50.890961 |
1500 |
1685577615 |
7.378998 |
50.708329 |
3975 |
1685577615 |
8.034981 |
50.251923 |
2325 |
1685577615 |
… |
… |
… |
… |
example_data.txt (3.2 KB)
I want all points (=all aircraft positions) with a given timestamp plotted in a single frame. So far I only get one aircraft to show up in the movie.
My events
call looks like this:
gmt events example_data.txt \
-R007:30/49:30/010:00/50:45r \
-JL008:45/50:01:59.90/49:31:59.90/50:31:59.90/17.3562c \
-Sc5p -Gred \
--TIME_SYSTEM=UNIX -T${MOVIE_COL0} -i0,1,3
Am I doing something obvious wrong? Please nudge me in the right direction.
Some code to play with:
My movie.sh
file:
#!/usr/bin/env bash
cat << EOF > box.txt
>
0 0
6.6439 0
6.6439 13.5
0 13.5
0 0
EOF
cat <<- EOF | gmt sample1d -ft --TIME_SYSTEM=UNIX -I5 -Fa > times.txt
1685577600
1685577720
EOF
gmt begin background ps
gmt set MAP_FRAME_TYPE=inside
gmt set MAP_FRAME_PEN=0p,black
gmt set PS_MEDIA=24cx13.5c
gmt set MAP_ORIGIN_X=6.6439c
gmt set MAP_ORIGIN_Y=0
gmt plot -R0/6.6439/0/13.5 -JX6.6439c/13.5c box.txt -Gblack -D-6.6439c/0
gmt end
gmt movie main.sh -Sbbackground.ps -C24cx13.5cx160 -Ttimes.txt -Nfra-tracks -H8 -Fmp4 --TIME_SYSTEM=UNIX -Z
My main.sh
file:
gmt begin
gmt set MAP_FRAME_TYPE=inside
gmt set MAP_FRAME_PEN=0p,black
gmt set PS_MEDIA=24cx13.5c
gmt set MAP_ORIGIN_X=6.6439c
gmt set MAP_ORIGIN_Y=0
gmt events example_data.txt \
-R007:30/49:30/010:00/50:45r \
-JL008:45/50:01:59.90/49:31:59.90/50:31:59.90/17.3562c \
-Sc5p -Gred \
--TIME_SYSTEM=UNIX -T${MOVIE_COL0} -i0,1,3
echo "Timestamp ${MOVIE_COL0}"
gmt end
Hi Kristof
Try with this script only (and your data file).
This is the last frame.
![fra-tracks](https://forum.generic-mapping-tools.org/uploads/default/original/2X/7/78edbdd7991af63ea7e193cfa8637d8e56713df5.png)
#!/usr/bin/env bash
# 1. Create needed files
cat << 'EOF' > pre.sh
gmt begin
# A. Create box
cat << FILE > box.txt
>
0 0
6.6439 0
6.6439 13.5
0 13.5
0 0
FILE
# B. Create "timefile" for movie
cat <<- FILE | gmt sample1d -ft --TIME_SYSTEM=UNIX -I5 -Fa > times.txt
1685577600
1685577720
FILE
# C. Create background map
gmt set MAP_FRAME_TYPE=inside
gmt set MAP_FRAME_PEN=0p,black
gmt set PS_MEDIA=24cx13.5c
gmt set MAP_ORIGIN_X=6.6439c
gmt set MAP_ORIGIN_Y=0
gmt plot -R0/6.6439/0/13.5 -JX6.6439c/13.5c box.txt -Gblack -D-6.6439c/0 -Y0c -X0c
gmt end
EOF
# ---------------------------------------------------------------------------------------
# 2. Create main script
cat << 'EOF' > main.sh
gmt begin
gmt set MAP_FRAME_TYPE=inside
gmt set MAP_FRAME_PEN=0p,black
gmt set PS_MEDIA=24cx13.5c
gmt set MAP_ORIGIN_X=6.6439c
gmt set MAP_ORIGIN_Y=0
gmt events example_data.txt \
-R007:30/49:30/010:00/50:45r \
-JL008:45/50:01:59.90/49:31:59.90/50:31:59.90/17.3562c \
-Sc5p -Gred \
--TIME_SYSTEM=UNIX -T${MOVIE_COL0} -i0,1,3 -Y0c -X0c
#echo "Timestamp ${MOVIE_COL0}"
gmt end
EOF
# ---------------------------------------------------------------------------------------
# 3. Run the movie
#gmt movie main.sh -Sbpre.sh -C24cx13.5cx160 -Ttimes.txt -Nfra-tracks -H8 -Fmp4 --TIME_SYSTEM=UNIX -Zs
gmt movie main.sh -Sbpre.sh -C2160p -Ttimes.txt -Nfra-tracks -H8 -Ml,png --TIME_SYSTEM=UNIX -Zs -Fmp4 -Vi
# 4. Remove temporary files
rm box.txt times.txt
Hi Federico,
thank you for your answer. If you look at the sample data the last three points have the same timestamp but different positions:
lon |
lat |
alt |
time |
7.19701 |
50.637476 |
5000 |
1685577720 |
7.271729 |
50.781788 |
2050 |
1685577720 |
7.954918 |
50.209987 |
2475 |
1685577720 |
Same goes for the timestamps before those. So I expected to see three different trajectories instead of just one.
Have you used events -Ar
for plotting trajectories? Maybe this is the way to go?
I think that you will need to split your input file in 4 and then use a gmt events for each one
I have a doubt. Do you want to plot the “now” position? or the trajectory (so, the “now” and the past positions)?
I want to have something like a trail
O o . . . . . . . . . .
behind the now position. As I don’t know how many aircraft are in my frame I’m not sure how I can determine the amount of calls to gmt events
.
I don’t know if something like
> aircraft1
lon lat timestamp1
lon lat timestamp2
lon lat timestamp3
lon lat timestamp4
lon lat timestamp5
> aircraft2
lon lat timestamp1
lon lat timestamp2
lon lat timestamp3
lon lat timestamp4
lon lat timestamp5
lon lat timestamp6
> aircraft3
lon lat timestamp1
lon lat timestamp2
lon lat timestamp3
lon lat timestamp4
lon lat timestamp5
lon lat timestamp6
would work when I dont want to plot lines but just symbols at a given timestamp.
How did you achieve that? That looks awesome!
Update the main script
with this. Notice that I change the region so I could see the 4 planes. In the original region, 3 were always outside the region.
cat << 'EOF' > main.sh
gmt begin
gmt set MAP_FRAME_TYPE=inside
gmt set MAP_FRAME_PEN=0p,black
gmt set PS_MEDIA=24cx13.5c
gmt set MAP_ORIGIN_X=6.6439c
gmt set MAP_ORIGIN_Y=0
gmt set TIME_SYSTEM=UNIX
gmt basemap -R007:00/49:30/010:00/51:00r -JL008:45/50:01:59.90/49:31:59.90/50:31:59.90/17.3562 -Baf
grep ${MOVIE_COL0} ../../example_data.txt | gmt plot -Sc5p -Gred
gmt end
EOF
1 Like
You could also events to get the trayectory
gmt basemap -R007:00/49:30/010:00/51:00r -JL008:45/50:01:59.90/49:31:59.90/50:31:59.90/17.3562 -Baf
gmt events example_data.txt -i0,1,3 -T${MOVIE_COL0} -Sc2p -Gblack
grep ${MOVIE_COL0} ../../example_data.txt | gmt plot -Sc5p -Gred
Sorry, I got confused. There is no need to use grep
. Just use events like this for example:
gmt events example_data.txt -i0,1,3 -T${MOVIE_COL0} -Sc1p -Gred -Es+d60 -Ms3+c1 -Mt+c0