Skip to content

Commit 0c5e7c5

Browse files
author
Mike Hearne
authored
Merge pull request #223 from mhearne-usgs/typefix
Added more event types to getcsv, fixed bug in getcsv
2 parents 73cbf66 + d4c91af commit 0c5e7c5

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

libcomcat/bin/getcsv.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
get_summary_data_frame)
1515
from libcomcat.logging import setup_logger
1616

17+
EVTYPES = ['earthquake', 'explosion', 'landslide', 'volcanic eruption']
18+
1719

1820
def get_parser():
1921
desc = '''Download basic earthquake information in line format (csv, tab, etc.).
@@ -219,6 +221,11 @@ def get_parser():
219221
parser.add_argument('-x', '--count', dest='getCount',
220222
action='store_true',
221223
help=helpstr)
224+
typehelp = '''Select event type other than "earthquake".'''
225+
226+
parser.add_argument('--event-type', default='earthquake',
227+
choices=EVTYPES,
228+
help=typehelp)
222229
return parser
223230

224231

@@ -347,6 +354,7 @@ def main():
347354
maxsig=maxsig,
348355
producttype=args.limitByProductType,
349356
host=args.host,
357+
eventtype=args.event_type,
350358
alertlevel=args.alert_level)
351359
else:
352360
events = []
@@ -373,6 +381,7 @@ def main():
373381
maxsig=maxsig,
374382
producttype=args.limitByProductType,
375383
host=args.host,
384+
eventtype=args.event_type,
376385
alertlevel=args.alert_level)
377386
events += tevents
378387

@@ -401,7 +410,10 @@ def main():
401410
first_columns = list(events[0].toDict().keys())
402411
col_list = list(df.columns)
403412
for column in first_columns:
404-
col_list.remove(column)
413+
try:
414+
col_list.remove(column)
415+
except Exception as e:
416+
x = 1
405417
df = df[first_columns + col_list]
406418

407419
if args.country:

libcomcat/classes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ def toDict(self):
344344
edict['magnitude'] = self.magnitude
345345
edict['alert'] = self.alert
346346
edict['url'] = self.url
347+
edict['eventtype'] = self._jdict['properties']['type']
347348
edict['significance'] = self['sig']
348349
return edict
349350

@@ -578,7 +579,9 @@ def toDict(self, catalog=None,
578579
edict['magnitude'] = self.magnitude
579580
edict['magtype'] = self._jdict['properties']['magType']
580581
edict['url'] = self.url
582+
edict['eventtype'] = self._jdict['properties']['type']
581583
edict['alert'] = self.alert
584+
edict['significance'] = self['sig']
582585
else:
583586
try:
584587
phase_sources = []

0 commit comments

Comments
 (0)