GMT movie

Hi everyone,
I’m trying to use a GMT movie to make an animated gif now.

However, it seems to be not allowed to make gif files.

Here is my coding

gmt begin Subtropical_High png
gmt basemap -R100/180/0/45 -JQ180/9 -Bxa10Wf5W -Bya10Nf5N -BWeSn -X1 -Y2
gmt coast -W1 -G200 -Di

gmt plot %1.monthly -R100/180/0/45 -Sc0.1i -W0.01i,0/0/0 -G153/0/153
gmt contour %2.monthly -A5880+f18+d+r1 -W5p,red

gmt movie Subtropical_High.bat -Chd -Nanime02 -Tangles.txt -Fgif -H8 -Vi -SbSubtropical_High.bat
gmt end

And if replaced “begin Subtropical_High gif” by “begin Subtropical_High tif”
The problem appears like this

Please help me to over this problem.

The shell script you use to generate the frames of the movie doesn’t need a figure name or output format after “gmt begin” . The frame differences can be set using the MOVIE_ variables.
The output name is specified in the call to gmt movie using the -N option and gif output using -Agif (I see you have GraphicsMagick installed so that should work).
The man page makes this quite clear: have a look at the examples.
NB The documentation may be a concise description of many options, but it’s worth reading.

1 Like

Hello,
Thank you for your response.

  • I also modified based on your comments. Now, I’m using GMT 6.3 and as I read in movie documents (movie — GMT 6.5.0 documentation). There is no -A, instead of that we use -F.

    gmt begin
    gmt basemap -R100/180/0/45 -JQ%MOVIE_FRAME%180/9%MOVIE_WIDTH% -Bxa10Wf5W -Bya10Nf5N -BWeSn -X1 -Y2
    gmt coast -W1 -G200 -Di

    gmt plot %1.monthly -R100/180/0/45 -Sc0.1i -W0.01i,0/0/0 -G153/0/153
    gmt contour %2.monthly -A5880+f18+d+r1 -W5p,red
    gmt movie Subtropical_High.bat -Chd -Nanime02 -Fgif -T5 -H8 -Vi -Z
    gmt end

  • I wanna generate the series of figures in gif, thus I use the call function to do that. Is it the right way to do generate figures and make gif?. %1 and %2 in Subtropical High.bat is corresponded to STPs_1977 and WSPH_1977 in call function.

Here is the call function.

call Subtropical_High STPs_1977 WSPH_1977
call Subtropical_High STPs_1978 WSPH_1978
call Subtropical_High STPs_1979 WSPH_1979
call Subtropical_High STPs_1980 WSPH_1980
call Subtropical_High STPs_1981 WSPH_1981
  • After that, I combine it with the above subtropical high batch to generate the gif. But the output generates more folders. There is still no gif output!!!
    .

It is the first time I use GMT 6, and it is a huge difference from GMT 5. I read examples, but most of them are related to Linux. There is some strange to me like CAT < function. I use call function to replace it and it seems to be not working well.

I very much appreciate any kind of help.

"This is the response from the command window! It is quite strange to me. "

