We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents e7152ff + ff9f4fb commit 2eb7b6aCopy full SHA for 2eb7b6a
6 files changed
libcomcat/classes.py
@@ -648,12 +648,11 @@ def toDict(self, catalog=None,
648
phase_url = phase_data.getContentURL('quakeml.xml')
649
catalog = read_events(phase_url)
650
event = catalog.events[0]
651
- imag = 1
652
- for magnitude in event.magnitudes:
+ for imag, magnitude in enumerate(event.magnitudes):
653
edict['magnitude%i' % imag] = magnitude.mag
654
edict['magtype%i' %
655
imag] = magnitude.magnitude_type
656
- imag += 1
+ edict['magsource%i' % imag] = magnitude.creation_info.agency_id
657
658
return edict
659
libcomcat/search.py
@@ -610,8 +610,12 @@ def get_authoritative_info(eventid):
610
origins = detail.getProducts('origin', source='all')
611
for origin in origins:
612
source = origin.source
613
- magtype = origin['magnitude-type']
614
- magval = float(origin['magnitude'])
+ if origin['magnitude-source'].lower() != source.lower():
+ magval = np.nan
615
+ magtype = 'NA'
616
+ else:
617
+ magval = float(origin['magnitude'])
618
+ magtype = origin['magnitude-type']
619
colname = '%s-%s' % (source, magtype)
620
mag_row[colname] = magval
621
latname = '%s-%s' % (origin.source, 'latitude')
notebooks/ComparingMagnitudes.ipynb
notebooks/data/events.xlsx
1.22 KB
tests/bin/getmags_test.py
@@ -55,7 +55,7 @@ def test_mag():
55
shutil.rmtree(tmpdir)
56
# The largest recorded earthquake is a relatively stable check
57
target_columns = ['id', 'time', 'lat', 'lon', 'depth', 'location',
58
- 'url', 'hypo_src', 'official-mw', 'us-mw']
+ 'url', 'hypo_src', 'official-mw', 'us-NA']
59
np.testing.assert_array_equal(df.columns, target_columns)
60
target_id = 'official19600522191120_30'
61
target_location = '1960 Great Chilean Earthquake (Valdivia Earthquake)'
@@ -78,7 +78,7 @@ def test_mag():
78
79
80
81
82
83
84
tests/libcomcat/classes_test.py
@@ -200,7 +200,7 @@ def test_detail():
200
assert atdict['depth'] == 9.0
201
202
ncdict_allmags = event.toDict(get_all_magnitudes=True)
203
- assert ncdict_allmags['magtype3'] == 'Ml'
+ assert ncdict_allmags['magtype1'] == 'Md'
204
205
ncdict_alltensors = event.toDict(get_tensors='all')
206
assert ncdict_alltensors['us_Mwb_mrr'] == 7.63e+16
0 commit comments