Created
October 25, 2012 02:49
-
-
Save jreyes1108/3950169 to your computer and use it in GitHub Desktop.
Antelope origin subset and print
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PF= | |
MAN1= | |
BIN=test | |
include $(ANTELOPEMAKE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
path = '/opt/antelope/data/db/demo/demo' | |
#verbose = True | |
from optparse import OptionParser | |
usage = "Usage: test [-v] [-t time]" | |
parser = OptionParser(usage=usage) | |
parser.add_option("-v", "--verbose", action="store_true", | |
dest="verbose", default=False, help="verbose output") | |
parser.add_option("-t", "--time", action="store", | |
dest="time", type="int", help="subset orids after time") | |
(options, args) = parser.parse_args() | |
#print "options %s" % options | |
#print "args %s" % args | |
verbose = options.verbose | |
time = options.time | |
# import datascope libs | |
import antelope.datascope as datascope | |
# opend the databse read-only | |
db = datascope.dbopen(path,'r') | |
# look for the origin table | |
db = db.lookup( table='origin' ) | |
# look for total records in table | |
nrecs = db.nrecs() | |
if verbose: print "Records in origin table: %s" % nrecs | |
if not nrecs: | |
exit('No records in origin table') | |
if verbose: print "Join netmag" | |
# add magnitudes | |
db = db.join( 'netmag' ) | |
# look for total records in table | |
nrecs = db.nrecs() | |
if verbose: print "Records after join of netmag: %s" % nrecs | |
if not nrecs: | |
exit('No records in origin table') | |
if verbose: print "Subset for time > %s" % time | |
# look for events after time | |
db = db.subset( "time > %s" % time ) | |
nrecs = db.nrecs() | |
if verbose: print "Records after time subset: %s" % nrecs | |
if not nrecs: | |
exit('No records in origin table') | |
# extrat table values | |
for x in range(db.nrecs()): | |
db[3] = x | |
try: | |
lat, lon, depth, orid_time, mag, magtype = db.getv( 'lat', 'lon', 'depth', 'time','magnitude','magtype' ) | |
except Exception,e: | |
print 'dbgetv error: %s' % e | |
if verbose: | |
print '\t%s) lat:%s lon:%s depth:%s time:%s mag:%s type:%s' % (x,lat,lon,depth,orid_time,mag,magtype) | |
else: | |
print '\t%s %s %s %s %s %s' % (lat,lon,depth,orid_time,mag,magtype) | |
if verbose: print 'Done' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment