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


Python obspy.read方法代码示例

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


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

示例1: read_coal4D

# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read [as 别名]
def read_coal4D(self, fname):
        """
        Reads a binary numpy file containing 4-D coalescence grid output by
        _compute() .

        Parameters
        ----------
        fname : str or pathlib.Path object
            Location of file to be read

        Returns
        -------
        map_4d : array-like
            4-D coalescence grid

        """

        map_4d = np.load(fname)

        return map_4d 
开发者ID:QuakeMigrate,项目名称:QuakeMigrate,代码行数:22,代码来源:quakeio.py

示例2: test_process_obsd

# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read [as 别名]
def test_process_obsd():

    st = testobs.copy()
    inv = deepcopy(teststaxml)
    event = obspy.readEvents(testquakeml)[0]
    origin = event.preferred_origin() or event.origins[0]
    event_lat = origin.latitude
    event_lon = origin.longitude
    event_time = origin.time

    pre_filt = [1/90., 1/60., 1/27.0, 1/22.5]
    t1 = event_time
    t2 = event_time + 6000.0
    st_new = proc.process_stream(
        st, remove_response_flag=True, water_level=60, inventory=inv,
        filter_flag=True, pre_filt=pre_filt,
        starttime=t1, endtime=t2, resample_flag=True,
        sampling_rate=2.0, taper_type="hann",
        taper_percentage=0.05, rotate_flag=True,
        event_latitude=event_lat,
        event_longitude=event_lon)
    bmfile = os.path.join(DATA_DIR, "proc", "IU.KBL.obs.proc.mseed")
    st_compare = obspy.read(bmfile)
    assert compare_stream_kernel(st_new, st_compare) 
开发者ID:computational-seismology,项目名称:pytomo3d,代码行数:26,代码来源:test_process.py

示例3: test_process_synt

# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read [as 别名]
def test_process_synt():
    staxmlfile = os.path.join(DATA_DIR, "stationxml", "IU.KBL.syn.xml")
    inv = obspy.read_inventory(staxmlfile)

    st = testsyn.copy()
    event = obspy.readEvents(testquakeml)[0]
    origin = event.preferred_origin() or event.origins[0]
    event_lat = origin.latitude
    event_lon = origin.longitude
    event_time = origin.time

    pre_filt = [1/90., 1/60., 1/27.0, 1/22.5]
    t1 = event_time
    t2 = event_time + 6000.0
    st_new = proc.process_stream(
        st, remove_response_flag=False, inventory=inv,
        filter_flag=True, pre_filt=pre_filt,
        starttime=t1, endtime=t2, resample_flag=True,
        sampling_rate=2.0, taper_type="hann",
        taper_percentage=0.05, rotate_flag=True,
        event_latitude=event_lat,
        event_longitude=event_lon)
    bmfile = os.path.join(DATA_DIR, "proc", "IU.KBL.syn.proc.mseed")
    st_compare = obspy.read(bmfile)
    assert compare_stream_kernel(st_new, st_compare) 
开发者ID:computational-seismology,项目名称:pytomo3d,代码行数:27,代码来源:test_process.py

示例4: test_update_user_levels

# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read [as 别名]
def test_update_user_levels():
    obs_tr = read(obsfile)[0]
    syn_tr = read(synfile)[0]

    config_file = os.path.join(DATA_DIR, "window", "27_60.BHZ.config.yaml")
    config = wio.load_window_config_yaml(config_file)

    cat = readEvents(quakeml)
    inv = read_inventory(staxml)

    user_module = "pytomo3d.window.tests.user_module_example"
    config = win.update_user_levels(user_module, config, inv, cat,
                                    obs_tr, syn_tr)

    npts = obs_tr.stats.npts
    assert isinstance(config.stalta_waterlevel, np.ndarray)
    assert len(config.stalta_waterlevel) == npts
    assert isinstance(config.tshift_acceptance_level, np.ndarray)
    assert len(config.tshift_acceptance_level) == npts
    assert isinstance(config.dlna_acceptance_level, np.ndarray)
    assert len(config.dlna_acceptance_level) == npts
    assert isinstance(config.cc_acceptance_level, np.ndarray)
    assert len(config.cc_acceptance_level) == npts
    assert isinstance(config.s2n_limit, np.ndarray)
    assert len(config.s2n_limit) == npts 