D:\Subtropical_High\Data\Animation>gmt movie Subtropical_High.bat -Chd -Nanime02 -Fgif -T5 -H8 -Vi -Z
movie [INFORMATION]: GraphicsMagick 1.3.36 found.
movie [INFORMATION]: Paper dimensions: Width = 24c Height = 13.5c
movie [INFORMATION]: Pixel dimensions: 1920 x 1080
movie [INFORMATION]: Building opaque PNG images.
movie [INFORMATION]: Create parameter initiation script movie_init.bat
movie [INFORMATION]: Number of main animation frames: 5
movie [INFORMATION]: Parameter files for main animation: 5
movie [INFORMATION]: Create main movie frame script movie_frame.bat
movie [INFORMATION]: Total frames to process: 5
movie [INFORMATION]: Build frames using 15 cores
movie [INFORMATION]: Execute movie frame scripts in parallel
gmt [ERROR]: Unrecognized keyword =.
gmt [ERROR]: 1 GMT Defaults conversion errors in file C:/Users/user/.gmt/sessions/gmt_session.1/gmt.conf.1!
plot [ERROR]: Cannot find file 1.monthly
plot [ERROR]: Cannot find file 3.monthly
plot [ERROR]: Cannot find file 0.monthly
plot [ERROR]: Cannot find file 2.monthly
contour [ERROR]: Cannot find file .monthly
plot [ERROR]: Cannot find file 4.monthly
contour [ERROR]: Cannot find file .monthly
contour [ERROR]: Cannot find file .monthly
contour [ERROR]: Cannot find file .monthly
contour [ERROR]: Cannot find file .monthly
movie [INFORMATION]: GraphicsMagick 1.3.36 found.
movie [INFORMATION]: Paper dimensions: Width = 24c Height = 13.5c
movie [INFORMATION]: Pixel dimensions: 1920 x 1080
movie [INFORMATION]: Building opaque PNG images.
movie [INFORMATION]: Create parameter initiation script movie_init.bat
movie [INFORMATION]: Number of main animation frames: 5
movie [INFORMATION]: Parameter files for main animation: 5
movie [INFORMATION]: GraphicsMagick 1.3.36 found.
movie [INFORMATION]: Paper dimensions: Width = 24c Height = 13.5c
movie [INFORMATION]: Pixel dimensions: 1920 x 1080
movie [INFORMATION]: Building opaque PNG images.
movie [INFORMATION]: Create main movie frame script movie_frame.bat
movie [INFORMATION]: Create parameter initiation script movie_init.bat
movie [INFORMATION]: Total frames to process: 5
movie [INFORMATION]: Build frames using 15 cores
movie [INFORMATION]: Number of main animation frames: 5
movie [INFORMATION]: Execute movie frame scripts in parallel
movie [INFORMATION]: Parameter files for main animation: 5
movie [INFORMATION]: Create main movie frame script movie_frame.bat
movie [INFORMATION]: Total frames to process: 5
movie [INFORMATION]: Build frames using 15 cores
movie [INFORMATION]: Execute movie frame scripts in parallel
movie [INFORMATION]: GraphicsMagick 1.3.36 found.
movie [INFORMATION]: Paper dimensions: Width = 24c Height = 13.5c
movie [INFORMATION]: Pixel dimensions: 1920 x 1080
movie [INFORMATION]: Building opaque PNG images.
movie [INFORMATION]: Create parameter initiation script movie_init.bat
movie [INFORMATION]: Number of main animation frames: 5
movie [INFORMATION]: Parameter files for main animation: 5
movie [INFORMATION]: Create main movie frame script movie_frame.bat
movie [INFORMATION]: Total frames to process: 5
movie [INFORMATION]: Build frames using 15 cores
movie [INFORMATION]: Execute movie frame scripts in parallel
movie [INFORMATION]: GraphicsMagick 1.3.36 found.
movie [INFORMATION]: Paper dimensions: Width = 24c Height = 13.5c
movie [INFORMATION]: Pixel dimensions: 1920 x 1080
movie [INFORMATION]: Building opaque PNG images.
movie [INFORMATION]: Create parameter initiation script movie_init.bat
movie [INFORMATION]: Number of main animation frames: 5
movie [INFORMATION]: Parameter files for the main animation: 5
movie [INFORMATION]: GraphicsMagick 1.3.36 found.
movie [INFORMATION]: Paper dimensions: Width = 24c Height = 13.5c
movie [INFORMATION]: Pixel dimensions: 1920 x 1080
movie [INFORMATION]: Create main movie frame script movie_frame.bat
movie [INFORMATION]: Building opaque PNG images.
movie [INFORMATION]: Total frames to process: 5
movie [INFORMATION]: Build frames using 15 cores
movie [INFORMATION]: Create parameter initiation script movie_init.bat
movie [INFORMATION]: Execute movie frame scripts in parallel
movie [INFORMATION]: Number of main animation frames: 5
movie [INFORMATION]: Parameter files for main animation: 5
movie [INFORMATION]: Create main movie frame script movie_frame.bat
movie [INFORMATION]: Total frames to process: 5
movie [INFORMATION]: Build frames using 15 cores
movie [INFORMATION]: Execute movie frame scripts in parallel
figure [ERROR]: gmt figure: Cannot select an existing figure and change its format.
figure [ERROR]: gmt figure: Cannot select an existing figure and change its format.
figure [ERROR]: gmt figure: Cannot select an existing figure and change its format.
figure [ERROR]: gmt figure: Cannot select an existing figure and change its format.
figure [ERROR]: gmt figure: Cannot select an existing figure and change its format.
figure [ERROR]: gmt figure: Cannot select an existing figure and change its format.
figure [ERROR]: gmt figure: Cannot select an existing figure and change its format.
begin [ERROR]: Failed to remove gmt.conf! [remove error: Permission denied]
begin [WARNING]: Unable to remove gmt.conf [permissions?]
figure [ERROR]: gmt figure: Cannot select an existing figure and change its format.
figure [ERROR]: gmt figure: Cannot select an existing figure and change its format.
figure [ERROR]: gmt figure: Cannot select an existing figure and change its format.
figure [ERROR]: gmt figure: Cannot select an existing figure and change its format.
figure [ERROR]: gmt figure: Cannot select an existing figure and change its format.
figure [ERROR]: gmt figure: Cannot select an existing figure and change its format.

