d_x_wvl = {} for order, z in echel.zdata.items(): xy_T = affine_tr.transform(np.array([z.x, z.y]).T) x_T = xy_T[:,0] d_x_wvl[order]=(x_T, z.wvl) 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))
x_T = xy_T[:, 0] d_x_wvl[order] = (x_T, z.wvl) 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)
ss0 = np.concatenate([ss[0], s["pixel"]]) ss1 = np.concatenate([ss[1], s["wavelength"]]) reidentified_lines_map[int(i)] = (ss0, ss1) xl, yl, zl = get_ordered_line_data(reidentified_lines_map) # 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] x_degree, y_degree = 4, 3 #x_degree, y_degree = 3, 2 p, m = fit_2dspec(xl, yl, zl, x_degree=x_degree, y_degree=y_degree, x_domain=x_domain, y_domain=y_domain) # 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]
xl, yl, zl = get_ordered_line_data(reidentified_lines_map) # 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] x_degree, y_degree = 4, 3 #x_degree, y_degree = 3, 2 p, m = fit_2dspec(xl, yl, zl, x_degree=x_degree, y_degree=y_degree, x_domain=x_domain, y_domain=y_domain) # 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)]