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
def rotate_adj_stream(adj_stream, elatitude, elongitude, inventory): """ Rotate adjoint stream from "RT" to "EN" """ if inventory is None: raise ValueError("Station must be provied to rotate the" "adjoint source") rotate_stream(adj_stream, elatitude, elongitude, inventory, mode="RT->NE")
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)
def rotate_adj_stream(adj_stream, event, inventory): """ Rotate adjoint stream from "RT" to "EN" """ if event is None or inventory is None: raise ValueError("Event and Station must be provied to rotate the" "adjoint source") # extract event information origin = event.preferred_origin() or event.origins[0] elat = origin.latitude elon = origin.longitude rotate_stream(adj_stream, elat, elon, inventory, mode="RT->NE")
def rotate_adj_stream(adj_stream, event, inventory): """ Rotate adjoint stream from "RT" to "EN" """ # add zero trace for missing components, otherwise, we won't # be able to rotate with missing one horizontal component component_list = ["Z", "R", "T"] add_missing_components(adj_stream, component_list) if event is None or inventory is None: raise ValueError("Event and Station must be provied to rotate the" "adjoint source") # extract event information origin = event.preferred_origin() or event.origins[0] elat = origin.latitude elon = origin.longitude rotate_stream(adj_stream, elat, elon, inventory, mode="RT->NE")
def test_rotate_stream(): obs = testobs.copy() syn = testsyn.copy() inv = deepcopy(teststaxml) obs_r = rotate.rotate_stream(obs, 0.0, 0.0, inv, mode="NE->RT") syn_r = rotate.rotate_stream(syn, 0.0, 0.0, inv, mode="NE->RT") st = testobs.copy() + testsyn.copy() st_r = rotate.rotate_stream(st, 0.0, 0.0, inv, mode="NE->RT") assert st_r.select(location="") == obs_r assert st_r.select(location="S3") == syn_r st = testobs.copy() + testsyn.copy() st_r = rotate.rotate_stream(st, 0.0, 0.0, inv, mode="NE->RT", sanity_check=True) assert len(st_r.select(location="")) == 1 assert st_r.select(location="")[0].stats.channel == "BHZ" assert len(st_r.select(location="S3")) == 0
def test_rotate_stream(): return obs = testobs.copy() syn = testsyn.copy() inv = deepcopy(teststaxml) obs_r = rotate.rotate_stream(obs, 0.0, 0.0, inv, mode="NE->RT") syn_r = rotate.rotate_stream(syn, 0.0, 0.0, inv, mode="NE->RT") st = testobs.copy() + testsyn.copy() st_r = rotate.rotate_stream(st, 0.0, 0.0, inv, mode="NE->RT") assert st_r.select(location="") == obs_r assert st_r.select(location="S3") == syn_r st = testobs.copy() + testsyn.copy() st_r = rotate.rotate_stream(st, 0.0, 0.0, inv, mode="NE->RT", sanity_check=True) assert len(st_r.select(location="")) == 1 assert st_r.select(location="")[0].stats.channel == "BHZ" assert len(st_r.select(location="S3")) == 0
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