Project

General

Profile

« Previous | Next » 

Revision fc205746

Added by Benoit Parmentier about 8 years ago

adding function to generate animation in part 2 function script

View differences:

climate/research/oregon/interpolation/global_product_assessment_part2_functions.R
4 4
#This part 2 of the assessment focuses on graphics to explore the spatial patterns of raster times series as figures and movie.
5 5
#AUTHOR: Benoit Parmentier 
6 6
#CREATED ON: 05/24/2016  
7
#MODIFIED ON: 10/03/2016            
8
#Version: 1
7
#MODIFIED ON: 10/09/2016            
8
#Version: 2
9 9
#PROJECT: Environmental Layers project     
10 10
#COMMENTS: Initial commit, script based on part NASA biodiversity conference 
11 11
#TODO:
......
19 19
#
20 20
#setfacl -Rmd user:aguzman4:rwx /nobackupp8/bparmen1/output_run10_1500x4500_global_analyses_pred_1992_10052015
21 21

  
22
##COMMIT: Changes to plotting function for raster mosaic and other 
22
##COMMIT: adding function to generate animation
23 23

  
24 24
#################################################################################################
25 25

  
......
250 250
  return(missing_dates)
251 251
}
252 252

  
253
#create animation from figures:
254
generate_animation_from_figures_fun <- function(filenames_figures,frame_speed=60,format_file=".gif",out_suffix="",out_dir=".",out_filename_figure_animation=NULL){
255

  
256
  if(is.null(out_filename_figure_animation)){
257
    #out_filename_figure_movies <- file.path(out_dir,paste("mosaic_movie_",out_suffix_movie,".gif",sep=""))
258
    out_filename_figure_animation <- file.path(out_dir,paste("animation_frame_",frame_speed,"_",out_suffix,format_file,sep=""))
259
  }
260
  
261
  if(class(filenames_figures)=="list"){
262
    #filename_figures_mosaic <- file.path(out_dir,"mosaic_plot_fig.txt")
263
    out_filenames_figures <- file.path(out_dir,paste("list_figures_animation_",out_suffix,".txt",sep=""))
264
    write.table(unlist(filenames_figures),out_filenames_figures,row.names = F,col.names = F,quote = F)
265
    filenames_figures <- out_filenames_figures
266
  }
267
  
268
  #now generate movie with imageMagick
269

  
270
  #-delay 20
271
  #delay_option <- 60
272
  delay_option <- frame_speed
273
  
274
  cmd_str <- paste("convert",
275
                   paste("-delay",delay_option),
276
                   paste0("@",filenames_figures),
277
                   out_filename_figure_animation)
278
  #convert @myimages.txt mymovie.gif
279
  #save cmd_str in text file!!!
280
  
281
  system(cmd_str)
282
  
283
  return(out_filename_figure_animation)
284

  
285
}
253 286

  
254 287
############################ END OF SCRIPT ##################################

Also available in: Unified diff