开发者ID:computational-seismology,项目名称:pytomo3d,代码行数:27,代码来源:test_window.py

示例5: test_window_on_trace

# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read [as 别名]
def test_window_on_trace():
    obs_tr = read(obsfile).select(channel="*R")[0]
    syn_tr = read(synfile).select(channel="*R")[0]

    config_file = os.path.join(DATA_DIR, "window", "27_60.BHZ.config.yaml")
    config = wio.load_window_config_yaml(config_file)

    cat = readEvents(quakeml)
    inv = read_inventory(staxml)

    windows = win.window_on_trace(obs_tr, syn_tr, config, station=inv,
                                  event=cat, _verbose=False,
                                  figure_mode=False)

    assert len(windows) == 5

    winfile_bm = os.path.join(DATA_DIR, "window",
                              "IU.KBL..BHR.window.json")
    with open(winfile_bm) as fh:
        windows_json = json.load(fh)
    for _win, _win_json_bm in zip(windows, windows_json):
        _win_bm = Window._load_from_json_content(_win_json_bm)
        assert _win == _win_bm 
开发者ID:computational-seismology,项目名称:pytomo3d,代码行数:25,代码来源:test_window.py

示例6: test_window_on_trace_with_none_user_levels

# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read [as 别名]
def test_window_on_trace_with_none_user_levels():
    obs_tr = read(obsfile).select(channel="*R")[0]
    syn_tr = read(synfile).select(channel="*R")[0]

    config_file = os.path.join(DATA_DIR, "window", "27_60.BHZ.config.yaml")
    config = wio.load_window_config_yaml(config_file)

    cat = readEvents(quakeml)
    inv = read_inventory(staxml)

    windows = win.window_on_trace(obs_tr, syn_tr, config, station=inv,
                                  event=cat, user_module="None",
                                  _verbose=False, figure_mode=False)

    winfile_bm = os.path.join(DATA_DIR, "window",
                              "IU.KBL..BHR.window.json")
    with open(winfile_bm) as fh:
        windows_json = json.load(fh)
    for _win, _win_json_bm in zip(windows, windows_json):
        _win_bm = Window._load_from_json_content(_win_json_bm)
        assert _win == _win_bm 
开发者ID:computational-seismology,项目名称:pytomo3d,代码行数:23,代码来源:test_window.py

示例7: test_window_on_stream

# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read [as 别名]
def test_window_on_stream():
    obs_tr = read(obsfile)
    syn_tr = read(synfile)

    config_file = os.path.join(DATA_DIR, "window", "27_60.BHZ.config.yaml")
    config = wio.load_window_config_yaml(config_file)
    config_dict = {"Z": config, "R": config, "T": config}

    config_file = os.path.join(DATA_DIR, "window", "27_60.BHZ.config.yaml")
    config = wio.load_window_config_yaml(config_file)

    cat = readEvents(quakeml)
    inv = read_inventory(staxml)

    windows = win.window_on_stream(obs_tr, syn_tr, config_dict, station=inv,
                                   event=cat, _verbose=False,
                                   figure_mode=False)

    assert len(windows) == 3
    nwins = dict((_w, len(windows[_w])) for _w in windows)
    assert nwins == {"IU.KBL..BHR": 5, "IU.KBL..BHZ": 2, "IU.KBL..BHT": 4} 
开发者ID:computational-seismology,项目名称:pytomo3d,代码行数:23,代码来源:test_window.py

示例8: test_window_on_stream_user_levels

# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read [as 别名]
def test_window_on_stream_user_levels():
    obs_tr = read(obsfile)
    syn_tr = read(synfile)

    config_file = os.path.join(DATA_DIR, "window", "27_60.BHZ.config.yaml")
    config = wio.load_window_config_yaml(config_file)
    config_dict = {"Z": config, "R": config, "T": config}

    config_file = os.path.join(DATA_DIR, "window", "27_60.BHZ.config.yaml")
    config = wio.load_window_config_yaml(config_file)

    cat = readEvents(quakeml)
    inv = read_inventory(staxml)

    _mod = "pytomo3d.window.tests.user_module_example"
    user_modules = {"BHZ": _mod, "BHR": _mod, "BHT": _mod}

    windows = win.window_on_stream(obs_tr, syn_tr, config_dict, station=inv,
                                   event=cat, user_modules=user_modules,
                                   _verbose=False,
                                   figure_mode=False)

    assert len(windows) == 3
    nwins = dict((_w, len(windows[_w])) for _w in windows)
    assert nwins == {"IU.KBL..BHR": 5, "IU.KBL..BHZ": 2, "IU.KBL..BHT": 4} 
开发者ID:computational-seismology,项目名称:pytomo3d,代码行数:27,代码来源:test_window.py

示例9: test_plot_window_figure

# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read [as 别名]
def test_plot_window_figure(tmpdir):
    reset_matplotlib()

    obs_tr = read(obsfile).select(channel="*R")[0]
    syn_tr = read(synfile).select(channel="*R")[0]

    config_file = os.path.join(DATA_DIR, "window", "27_60.BHZ.config.yaml")
    config = wio.load_window_config_yaml(config_file)

    cat = readEvents(quakeml)
    inv = read_inventory(staxml)

    ws = WindowSelector(obs_tr, syn_tr, config, event=cat, station=inv)
    windows = ws.select_windows()

    assert len(windows) > 0

    win.plot_window_figure(str(tmpdir), obs_tr.id, ws, True,
                           figure_format="png") 
开发者ID:computational-seismology,项目名称:pytomo3d,代码行数:21,代码来源:test_window.py

示例10: test_stationxml_is_invalid_tag_name

# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read [as 别名]
def test_stationxml_is_invalid_tag_name(tmpdir):
    """
    StationXML is an invalid waveform path.
    """
    filename = os.path.join(tmpdir.strpath, "example.h5")

    data_set = ASDFDataSet(filename)
    st = obspy.read()

    with pytest.raises(ValueError):
        data_set.add_waveforms(st, tag="StationXML")
    with pytest.raises(ValueError):
        data_set.add_waveforms(st, tag="stationxml")

    # Adding with a proper path works just fine.
    data_set.add_waveforms(st, tag="random_waveform") 
开发者ID:SeismicData,项目名称:pyasdf,代码行数:18,代码来源:test_asdf_data_set.py

示例11: test_adding_a_provenance_record

# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read [as 别名]
def test_adding_a_provenance_record(tmpdir):
    """
    Tests adding a provenance record.
    """
    asdf_filename = os.path.join(tmpdir.strpath, "test.h5")
    data_set = ASDFDataSet(asdf_filename)

    filename = os.path.join(data_dir, "example_schematic_processing_chain.xml")

    # Add it as a document.
    doc = prov.read(filename, format="xml")
    data_set.add_provenance_document(doc, name="test_provenance")
    del data_set

    # Read it again.
    data_set = ASDFDataSet(asdf_filename)
    assert data_set.provenance.test_provenance == doc 
开发者ID:SeismicData,项目名称:pyasdf,代码行数:19,代码来源:test_asdf_data_set.py

示例12: test_provenance_dicionary_behaviour

# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read [as 别名]
def test_provenance_dicionary_behaviour(tmpdir):
    asdf_filename = os.path.join(tmpdir.strpath, "test.h5")
    data_set = ASDFDataSet(asdf_filename)

    filename = os.path.join(data_dir, "example_schematic_processing_chain.xml")

    # Add it as a document.
    doc = prov.read(filename, format="xml")
    # Setting via setitem.
    data_set.provenance["test_provenance"] = doc

    data_set.__del__()
    del data_set

    new_data_set = ASDFDataSet(asdf_filename)
    assert new_data_set.provenance.list() == ["test_provenance"]

    assert new_data_set.provenance["test_provenance"] == doc
    assert getattr(new_data_set.provenance, "test_provenance") == doc

    assert list(new_data_set.provenance.keys()) == ["test_provenance"]
    assert list(new_data_set.provenance.values()) == [doc]
    assert list(new_data_set.provenance.items()) == [("test_provenance", doc)] 