Yes it is very linux oriented which can be confusing for those dealing with the inadequacies of DOS

My suggestion:

  1. create a timeline file (eg TimeLine.dat) containing parameters that change in each frame:
    TimeLine.dat:
    STPs_1977 WSPH_1977
    STPs_1978 WSPH_1978
    STPs_1979 WSPH_1979
    STPs_1980 WSPH_1980
    STPs_1981 WSPH_1981

  2. the SubtropicalHigh.bat should probably be:
    SubtropicalHigh.bat:
    gmt begin
    gmt basemap -R100/180/0/45 -JQ180/%MOVIE_WIDTH% -Bxa10Wf5W -Bya10Nf5N -BWeSn -X1 -Y2
    gmt coast -W1 -G200 -Di
    gmt plot %MOVIE_COL1%.monthly -Sc0.1i -W0.01i,0/0/0 -G153/0/153
    gmt contour %MOVIE_COL2%.monthly -A5880+f18+d+r1 -W5p,red
    gmt end

    the MOVIE_COLn variables pick up the data from your timeline file
    In modern mode you don’t need to repeat the -R option in the plot command

Don’t include the movie instruction in the SubtropicalHigh.bat – this will just create recursion (giving you all those subdirectories)

  1. call from the command line (or a separate batch file)
    gmt movie Subtropical_High.bat -Chd -Nanime02 -Fgif -TTimeLine.dat

As all that seems to be changing is the plot and contour commands you could probably put the basemap and coast commands in a background script file which can be specified in the -Sb option to movie.

This should generate a file anime02.gif in the working directory and the individual frames as .png in the ./anime02 subdirectory.
If I wanted each of these frames as gif files I would use ImageMagick: cd into the subdirectory and run:
mogrify -format gif *.png

Hope this helps

1 Like

Your suggestion is useful and actually similar to what I tried to do last night.

There is a bug that I cannot understand the reason behind that cannot recognize my file name “STPs_1977 WSPH_1977” as stored up in TimeLine.dat. So the results in empty.

Again, thank you so much for this kind of help.

Here is new coding:

Blockquote
gmt begin
gmt set GMT_THEME cookbook
gmt set FONT_ANNOT_PRIMARY +20p FONT_LABEL +20p
gmt set MAP_TICK_LENGTH 4p MAP_TICK_PEN 2p MAP_FRAME_PEN 1p
gmt set PROJ_LENGTH_UNIT INCH FORMAT_GEO_MAP ddd:mm:ssF gmt basemap -R100/180/0/45 -JQ180/%MOVIE_WIDTH% -Bxa10Wf5W -Bya10Nf5N -BWeSn -X1 -Y2
gmt coast -W1 -G200 -Di
gmt plot %MOVIE_COL1%.monthly -R100/180/0/45 -Sc0.1i -W0.01i,0/0/0 -G153/0/153
gmt contour %MOVIE_COL2%.monthly -A5880+f18+d+r1 -W5p,red
gmt end

