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


Python AttribDict.sensitivity_value方法代码示例

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


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

示例1: obspy_nsc2sacpz

# 需要导入模块: from obspy.core import AttribDict [as 别名]
# 或者: from obspy.core.AttribDict import sensitivity_value [as 别名]
def obspy_nsc2sacpz(net, sta, cha, input_unit=None):
    """
    Convert an individual ObsPy inventory channel to a sacpz object
    """

    if input_unit is not None:
        input_unit = rectify_unit(input_unit)

    pz = AttribDict(
        net = net.code,
        sta = sta.code,
        loc = cha.location_code,
        cha = cha.code )


    pz.depth = cha.depth
    pz.start_date = str(cha.start_date)[:19]

#   if cha.end_date is not None:
#       if cha.end_date.timestamp > 1<<31:
#           cha.end_date = None
    if cha.end_date is not None:
        pz["end_date"] = str(cha.end_date)[:19]
    else:
        pz["end_date"] = "2599-12-31T23:59:59"
#   pz["created"] = str(inventory.created)[:19]


    pz.description = cha.description
    pz.dip = cha.dip
    pz.azimuth = cha.azimuth
    pz.fsamp = cha.sample_rate
    pz.lat = cha.latitude
    pz.lon = cha.longitude
    pz.ele = cha.elevation

    pz_stage = None
    for stage in cha.response.response_stages:
        if type(stage) == PolesZerosResponseStage:
            if not stage.pz_transfer_function_type.upper().startswith("LAPLACE"):
                continue
            if len(stage.poles)>0 or len(stage.zeros)>0:
#               if pz_stage is None:
                    pz_stage = stage
#               else:
#                   sys.stderr.write("%s: more than one PZ stage found - skipping this one\n" % nslc(pz))
    if not pz_stage:
        return
    pz.a0  = pz_stage.normalization_factor

    if not cha.sensor.manufacturer and not cha.sensor.model:
        # sloppy XML produced by the IRIS fdsnws
        pz.sensor_type = cha.sensor.type
    else:
        # properly populated XML
        pz.sensor_type = "%s %s" % (cha.sensor.manufacturer, cha.sensor.model)
    pz.sni = cha.response.instrument_sensitivity.input_units.upper()
    pz.sno = cha.response.instrument_sensitivity.output_units.upper()
    if not pz.sno or pz.sno == "None":
        sys.stderr.write("Warning: %s: setting empty OutputUnits to 'COUNTS'\n" % nslc(pz))
        pz.sno = "COUNTS"
    pz.sensitivity_value = cha.response.instrument_sensitivity.value
    pz.sensitivity_frequency = cha.response.instrument_sensitivity.frequency
    pz.sgn = pz_stage.stage_gain
    pz.sgf = pz_stage.stage_gain_frequency
    pz.inu = "%s / %s" % (pz_stage.output_units, pz_stage.input_units)
    if pz_stage.pz_transfer_function_type == "LAPLACE (RADIANS/SECOND)":
        factor = 1
    elif pz_stage.pz_transfer_function_type == "LAPLACE (HERTZ)":
        factor = 6.283185307179586
    else:
        raise TypeError, "%s: unknown transfer function type '%s'\n" % (nslc(pz),pz_stage.pz_transfer_function_type)

    if input_unit is not None:
        if input_unit != pz_stage.input_units:
            dnz = valid_units[pz["sni"]]-valid_units[input_unit]
            if dnz == 0:
                pass # nothing to do
            elif 0 < dnz <=2:
                # add one or two zeros
                pz_stage.zeros.extend(dnz*[0.])
            else:
                raise NotImplementedError, "removal of zeros not implemented"
        pz.snj = input_unit
    else:
        pz.snj = pz.sni

    zeros = []
    poles = []

    sacpz = "ZEROS   %d\n" % len(pz_stage.zeros)
    for zero in pz_stage.zeros:
        zero = complex(zero)*factor
        pz.a0 /= factor
        sacpz += "        %+.6e %+.6e\n" % (zero.real, zero.imag)
        zeros.append(zero)
    sacpz += "POLES   %d\n" % len(pz_stage.poles)
    for pole in pz_stage.poles:
        pole = complex(pole)*factor
        pz.a0 *= factor
#.........这里部分代码省略.........
开发者ID:jsaul,项目名称:fdsnws,代码行数:103,代码来源:paz.py


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