def test_identify_lines(helper, band, obsids): from libs.master_calib import load_ref_data ref_spec = load_ref_data(helper.config, band, kind="SKY_REFSPEC_JSON") caldb = helper.get_caldb() master_obsid = obsids[0] tgt_spec = caldb.load_item_from((band, master_obsid), "ONED_SPEC_JSON") from libs.process_thar import get_offset_treanform_between_2spec d = get_offset_treanform_between_2spec(ref_spec, tgt_spec) print d
def identify_lines(helper, band, obsids): from libs.master_calib import load_ref_data ref_spec_key, ref_identified_lines_key = _get_ref_spec_name(helper) ref_spec = load_ref_data(helper.config, band, kind=ref_spec_key) caldb = helper.get_caldb() master_obsid = obsids[0] tgt_spec_path = caldb.query_item_path((band, master_obsid), "ONED_SPEC_JSON") tgt_spec = caldb.load_item_from_path(tgt_spec_path) from libs.process_thar import get_offset_treanform_between_2spec intersected_orders, d = get_offset_treanform_between_2spec(ref_spec, tgt_spec) #REF_TYPE="OH" #fn = "../%s_IGRINS_identified_%s_%s.json" % (REF_TYPE, band, # helper.refdate) l = load_ref_data(helper.config, band, kind=ref_identified_lines_key) #l = json.load(open(fn)) #ref_spectra = load_ref_data(helper.config, band, kind="SKY_REFSPEC_JSON") offsetfunc_map = dict(zip(intersected_orders, d["sol_list"])) from libs.identified_lines import IdentifiedLines identified_lines_ref = IdentifiedLines(l) ref_map = identified_lines_ref.get_dict() identified_lines_tgt = IdentifiedLines(l) identified_lines_tgt.update(dict(wvl_list=[], ref_indices_list=[], pixpos_list=[], orders=[], spec_path=tgt_spec_path)) from libs.line_identify_simple import match_lines1_pix for o, s in zip(tgt_spec["orders"], tgt_spec["specs"]): if (o not in ref_map) or (o not in offsetfunc_map): wvl, indices, pixpos = [], [], [] else: pixpos, indices, wvl = ref_map[o] pixpos = np.array(pixpos) msk = (pixpos >= 0) ref_pix_list = offsetfunc_map[o](pixpos[msk]) pix_list, dist = match_lines1_pix(np.array(s), ref_pix_list) pix_list[dist>1] = -1 pixpos[msk] = pix_list identified_lines_tgt.append_order_info(o, wvl, indices, pixpos) #REF_TYPE = "OH" #fn = "%s_IGRINS_identified_%s_%s.json" % (REF_TYPE, band, helper.utdate) # item_path = caldb.query_item_path((band, master_obsid), # "IDENTIFIED_LINES") # item_path = caldb.query_item_path((band, master_obsid), # "IDENTIFIED_LINES") caldb.store_dict((band, master_obsid), "IDENTIFIED_LINES_JSON", identified_lines_tgt.data)