本文整理汇总了Python中obspy.core.event.Origin.epicenter_fixed方法的典型用法代码示例。如果您正苦于以下问题:Python Origin.epicenter_fixed方法的具体用法?Python Origin.epicenter_fixed怎么用?Python Origin.epicenter_fixed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obspy.core.event.Origin
的用法示例。
在下文中一共展示了Origin.epicenter_fixed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _parse_record_dp
# 需要导入模块: from obspy.core.event import Origin [as 别名]
# 或者: from obspy.core.event.Origin import epicenter_fixed [as 别名]
def _parse_record_dp(self, line, event):
"""
Parses the 'source parameter data - primary' record Dp
"""
source_contributor = line[2:6].strip()
computation_type = line[6]
exponent = self._int_zero(line[7])
scale = math.pow(10, exponent)
centroid_origin_time = line[8:14] + '.' + line[14]
orig_time_stderr = line[15:17]
if orig_time_stderr == 'FX':
orig_time_stderr = 'Fixed'
else:
orig_time_stderr = \
self._float_with_format(orig_time_stderr, '2.1', scale)
centroid_latitude = self._float_with_format(line[17:21], '4.2')
lat_type = line[21]
if centroid_latitude is not None:
centroid_latitude *= self._coordinate_sign(lat_type)
lat_stderr = line[22:25]
if lat_stderr == 'FX':
lat_stderr = 'Fixed'
else:
lat_stderr = self._float_with_format(lat_stderr, '3.2', scale)
centroid_longitude = self._float_with_format(line[25:30], '5.2')
lon_type = line[30]
if centroid_longitude is not None:
centroid_longitude *= self._coordinate_sign(lon_type)
lon_stderr = line[31:34]
if lon_stderr == 'FX':
lon_stderr = 'Fixed'
else:
lon_stderr = self._float_with_format(lon_stderr, '3.2', scale)
centroid_depth = self._float_with_format(line[34:38], '4.1')
depth_stderr = line[38:40]
if depth_stderr == 'FX' or depth_stderr == 'BD':
depth_stderr = 'Fixed'
else:
depth_stderr = self._float_with_format(depth_stderr, '2.1', scale)
station_number = self._int_zero(line[40:43])
component_number = self._int_zero(line[43:46])
station_number2 = self._int_zero(line[46:48])
component_number2 = self._int_zero(line[48:51])
# unused: half_duration = self._float_with_format(line[51:54], '3.1')
moment = self._float_with_format(line[54:56], '2.1')
moment_stderr = self._float_with_format(line[56:58], '2.1')
moment_exponent = self._int(line[58:60])
if (moment is not None) and (moment_exponent is not None):
moment *= math.pow(10, moment_exponent)
if (moment_stderr is not None) and (moment_exponent is not None):
moment_stderr *= math.pow(10, moment_exponent)
evid = event.resource_id.id.split('/')[-1]
# Create a new origin only if centroid time is defined:
origin = None
if centroid_origin_time.strip() != '.':
origin = Origin()
res_id = '/'.join((res_id_prefix, 'origin',
evid, source_contributor.lower(),
'mw' + computation_type.lower()))
origin.resource_id = ResourceIdentifier(id=res_id)
origin.creation_info = \
CreationInfo(agency_id=source_contributor)
date = event.origins[0].time.strftime('%Y%m%d')
origin.time = UTCDateTime(date + centroid_origin_time)
# Check if centroid time is on the next day:
if origin.time < event.origins[0].time:
origin.time += timedelta(days=1)
self._store_uncertainty(origin.time_errors, orig_time_stderr)
origin.latitude = centroid_latitude
origin.longitude = centroid_longitude
origin.depth = centroid_depth * 1000
if lat_stderr == 'Fixed' and lon_stderr == 'Fixed':
origin.epicenter_fixed = True
else:
self._store_uncertainty(origin.latitude_errors,
self._lat_err_to_deg(lat_stderr))
self._store_uncertainty(origin.longitude_errors,
self._lon_err_to_deg(lon_stderr,
origin.latitude))
if depth_stderr == 'Fixed':
origin.depth_type = 'operator assigned'
else:
origin.depth_type = 'from location'
self._store_uncertainty(origin.depth_errors,
depth_stderr, scale=1000)
quality = OriginQuality()
quality.used_station_count = \
station_number + station_number2
quality.used_phase_count = \
component_number + component_number2
origin.quality = quality
origin.origin_type = 'centroid'
event.origins.append(origin)
focal_mechanism = FocalMechanism()
res_id = '/'.join((res_id_prefix, 'focalmechanism',
evid, source_contributor.lower(),
'mw' + computation_type.lower()))
focal_mechanism.resource_id = ResourceIdentifier(id=res_id)
focal_mechanism.creation_info = \
#.........这里部分代码省略.........
示例2: _parse_first_line_origin
# 需要导入模块: from obspy.core.event import Origin [as 别名]
# 或者: from obspy.core.event.Origin import epicenter_fixed [as 别名]
def _parse_first_line_origin(self, line, event, magnitudes):
"""
Parse the first line of origin data.
:type line: str
:param line: Line to parse.
:type event: :class:`~obspy.core.event.event.Event`
:param event: Event of the origin.
:type magnitudes: list of
:class:`~obspy.core.event.magnitude.Magnitude`
:param magnitudes: Store magnitudes in a list to keep
their positions.
:rtype: :class:`~obspy.core.event.origin.Origin`,
:class:`~obspy.core.event.resourceid.ResourceIdentifier`
:returns: Parsed origin or None, resource identifier of the
origin.
"""
magnitude_types = []
magnitude_values = []
magnitude_station_counts = []
fields = self.fields['line_1']
time_origin = line[fields['time']].strip()
time_fixed_flag = line[fields['time_fixf']].strip()
latitude = line[fields['lat']].strip()
longitude = line[fields['lon']].strip()
epicenter_fixed_flag = line[fields['epicenter_fixf']].strip()
depth = line[fields['depth']].strip()
depth_fixed_flag = line[fields['depth_fixf']].strip()
phase_count = line[fields['n_def']].strip()
station_count = line[fields['n_sta']].strip()
azimuthal_gap = line[fields['gap']].strip()
magnitude_types.append(line[fields['mag_type_1']].strip())
magnitude_values.append(line[fields['mag_1']].strip())
magnitude_station_counts.append(line[fields['mag_n_sta_1']].strip())
magnitude_types.append(line[fields['mag_type_2']].strip())
magnitude_values.append(line[fields['mag_2']].strip())
magnitude_station_counts.append(line[fields['mag_n_sta_2']].strip())
magnitude_types.append(line[fields['mag_type_3']].strip())
magnitude_values.append(line[fields['mag_3']].strip())
magnitude_station_counts.append(line[fields['mag_n_sta_3']].strip())
author = line[fields['author']].strip()
origin_id = line[fields['id']].strip()
origin = Origin()
origin.quality = OriginQuality()
try:
origin.time = UTCDateTime(time_origin.replace('/', '-'))
origin.latitude = float(latitude)
origin.longitude = float(longitude)
except (TypeError, ValueError):
self._warn('Missing origin data, skipping event')
return None, None
origin.time_fixed = time_fixed_flag.lower() == 'f'
origin.epicenter_fixed = epicenter_fixed_flag.lower() == 'f'
try:
# Convert value from km to m
origin.depth = float(depth) * 1000
except ValueError:
pass
try:
origin.depth_type = DEPTH_TYPES[depth_fixed_flag]
except KeyError:
origin.depth_type = OriginDepthType('from location')
try:
origin.quality.used_phase_count = int(phase_count)
origin.quality.associated_phase_count = int(phase_count)
except ValueError:
pass
try:
origin.quality.used_station_count = int(station_count)
origin.quality.associated_station_count = int(station_count)
except ValueError:
pass
try:
origin.quality.azimuthal_gap = float(azimuthal_gap)
except ValueError:
pass
self.author = author
origin.creation_info = self._get_creation_info()
public_id = "origin/%s" % origin_id
origin_res_id = self._get_res_id(public_id)
for i in range(3):
try:
magnitude = Magnitude()
magnitude.creation_info = self._get_creation_info()
magnitude.magnitude_type = magnitude_types[i]
magnitude.mag = float(magnitude_values[i])
magnitude.station_count = int(magnitude_station_counts[i])
magnitude.origin_id = origin_res_id
magnitudes.append(magnitude)
event.magnitudes.append(magnitude)
except ValueError:
#.........这里部分代码省略.........
示例3: _parseRecordDp
# 需要导入模块: from obspy.core.event import Origin [as 别名]
# 或者: from obspy.core.event.Origin import epicenter_fixed [as 别名]
def _parseRecordDp(self, line, event):
"""
Parses the 'source parameter data - primary' record Dp
"""
source_contributor = line[2:6].strip()
computation_type = line[6]
exponent = self._intZero(line[7])
scale = math.pow(10, exponent)
centroid_origin_time = line[8:14] + "." + line[14]
orig_time_stderr = line[15:17]
if orig_time_stderr == "FX":
orig_time_stderr = "Fixed"
else:
orig_time_stderr = self._floatWithFormat(orig_time_stderr, "2.1", scale)
centroid_latitude = self._floatWithFormat(line[17:21], "4.2")
lat_type = line[21]
if centroid_latitude is not None:
centroid_latitude *= self._coordinateSign(lat_type)
lat_stderr = line[22:25]
if lat_stderr == "FX":
lat_stderr = "Fixed"
else:
lat_stderr = self._floatWithFormat(lat_stderr, "3.2", scale)
centroid_longitude = self._floatWithFormat(line[25:30], "5.2")
lon_type = line[30]
if centroid_longitude is not None:
centroid_longitude *= self._coordinateSign(lon_type)
lon_stderr = line[31:34]
if lon_stderr == "FX":
lon_stderr = "Fixed"
else:
lon_stderr = self._floatWithFormat(lon_stderr, "3.2", scale)
centroid_depth = self._floatWithFormat(line[34:38], "4.1")
depth_stderr = line[38:40]
if depth_stderr == "FX" or depth_stderr == "BD":
depth_stderr = "Fixed"
else:
depth_stderr = self._floatWithFormat(depth_stderr, "2.1", scale)
station_number = self._intZero(line[40:43])
component_number = self._intZero(line[43:46])
station_number2 = self._intZero(line[46:48])
component_number2 = self._intZero(line[48:51])
# unused: half_duration = self._floatWithFormat(line[51:54], '3.1')
moment = self._floatWithFormat(line[54:56], "2.1")
moment_stderr = self._floatWithFormat(line[56:58], "2.1")
moment_exponent = self._int(line[58:60])
if (moment is not None) and (moment_exponent is not None):
moment *= math.pow(10, moment_exponent)
if (moment_stderr is not None) and (moment_exponent is not None):
moment_stderr *= math.pow(10, moment_exponent)
evid = event.resource_id.id.split("/")[-1]
# Create a new origin only if centroid time is defined:
origin = None
if centroid_origin_time.strip() != ".":
origin = Origin()
res_id = "/".join(
(res_id_prefix, "origin", evid, source_contributor.lower(), "mw" + computation_type.lower())
)
origin.resource_id = ResourceIdentifier(id=res_id)
origin.creation_info = CreationInfo(agency_id=source_contributor)
date = event.origins[0].time.strftime("%Y%m%d")
origin.time = UTCDateTime(date + centroid_origin_time)
# Check if centroid time is on the next day:
if origin.time < event.origins[0].time:
origin.time += timedelta(days=1)
self._storeUncertainty(origin.time_errors, orig_time_stderr)
origin.latitude = centroid_latitude
origin.longitude = centroid_longitude
origin.depth = centroid_depth * 1000
if lat_stderr == "Fixed" and lon_stderr == "Fixed":
origin.epicenter_fixed = True
else:
self._storeUncertainty(origin.latitude_errors, self._latErrToDeg(lat_stderr))
self._storeUncertainty(origin.longitude_errors, self._lonErrToDeg(lon_stderr, origin.latitude))
if depth_stderr == "Fixed":
origin.depth_type = "operator assigned"
else:
origin.depth_type = "from location"
self._storeUncertainty(origin.depth_errors, depth_stderr, scale=1000)
quality = OriginQuality()
quality.used_station_count = station_number + station_number2
quality.used_phase_count = component_number + component_number2
origin.quality = quality
origin.type = "centroid"
event.origins.append(origin)
focal_mechanism = FocalMechanism()
res_id = "/".join(
(res_id_prefix, "focalmechanism", evid, source_contributor.lower(), "mw" + computation_type.lower())
)
focal_mechanism.resource_id = ResourceIdentifier(id=res_id)
focal_mechanism.creation_info = CreationInfo(agency_id=source_contributor)
moment_tensor = MomentTensor()
if origin is not None:
moment_tensor.derived_origin_id = origin.resource_id
else:
# this is required for QuakeML validation:
res_id = "/".join((res_id_prefix, "no-origin"))
moment_tensor.derived_origin_id = ResourceIdentifier(id=res_id)
for mag in event.magnitudes:
#.........这里部分代码省略.........