使用Python读SEGY道头
自己遇到的一个问题, WestGeco的3D地震数据, 提取导航数据:
#!/bin/env python
import sys
import struct
try:
f=open(sys.argv[1],'rb')
except (IOError,Exception):
print '''usage:
scriptname segyfilename
'''
sys.exit(1)
#skip EBCDIC header
try:
f.seek(3200)
except Exception:
print 'Oops! your file is broken..'
#read binary header
binhead = f.read(400)
ns = struct.unpack('>h',binhead[20:22])[0]
if ns < 0:
print 'file read error'
sys.exit(1)
#read trace header
while True:
trchead = f.read(240)
if trchead == '':
break
nav = trchead[224:228]+\
trchead[228:232]+\
trchead[200:204]+\
trchead[204:208]+\
trchead[60:64]
#define output format
nl = struct.unpack('>5i',nav)
print 'QL%-4d%9s%10.2f%10.2f%5s' % (nl[0], nl[1], nl[2]/100.0, nl[3]/100.0, nl[4])
f.seek(ns*4,1)
f.close()
相关文档:
1,下载org.python.pydev.feature-1.5.0.1251989166.zip http://sourceforge.net/projects/pydev/files/
2,安装插件到eclipse
3,重启eclipse
注意:使用1.5.6版本pydev插件,创建python工程会报错,使用1.5.0版本无此问题。 ......
1,编写Server.py
import socket
s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
s.bind(('localhost',8081))
while True:
data,addr=s.recvfrom(1024)
print 'receive:',data,'from',addr
2,编写Client.py
import socket
s=socket.socket(socket.AF_INET,socket.SOC ......
编译了一个windows下的python3连接Mysql的库
mypysql
版本是 0.5.1 ,根据官方的修改日志,这个版本修改了0.5中一个内存泄漏问题。
源代码和编译后的文件为:
http://211.147.215.55/down/mypysql-0.5.1-win.zip
mypysql的官方地址 https://sourceforge.net/projects/mypysql/
......
#from pp3e Chapter 9.3
#############################################################################
# popup three new window, with style
# destroy() kills one window, quit() kills all windows and app; top-level
# windows have title, icon, iconify/deiconify and protocol for wm events;
# there ......