netcdf2mp4: A python script to create animated data visualizations from spatio-temporal netcdf datasets in GIF and MP4 format.
This script uses gdal
to read NetCDF data, uses matplotlib
to plot the data for each point in time, and uses imageio
to create an animated GIF. Finally, it uses moviepy
to convert the animated gif to MP4 video format, which will reduce file size. For example, the below GIF is 29MB, and the corresponding MP4 file is less than 3MB.
For example, this script can be used to visualize the average monthly temperature for each 0.5° x 0.5° grid cell from 1901-2020 from the CRU TS monthly high-resolution gridded multivariate climate dataset (Harris et al. 2020; https://www.nature.com/articles/s41597-020-0453-3).
For further code on CRU data extraction and visualization, see https://github.com/johannesuhl/cru_data_processing.
Harris, I., Osborn, T. J., Jones, P., & Lister, D. (2020). Version 4 of the CRU TS monthly high-resolution gridded multivariate climate dataset. Scientific data, 7(1), 1-18. https://doi.org/10.1038/s41597-020-0453-3