def get_event_origin_row(row, selected_agencies=[]): """ Parses the Origin row from ISF format to an instance of an isf_catalogue.Origin class. If the author is not one of the selected agencies then None is returns """ origin_id = _to_str(row[128:]) author = _to_str(row[118:127]) if len(selected_agencies) and not author in selected_agencies: # Origin not an instance of ISC Reviewed, Engdahl, HRVD or GCMT - # origin not saved! return None # Get date yyyy/mm/dd ymd = map(int, row[:10].split("/")) date = datetime.date(ymd[0], ymd[1], ymd[2]) # Get time time, time_error, time_rms = get_time_from_str(row) # Get longitude and latitude latitude = float(row[36:44]) longitude = float(row[45:54]) # Get error ellipse semimajor90 = _to_float(row[55:60]) semiminor90 = _to_float(row[61:66]) error_strike = _to_float(row[67:70]) # Get depths depth = _to_float(row[71:76]) depth_error = _to_float(row[78:82]) # Create location class location = Location(origin_id, longitude, latitude, depth, semimajor90, semiminor90, error_strike, depth_error) # Get the metadata metadata = get_origin_metadata(row) return Origin(origin_id, date, time, location, author, time_error=time_error, time_rms=time_rms, metadata=metadata)
def get_origin_metadata(row): """ Returns the dictionary of metadata from the origins """ metadata = { 'Nphases': _to_int(row[83:87]), 'Nstations': _to_int(row[88:92]), 'AzimuthGap': _to_float(row[93:96]), 'minDist': _to_float(row[97:103]), 'maxDist': _to_float(row[104:110]), 'FixedTime': _to_str(row[22]), 'DepthSolution': _to_str(row[54]), 'AnalysisType': _to_str(row[111]), 'LocationMethod': _to_str(row[113]), 'EventType': _to_str(row[115:117])} return metadata
def get_origin_metadata(row): """ Returns the dictionary of metadata from the origins """ metadata = { "Nphases": _to_int(row[83:87]), "Nstations": _to_int(row[88:92]), "AzimuthGap": _to_float(row[93:96]), "minDist": _to_float(row[97:103]), "maxDist": _to_float(row[104:110]), "FixedTime": _to_str(row[22]), "DepthSolution": _to_str(row[54]), "AnalysisType": _to_str(row[111]), "LocationMethod": _to_str(row[113]), "EventType": _to_str(row[115:117]), } return metadata
def get_event_origin_row(row, selected_agencies=[]): ''' Parses the Origin row from ISF format to an instance of an isf_catalogue.Origin class. If the author is not one of the selected agencies then None is returns ''' origin_id = _to_str(row[128:]) author = _to_str(row[118:127]) if len(selected_agencies) and not author in selected_agencies: # Origin not an instance of (or authored by) a selected agency return None # Get date yyyy/mm/dd ymd = map(int, row[:10].split('/')) #print "YMD",ymd date = datetime.date(ymd[0], ymd[1], ymd[2]) # Get time time, time_error, time_rms = get_time_from_str(row) # Get longitude and latitude latitude = float(row[36:44]) longitude = float(row[45:54]) # Get error ellipse semimajor90 = _to_float(row[55:60]) semiminor90 = _to_float(row[61:66]) error_strike = _to_float(row[67:70]) # Get depths #depth = _to_float(row[71:75]) depth = _to_float(row[71:75]) depthSolution = _to_str(row[76:78]) #if depthSolution == "f": # print "depth= ", depth, "DepthSolution =", depthSolution depth_error = _to_float(row[78:82]) # Create location class location = Location(origin_id, longitude, latitude, depth, depthSolution, semimajor90, semiminor90, error_strike, depth_error) # Get the metadata metadata = get_origin_metadata(row) return Origin(origin_id, date, time, location, author, time_error=time_error, time_rms=time_rms, metadata=metadata)
def get_event_magnitude(row, event_id, selected_agencies=[]): """ Creates an instance of an isf_catalogue.Magnitude object from the row string, or returns None if the author is not one of the selected agencies """ origin_id = _to_str(row[30:]) author = row[20:29].strip(" ") if len(selected_agencies) and not author in selected_agencies: # Magnitude does not corresond to a selected agency - ignore return None sigma = _to_float(row[11:14]) nstations = _to_int(row[15:19]) return Magnitude( event_id, origin_id, _to_float(row[6:10]), author, scale=row[:5].strip(" "), sigma=sigma, stations=nstations )
def get_event_magnitude(row, event_id, selected_agencies=[]): #,selected_types=[]): """ Creates an instance of an isf_catalogue.Magnitude object from the row string, or returns None if the author is not one of the selected agencies or magnitude types """ origin_id = _to_str(row[30:]) author = row[20:29].strip(' ') scale=row[:5].strip(' ') if (len(selected_agencies) and not author in selected_agencies): # Magnitude does not correspond to a selected agency - ignore return None sigma = _to_float(row[11:14]) nstations = _to_int(row[15:19]) return Magnitude(event_id, origin_id, _to_float(row[6:10]), author, scale=scale, sigma=sigma, stations=nstations)