本文整理匯總了Python中pycbc.io.FieldArray.from_ligolw_table方法的典型用法代碼示例。如果您正苦於以下問題:Python FieldArray.from_ligolw_table方法的具體用法?Python FieldArray.from_ligolw_table怎麽用?Python FieldArray.from_ligolw_table使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pycbc.io.FieldArray
的用法示例。
在下文中一共展示了FieldArray.from_ligolw_table方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from pycbc.io import FieldArray [as 別名]
# 或者: from pycbc.io.FieldArray import from_ligolw_table [as 別名]
def __init__(self, filename, approximant=None, **kwds):
ext = os.path.basename(filename)
if 'xml' in ext:
self.indoc = ligolw_utils.load_filename(
filename, False, contenthandler=LIGOLWContentHandler)
self.table = table.get_table(
self.indoc, lsctables.SnglInspiralTable.tableName)
self.table = FieldArray.from_ligolw_table(self.table)
# inclination stored in xml alpha3 column
names = list(self.table.dtype.names)
names = tuple([n if n != 'alpha3' else 'inclination' for n in names])
self.table.dtype.names = names
elif 'hdf' in ext:
f = h5py.File(filename, 'r')
dtype = []
data = {}
for key in f.keys():
try:
data[str(key)] = f[key][:]
dtype.append((str(key), data[key].dtype))
except:
pass
num = len(data[data.keys()[0]])
self.table = FieldArray(num, dtype=dtype)
for key in data:
self.table[key] = data[key]
else:
raise ValueError("Unsupported template bank file extension %s" % ext)
if not hasattr(self.table, 'template_duration'):
self.table = self.table.add_fields(numpy.zeros(len(self.table),
dtype=numpy.float32), 'template_duration')
self.extra_args = kwds
self.approximant_str = approximant