Make the MO global analysis videoΒΆ

To make the video you need to run the plot script thousands of times, making an image file for each point in time, and then to merge the thousands of resulting images into a single video.

To make a smooth video we generate one frame each 30 minutes - the temperatures and winds are available on the hour and the precipitation on the half hours, so making frames at 15 and 45 minutes past the hour makes each frame the same (as opposed to having some original data frames and some interpolated data frames).

This script makes a list of commands to plot a frame each 30 minutes over a year:

#!/usr/bin/env python

# Make all the individual frames for a movie

import os
import subprocess
import datetime

# Where to put the output files
opdir="%s/slurm_output" % os.getenv('SCRATCH')
if not os.path.isdir(opdir):

# Function to check if the job is already done for this timepoint
def is_done(year,month,day,hour):
    op_file_name=("%s/images/opfc_global_3var_meanp/" +
                  "%04d%02d%02d%02d%02d.png") % (
    if os.path.isfile(op_file_name):
        return True
    return False


start_day=datetime.datetime(2018,   9, 26,  0, 15)
end_day  =datetime.datetime(2019,   9, 18, 23, 45)

while current_day<=end_day:
    if is_done(current_day.year,current_day.month,
    cmd=("./ --year=%d --month=%d " +
         "--day=%d --hour=%f "+
         "--pole_latitude=90 --pole_longitude=180 "+
         "--npg_longitude=0 "+
         "--zoom=1 "+
         "\n") % (

You will want to run those jobs in parallel, either with GNU parallel or by submitting them to a batch system (I used the MO SPICE cluster).

When all the frame images are rendered make a video using ffmpeg. Because of all the detail in the wind and precipitation fields, this video requires a lot of bandwidth, so render it at 20Mbps bandwidth (this is also why the frames are 3840X2160 in size - this produces a 4k video.

ffmpeg -r 48 -pattern_type glob -i opfc_global_3var_meanp/\*.png \
       -c:v libx264 -threads 16 -preset veryslow -tune film \
       -profile:v high -level 4.2 -pix_fmt yuv420p -b:v 19M \
       -maxrate 19M -bufsize 20M -c:a copy opfc_global_3var_meanp.mp4