core.py 文件源码

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

项目:goodman 作者: soar-telescope 项目源码 文件源码
def create_background_image(ccd, profile_model, nsigma, separation):
    """Creates a background-only image

    Using a profile model and assuming the spectrum is misaligned only a little
    bit (i.e. a couple of pixels from end to end) with respect to the lines of
    the detector. The number of sigmas determines the width of the zone to be
    masked and the separation is an offset that is added.

    Args:
        ccd (object): A ccdproc.CCDData instance.
        profile_model (object): An astropy.modeling.Model instance. Describes
            the spatial profile of the target.
        nsigma (float): Number of sigmas. Used to calculate the width of the
            target zone to be masked.
        separation (float): Additional offset that adds to the width of the
            target zone.

    Returns:
        A ccdproc.CCDData instance with the spectrum masked.

    """
    background_ccd = ccd.copy()
    spatial_length, dispersion_length = background_ccd.data.shape
    target_profiles = []
    if 'CompoundModel' in profile_model.__class__.name:
        log_spec.debug(profile_model.submodel_names)
        for m in range(len(profile_model.submodel_names)):
            submodel_name = profile_model.submodel_names[m]

            target_profiles.append(profile_model[submodel_name])
    else:
        target_profiles.append(profile_model)

    for target in target_profiles:
        target_mean = target.mean.value
        target_stddev = target.stddev.value

        data_low_lim = np.int(np.max(
            [0, target_mean - (nsigma / 2. + separation) * target_stddev]))

        data_high_lim = np.int(np.min([spatial_length, int(
            target_mean + (nsigma / 2. + separation) * target_stddev)]))

        background_ccd.data[data_low_lim:data_high_lim, :] = 0

    if False:
        plt.title('Background Image')
        plt.imshow(background_ccd.data, clim=(0, 50))
        plt.show()

    return background_ccd
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号