Esempio n. 1
0
    def make_flatoff_hotpixmap(self, sigma_clip1=100, sigma_clip2=10,
                               medfilter_size=None,
                               destripe=True):

        flat_off_cards = []

        flat_off = stsci_median(self.data_list)

        if destripe:
            flat_offs = destriper.get_destriped(flat_off)
            flat_off_cards.append(Card(("HISTORY", "IGR: image destriped.")))

        hotpix_mask = bp.badpixel_mask(flat_offs,
                                       sigma_clip1=sigma_clip1,
                                       sigma_clip2=sigma_clip2,
                                       medfilter_size=medfilter_size)

        bg_std = flat_offs[~hotpix_mask].std()


        flat_off_cards.append(Card(("BG_STD", bg_std,
                                    "IGR: stddev of combined flat")))
        flat_off_image = PipelineImageBase(flat_off_cards,
                                           flat_offs)

        hotpix_mask_image = PipelineImageBase([],
                                              hotpix_mask)


        from storage_descriptions import (FLAT_OFF_DESC,
                                          FLATOFF_JSON_DESC,
                                          HOTPIX_MASK_DESC)

        r = PipelineProducts("flat off products")
        r.add(FLAT_OFF_DESC, flat_off_image)

        r.add(HOTPIX_MASK_DESC,
              hotpix_mask_image)

        r.add(FLATOFF_JSON_DESC,
              PipelineDict(bg_std=bg_std))

        return r
Esempio n. 2
0
    def make_flatoff_hotpixmap(self,
                               sigma_clip1=100,
                               sigma_clip2=10,
                               medfilter_size=None,
                               destripe=True):

        flat_off_cards = []

        flat_off = stsci_median(self.data_list)

        if destripe:
            flat_offs = destriper.get_destriped(flat_off)
            flat_off_cards.append(Card(("HISTORY", "IGR: image destriped.")))

        hotpix_mask = bp.badpixel_mask(flat_offs,
                                       sigma_clip1=sigma_clip1,
                                       sigma_clip2=sigma_clip2,
                                       medfilter_size=medfilter_size)

        bg_std = flat_offs[~hotpix_mask].std()

        flat_off_cards.append(
            Card(("BG_STD", bg_std, "IGR: stddev of combined flat")))
        flat_off_image = PipelineImageBase(flat_off_cards, flat_offs)

        hotpix_mask_image = PipelineImageBase([], hotpix_mask)

        from storage_descriptions import (FLAT_OFF_DESC, FLATOFF_JSON_DESC,
                                          HOTPIX_MASK_DESC)

        r = PipelineProducts("flat off products")
        r.add(FLAT_OFF_DESC, flat_off_image)

        r.add(HOTPIX_MASK_DESC, hotpix_mask_image)

        r.add(FLATOFF_JSON_DESC, PipelineDict(bg_std=bg_std))

        return r
Esempio n. 3
0
def process_flat(ondata_list, offdata_list):

    from stsci_helper import stsci_median

    return_object = {}

    flat_on = stsci_median(ondata_list)
    flat_off = stsci_median(offdata_list)

    bpix_mask = bp.badpixel_mask(flat_off, sigma_clip1=100)

    bg_std = flat_off[~bpix_mask].std()

    flat_on_off = flat_on - flat_off

    norm_factor = get_flat_normalization(flat_on_off, bg_std, bpix_mask)

    flat_norm = flat_on_off / norm_factor
    bg_std_norm = bg_std / norm_factor

    flat_bpix = flat_norm.astype("d", copy=True)
    flat_bpix[bpix_mask] = np.nan

    flat_mask = get_flat_mask(flat_bpix, bg_std_norm, sigma=5)

    return_object["flat_on_off"] = flat_on_off
    return_object["flat_norm_factor"] = norm_factor
    return_object["flat_normed"] = flat_norm
    return_object["flat_bpix_mask"] = bpix_mask
    return_object["bg_std"] = bg_std
    return_object["bg_std_normed"] = bg_std_norm
    return_object["flat_mask"] = flat_mask

    flat_deriv_ = get_y_derivativemap(flat_norm,
                                      flat_bpix,
                                      bg_std_norm,
                                      max_sep_order=150,
                                      pad=50,
                                      flat_mask=flat_mask)

    flat_deriv, flat_deriv_pos_msk, flat_deriv_neg_msk = flat_deriv_[
        "data"], flat_deriv_["pos_mask"], flat_deriv_["neg_mask"]

    return_object["flat_deriv"] = flat_deriv
    return_object["flat_deriv_pos_mask"] = flat_deriv_pos_msk
    return_object["flat_deriv_neg_mask"] = flat_deriv_neg_msk

    ny, nx = flat_deriv.shape
    cent_bottom_list = identify_horizontal_line(flat_deriv,
                                                flat_deriv_pos_msk,
                                                pad=50,
                                                bg_std=bg_std_norm)

    cent_up_list = identify_horizontal_line(-flat_deriv,
                                            flat_deriv_neg_msk,
                                            pad=50,
                                            bg_std=bg_std_norm)

    if 1:  # chevyshev
        _ = trace_centroids_chevyshev(cent_bottom_list,
                                      cent_up_list,
                                      domain=[0, 2048],
                                      ref_x=nx / 2)

    if 0:
        order = 5
        func_fitter = get_line_fiiter(order)

        _ = trace_centroids(cent_bottom_list,
                            cent_up_list,
                            func_fitter=func_fitter,
                            ref_x=nx / 2)

    bottom_up_solutions, centroid_bottom_up_list = _

    if 0:
        plot_solutions(flat_norm, centroid_bottom_up_list, bottom_up_solutions)

    return_object["cent_up_list"] = cent_up_list
    return_object["cent_bottom_list"] = cent_bottom_list
    return_object["bottomup_solutions"] = bottom_up_solutions
    return_object["bottomup_centroids"] = centroid_bottom_up_list

    return return_object
