示例#1
0
        yi = np.linspace(0, 2048, 256 + 1)
        # yi = np.linspace(orders_band[0]-1, orders_band[-1]+1,
        #                  len(orders_band)*10)
        gi = GridInterpolator(xi, yi)

        from mpl_toolkits.axes_grid1 import ImageGrid
        fig2 = plt.figure(figsize=(14, 7))
        grid = ImageGrid(fig2, 111, (1, 2), share_all=True)

        x_det, y_det = x, y
        plot_detected(grid[0], im, x_det, y_det)

        ax2 = grid[1]
        im = check_dx1(ax2, x, y, dx, gi, mystd=2 * mystd)
        from mpl_toolkits.decorator import colorbar
        cb = colorbar(im, ax=ax2, loc=1)
        cb.set_label(r"$\Delta\lambda$ [pixel]")
        check_dx2(ax2, x, y, dx)

        ax1 = grid[0]
        ax1.set_xlim(0, 2048)
        ax1.set_ylim(0, 2048)

        ax1.set_xlabel("x-pixel")
        ax1.set_ylabel("y-pixel")

        fig2.tight_layout()

    fig3 = plt.figure()
    ax = fig3.add_subplot(111)
    #ax.hist(dx, bins=np.linspace(-10, 10, 50))
示例#2
0
        yi = np.linspace(0, 2048, 256+1)
        # yi = np.linspace(orders_band[0]-1, orders_band[-1]+1,
        #                  len(orders_band)*10)
        gi = GridInterpolator(xi, yi)

        from mpl_toolkits.axes_grid1 import ImageGrid
        fig2 = plt.figure(figsize=(14, 7))
        grid = ImageGrid(fig2, 111, (1, 2), share_all=True)

        x_det, y_det = x, y
        plot_detected(grid[0], im, x_det, y_det)

        ax2 = grid[1]
        im = check_dx1(ax2, x, y, dx, gi, mystd=2*mystd)
        from mpl_toolkits.decorator import colorbar
        cb = colorbar(im, ax=ax2, loc=1)
        cb.set_label(r"$\Delta\lambda$ [pixel]")
        check_dx2(ax2, x, y, dx)

        ax1 = grid[0]
        ax1.set_xlim(0, 2048)
        ax1.set_ylim(0, 2048)

        ax1.set_xlabel("x-pixel")
        ax1.set_ylabel("y-pixel")

        fig2.tight_layout()

    fig3 = plt.figure()
    ax=fig3.add_subplot(111)
    #ax.hist(dx, bins=np.linspace(-10, 10, 50))
示例#3
0
def check_thar_transorm(thar_products, thar_echell_products):
    # to check the fit results.

    from storage_descriptions import (COMBINED_IMAGE_DESC,
                                      THAR_ALIGNED_JSON_DESC)

    combined_im = thar_products[COMBINED_IMAGE_DESC].data

    thar_echell_products = thar_echell_products[THAR_ALIGNED_JSON_DESC]
    affine_tr = thar_echell_products["affine_tr"]
    affine_tr_mask = thar_echell_products["affine_tr_mask"]
    xy1f, xy2f = thar_echell_products["xy1f"], thar_echell_products["xy2f"]

    xy1f_tr = affine_tr.transform(xy1f) #[:,0], xy1f[:,1])


    dx_ = xy1f_tr[:,0] - xy2f[:,0]
    #dy_ = xy1f_tr[:,1] - xy2f[:,1]

    mystd = dx_[affine_tr_mask].std()
    mm = [np.abs(dx_) < 3. * mystd]
    dx = dx_[mm]
    x  = xy1f_tr[:,0][mm]
    y = xy1f_tr[:,1][mm]

    from matplotlib.figure import Figure

    if 0: #plot the coverage of previous echellogram
        import matplotlib.pyplot as plt
        im = igrins_log.get_cal_hdus(band, "thar")[0].data

        zemax_xy_list = get_wvl_range(zdata_band, affine_tr)
        fig1 = plt.figure(figsize=(8, 8))
        ax = fig1.add_subplot(111)
        plot_zemax_coverage(ax, im, zemax_xy_list, band)
        ax.set_xlim(0, 2048)
        ax.set_ylim(0, 2048)
        ax.set_xlabel("x-pixel")
        ax.set_ylabel("y-pixel")
        fig1.tight_layout()

    #check_dx(im, x, y, dx, 3*mystd)

    if 1:
        #orders_band = igrins_orders[band]
        xi = np.linspace(0, 2048, 256+1)
        yi = np.linspace(0, 2048, 256+1)
        # yi = np.linspace(orders_band[0]-1, orders_band[-1]+1,
        #                  len(orders_band)*10)
        from grid_interpolator import GridInterpolator
        gi = GridInterpolator(xi, yi)

        from mpl_toolkits.axes_grid1 import ImageGrid
        #fig2 = plt.figure(figsize=(14, 7))
        fig2 = Figure(figsize=(14, 7))
        grid = ImageGrid(fig2, 111, (1, 2), share_all=True)

        x_det, y_det = x, y
        plot_detected(grid[0], combined_im, x_det, y_det)

        ax2 = grid[1]
        im = check_dx1(ax2, x, y, dx, gi, mystd=2*mystd)
        try:
            from mpl_toolkits.decorator import colorbar
        except ImportError:
            pass
        else:
            cb = colorbar(im, ax=ax2, loc=1)
            cb.set_label(r"$\Delta\lambda$ [pixel]")
        check_dx2(ax2, x, y, dx)

        ax1 = grid[0]
        ax1.set_xlim(0, 2048)
        ax1.set_ylim(0, 2048)

        ax1.set_xlabel("x-pixel")
        ax1.set_ylabel("y-pixel")

        fig2.tight_layout()

    fig3 = Figure() #plt.figure()
    ax=fig3.add_subplot(111)
    #ax.hist(dx, bins=np.linspace(-10, 10, 50))
    ax.hist(dx, bins=np.linspace(-5*mystd, 5*mystd, 50))
    ax.set_xlabel(r"$\Delta\lambda$ [pixel]")
    ax.set_ylabel("counts")
    fig3.tight_layout()

    return [fig2, fig3]