本文整理汇总了Python中pyasdf.ASDFDataSet.flush方法的典型用法代码示例。如果您正苦于以下问题:Python ASDFDataSet.flush方法的具体用法?Python ASDFDataSet.flush怎么用?Python ASDFDataSet.flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasdf.ASDFDataSet
的用法示例。
在下文中一共展示了ASDFDataSet.flush方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: write_new_synt_asdf
# 需要导入模块: from pyasdf import ASDFDataSet [as 别名]
# 或者: from pyasdf.ASDFDataSet import flush [as 别名]
def write_new_synt_asdf(self, file_prefix):
new_synt_dict = self._sort_new_synt()
for tag, win_array in new_synt_dict.iteritems():
filename = "%s.%s.h5" % (file_prefix, tag)
if os.path.exists(filename):
os.remove(filename)
logger.info("Output file exists, removed: %s" % filename)
else:
logger.info("Output new synt asdf: %s" % filename)
ds = ASDFDataSet(filename, mode='w')
added_list = []
for window in win_array:
synt_id = window.datalist['new_synt'].id
# skip duplicate obsd location id.
# for example, II.AAK.00.BHZ and II.AAK.10.BHZ will
# be treated as different traces. But the synt and
# new synt will be the same. So we only add one
if synt_id in added_list:
continue
else:
added_list.append(synt_id)
ds.add_waveforms(window.datalist['new_synt'], tag=tag)
# add stationxml
_staxml_asdf = self._asdf_file_dict['synt']
ds_sta = ASDFDataSet(_staxml_asdf)
self.__add_staxml_from_other_asdf(ds, ds_sta)
ds.flush()
示例2: _core
# 需要导入模块: from pyasdf import ASDFDataSet [as 别名]
# 或者: from pyasdf.ASDFDataSet import flush [as 别名]
def _core(self, path, param):
"""
Core function that handles one pair of asdf file(observed and
synthetic), windows and configuration for adjoint source
:param path: path information, path of observed asdf, synthetic
asdf, windows files, observed tag, synthetic tag, output adjoint
file, figure mode and figure directory
:type path: dict
:param param: parameter information for constructing adjoint source
:type param: dict
:return:
"""
adjoint_param = param["adjoint_config"]
postproc_param = param["process_config"]
obsd_file = path["obsd_asdf"]
synt_file = path["synt_asdf"]
window_file = path["window_file"]
output_filename = path["output_file"]
self.check_input_file(obsd_file)
self.check_input_file(synt_file)
self.check_input_file(window_file)
self.check_output_file(output_filename)
obsd_ds = self.load_asdf(obsd_file, mode="r")
obsd_tag = path["obsd_tag"]
synt_ds = self.load_asdf(synt_file, mode="r")
synt_tag = path["synt_tag"]
figure_mode = path["figure_mode"]
figure_dir = path["figure_dir"]
event = obsd_ds.events[0]
windows = self.load_windows(window_file)
adj_src_type = adjoint_param["adj_src_type"]
adjoint_param.pop("adj_src_type", None)
config = load_adjoint_config(adjoint_param, adj_src_type)
if self.mpi_mode and self.rank == 0:
output_ds = ASDFDataSet(output_filename, mpi=False)
if obsd_ds.events:
output_ds.events = obsd_ds.events
output_ds.flush()
del output_ds
if self.mpi_mode:
self.comm.barrier()
adjsrc_func = \
partial(adjoint_wrapper, config=config,
obsd_tag=obsd_tag, synt_tag=synt_tag,
windows=windows, event=event,
adj_src_type=adj_src_type,
postproc_param=postproc_param,
figure_mode=figure_mode, figure_dir=figure_dir)
results = obsd_ds.process_two_files(synt_ds, adjsrc_func,
output_filename)
return results