[cig-commits] r8460 - in seismo/2D/SPECFEM2D/trunk/DATA: . util

walter at geodynamics.org walter at geodynamics.org
Fri Dec 7 15:47:52 PST 2007


Author: walter
Date: 2007-12-07 15:47:52 -0800 (Fri, 07 Dec 2007)
New Revision: 8460

Added:
   seismo/2D/SPECFEM2D/trunk/DATA/util/
   seismo/2D/SPECFEM2D/trunk/DATA/util/su_create_Paul.python
Log:
added su_create_Paul.python to 2D code


Added: seismo/2D/SPECFEM2D/trunk/DATA/util/su_create_Paul.python
===================================================================
--- seismo/2D/SPECFEM2D/trunk/DATA/util/su_create_Paul.python	2005-02-08 15:11:05 UTC (rev 8459)
+++ seismo/2D/SPECFEM2D/trunk/DATA/util/su_create_Paul.python	2007-12-07 23:47:52 UTC (rev 8460)
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+#
+#  Python code to generate Seismic Unix files for Ux and Uz and plot them
+#
+from os import *
+import os.path, string
+#
+def createSU():
+	SEM=getcwd()
+	filename=SEM+'/DATA/Par_file'
+	#
+	# Variables to be put in SU header
+	# 
+	if path.exists(filename):
+		variables=['nt','dt']
+	else:
+		print 'No Par_file found !'
+		return 
+	#     
+	# Open the file and get the lines
+	# 
+	f = file(filename,'r')
+	lignes= f.readlines()
+	f.close()
+	# Get the title
+	for ligne in lignes:
+		lsplit=string.split(ligne)
+		if lsplit[0]=='title':
+		   title=' '.join(lsplit[2:])
+		   break 
+	print '#'*50
+	print '#  SU file creation for '+title
+	print  '#'*50
+	#  Get the variables
+	for var in variables:
+		for ligne in lignes:
+			lsplit=string.split(ligne)
+			if lsplit[0]==var:
+			   exec var+'='+string.replace(string.split(''.join(ligne))[2],'d','e') 
+			   break
+	# 
+	chdir(SEM+'/OUTPUT_FILES')
+	labels='label1="Time" label2="Receivers"'
+	# Create headers ans Su file
+	ordres=['suaddhead < Ux_file.bin ns='+str(nt)+' | sushw key=dt a='+str(int(dt*1e6))+' > Ux_file.su']
+	ordres.append('suaddhead < Uz_file.bin ns='+str(nt)+' | sushw key=dt a='+str(int(dt*1e6))+' > Uz_file.su')
+	ordres.append('suxwigb < Ux_file.su perc=96 '+labels+' title=" Ux : '+title+'"&')
+	ordres.append('suxwigb < Uz_file.su xbox=600 perc=96 '+labels+' title=" Uz : '+title+'"&')
+	# 
+	for i in range(len(ordres)):
+		 system(ordres[i]) 
+if __name__=='__main__':
+	createSU()
\ No newline at end of file



More information about the cig-commits mailing list