Exemplo n.º 1
0
    def test_curved_headers_are_all_one_pixel_apart(self, curved_trace):
        curved_trace["y1"] *= 1.1
        curved_trace["y2"] *= 1.2
        spt = SpectralTrace(curved_trace)
        pixel_size = 0.015
        hdrs = spt.get_curve_headers(pixel_size)
        dx = np.diff([hdr["CRVAL1D"] for hdr in hdrs])
        dy = np.diff([hdr["CRVAL2D"] for hdr in hdrs])
        dr = (dx**2 + dy**2)**0.5
        assert np.all(dr <= 1)

        # !!! PLOT this again to see issues
        if PLOTS:
            # orig world coords
            for row in curved_trace:
                x = [row["x0"], row["x2"]]
                y = [row["y0"], row["y2"]]
                len_mm = (np.diff(x)**2 + np.diff(y)**2)**0.5
                plt.plot(x, y, "k")
                plt.plot(x[0], y[0], "ko")
                plt.text(x[0], y[0], len_mm)

            # pixel coords
            for hdr in hdrs[::86]:
                xp = [0, hdr["NAXIS1"]]
                yp = [0, hdr["NAXIS2"]]
                wcs = WCS(hdr, key="D")
                # world coords
                xw, yw = wcs.all_pix2world(xp, yp, 1)
                plt.plot(xw, yw, "r")
                plt.plot(hdr["CRVAL1D"], hdr["CRVAL2D"], "ro")
                len_mm = (np.diff(xw)**2 + np.diff(yw)**2)**0.5
                plt.text(hdr["CRVAL1D"], hdr["CRVAL2D"], len_mm, color="red")
            plt.show()
Exemplo n.º 2
0
 def test_diagonal_headers_are_all_one_pixel_apart(self, horizontal_trace):
     spt = SpectralTrace(horizontal_trace)
     pixel_size = 0.015
     hdrs = spt.get_curve_headers(pixel_size)
     x = [hdr["CRVAL1D"] / pixel_size for hdr in hdrs]
     y = [hdr["CRVAL2D"] / pixel_size for hdr in hdrs]
     assert np.all(np.abs(np.diff(x)) == approx(1, rel=1e-5))