Skip to content

Commit

Permalink
Merge pull request #126 from mhearne-usgs/authorfix
Browse files Browse the repository at this point in the history
Added Agency to list of phase dataframe columns.
  • Loading branch information
cbworden authored Sep 20, 2018
2 parents 475529d + ad68648 commit e5438e1
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions libcomcat/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ def _get_phaserow(pick, catevent):
- Status: "manual" or "automatic".
- Residual: Arrival time residual.
- Weight: Arrival weight.
- Agency: Agency ID.
"""
pick_id = pick.resource_id
waveform_id = pick.waveform_id
arrival = get_arrival(catevent, pick_id)
if arrival is None:
#print('could not find arrival for pick %s' % pick_id)
return None

# save info to row of dataframe
Expand All @@ -215,7 +215,8 @@ def _get_phaserow(pick, catevent):
'Arrival Time': etime,
'Status': pick.evaluation_mode,
'Residual': arrival.time_residual,
'Weight': arrival.time_weight}
'Weight': arrival.time_weight,
'Agency': arrival.creation_info.agency_id}
return row


Expand All @@ -228,31 +229,33 @@ def get_phase_dataframe(detail, catalog='preferred'):
Source network ('us','ak', etc. ,or 'preferred'.)
:returns:
Pandas DataFrame containing columns:
- Channel: Network.Station.Channel.Location (NSCL) style station description.
("--" indicates missing information)
- Channel: Network.Station.Channel.Location (NSCL) style station
description. ("--" indicates missing information)
- Distance: Distance (kilometers) from epicenter to station.
- Azimuth: Azimuth (degrees) from epicenter to station.
- Phase: Name of the phase (Pn,Pg, etc.)
- Arrival Time: Pick arrival time (UTC).
- Status: "manual" or "automatic".
- Residual: Arrival time residual.
- Weight: Arrival weight.
- Agency: Agency ID.
:raises:
AttributeError if input DetailEvent does not have a phase-data product for the input catalog.
AttributeError if input DetailEvent does not have a phase-data product
for the input catalog.
"""
if catalog is None:
catalog = 'preferred'
df = pd.DataFrame(columns=['Channel', 'Distance', 'Azimuth',
'Phase', 'Arrival Time', 'Status',
'Residual', 'Weight'])
'Residual', 'Weight', 'Agency'])

phasedata = detail.getProducts('phase-data', source=catalog)[0]
quakeurl = phasedata.getContentURL('quakeml.xml')
try:
fh = urlopen(quakeurl, timeout=TIMEOUT)
data = fh.read()
fh.close()
except Exception as msg:
except Exception:
return None
unpickler = Unpickler()
with warnings.catch_warnings():
Expand All @@ -272,7 +275,7 @@ def get_detail_data_frame(events, get_all_magnitudes=False,
get_focals='preferred',
get_moment_supplement=False,
verbose=False):
"""Take the results of a search and extract the detailed event informat in a pandas DataFrame.
"""Extract the detailed event informat into a pandas DataFrame.
Usage:
TODO
Expand Down

0 comments on commit e5438e1

Please sign in to comment.