Пример #1
0
def transform_wavelength_solutions(helper, band, obsids):

    # load affine transform

    master_obsid = obsids[0]

    caldb = helper.get_caldb()
    orders = caldb.load_resource_for((band, master_obsid), "orders")["orders"]

    d = caldb.load_item_from((band, master_obsid),
                             "ALIGNING_MATRIX_JSON")

    affine_tr_matrix = d["affine_tr_matrix"]

    # load echellogram
    from libs.master_calib import load_ref_data
    echellogram_data = load_ref_data(helper.config, band,
                                     kind="ECHELLOGRAM_JSON")

    from libs.echellogram import Echellogram
    echellogram = Echellogram.from_dict(echellogram_data)


    wvl_sol = get_wavelength_solutions(affine_tr_matrix,
                                       echellogram.zdata,
                                       orders)

    caldb.store_dict((band, master_obsid),
                     item_type="WVLSOL_V0_JSON",
                     data=dict(orders=orders,
                               wvl_sol=wvl_sol))


    return wvl_sol
Пример #2
0
def find_affine_transform(helper, band, obsids):

    master_obsid = obsids[0]

    caldb = helper.get_caldb()
    orders = caldb.load_resource_for((band, master_obsid), "orders")["orders"]

    ap = get_simple_aperture(helper, band, obsids, orders=orders)

    item_path = caldb.query_item_path((band, master_obsid),
                                      "IDENTIFIED_LINES_JSON")

    from libs.identified_lines import IdentifiedLines
    identified_lines_tgt = IdentifiedLines.load(item_path)

    xy_list_tgt = identified_lines_tgt.get_xy_list_from_pixlist(ap)

    from libs.echellogram import Echellogram


    from libs.master_calib import load_ref_data
    echellogram_data = load_ref_data(helper.config, band,
                                     kind="ECHELLOGRAM_JSON")

    echellogram = Echellogram.from_dict(echellogram_data)

    xy_list_ref = identified_lines_tgt.get_xy_list_from_wvllist(echellogram)

    assert len(xy_list_tgt) == len(xy_list_ref)

    from libs.align_echellogram_thar import fit_affine_clip
    affine_tr, mm = fit_affine_clip(np.array(xy_list_ref),
                                    np.array(xy_list_tgt))

    from libs.products import PipelineDict
    d = PipelineDict(xy1f=xy_list_ref, xy2f=xy_list_tgt,
                     affine_tr_matrix=affine_tr.get_matrix(),
                     affine_tr_mask=mm)

    caldb.store_dict((band, master_obsid),
                     item_type="ALIGNING_MATRIX_JSON",
                     data=d)