[cig-commits] r19195 - seismo/2D/SPECFEM2D/trunk/UTILS

dkomati1 at geodynamics.org dkomati1 at geodynamics.org
Mon Nov 14 08:51:18 PST 2011


Author: dkomati1
Date: 2011-11-14 08:51:18 -0800 (Mon, 14 Nov 2011)
New Revision: 19195

Added:
   seismo/2D/SPECFEM2D/trunk/UTILS/process_Jpg_movie_files_to_change_their_names.py
Log:
added Paul Cristini's Python script to process JPEG movie files to change their names in order to create movies more easily based on a set of such files.


Added: seismo/2D/SPECFEM2D/trunk/UTILS/process_Jpg_movie_files_to_change_their_names.py
===================================================================
--- seismo/2D/SPECFEM2D/trunk/UTILS/process_Jpg_movie_files_to_change_their_names.py	                        (rev 0)
+++ seismo/2D/SPECFEM2D/trunk/UTILS/process_Jpg_movie_files_to_change_their_names.py	2011-11-14 16:51:18 UTC (rev 19195)
@@ -0,0 +1,55 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Mon Oct 10 09:40:11 2011
+
+Add images with time step in file names if number was originally used or add
+images with number in file names if time step was originally used 
+
+Usage : change directory to the the directory where the images were created and
+type "python PathTo/SPECFEM2D/UTILS/ProcessJpgFiles.py"
+
+ at author: Cristini Paul, Laboratoire de Mecanique et d'Acoustique, CNRS, Marseille, France
+"""
+from os import listdir
+from shutil import copy
+from os.path import exists
+
+def LecDataBaseNstep():
+    # Open the first Database
+    f = file('Database00000','r')
+    lignes= f.readlines()
+    f.close()
+    #
+    nstep=int(lignes[13])
+    return nstep
+
+def ConvertImage(ListFich):
+    ct=0
+    for filename in ListFich:
+        if filename.startswith('image'):
+            ct+=1
+            fname='img'+str(ct)+'.jpg'
+            copy(filename,fname)
+    return
+    
+def ConvertImage000(ListFich):
+    nstep=LecDataBaseNstep()
+    ct=0
+    for filename in ListFich:
+        if filename.startswith('img'):
+            ct+=1
+            if ct==1:
+                tstep=5
+            else:
+                tstep=(ct-1)*nstep
+            fname='image%07i.jpg'% tstep
+            copy(filename,fname)
+    return
+    
+if __name__=='__main__':
+     ListFich=sorted(listdir('.'))
+     if not (exists('img1.jpg') & exists('image0000005.jpg')):
+         if exists('img1.jpg'): ConvertImage000(ListFich)
+         if  exists('image0000005.jpg'): ConvertImage(ListFich)
+     else:
+        print 'Nothing to do !'


Property changes on: seismo/2D/SPECFEM2D/trunk/UTILS/process_Jpg_movie_files_to_change_their_names.py
___________________________________________________________________
Name: svn:executable
   + *



More information about the CIG-COMMITS mailing list