当前位置: 首页>>代码示例>>Python>>正文


Python Pipeline.position_angle方法代码示例

本文整理汇总了Python中sklearn.pipeline.Pipeline.position_angle方法的典型用法代码示例。如果您正苦于以下问题:Python Pipeline.position_angle方法的具体用法?Python Pipeline.position_angle怎么用?Python Pipeline.position_angle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sklearn.pipeline.Pipeline的用法示例。


在下文中一共展示了Pipeline.position_angle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from sklearn.pipeline import Pipeline [as 别名]
# 或者: from sklearn.pipeline.Pipeline import position_angle [as 别名]
def main():
    args = get_args()

    equatorial_coordinates = loadtxt(args.input)
    RA_0, Dec_0, D_0 = args.center

    # transforms coordinates from equatorial to cartesian
    eq2cart = transformations.Equatorial2Cartesian(RA_0, Dec_0, D_0)

    # plane fitting pipeline
    plane = Pipeline([('Cartesian', eq2cart),
                      ('Plane', models.Plane())])
    # ellipsoid fitting pipeline
    ellipsoid = Pipeline([('Cartesian', eq2cart),
                          ('Ellipsoid', models.Ellipsoid())])

    (a, b, c), (i, theta) = plane.fit_transform(equatorial_coordinates)

    print('(a, b, c) =', ', '.join(map(str,(a, b, c))))
    print('(i, theta) =', ', '.join(map(lambda x: str(numpy.rad2deg(x)),
                                        (i, theta))))

    (S_1, S_2, S_3), (i, theta) = ellipsoid.fit_transform(
        equatorial_coordinates)

    print('(S_1, S_2, S_3) =', ', '.join(map(str,(S_1, S_2, S_3))))
    print('(i, theta) =', ', '.join(map(lambda x: str(numpy.rad2deg(x)),
                                        (i, theta))))
    print('T =', ellipsoid.named_steps['Ellipsoid'].evecs)

    
    exit()

    
    cartesian_coordinates = eq2cart.transform(equatorial_coordinates)

#    demean(xyz) # subtract the mean from each column
    savetxt(path.join(args.output, "cartesian.dat"), xyz)
    x, y, z = xyz.T
    plots.plot2d(x, y, path.join(args.output, "unrotated_xy.png"),
                 title='Unrotated cartesian')

    ra, dec, dist = ra_dec_dist.T
    plots.plot2d(ra, dec, path.join(args.output, "radec.png"),
                 xlabel='RA', ylabel='Dec', title='RA/Dec')

    (a, b, c), (aerr, berr, cerr) = args.fit(xyz, **args.__dict__)
    print("a = {} +- {}, b = {} +- {}, c = {} +- {}".format(
        a, aerr, b, berr, c, cerr))
#    plots.plot3d(x, y, z, a, b, c)
    i, ierr = plane.inclination(a, b, aerr, berr)
    theta, thetaerr = plane.position_angle(a, b, aerr, berr)
    print("i = {} +- {}, theta = {} +- {}".format(i*rad2deg, ierr*rad2deg,
                                                  theta*rad2deg,
                                                  thetaerr*rad2deg))

    xyz_ = array([transformations.rotate2plane(x, y, z, i, theta)
                  for x, y, z in xyz])
    x_, y_, z_ = xyz_.T
    plots.plot2d(x_, y_, path.join(args.output, "rotated_xy.png"),
                 title='Rotated cartesian')
    plots.plot2d(x_, z_, path.join(args.output, "rotated_xz.png"),
                 title='Rotated cartesian')
    I = ellipsoid.moment_of_inertia_tensor(xyz)
    unsorted_eigvals, unsorted_eigvecs = eig(I)
    index_array = numpy.fromiter(
        reversed(unsorted_eigvals.argsort(kind='mergesort')),
        dtype=int
    )
    eigvals = unsorted_eigvals[index_array]
    eigvecs = unsorted_eigvecs[index_array,:]
    exit(print(eigvals))
    S_1, S_2, S_3 = ellipsoid.get_axes(eigvals)
    i, ierr = ellipsoid.inclination(eigvecs)
    theta, thetaerr = ellipsoid.position_angle(eigvecs)
    print("S_1 = {}, S_2 = {}, S_3 = {}".format(S_1, S_2, S_3))
    print("i = {} +- {}, theta = {} +- {}".format(i*rad2deg, None,#ierr*rad2deg,
                                                  theta*rad2deg,
                                                  None))#thetaerr*rad2deg))
开发者ID:astroswego,项目名称:magellanic-structure,代码行数:81,代码来源:magstruct.py


注:本文中的sklearn.pipeline.Pipeline.position_angle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。