本文整理汇总了Python中obspy.read_inventory方法的典型用法代码示例。如果您正苦于以下问题:Python obspy.read_inventory方法的具体用法?Python obspy.read_inventory怎么用?Python obspy.read_inventory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obspy
的用法示例。
在下文中一共展示了obspy.read_inventory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_process_synt
# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read_inventory [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)
示例2: test_process_adjoint_2
# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read_inventory [as 别名]
def test_process_adjoint_2():
st, meta = prepare_real_adj_data()
inv = obspy.read_inventory()
event = obspy.read_events()[0]
adjs = pa.convert_stream_to_adjs(st, meta)
starttime = adjs[0].starttime - 20
delta = adjs[0].dt / 2.0
npts = 40 + 2 * len(adjs[0].adjoint_source)
new_adj = pa.process_adjoint(
adjs, interp_flag=True, interp_starttime=starttime,
interp_delta=delta, interp_npts=npts, sum_over_comp_flag=True,
weight_flag=False, filter_flag=True,
pre_filt=[0.02, 0.025, 0.059, 0.073],
taper_percentage=0.05, taper_type="hann",
add_missing_comp_flag=True, rotate_flag=True,
inventory=inv, event=event
)
assert len(new_adj) == 3
示例3: test_window_on_trace
# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read_inventory [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
示例4: test_window_on_trace_user_levels
# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read_inventory [as 别名]
def test_window_on_trace_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"
windows = win.window_on_trace(obs_tr, syn_tr, config, station=inv,
event=cat, user_module=user_module,
_verbose=False,
figure_mode=False)
assert len(windows) == 4
示例5: test_window_on_trace_with_none_user_levels
# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read_inventory [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
示例6: test_window_on_stream
# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read_inventory [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}
示例7: test_window_on_stream_user_levels
# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read_inventory [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}
示例8: test_information_in_other_namespaces_stationxml_is_retained
# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read_inventory [as 别名]
def test_information_in_other_namespaces_stationxml_is_retained(tmpdir):
filename = os.path.join(data_dir, "multi_station_epoch.xml")
asdf_filename = os.path.join(tmpdir.strpath, "test.h5")
inv = obspy.read_inventory(filename)
# We want to retain this.
assert inv[0][0].extra == {
"something": {"namespace": "https://example.com", "value": "test"}
}
assert inv[0][1].extra == {}
assert inv[0][2].extra == {}
# Write and close.
with ASDFDataSet(asdf_filename) as ds:
ds.add_stationxml(filename)
# Open again and test.
with ASDFDataSet(asdf_filename) as ds:
inv2 = ds.waveforms.XX_YYY.StationXML
assert inv2[0][0].extra == {
"something": {"namespace": "https://example.com", "value": "test"}
}
assert inv2[0][1].extra == {}
assert inv2[0][2].extra == {}
示例9: test_isolate_and_merge_with_station_level_information
# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read_inventory [as 别名]
def test_isolate_and_merge_with_station_level_information():
"""
Tests isolate and merge with a station level station files which used to
cause an error.
"""
inv = obspy.read_inventory()
for net in inv:
for sta in net:
sta.channels = []
inv = isolate_and_merge_station(inv, network_id="GR", station_id="FUR")
assert len(inv.networks) == 1
assert len(inv[0].stations) == 1
assert inv[0].code == "GR"
assert inv[0][0].code == "FUR"
示例10: safe_load_staxml
# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read_inventory [as 别名]
def safe_load_staxml(staxmlfile):
try:
inv = read_inventory(staxmlfile)
except Exception as exp:
raise("Failed to parse staxml file(%s) due to: %s"
% (staxmlfile, exp))
return inv
示例11: test_rotate_adj_stream
# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read_inventory [as 别名]
def test_rotate_adj_stream():
# rotate from NEZ to RTZ and rotate back
st = SAMPLE_STREAM.copy()
inv = obspy.read_inventory()
st_rtz = st.copy()
rotate_stream(st_rtz, 0, 0, inv, mode="NE->RT", sanity_check=True)
st_nez = st_rtz.copy()
pa.rotate_adj_stream(st_nez, 0, 0, inv)
for tr1, tr2 in zip(st, st_nez):
assert_trace_equal(tr1, tr2)
示例12: prepare_real_adj_data
# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read_inventory [as 别名]
def prepare_real_adj_data():
st = SAMPLE_STREAM.copy()
inv = obspy.read_inventory()
event = obspy.read_events()[0]
elat = event.preferred_origin().latitude
elon = event.preferred_origin().longitude
rotate_stream(st, elat, elon, inv)
new_z = st.select(component="Z")[0].copy()
new_z.stats.location = "00"
st.append(new_z)
meta = {
"BW.RJOB..EHZ": {
"adj_src_type": "waveform_misfit", "misfit": 1.0,
"min_period": 17.0, "max_period": 40.0},
"BW.RJOB..EHR": {
"adj_src_type": "waveform_misfit", "misfit": 2.0,
"min_period": 17.0, "max_period": 40.0},
"BW.RJOB..EHT": {
"adj_src_type": "waveform_misfit", "misfit": 3.0,
"min_period": 17.0, "max_period": 40.0},
"BW.RJOB.00.EHZ": {
"adj_src_type": "waveform_misfit", "misfit": 4.0,
"min_period": 17.0, "max_period": 40.0}}
return st, meta
示例13: get_windows
# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read_inventory [as 别名]
def get_windows():
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)
return windows
示例14: get_inventory
# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read_inventory [as 别名]
def get_inventory():
print('Read inventory file')
try:
return read_inventory(invname, 'STATIONXML')
except Exception:
pass
print('Create inventory file...')
client = FSDNClient('ORFEUS')
inv = client.get_stations(**inventory_kwargs)
for net in inv:
for sta in net[:]:
if sta.code not in stations:
net.stations.remove(sta)
inv.write(invname, 'STATIONXML')
return inv
示例15: _get_station
# 需要导入模块: import obspy [as 别名]
# 或者: from obspy import read_inventory [as 别名]
def _get_station(self, station_name):
"""
Retrieves the specified StationXML as an ObsPy Inventory object. For
internal use only, use the dot accessors for external access.
:param station_name: A string with network id and station id,
e.g. ``"IU.ANMO"``
:type station_name: str
"""
if (
station_name not in self.__file["Waveforms"]
or "StationXML" not in self.__file["Waveforms"][station_name]
):
return None
data = self.__file["Waveforms"][station_name]["StationXML"]
with io.BytesIO(_read_string_array(data)) as buf:
try:
inv = obspy.read_inventory(buf, format="stationxml")
except lxml.etree.XMLSyntaxError:
raise ValueError(
"Invalid XML file stored in the StationXML group for "
"station %s (HDF5 path '/Waveforms/%s/StationXML'). Talk "
"to the person/program that created the file!"
% (station_name, station_name)
)
return inv