Пример #1
0
def get_offset_treanform_between_2spec(ref_spec, tgt_spec):
    import numpy as np

    orders_ref = ref_spec["orders"]
    s_list_ref = ref_spec["specs"]

    orders_tgt = tgt_spec["orders"]
    s_list_tgt = tgt_spec["specs"]

    s_list_tgt = [np.array(s) for s in s_list_tgt]

    orders_intersection = set(orders_ref).intersection(orders_tgt)
    orders_intersection = sorted(orders_intersection)

    def filter_order(orders, s_list, orders_intersection):
        s_dict = dict(zip(orders, s_list))
        s_list_filtered = [s_dict[o] for o in orders_intersection]
        return s_list_filtered

    s_list_ref_filtered = filter_order(orders_ref, s_list_ref,
                                       orders_intersection)
    s_list_tgt_filtered = filter_order(orders_tgt, s_list_tgt,
                                       orders_intersection)

    from reidentify_thar_lines import get_offset_transform
    offset_transform = get_offset_transform(s_list_ref_filtered,
                                            s_list_tgt_filtered)

    return orders_intersection, offset_transform
Пример #2
0
def get_offset_treanform_between_2spec(ref_spec, tgt_spec):
    import numpy as np

    orders_ref = ref_spec["orders"]
    s_list_ref = ref_spec["specs"]

    orders_tgt = tgt_spec["orders"]
    s_list_tgt = tgt_spec["specs"]

    s_list_tgt = [np.array(s) for s in s_list_tgt]

    orders_intersection = set(orders_ref).intersection(orders_tgt)
    orders_intersection = sorted(orders_intersection)

    def filter_order(orders, s_list, orders_intersection):
        s_dict = dict(zip(orders, s_list))
        s_list_filtered = [s_dict[o] for o in orders_intersection]
        return s_list_filtered

    s_list_ref_filtered = filter_order(orders_ref, s_list_ref,
                                       orders_intersection)
    s_list_tgt_filtered = filter_order(orders_tgt, s_list_tgt,
                                       orders_intersection)

    from reidentify_thar_lines import get_offset_transform
    offset_transform = get_offset_transform(s_list_ref_filtered,
                                            s_list_tgt_filtered)

    return orders_intersection, offset_transform
Пример #3
0
def reidentify_ThAr_lines(thar_products, thar_ref_data):
    import numpy as np

    orders_src = thar_ref_data["orders"]
    s_list_src = thar_ref_data["ref_s_list"]

    # load spec
    #s_list_ = json.load(open("arc_spec_thar_%s_%s.json" % (band, date)))

    from storage_descriptions import ONED_SPEC_JSON_DESC

    orders_dst = thar_products[ONED_SPEC_JSON_DESC]["orders"]
    s_list_ = thar_products[ONED_SPEC_JSON_DESC]["specs"]

    s_list_dst = [np.array(s) for s in s_list_]

    orders_intersection = set(orders_src).intersection(orders_dst)

    def filter_order(orders, s_list, orders_intersection):
        s_list_filtered = [
            s for o, s in zip(orders, s_list) if o in orders_intersection
        ]
        return s_list_filtered

    s_list_src = filter_order(orders_src, s_list_src, orders_intersection)
    s_list_dst = filter_order(orders_dst, s_list_dst, orders_intersection)

    ref_lines_list = filter_order(orders_src, thar_ref_data["ref_lines_list"],
                                  orders_intersection)

    orders = sorted(orders_intersection)

    from reidentify_thar_lines import get_offset_transform
    # get offset function from source spectra to target specta.
    sol_list_transform = get_offset_transform(s_list_src, s_list_dst)

    from reidentify import reidentify_lines_all2

    #ref_lines_map = dict(zip(orders_src, ref_lines_list))

    #ref_lines_list_dst = [ref_lines_map[o] for o in orders_dst]
    reidentified_lines_with_id = reidentify_lines_all2(s_list_dst,
                                                       ref_lines_list,
                                                       sol_list_transform)

    from storage_descriptions import THAR_REID_JSON_DESC

    r = PipelineProducts("initial reidentification of ThAr lines")
    r.add(
        THAR_REID_JSON_DESC,
        PipelineDict(
            orders=orders,
            match_list=reidentified_lines_with_id,
            #ref_date=ref_date,
            ref_spec_file=thar_ref_data["ref_spec_file"],
            ref_id_file=thar_ref_data["ref_id_file"]))

    return r
Пример #4
0
def reidentify_ThAr_lines(thar_products, thar_ref_data):
    import numpy as np

    orders_src = thar_ref_data["orders"]
    s_list_src = thar_ref_data["ref_s_list"]

    # load spec
    #s_list_ = json.load(open("arc_spec_thar_%s_%s.json" % (band, date)))

    from storage_descriptions import ONED_SPEC_JSON_DESC

    orders_dst = thar_products[ONED_SPEC_JSON_DESC]["orders"]
    s_list_ = thar_products[ONED_SPEC_JSON_DESC]["specs"]

    s_list_dst = [np.array(s) for s in s_list_]

    orders_intersection = set(orders_src).intersection(orders_dst)

    def filter_order(orders, s_list, orders_intersection):
        s_list_filtered = [s for o, s in zip(orders, s_list) if o in orders_intersection]
        return s_list_filtered

    s_list_src = filter_order(orders_src, s_list_src, orders_intersection)
    s_list_dst = filter_order(orders_dst, s_list_dst, orders_intersection)

    ref_lines_list = filter_order(orders_src,
                                  thar_ref_data["ref_lines_list"],
                                  orders_intersection)

    orders = sorted(orders_intersection)

    from libs.reidentify_thar_lines import get_offset_transform
    # get offset function from source spectra to target specta.
    sol_list_transform = get_offset_transform(s_list_src, s_list_dst)

    from libs.reidentify import reidentify_lines_all2

    #ref_lines_map = dict(zip(orders_src, ref_lines_list))



    #ref_lines_list_dst = [ref_lines_map[o] for o in orders_dst]
    reidentified_lines_with_id = reidentify_lines_all2(s_list_dst,
                                                       ref_lines_list,
                                                       sol_list_transform)

    from storage_descriptions import THAR_REID_JSON_DESC

    r = PipelineProducts("initial reidentification of ThAr lines")
    r.add(THAR_REID_JSON_DESC,
          PipelineDict(orders=orders,
                       match_list=reidentified_lines_with_id,
                       #ref_date=ref_date,
                       ref_spec_file=thar_ref_data["ref_spec_file"],
                       ref_id_file=thar_ref_data["ref_id_file"]))

    return r