本文整理汇总了Python中obspy.core.event.Origin.origin_uncertainty方法的典型用法代码示例。如果您正苦于以下问题:Python Origin.origin_uncertainty方法的具体用法?Python Origin.origin_uncertainty怎么用?Python Origin.origin_uncertainty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obspy.core.event.Origin
的用法示例。
在下文中一共展示了Origin.origin_uncertainty方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _deserialize
# 需要导入模块: from obspy.core.event import Origin [as 别名]
# 或者: from obspy.core.event.Origin import origin_uncertainty [as 别名]
def _deserialize(self, zmap_str):
catalog = Catalog()
for row in zmap_str.split('\n'):
if len(row) == 0:
continue
origin = Origin()
event = Event(origins=[origin])
event.preferred_origin_id = origin.resource_id.id
# Begin value extraction
columns = row.split('\t', 13)[:13] # ignore extra columns
values = dict(zip(_STD_ZMAP_COLUMNS + _EXT_ZMAP_COLUMNS, columns))
# Extract origin
origin.longitude = self._str2num(values.get('lon'))
origin.latitude = self._str2num(values.get('lat'))
depth = self._str2num(values.get('depth'))
if depth is not None:
origin.depth = depth * 1000.0
z_err = self._str2num(values.get('z_err'))
if z_err is not None:
origin.depth_errors.uncertainty = z_err * 1000.0
h_err = self._str2num(values.get('h_err'))
if h_err is not None:
ou = OriginUncertainty()
ou.horizontal_uncertainty = h_err
ou.preferred_description = 'horizontal uncertainty'
origin.origin_uncertainty = ou
year = self._str2num(values.get('year'))
if year is not None:
t_fields = ['year', 'month', 'day', 'hour', 'minute', 'second']
comps = [self._str2num(values.get(f)) for f in t_fields]
if year % 1 != 0:
origin.time = self._decyear2utc(year)
elif any(v > 0 for v in comps[1:]):
# no seconds involved
if len(comps) < 6:
utc_args = [int(v) for v in comps if v is not None]
# we also have to handle seconds
else:
utc_args = [int(v) if v is not None else 0
for v in comps[:-1]]
# just leave float seconds as is
utc_args.append(comps[-1])
origin.time = UTCDateTime(*utc_args)
mag = self._str2num(values.get('mag'))
# Extract magnitude
if mag is not None:
magnitude = Magnitude(mag=mag)
m_err = self._str2num(values.get('m_err'))
magnitude.mag_errors.uncertainty = m_err
event.magnitudes.append(magnitude)
event.preferred_magnitude_id = magnitude.resource_id.id
event.scope_resource_ids()
catalog.append(event)
return catalog
示例2: _deserialize
# 需要导入模块: from obspy.core.event import Origin [as 别名]
# 或者: from obspy.core.event.Origin import origin_uncertainty [as 别名]
def _deserialize(self, zmap_str):
catalog = Catalog()
for row in zmap_str.split("\n"):
if len(row) == 0:
continue
origin = Origin()
event = Event(origins=[origin])
event.preferred_origin_id = origin.resource_id.id
# Begin value extraction
columns = row.split("\t", 13)[:13] # ignore extra columns
values = dict(zip(_STD_ZMAP_COLUMNS + _EXT_ZMAP_COLUMNS, columns))
# Extract origin
origin.longitude = self._str2num(values.get("lon"))
origin.latitude = self._str2num(values.get("lat"))
depth = self._str2num(values.get("depth"))
if depth is not None:
origin.depth = depth * 1000.0
z_err = self._str2num(values.get("z_err"))
if z_err is not None:
origin.depth_errors.uncertainty = z_err * 1000.0
h_err = self._str2num(values.get("h_err"))
if h_err is not None:
ou = OriginUncertainty()
ou.horizontal_uncertainty = h_err
ou.preferred_description = "horizontal uncertainty"
origin.origin_uncertainty = ou
year = self._str2num(values.get("year"))
if year is not None:
t_fields = ["year", "month", "day", "hour", "minute", "second"]
comps = [self._str2num(values.get(f)) for f in t_fields]
if year % 1 != 0:
origin.time = self._decyear2utc(year)
elif any(v > 0 for v in comps[1:]):
utc_args = [int(v) for v in comps if v is not None]
origin.time = UTCDateTime(*utc_args)
mag = self._str2num(values.get("mag"))
# Extract magnitude
if mag is not None:
magnitude = Magnitude(mag=mag)
m_err = self._str2num(values.get("m_err"))
magnitude.mag_errors.uncertainty = m_err
event.magnitudes.append(magnitude)
event.preferred_magnitude_id = magnitude.resource_id.id
catalog.append(event)
return catalog
示例3: _read_single_hypocenter
# 需要导入模块: from obspy.core.event import Origin [as 别名]
# 或者: from obspy.core.event.Origin import origin_uncertainty [as 别名]
#.........这里部分代码省略.........
"Note: Depth/Latitude/Longitude errors are calculated from covariance "
"matrix as 1D marginal (Lon/Lat errors as great circle degrees) "
"while OriginUncertainty min/max horizontal errors are calculated "
"from 2D error ellipsoid and are therefore seemingly higher compared "
"to 1D errors. Error estimates can be reconstructed from the "
"following original NonLinLoc error statistics line:\nSTATISTICS " +
lines["STATISTICS"])
# goto location quality info line
line = lines["QML_OriginQuality"].split()
(assoc_phase_count, used_phase_count, assoc_station_count,
used_station_count, depth_phase_count) = map(int, line[1:11:2])
stderr, az_gap, sec_az_gap = map(float, line[11:17:2])
gt_level = line[17]
min_dist, max_dist, med_dist = map(float, line[19:25:2])
# goto location quality info line
line = lines["QML_OriginUncertainty"]
if "COMMENT" in lines:
comment = lines["COMMENT"].strip()
comment = comment.strip('\'"')
comment = comment.strip()
hor_unc, min_hor_unc, max_hor_unc, hor_unc_azim = \
map(float, line.split()[1:9:2])
# assign origin info
event = Event()
o = Origin()
event.origins = [o]
event.preferred_origin_id = o.resource_id
o.origin_uncertainty = OriginUncertainty()
o.quality = OriginQuality()
ou = o.origin_uncertainty
oq = o.quality
o.comments.append(Comment(text=stats_info_string, force_resource_id=False))
event.comments.append(Comment(text=comment, force_resource_id=False))
# SIGNATURE field's first item is LOCSIG, which is supposed to be
# 'Identification of an individual, institiution or other entity'
# according to
# http://alomax.free.fr/nlloc/soft6.00/control.html#_NLLoc_locsig_
# so use it as author in creation info
event.creation_info = CreationInfo(creation_time=creation_time,
version=version,
author=signature)
o.creation_info = CreationInfo(creation_time=creation_time,
version=version,
author=signature)
# negative values can appear on diagonal of covariance matrix due to a
# precision problem in NLLoc implementation when location coordinates are
# large compared to the covariances.
o.longitude = x
try:
o.longitude_errors.uncertainty = kilometer2degrees(sqrt(covariance_xx))
except ValueError:
if covariance_xx < 0:
msg = ("Negative value in XX value of covariance matrix, not "
"setting longitude error (epicentral uncertainties will "
"still be set in origin uncertainty).")
warnings.warn(msg)
else:
raise
示例4: __toOrigin
# 需要导入模块: from obspy.core.event import Origin [as 别名]
# 或者: from obspy.core.event.Origin import origin_uncertainty [as 别名]
def __toOrigin(parser, origin_el):
"""
Parses a given origin etree element.
:type parser: :class:`~obspy.core.util.xmlwrapper.XMLParser`
:param parser: Open XMLParser object.
:type origin_el: etree.element
:param origin_el: origin element to be parsed.
:return: A ObsPy :class:`~obspy.core.event.Origin` object.
"""
origin = Origin()
# I guess setting the program used as the method id is fine.
origin.method_id = parser.xpath2obj('program', origin_el)
# Standard parameters.
origin.time, origin.time_errors = \
__toTimeQuantity(parser, origin_el, "time")
origin.latitude, origin.latitude_errors = \
__toFloatQuantity(parser, origin_el, "latitude")
origin.longitude, origin.longitude_errors = \
__toFloatQuantity(parser, origin_el, "longitude")
origin.depth, origin.depth_errors = \
__toFloatQuantity(parser, origin_el, "depth")
# Figure out the depth type.
depth_type = parser.xpath2obj("depth_type", origin_el, str)
# Map Seishub specific depth type to the QuakeML depth type.
if depth_type == "from location program":
depth_type == "from location"
origin.depth_type = "from location"
# Earth model.
origin.earth_model_id = parser.xpath2obj("earth_mod", origin_el, str)
# Parse th origin uncertainty. Rather verbose but should cover all cases.
pref_desc = parser.xpath2obj("originUncertainty/preferredDescription",
origin_el, str)
hor_uncert = parser.xpath2obj("originUncertainty/horizontalUncertainty",
origin_el, float)
min_hor_uncert = parser.xpath2obj(\
"originUncertainty/minHorizontalUncertainty", origin_el, float)
max_hor_uncert = parser.xpath2obj(\
"originUncertainty/maxHorizontalUncertainty", origin_el, float)
azi_max_hor_uncert = parser.xpath2obj(\
"originUncertainty/azimuthMaxHorizontalUncertainty", origin_el, float)
origin_uncert = {}
if pref_desc:
origin_uncert["preferred_description"] = pref_desc
if hor_uncert:
origin_uncert["horizontal_uncertainty"] = hor_uncert
if min_hor_uncert:
origin_uncert["min_horizontal_uncertainty"] = min_hor_uncert
if max_hor_uncert:
origin_uncert["max_horizontal_uncertainty"] = max_hor_uncert
if azi_max_hor_uncert:
origin_uncert["azimuth_max_horizontal_uncertainty"] = \
azi_max_hor_uncert
if origin_uncert:
origin.origin_uncertainty = origin_uncert
# Parse the OriginQuality if applicable.
if not origin_el.xpath("originQuality"):
return origin
origin_quality_el = origin_el.xpath("originQuality")[0]
origin.quality = OriginQuality()
origin.quality.associated_phase_count = \
parser.xpath2obj("associatedPhaseCount", origin_quality_el, int)
# QuakeML does apparently not distinguish between P and S wave phase
# count. Some Seishub event files do.
p_phase_count = parser.xpath2obj("P_usedPhaseCount", origin_quality_el,
int)
s_phase_count = parser.xpath2obj("S_usedPhaseCount", origin_quality_el,
int)
# Use both in case they are set.
if p_phase_count and s_phase_count:
phase_count = p_phase_count + s_phase_count
# Also add two Seishub element file specific elements.
origin.quality.p_used_phase_count = p_phase_count
origin.quality.s_used_phase_count = s_phase_count
# Otherwise the total usedPhaseCount should be specified.
else:
phase_count = parser.xpath2obj("usedPhaseCount",
origin_quality_el, int)
origin.quality.used_phase_count = phase_count
origin.quality.associated_station_count = \
parser.xpath2obj("associatedStationCount", origin_quality_el, int)
origin.quality.used_station_count = \
parser.xpath2obj("usedStationCount", origin_quality_el, int)
origin.quality.depth_phase_count = \
parser.xpath2obj("depthPhaseCount", origin_quality_el, int)
origin.quality.standard_error = \
parser.xpath2obj("standardError", origin_quality_el, float)
origin.quality.azimuthal_gap = \
parser.xpath2obj("azimuthalGap", origin_quality_el, float)
origin.quality.secondary_azimuthal_gap = \
parser.xpath2obj("secondaryAzimuthalGap", origin_quality_el, float)
#.........这里部分代码省略.........
示例5: read_nlloc_hyp
# 需要导入模块: from obspy.core.event import Origin [as 别名]
# 或者: from obspy.core.event.Origin import origin_uncertainty [as 别名]
#.........这里部分代码省略.........
line = lines["STATISTICS"]
covariance_XX = float(line.split()[7])
covariance_YY = float(line.split()[13])
covariance_ZZ = float(line.split()[17])
stats_info_string = str(
"Note: Depth/Latitude/Longitude errors are calculated from covariance "
"matrix as 1D marginal (Lon/Lat errors as great circle degrees) "
"while OriginUncertainty min/max horizontal errors are calculated "
"from 2D error ellipsoid and are therefore seemingly higher compared "
"to 1D errors. Error estimates can be reconstructed from the "
"following original NonLinLoc error statistics line:\nSTATISTICS " +
lines["STATISTICS"])
# goto location quality info line
line = lines["QML_OriginQuality"].split()
(assoc_phase_count, used_phase_count, assoc_station_count,
used_station_count, depth_phase_count) = map(int, line[1:11:2])
stderr, az_gap, sec_az_gap = map(float, line[11:17:2])
gt_level = line[17]
min_dist, max_dist, med_dist = map(float, line[19:25:2])
# goto location quality info line
line = lines["QML_OriginUncertainty"]
hor_unc, min_hor_unc, max_hor_unc, hor_unc_azim = \
map(float, line.split()[1:9:2])
# assign origin info
event = Event()
cat = Catalog(events=[event])
o = Origin()
event.origins = [o]
o.origin_uncertainty = OriginUncertainty()
o.quality = OriginQuality()
ou = o.origin_uncertainty
oq = o.quality
o.comments.append(Comment(text=stats_info_string))
cat.creation_info.creation_time = UTCDateTime()
cat.creation_info.version = "ObsPy %s" % __version__
event.creation_info = CreationInfo(creation_time=creation_time,
version=version)
event.creation_info.version = version
o.creation_info = CreationInfo(creation_time=creation_time,
version=version)
# negative values can appear on diagonal of covariance matrix due to a
# precision problem in NLLoc implementation when location coordinates are
# large compared to the covariances.
o.longitude = x
try:
o.longitude_errors.uncertainty = kilometer2degrees(sqrt(covariance_XX))
except ValueError:
if covariance_XX < 0:
msg = ("Negative value in XX value of covariance matrix, not "
"setting longitude error (epicentral uncertainties will "
"still be set in origin uncertainty).")
warnings.warn(msg)
else:
raise
o.latitude = y
try:
o.latitude_errors.uncertainty = kilometer2degrees(sqrt(covariance_YY))
except ValueError:
if covariance_YY < 0:
示例6: __toOrigin
# 需要导入模块: from obspy.core.event import Origin [as 别名]
# 或者: from obspy.core.event.Origin import origin_uncertainty [as 别名]
def __toOrigin(parser, origin_el):
"""
Parses a given origin etree element.
:type parser: :class:`~obspy.core.util.xmlwrapper.XMLParser`
:param parser: Open XMLParser object.
:type origin_el: etree.element
:param origin_el: origin element to be parsed.
:return: A ObsPy :class:`~obspy.core.event.Origin` object.
"""
global CURRENT_TYPE
origin = Origin()
origin.resource_id = ResourceIdentifier(prefix="/".join([RESOURCE_ROOT, "origin"]))
# I guess setting the program used as the method id is fine.
origin.method_id = "%s/location_method/%s/1" % (RESOURCE_ROOT,
parser.xpath2obj('program', origin_el))
if str(origin.method_id).lower().endswith("none"):
origin.method_id = None
# Standard parameters.
origin.time, origin.time_errors = \
__toTimeQuantity(parser, origin_el, "time")
origin.latitude, origin_latitude_error = \
__toFloatQuantity(parser, origin_el, "latitude")
origin.longitude, origin_longitude_error = \
__toFloatQuantity(parser, origin_el, "longitude")
origin.depth, origin.depth_errors = \
__toFloatQuantity(parser, origin_el, "depth")
if origin_longitude_error:
origin_longitude_error = origin_longitude_error["uncertainty"]
if origin_latitude_error:
origin_latitude_error = origin_latitude_error["uncertainty"]
# Figure out the depth type.
depth_type = parser.xpath2obj("depth_type", origin_el)
# Map Seishub specific depth type to the QuakeML depth type.
if depth_type == "from location program":
depth_type = "from location"
if depth_type is not None:
origin.depth_type = depth_type
# XXX: CHECK DEPTH ORIENTATION!!
if CURRENT_TYPE == "seiscomp3":
origin.depth *= 1000
if origin.depth_errors.uncertainty:
origin.depth_errors.uncertainty *= 1000
else:
# Convert to m.
origin.depth *= -1000
if origin.depth_errors.uncertainty:
origin.depth_errors.uncertainty *= 1000
# Earth model.
earth_mod = parser.xpath2obj('earth_mod', origin_el, str)
if earth_mod:
earth_mod = earth_mod.split()
earth_mod = ",".join(earth_mod)
origin.earth_model_id = "%s/earth_model/%s/1" % (RESOURCE_ROOT,
earth_mod)
if (origin_latitude_error is None or origin_longitude_error is None) and \
CURRENT_TYPE not in ["seiscomp3", "toni"]:
print "AAAAAAAAAAAAA"
raise Exception
if origin_latitude_error and origin_latitude_error:
if CURRENT_TYPE in ["baynet", "obspyck"]:
uncert = OriginUncertainty()
if origin_latitude_error > origin_longitude_error:
uncert.azimuth_max_horizontal_uncertainty = 0
else:
uncert.azimuth_max_horizontal_uncertainty = 90
uncert.min_horizontal_uncertainty, \
uncert.max_horizontal_uncertainty = \
sorted([origin_longitude_error, origin_latitude_error])
uncert.min_horizontal_uncertainty *= 1000.0
uncert.max_horizontal_uncertainty *= 1000.0
uncert.preferred_description = "uncertainty ellipse"
origin.origin_uncertainty = uncert
elif CURRENT_TYPE == "earthworm":
uncert = OriginUncertainty()
uncert.horizontal_uncertainty = origin_latitude_error
uncert.horizontal_uncertainty *= 1000.0
uncert.preferred_description = "horizontal uncertainty"
origin.origin_uncertainty = uncert
elif CURRENT_TYPE in ["seiscomp3", "toni"]:
pass
else:
raise Exception
# Parse the OriginQuality if applicable.
if not origin_el.xpath("originQuality"):
return origin
origin_quality_el = origin_el.xpath("originQuality")[0]
#.........这里部分代码省略.........
示例7: _map_join2origin
# 需要导入模块: from obspy.core.event import Origin [as 别名]
# 或者: from obspy.core.event.Origin import origin_uncertainty [as 别名]
def _map_join2origin(self, db):
"""
Return an Origin instance from an dict of CSS key/values
Inputs
======
db : dict of key/values of CSS fields related to the origin (see Join)
Returns
=======
obspy.core.event.Origin
Notes
=====
Any object that supports the dict 'get' method can be passed as
input, e.g. OrderedDict, custom classes, etc.
Join
----
origin <- origerr (outer)
"""
#-- Basic location ------------------------------------------
origin = Origin()
origin.latitude = db.get('lat')
origin.longitude = db.get('lon')
origin.depth = _km2m(db.get('depth'))
origin.time = _utc(db.get('time'))
origin.extra = {}
#-- Quality -------------------------------------------------
quality = OriginQuality(
associated_phase_count = db.get('nass'),
used_phase_count = db.get('ndef'),
standard_error = db.get('sdobs'),
)
origin.quality = quality
#-- Solution Uncertainties ----------------------------------
# in CSS the ellipse is projected onto the horizontal plane
# using the covariance matrix
uncertainty = OriginUncertainty()
a = _km2m(db.get('smajax'))
b = _km2m(db.get('sminax'))
s = db.get('strike')
dep_u = _km2m(db.get('sdepth'))
time_u = db.get('stime')
uncertainty.max_horizontal_uncertainty = a
uncertainty.min_horizontal_uncertainty = b
uncertainty.azimuth_max_horizontal_uncertainty = s
uncertainty.horizontal_uncertainty = a
uncertainty.preferred_description = "horizontal uncertainty"
if db.get('conf') is not None:
uncertainty.confidence_level = db.get('conf') * 100.
if uncertainty.horizontal_uncertainty is not None:
origin.origin_uncertainty = uncertainty
#-- Parameter Uncertainties ---------------------------------
if all([a, b, s]):
n, e = _get_NE_on_ellipse(a, b, s)
lat_u = _m2deg_lat(n)
lon_u = _m2deg_lon(e, lat=origin.latitude)
origin.latitude_errors = {'uncertainty': lat_u}
origin.longitude_errors = {'uncertainty': lon_u}
if dep_u:
origin.depth_errors = {'uncertainty': dep_u}
if time_u:
origin.time_errors = {'uncertainty': time_u}
#-- Analyst-determined Status -------------------------------
posted_author = _str(db.get('auth'))
mode, status = self.get_event_status(posted_author)
origin.evaluation_mode = mode
origin.evaluation_status = status
# Save etype per origin due to schema differences...
css_etype = _str(db.get('etype'))
# Compatible with future patch rename "_namespace" -> "namespace"
origin.extra['etype'] = {
'value': css_etype,
'namespace': CSS_NAMESPACE
}
origin.creation_info = CreationInfo(
creation_time = _utc(db.get('lddate')),
agency_id = self.agency,
version = db.get('orid'),
author = posted_author,
)
origin.resource_id = self._rid(origin)
return origin