utils.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:sbpy 作者: mommermi 项目源码 文件源码
def yarray(shape, yx=[0, 0], th=None):
    """2D array of y values.

    Parameters
    ----------
    shape : tuple of int
      The shape of the resulting array, (y, x).
    yx : tuple of float
      Offset the array to align with this y, x center.
    th : Quantity, optional
      Place the y-axis along this position angle, measured
      counterclockwise from the original y-axis.

    Returns
    -------
    y : ndarray
      An array of y values.

    >>> from sbpy.imageanalysis.utils import yarray
    >>> y = yarray((10, 10))
    >>> y[3, 0]
    3

    """

    import numpy as np
    import astropy.units as u

    y, x = np.indices(shape)[-2:]
    y = y - yx[0]
    x = x - yx[1]

    if th is not None:
        y = -x * np.sin(th.to(u.rad).value) + y * np.cos(th.to(u.rad).value)

    return y
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号