Project

General

Profile

« Previous | Next » 

Revision 6225b4b7

Added by Benoit Parmentier about 8 years ago

modifying function to generate animation to accept list of files and additional documentation

View differences:

climate/research/oregon/interpolation/global_product_assessment_part2_functions.R
1 1
####################################  INTERPOLATION OF TEMPERATURES  #######################################
2 2
#######################  Assessment of product part 2 functions: mosaic and accuracy ##############################
3 3
#This script uses the worklfow code applied to the globe. Results currently reside on NEX/PLEIADES NASA.
4
#This part 2 of the assessment focuses on graphics to explore the spatial patterns of raster times series as figures and movie.
4
#This part 2 of the product assessment focuses on graphics to explore the spatial patterns of raster times series as figures.
5
#The file contains functions to genrate figures and animation (movie).
5 6
#AUTHOR: Benoit Parmentier 
6
#CREATED ON: 05/24/2016  
7
#MODIFIED ON: 10/09/2016            
7
#CREATED ON: 10/03/2016  
8
#MODIFIED ON: 10/10/2016            
8 9
#Version: 2
9 10
#PROJECT: Environmental Layers project     
10
#COMMENTS: Initial commit, script based on part NASA biodiversity conference 
11
#COMMENTS:
11 12
#TODO:
12 13
#1) Add plot broken down by year and region 
13 14
#2) Modify code for overall assessment accross all regions and year
......
19 20
#
20 21
#setfacl -Rmd user:aguzman4:rwx /nobackupp8/bparmen1/output_run10_1500x4500_global_analyses_pred_1992_10052015
21 22

  
22
##COMMIT: adding function to generate animation
23
##COMMIT: modifying function to generate animation to accept list of files and additional documentation
23 24

  
24 25
#################################################################################################
25 26

  
......
252 253

  
253 254
#create animation from figures:
254 255
generate_animation_from_figures_fun <- function(filenames_figures,frame_speed=60,format_file=".gif",out_suffix="",out_dir=".",out_filename_figure_animation=NULL){
256
  #This function generates an animation given a list of files or textfile. The default format is .gif.
257
  #The function requires ImageMagick to produce animation.
258
  #INPUTS:
259
  #1) filenames_figures: list of files as "list" or "character, or file name of a text file containing the list of figures.
260
  #2) frame_speed: delay option in constructing the animation, default is 60
261
  #3) format_file=".gif"
262
  #4) out_suffix=""
263
  #5) out_dir=".",
264
  #6) out_filename_figure_animation=NUL
265
  #OUTPUTS:
266
  #
255 267

  
256 268
  if(is.null(out_filename_figure_animation)){
257 269
    #out_filename_figure_movies <- file.path(out_dir,paste("mosaic_movie_",out_suffix_movie,".gif",sep=""))
258 270
    out_filename_figure_animation <- file.path(out_dir,paste("animation_frame_",frame_speed,"_",out_suffix,format_file,sep=""))
259 271
  }
260 272
  
261
  if(class(filenames_figures)=="list"){
273
  if(class(filenames_figures)=="list" | (length(filenames_figures)>1)){ #if length of object greater than 1 then assume a list of files
262 274
    #filename_figures_mosaic <- file.path(out_dir,"mosaic_plot_fig.txt")
263 275
    out_filenames_figures <- file.path(out_dir,paste("list_figures_animation_",out_suffix,".txt",sep=""))
264 276
    write.table(unlist(filenames_figures),out_filenames_figures,row.names = F,col.names = F,quote = F)
265 277
    filenames_figures <- out_filenames_figures
266 278
  }
267 279
  
280
  
268 281
  #now generate movie with imageMagick
269 282

  
270 283
  #-delay 20

Also available in: Unified diff