本文整理汇总了Python中obspy.core.AttribDict.source_latitude方法的典型用法代码示例。如果您正苦于以下问题:Python AttribDict.source_latitude方法的具体用法?Python AttribDict.source_latitude怎么用?Python AttribDict.source_latitude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obspy.core.AttribDict
的用法示例。
在下文中一共展示了AttribDict.source_latitude方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _read_SES3D
# 需要导入模块: from obspy.core import AttribDict [as 别名]
# 或者: from obspy.core.AttribDict import source_latitude [as 别名]
def _read_SES3D(fh, headonly=False):
"""
Internal SES3D parsing routine.
"""
# Import here to avoid circular imports.
from obspy.core import AttribDict, Trace, Stream
# Read the header.
component = fh.readline().split()[0].lower()
npts = int(fh.readline().split()[-1])
delta = float(fh.readline().split()[-1])
# Skip receiver location line.
fh.readline()
rec_loc = fh.readline().split()
rec_x, rec_y, rec_z = map(float, [rec_loc[1], rec_loc[3], rec_loc[5]])
# Skip the source location line.
fh.readline()
src_loc = fh.readline().split()
src_x, src_y, src_z = map(float, [src_loc[1], src_loc[3], src_loc[5]])
# Read the data.
if headonly is False:
data = np.array(map(float, fh.readlines()),
dtype="float32")
else:
data = np.array([])
ses3d = AttribDict()
ses3d.receiver_latitude = rotations.colat2lat(rec_x)
ses3d.receiver_longitude = rec_y
ses3d.receiver_depth_in_m = rec_z
ses3d.source_latitude = rotations.colat2lat(src_x)
ses3d.source_longitude = src_y
ses3d.source_depth_in_m = src_z
header = {
"delta": delta,
"channel": COMPONENT_MAP[component],
"ses3d": ses3d,
"npts": npts
}
# Setup Obspy Stream/Trace structure.
tr = Trace(data=data, header=header)
# Small check.
if headonly is False and npts != tr.stats.npts:
msg = "The sample count specified in the header does not match " + \
"the actual data count."
warnings.warn(msg)
return Stream(traces=[tr])
示例2: read_xh_0_98
# 需要导入模块: from obspy.core import AttribDict [as 别名]
# 或者: from obspy.core.AttribDict import source_latitude [as 别名]
def read_xh_0_98(filename, byte_order):
"""
Reads the given file to an ObsPy Stream object for the XH format version
0.98.
:param filename: The file to read.
:type filename: str
"""
st = obspy.Stream()
with io.open(filename, "rb") as fh:
while True:
header = fh.read(1024)
if len(header) < 1024:
break
header = np.frombuffer(
header, dtype=header_0_98.get_header_dtype(byte_order))
header = _record_array_to_dict(header)
# Convert both times.
ref_origin_time = obspy.UTCDateTime(
header["ot_year"],
header["ot_month"],
header["ot_day"],
header["ot_hour"],
header["ot_minute"],
header["ot_second"])
starttime = obspy.UTCDateTime(
header["tstart_year"],
header["tstart_month"],
header["tstart_day"],
header["tstart_hour"],
header["tstart_minute"],
header["tstart_second"])
data = np.frombuffer(fh.read(header["ndata"] * 4),
dtype=byte_order + "f4")
tr = obspy.Trace(data=data)
tr.stats.network = header["netw"]
tr.stats.station = header["stnm"]
tr.stats.channel = header_0_98.CHANNEL_MAP[header["chid"]]
tr.stats.location = header_0_98.LOCATION_MAP[header["locc"]]
# The name 'delta' for the sampling rate is a bit odd but it
# appears to be interpreted correctly here.
tr.stats.sampling_rate = header["delta"]
tr.stats.starttime = starttime
# The reason why this is here is a bit complicated and has to do
# with ObsPy interna. It can be anywhere if one uses a stable ObsPy
# version or does not jump between ObsPy versions which most users
# don't do.
from obspy.station.response import (InstrumentSensitivity,
Response,
PolesZerosResponseStage)
# Build the instrument response.
# XXX: The instrument response definition in XH is very basic and
# so the definition is not complete and might not work with ObsPy.
response = Response()
sensitivity = InstrumentSensitivity(
# Random choice, but not really used by anything so it should
# be ok.
frequency=1.0,
# Assume the DS field is the total sensitivity.
value=header["DS"],
# This is true for most commonly used instruments.
input_units="M/S",
input_units_description="Velocity in Meters Per Second",
output_units="COUNTS",
output_units_description="Digital Counts")
paz = PolesZerosResponseStage(
stage_sequence_number=1,
# We assume DS is somehow the total sensitivity. As we have
# only one stage we also make it he gain of this stage.
stage_gain_frequency=1.0,
stage_gain=header["DS"],
input_units="M/S",
output_units="V",
pz_transfer_function_type="LAPLACE (RADIANS/SECOND)",
# Arbitrary frequency. Usually 1 for most instruments. Must be
# correct to assure everything works as expected!
normalization_frequency=1.0,
normalization_factor=header["A0"],
zeros=[CustomComplex(_i) for _i in header["zero"]],
poles=[CustomComplex(_i) for _i in header["pole"]])
response.instrument_sensitivity = sensitivity
response.response_stages.append(paz)
# Attach to trace object.
tr.stats.response = response
# Assemble XH specific header.
xh_header = AttribDict()
xh_header.reference_time = ref_origin_time
xh_header.source_latitude = header["elat"]
xh_header.source_longitude = header["elon"]
xh_header.source_depth_in_km = header["edep"]
xh_header.source_body_wave_magnitude = header["Mb"]
xh_header.source_surface_wave_magnitude = header["Ms"]
xh_header.source_moment_magnitude = header["Mw"]
#.........这里部分代码省略.........