Esempio n. 4
0
def process_flat(ondata_list, offdata_list):

    from stsci_helper import stsci_median

    return_object = {}

    flat_on = stsci_median(ondata_list)
    flat_off = stsci_median(offdata_list)

    bpix_mask = bp.badpixel_mask(flat_off, sigma_clip1=100)

    bg_std = flat_off[~bpix_mask].std()

    flat_on_off = flat_on - flat_off

    norm_factor = get_flat_normalization(flat_on_off,
                                         bg_std, bpix_mask)

    flat_norm = flat_on_off / norm_factor
    bg_std_norm = bg_std/norm_factor


    flat_bpix = flat_norm.astype("d", copy=True)
    flat_bpix[bpix_mask] = np.nan

    flat_mask = get_flat_mask(flat_bpix, bg_std_norm, sigma=5)


    return_object["flat_on_off"] = flat_on_off
    return_object["flat_norm_factor"] = norm_factor
    return_object["flat_normed"] = flat_norm
    return_object["flat_bpix_mask"] = bpix_mask
    return_object["bg_std"] = bg_std
    return_object["bg_std_normed"] = bg_std_norm
    return_object["flat_mask"] = flat_mask


    flat_deriv_ = get_y_derivativemap(flat_norm, flat_bpix,
                                      bg_std_norm,
                                      max_sep_order=150, pad=50,
                                      flat_mask=flat_mask)

    flat_deriv, flat_deriv_pos_msk, flat_deriv_neg_msk = flat_deriv_["data"], flat_deriv_["pos_mask"], flat_deriv_["neg_mask"]


    return_object["flat_deriv"] = flat_deriv
    return_object["flat_deriv_pos_mask"] = flat_deriv_pos_msk
    return_object["flat_deriv_neg_mask"] = flat_deriv_neg_msk

    ny, nx = flat_deriv.shape
    cent_bottom_list = identify_horizontal_line(flat_deriv,
                                                flat_deriv_pos_msk,
                                                pad=50,
                                                bg_std=bg_std_norm)

    cent_up_list = identify_horizontal_line(-flat_deriv,
                                            flat_deriv_neg_msk,
                                            pad=50,
                                            bg_std=bg_std_norm)


    if 1: # chevyshev
        _ = trace_centroids_chevyshev(cent_bottom_list,
                                      cent_up_list,
                                      domain=[0, 2048],
                                      ref_x=nx/2)

    if 0:
        order = 5
        func_fitter = get_line_fiiter(order)

        _ = trace_centroids(cent_bottom_list,
                            cent_up_list,
                            func_fitter=func_fitter,
                            ref_x=nx/2)

    bottom_up_solutions, centroid_bottom_up_list = _

    if 0:
        plot_solutions(flat_norm,
                       centroid_bottom_up_list,
                       bottom_up_solutions)

    return_object["cent_up_list"] = cent_up_list
    return_object["cent_bottom_list"] = cent_bottom_list
    return_object["bottomup_solutions"] = bottom_up_solutions
    return_object["bottomup_centroids"] = centroid_bottom_up_list

    return return_object