Blockquote
movie [INFORMATION]: Frame 00 of 44 completed [ 2.3 %]
movie [INFORMATION]: Frame 03 of 44 completed [ 4.5 %]
movie [INFORMATION]: Frame 01 of 44 completed [ 6.8 %]
movie [INFORMATION]: Frame 02 of 44 completed [ 9.1 %]
movie [INFORMATION]: Frame 04 of 44 completed [ 11.4 %]
movie [INFORMATION]: Frame 05 of 44 completed [ 13.6 %]
movie [INFORMATION]: Frame 06 of 44 completed [ 15.9 %]
movie [INFORMATION]: Frame 07 of 44 completed [ 18.2 %]
movie [INFORMATION]: Frame 08 of 44 completed [ 20.5 %]
movie [INFORMATION]: Frame 09 of 44 completed [ 22.7 %]
movie [INFORMATION]: Frame 10 of 44 completed [ 25.0 %]
movie [INFORMATION]: Frame 11 of 44 completed [ 27.3 %]
movie [INFORMATION]: Frame 12 of 44 completed [ 29.5 %]
movie [INFORMATION]: Frame 13 of 44 completed [ 31.8 %]
movie [INFORMATION]: Frame 14 of 44 completed [ 34.1 %]
plot [ERROR]: Cannot find file 15.monthly
contour [ERROR]: Cannot find file 15.monthly
plot [ERROR]: Cannot find file 16.monthly
plot [ERROR]: Cannot find file 17.monthly
plot [ERROR]: Cannot find file 22.monthly
contour [ERROR]: Cannot find file 17.monthly
plot [ERROR]: Cannot find file 19.monthly
contour [ERROR]: Cannot find file 16.monthly
plot [ERROR]: Cannot find file 18.monthly
plot [ERROR]: Cannot find file 20.monthly
plot [ERROR]: Cannot find file 21.monthly
contour [ERROR]: Cannot find file 22.monthly
contour [ERROR]: Cannot find file 18.monthly
contour [ERROR]: Cannot find file 19.monthly
contour [ERROR]: Cannot find file 20.monthly
plot [ERROR]: Cannot find file 23.monthly
plot [ERROR]: Cannot find file 24.monthly
contour [ERROR]: Cannot find file 21.monthly
plot [ERROR]: Cannot find file 26.monthly
plot [ERROR]: Cannot find file 25.monthly
contour [ERROR]: Cannot find file 24.monthly
contour [ERROR]: Cannot find file 23.monthly
plot [ERROR]: Cannot find file 28.monthly
contour [ERROR]: Cannot find file 26.monthly
contour [ERROR]: Cannot find file 25.monthly
contour [ERROR]: Cannot find file 28.monthly
plot [ERROR]: Cannot find file 29.monthly
plot [ERROR]: Cannot find file 27.monthly
contour [ERROR]: Cannot find file 29.monthly
contour [ERROR]: Cannot find file 27.monthly
movie [INFORMATION]: Frame 15 of 44 completed [ 36.4 %]
movie [INFORMATION]: Frame 17 of 44 completed [ 38.6 %]
movie [INFORMATION]: Frame 16 of 44 completed [ 40.9 %]
movie [INFORMATION]: Frame 18 of 44 completed [ 43.2 %]
movie [INFORMATION]: Frame 19 of 44 completed [ 45.5 %]
movie [INFORMATION]: Frame 20 of 44 completed [ 47.7 %]
movie [INFORMATION]: Frame 22 of 44 completed [ 50.0 %]
movie [INFORMATION]: Frame 24 of 44 completed [ 52.3 %]
movie [INFORMATION]: Frame 21 of 44 completed [ 54.5 %]
movie [INFORMATION]: Frame 23 of 44 completed [ 56.8 %]
movie [INFORMATION]: Frame 25 of 44 completed [ 59.1 %]
movie [INFORMATION]: Frame 26 of 44 completed [ 61.4 %]
movie [INFORMATION]: Frame 27 of 44 completed [ 63.6 %]
movie [INFORMATION]: Frame 28 of 44 completed [ 65.9 %]
movie [INFORMATION]: Frame 29 of 44 completed [ 68.2 %]
plot [ERROR]: Cannot find file 30.monthly
contour [ERROR]: Cannot find file 30.monthly
plot [ERROR]: Cannot find file 31.monthly
contour [ERROR]: Cannot find file 31.monthly
plot [ERROR]: Cannot find file 33.monthly
plot [ERROR]: Cannot find file 32.monthly
plot [ERROR]: Cannot find file 37.monthly

