当前位置: 首页>>代码示例>>Python>>正文


Python AttribDict.source_body_wave_magnitude方法代码示例

本文整理汇总了Python中obspy.core.AttribDict.source_body_wave_magnitude方法的典型用法代码示例。如果您正苦于以下问题:Python AttribDict.source_body_wave_magnitude方法的具体用法?Python AttribDict.source_body_wave_magnitude怎么用?Python AttribDict.source_body_wave_magnitude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在obspy.core.AttribDict的用法示例。


在下文中一共展示了AttribDict.source_body_wave_magnitude方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: read_xh_0_98

# 需要导入模块: from obspy.core import AttribDict [as 别名]
# 或者: from obspy.core.AttribDict import source_body_wave_magnitude [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"]
#.........这里部分代码省略.........
开发者ID:krischer,项目名称:obspy_xh,代码行数:103,代码来源:core.py


注:本文中的obspy.core.AttribDict.source_body_wave_magnitude方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。