fig2.savefig("align_zemax_%s_fig2_fit.png" % postfix) fig3.savefig("align_zemax_%s_fig3_hist_dlambda.png" % postfix) if 0: from ecfit.ecfit import get_ordered_line_data, fit_2dspec, check_fit 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)
if 0: postfix = "%s_%s" % (igrins_log.date, band) fig1.savefig("align_zemax_%s_fig1_coverage.png" % postfix) fig2.savefig("align_zemax_%s_fig2_fit.png" % postfix) fig3.savefig("align_zemax_%s_fig3_hist_dlambda.png" % postfix) if 0: from ecfit.ecfit import get_ordered_line_data, fit_2dspec, check_fit 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)
# 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) reidentified_lines_map = dict(zip(igrins_orders[band], reidentified_lines)) if band == "K": json_name = "hitran_reidentified_K_%s.json" % igrins_log.date r = json.load(open(json_name)) for i, s in r.items(): ss = reidentified_lines_map[int(i)] 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
# 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) reidentified_lines_map = dict(zip(igrins_orders[band], reidentified_lines)) if band == "K": json_name = "hitran_reidentified_K_%s.json" % igrins_log.date r = json.load(open(json_name)) for i, s in r.items(): ss = reidentified_lines_map[int(i)] 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,