开发者ID:SeismicData,项目名称:pyasdf,代码行数:25,代码来源:test_asdf_data_set.py

示例13: test_deleting_provenance_records

# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read [as 别名]
def test_deleting_provenance_records(tmpdir):
    """
    Tests the deletion of provenance records.
    """
    asdf_filename = os.path.join(tmpdir.strpath, "test.h5")
    ds = ASDFDataSet(asdf_filename)

    filename = os.path.join(data_dir, "example_schematic_processing_chain.xml")

    doc = prov.read(filename, format="xml")

    # Delete via attribute access.
    ds.add_provenance_document(doc, name="test_provenance")
    assert ds.provenance.test_provenance
    del ds.provenance.test_provenance
    with pytest.raises(AttributeError):
        ds.provenance.test_provenance

    # Delete via key access.
    ds.add_provenance_document(doc, name="test_provenance")
    assert ds.provenance["test_provenance"]
    del ds.provenance["test_provenance"]
    with pytest.raises(KeyError):
        ds.provenance["test_provenance"] 
开发者ID:SeismicData,项目名称:pyasdf,代码行数:26,代码来源:test_asdf_data_set.py

示例14: test_warning_that_data_exists_shows_up_every_time

# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read [as 别名]
def test_warning_that_data_exists_shows_up_every_time(tmpdir):
    asdf_filename = os.path.join(tmpdir.strpath, "test.h5")
    ds = ASDFDataSet(asdf_filename)

    tr = obspy.read()[0]
    # Make sure hash is unique.
    tr.stats.starttime += 12345.789

    # No warning for first time.
    with warnings.catch_warnings(record=True) as w:
        ds.add_waveforms(tr, tag="a")
    assert len(w) == 0

    # Warning for all subsequent times.
    for _i in range(10):
        _i += 1
        with warnings.catch_warnings(record=True) as w:
            ds.add_waveforms(tr, tag="a")
        assert len(w) == 1, "Run %i" % _i
        assert w[0].category is ASDFWarning, "Run %i" % _i
        assert "already exists in file" in str(w[0].message), "Run %i" % _i 
开发者ID:SeismicData,项目名称:pyasdf,代码行数:23,代码来源:test_asdf_data_set.py

示例15: save_waveforms_iter

# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read [as 别名]
def save_waveforms_iter(self, base_output_path, output_format, waveforms):
        """
        Save waveforms, returning an iterator of WaveformResult objects whose values are
        True (saved), False (already saved), or Exception (error)
        This is so the GUI layer can handle save progress and errors in its own fashion
        """
        if not os.path.exists(base_output_path):
            try:
                os.makedirs(base_output_path, 0o700)
            except Exception as e:
                raise Exception("Could not create the output path: %s" % str(e))

        # Get the file extension to use
        extension = OUTPUT_FORMAT_EXTENSIONS[output_format]

        for waveform in waveforms:
            waveform_id = waveform.waveform_id
            try:
                output_file = os.path.extsep.join((waveform.base_filename, extension))
                output_path = os.path.join(base_output_path, output_file)
                # Don't repeat any work that has already been done
                if not os.path.exists(output_path):
                    LOGGER.debug('reading %s', waveform.mseed_path)
                    st = obspy.read(waveform.mseed_path)
                    self.save_waveform(st, output_path, output_format, waveform)
                    yield WaveformResult(waveform_id, True)
                else:
                    yield WaveformResult(waveform_id, False)
            except Exception as e:
                yield WaveformResult(waveform_id, e) 
开发者ID:iris-edu,项目名称:pyweed,代码行数:32,代码来源:waveforms_handler.py


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