Note that if your TImeLine.dat file just has text (like file names) then there are no MOVIE_COL entries, just MOVIE_WORD1, MOVIE_WORD2 (see how to tell the -T option to break your text into words. MOVIE_COLs are for data columns of which you have none.

1 Like

Hello, Mr. Pwessel,
I have changed based on your suggestions. But it is still not working. Do you have any suggestions? Anything is fine regarding individual plotting, but I faced very difficulty applying the GMT movie function.

The minor problem is the movement of the framework. It is ok for individual plotting (I mean without GMT movie).

Here is my data structure.

Having file names with spaces is asking for trouble in scripting. Perhaps replace the with dash or underscore.

1 Like

Paul’s right about the text in the timeline file (and spaces in filenames). But you might find the words 0-based. Ie the first word accessed using MOVIE_WORD0

1 Like

But actually, there is no spacing in my file name, I can really sure about it. The name is STPs_1977.monthly and WSPH_1977.monthly. There are two different files.

And inside TimeLine.dat, I stored as two columns of “STPs_1977" and "WSPH_1977”.
So, my plotting is
“gmt plot %MOVIE_COL1%.monthly -Sc0.1i -W0.01i,0/0/0 -G153/0/153
gmt contour %MOVIE_COL2%.monthly -A5880+f18+d+r1 -W5p,red”

As I mentioned above, I work perfectly for plotting individual images. But coming to the movie function, such as errors appear.

Thank for your comments.

Following @pwessel and @biggle1856’s suggestions, I think you should change your plotting commands to:

gmt plot %MOVIE_WORD0%.monthly -Sc0.1i -W0.01i,0/0/0 -G153/0/153
gmt contour %MOVIE_WORD1%.monthly -A5880+f18+d+r1 -W5p,red
1 Like

Hi,
That’s not working at all even I replace my name’s file like this STPs1977. No spacing, no underscore, or nothing else. But the command and function cannot understand.

 D:\Subtropical_High\Data\Animation>gmt movie Subtropical_High.bat -Chd -Nanime02 -Fgif -Tfile_name.dat
plot [ERROR]: Cannot find file .monthly
plot [ERROR]: Cannot find file .monthly
plot [ERROR]: Cannot find file .monthly
movie [NOTICE]: Running: gm convert -delay 4 -loop 1 +dither D:\Subtropical_High\Data\Animation\anime02\anime02_*.png anime02.gif

If possible, please post your scripts and sample data files so that it’s easier for us to help.

1 Like

Sure, here is the compressed files that I run.
Thank you for the help from everyone. I’m very much grateful for that.
GMT_Forum.zip (849.9 KB)

Append +w to split the trailing string into individual words that can be accessed via variables MOVIE_WORD0 , MOVIE_WORD1 , etc.

Following the documentation, you need to use -Tfile_name.dat+w instead.

That’s work perfectly now. Just one thing I want to ask, why my frame is moving upward and is cannot fix position as I plotted individual images ??

Could you explain what you mean in a different way, or show it? I do not understand.

I think he struggles with -C (movie) as opposed to the dimensions imposed by -J (not movie)

The workaround I use is:
In plot adding a line

gmt basemap -R0/1/0/1 -JX(horizontal size)/(vertical size)

… just make sure this one is positioned at the bottom left corner (no -X or -Y history)

The in movie command use the sale dimensions as -J

gmt movie […] -C(hor)x(ver)xdpu