xl, yl, zl = get_ordered_line_data(d_x_wvl) # xl : pixel # yl : order # zl : wvl * order x_domain = [0, 2047] orders_band = igrins_orders[band] #orders = igrins_orders[band] y_domain = [orders_band[0]-2, orders_band[-1]+2] p = fit_2dspec(xl, yl, zl, x_degree=4, y_degree=3, x_domain=x_domain, y_domain=y_domain) if 0: import matplotlib.pyplot as plt fig = plt.figure(figsize=(12, 7)) check_fit(fig, xl, yl, zl, p, orders_band, d_x_wvl) fig.tight_layout() xx = np.arange(2048) wvl_sol = [] for o in orders_band: oo = np.empty_like(xx) oo.fill(o) wvl = p(xx, oo) / o wvl_sol.append(list(wvl)) if 1: json.dump(wvl_sol, open("wvl_sol_phase0_%s_%s.json" % \ (band, igrins_log.date), "w"))
x_domain = [0, 2047] orders_band = igrins_orders[band] #orders = igrins_orders[band] y_domain = [orders_band[0] - 2, orders_band[-1] + 2] p = fit_2dspec(xl, yl, zl, x_degree=4, y_degree=3, x_domain=x_domain, y_domain=y_domain) if 0: import matplotlib.pyplot as plt fig = plt.figure(figsize=(12, 7)) check_fit(fig, xl, yl, zl, p, orders_band, d_x_wvl) fig.tight_layout() xx = np.arange(2048) wvl_sol = [] for o in orders_band: oo = np.empty_like(xx) oo.fill(o) wvl = p(xx, oo) / o wvl_sol.append(list(wvl)) if 1: json.dump(wvl_sol, open("wvl_sol_phase0_%s_%s.json" % \ (band, igrins_log.date), "w"))
di_list = [len(reidentified_lines_map[k][0]) for k in keys] endi_list = np.add.accumulate(di_list) filter_mask = [m[endi-di:endi] for di, endi in zip(di_list, endi_list)] #from itertools import compress # _ = [list(compress(indices, mm)) for indices, mm \ # in zip(line_indices_list, filter_mask)] # line_indices_list_filtered = _ reidentified_lines_ = [reidentified_lines_map[k] for k in keys] _ = [(v[0][mm], v[1][mm]) for v, mm \ in zip(reidentified_lines_, filter_mask)] reidentified_lines_map_filtered = dict(zip(igrins_orders[band], _)) if 1: import matplotlib.pyplot as plt fig = plt.figure(figsize=(12, 7)) check_fit(fig, xl, yl, zl, p, orders_band, reidentified_lines_map) fig.tight_layout() fig = plt.figure(figsize=(12, 7)) check_fit(fig, xl[m], yl[m], zl[m], p, orders_band, reidentified_lines_map_filtered) fig.tight_layout()
# filter out the line indices not well fit by the surface keys = reidentified_lines_map.keys() di_list = [len(reidentified_lines_map[k][0]) for k in keys] endi_list = np.add.accumulate(di_list) filter_mask = [m[endi - di:endi] for di, endi in zip(di_list, endi_list)] #from itertools import compress # _ = [list(compress(indices, mm)) for indices, mm \ # in zip(line_indices_list, filter_mask)] # line_indices_list_filtered = _ reidentified_lines_ = [reidentified_lines_map[k] for k in keys] _ = [(v[0][mm], v[1][mm]) for v, mm \ in zip(reidentified_lines_, filter_mask)] reidentified_lines_map_filtered = dict(zip(igrins_orders[band], _)) if 1: import matplotlib.pyplot as plt fig = plt.figure(figsize=(12, 7)) check_fit(fig, xl, yl, zl, p, orders_band, reidentified_lines_map) fig.tight_layout() fig = plt.figure(figsize=(12, 7)) check_fit(fig, xl[m], yl[m], zl[m], p, orders_band, reidentified_lines_map_filtered) fig.tight_layout()