Skip to content

Commit 3906e44

Browse files
author
Mike Hearne
authored
Merge pull request #148 from mhearne-usgs/prodfix
Fixed some issues having to do with different or missing data from ol…
2 parents 17b8469 + 4a26b6d commit 3906e44

3 files changed

Lines changed: 230 additions & 63 deletions

File tree

bin/geteventhist

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,67 @@ class MyFormatter(argparse.RawTextHelpFormatter,
2828
def get_parser():
2929
desc = '''Print out ComCat event history.
3030
31-
Usage:
32-
geteventhist ci38457511
31+
This program summarizes the history of an event through the
32+
products found in ComCat. The products that can be described are:
33+
'dyfi', 'finite-fault', 'focal-mechanism', 'ground-failure',
34+
'losspager', 'moment-tensor', 'oaf', 'origin', 'phase-data',
35+
and 'shakemap'.
36+
37+
In the summary output (see below), all products will have the following
38+
columns:
39+
- Product:
40+
One of supported products (see above)
41+
- Authoritative Event ID:
42+
Authoritative ComCat event ID, mostly only useful when using -r flag.
43+
- Code:
44+
Event Source + Code, mostly only useful when using
45+
-r flag with geteventhist.
46+
- Associated:
47+
Boolean indicating whether this product is associated
48+
with authoritative event. (only appears when using -r flag).
49+
- Product Source:
50+
Network that contributed the product.
51+
- Product Version:
52+
Either ordinal number created by sorting products from a
53+
given source, or a version property set by the creator
54+
of the product.
55+
- Update Time:
56+
Time the product was sent, set either by PDL client or
57+
by the person or software that created the product
58+
(set as a property.)
59+
- Elapsed (min):
60+
Elapsed time in minutes between the update time and
61+
the *authoritative* origin time.
62+
- Description:
63+
Varies depending on the product, but all description
64+
fields are delineated first by a vertical pipe "|",
65+
and key/value pairs in each field are delineated
66+
by a hash "#". This is so that the -s option
67+
can parse the description column into many
68+
columns.
69+
70+
To get one summary spreadsheet in Excel format listing all products
71+
for the M7.1 event from the 2019 Ridgecrest Sequence:
72+
73+
geteventhist ci38457511 -o ~/tmp/ridgecrest -f excel
74+
75+
To get one summary spreadhsheet as above, *excluding* DYFI products:
76+
77+
geteventhist ci38457511 -o ~/tmp/ridgecrest -f excel -x dyfi
78+
79+
To split out the "description" column into separate columns, and
80+
the products into separate spreadsheets:
81+
82+
geteventhist ci38457511 -o ~/tmp/ridgecrest -f excel -s
83+
84+
To retrieve summary information for only origins and shakemaps:
85+
86+
geteventhist ci38457511 -o ~/tmp/ridgecrest -f excel -p origin shakemap
87+
88+
To retrieve information for only origins and shakemaps, and split them
89+
into separate spreadsheets:
90+
91+
geteventhist ci38457511 -o ~/tmp/ridgecrest -f excel -p origin shakemap -s
3392
3493
'''
3594
parser = argparse.ArgumentParser(description=desc,

libcomcat/classes.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,9 @@ def hasProperty(self, key):
503503
Returns:
504504
bool: Indicates whether that key exists or not.
505505
"""
506-
if key not in self._jdict['properties']:
506+
c1 = 'properties' not in self._jdict
507+
c2 = key not in self._jdict['properties']
508+
if c1 or c2:
507509
return False
508510
return True
509511

@@ -959,7 +961,9 @@ def hasProperty(self, key):
959961
Returns:
960962
bool: Indicates whether that key exists or not.
961963
"""
962-
if key not in self._product['properties']:
964+
c1 = 'properties' not in self._product
965+
c2 = c1 or key not in self._product['properties']
966+
if c2:
963967
return False
964968
return True
965969

@@ -1046,7 +1050,9 @@ def __getitem__(self, key):
10461050
Returns:
10471051
str: Desired property.
10481052
"""
1049-
if key not in self._product['properties']:
1053+
c1 = 'properties' not in self._product
1054+
c2 = c1 or key not in self._product['properties']
1055+
if c2:
10501056
msg = 'No property %s found in %s product.' % (
10511057
key, self._product_name)
10521058
raise AttributeError(msg)

0 commit comments

Comments
 (0)