本文整理汇总了Python中asdf.AsdfFile.tree[n]['model']方法的典型用法代码示例。如果您正苦于以下问题:Python AsdfFile.tree[n]['model']方法的具体用法?Python AsdfFile.tree[n]['model']怎么用?Python AsdfFile.tree[n]['model']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类asdf.AsdfFile
的用法示例。
在下文中一共展示了AsdfFile.tree[n]['model']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ifupost2asdf
# 需要导入模块: from asdf import AsdfFile [as 别名]
# 或者: from asdf.AsdfFile import tree[n]['model'] [as 别名]
def ifupost2asdf(ifupost_files, outname):
"""
Create a reference file of type ``ifupost`` .
Combines all IDT ``IFU-POST`` reference files in one ASDF file.
forward direction : MSA to Collimator
backward_direction: Collimator to MSA
Parameters
----------
ifupost_files : list
Names of all ``IFU-POST`` IDT reference files
outname : str
Name of output ``ASDF`` file
"""
ref_kw = common_reference_file_keywords("IFUPOST", "NIRSPEC IFU-POST transforms - CDP4")
fa = AsdfFile()
fa.tree = ref_kw
for fifu in ifupost_files:
n = int((fifu.split('IFU-POST_')[1]).split('.pcf')[0])
fa.tree[n] = {}
with open(fifu) as f:
lines = [l.strip() for l in f.readlines()]
factors = lines[lines.index('*Factor 2') + 1].split()
rotation_angle = float(lines[lines.index('*Rotation') + 1])
input_rot_center = lines[lines.index('*InputRotationCentre 2') + 1].split()
output_rot_center = lines[lines.index('*OutputRotationCentre 2') + 1].split()
linear_sky2det = homothetic_sky2det(input_rot_center, rotation_angle, factors, output_rot_center)
degree = int(lines[lines.index('*FitOrder') + 1])
xcoeff_index = lines.index('*xForwardCoefficients 21 2')
xlines = lines[xcoeff_index + 1: xcoeff_index + 22]
xcoeff_forward = coeffs_from_pcf(degree, xlines)
x_poly_forward = models.Polynomial2D(degree, name='x_poly_forward', **xcoeff_forward)
ycoeff_index = lines.index('*yForwardCoefficients 21 2')
ycoeff_forward = coeffs_from_pcf(degree, lines[ycoeff_index + 1: ycoeff_index + 22])
y_poly_forward = models.Polynomial2D(degree, name='y_poly_forward', **ycoeff_forward)
xcoeff_index = lines.index('*xBackwardCoefficients 21 2')
xcoeff_backward = coeffs_from_pcf(degree, lines[xcoeff_index + 1: xcoeff_index + 22])
x_poly_backward = models.Polynomial2D(degree, name='x_poly_backward', **xcoeff_backward)
ycoeff_index = lines.index('*yBackwardCoefficients 21 2')
ycoeff_backward = coeffs_from_pcf(degree, lines[ycoeff_index + 1: ycoeff_index + 22])
y_poly_backward = models.Polynomial2D(degree, name='y_poly_backward', **ycoeff_backward)
output2poly_mapping = Identity(2, name='output_mapping')
output2poly_mapping.inverse = Mapping([0, 1, 0, 1])
input2poly_mapping = Mapping([0, 1, 0, 1], name='input_mapping')
input2poly_mapping.inverse = Identity(2)
model_poly = input2poly_mapping | (x_poly_forward & y_poly_forward) | output2poly_mapping
model = linear_sky2det | model_poly
fa.tree[n]['model'] = model
asdffile = fa.write_to(outname)
return asdffile