def test_load_to_adjsrc():
array = np.array([1., 2., 3., 4., 5.])
adj = AdjointSource(
"cc_traveltime_misfit", 2.0, 1.0, 17, 40, "BHZ",
adjoint_source=array, network="II", station="AAK",
location="", starttime=UTCDateTime(1990, 1, 1))
station_info = {"latitude": 1.0, "longitude": 2.0, "depth_in_m": 3.0,
"elevation_in_m": 4.0}
adj_array, adj_path, parameters = sa.dump_adjsrc(adj, station_info)
# ensemble a faked adjoint source from hdf5
hdf5_adj = namedtuple("HDF5Adj", ['data', 'parameters'])
hdf5_adj.data = array
hdf5_adj.parameters = parameters
# load and check
loaded_adj, loaded_station_info = sa.load_to_adjsrc(hdf5_adj)
adjoint_equal(loaded_adj, adj)
for k in station_info:
npt.assert_almost_equal(station_info[k], loaded_station_info[k])
assert loaded_station_info["station"] == "AAK"
assert loaded_station_info["network"] == "II"
assert loaded_station_info["location"] == ""
test_sum_adjoint.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录