def test_initialises_spectral_trace_file(self):
        config = {
            "!SIM.spectral.wave_min": 1.45,
            "!SIM.spectral.wave_mid": 1.9,
            "!SIM.spectral.wave_max": 2.5,
            "!INST.pixel_scale": 0.004,
            "!INST.plate_scale": 0.26666667,
        }
        for key in config:
            rc.__currsys__[key] = config[key]

        ap_mask = efs.ApertureMask(filename="SLIT_3000x50mas.dat")
        assert isinstance(ap_mask, efs.ApertureMask)

        spt = efs.SpectralTraceList(filename="TRACE_15arcsec.fits",
                                    wave_colname="lam",
                                    s_colname="xi",
                                    col_number_start=1)
        assert isinstance(spt, efs.SpectralTraceList)

        waves = spt.fov_grid(which="waveset")
        print("# waves:", len(waves))

        params = {
            "sky_header": ap_mask.header,
            "det_header": None,
            "pixel_scale": "!INST.pixel_scale",
            "plate_scale": "!INST.plate_scale",
            "wave_min": "!SIM.spectral.wave_min",
            "wave_mid": "!SIM.spectral.wave_mid",
            "wave_max": "!SIM.spectral.wave_max"
        }
        fovs = spt.fov_grid(which="edges", **params)
        print("# fovs:", len(fovs))
        assert isinstance(fovs[-1], (fits.Header, PoorMansHeader))
示例#2
0
def test_plot_spec_trace_layout():

    spt = efs.SpectralTraceList(filename="TRACE_15arcsec.fits",
                                wave_colname="lam",
                                s_colname="xi",
                                invalid_value=0,
                                col_number_start=1)
    det = efs.DetectorList(filename="FPA_array_layout.dat")

    if PLOTS:
        spt.plot(1.4, 2.5)
        det.plot()
        plt.show()
示例#3
0
def mock_spectral_trace_list():
    """
    2 apertures, each with two traces. The main traces [0_A, 1_A] cover the
    waverange [1, 2]um, and are on the left of the image plane, spanning two
    detector. The secondary traces cover [1.8, 2.4]um and are right of centre
    """

    pri_hdu = fits.PrimaryHDU()
    pri_hdu.header.update({"ECAT": 1, "EDATA": 2})
    idx_hdu = table_to_hdu(
        Table(names=[
            'description', 'extension_id', 'aperture_id', 'image_plane_id'
        ],
              data=[["0_A", "0_B", "1_A", "1_B"], [2, 3, 4, 5], [0, 0, 1, 1],
                    [0] * 4]))
    names = ["wavelength", "s0", "s1", "x0", "x1", "y0", "y1"]
    wA, wB = [1.0, 2.0], [1.8, 2.4]
    s0, s1 = [-5, -5], [5, 5]
    trace_hdus = [
        table_to_hdu(
            Table(
                names=names,  # Trace 0_A
                data=[
                    wA, s0, s1, [-50, -50], [-40, -40], [-50, 50], [-50, 50]
                ])),
        table_to_hdu(
            Table(
                names=names,  # Trace 0_B
                data=[wB, s0, s1, [10, 10], [20, 20], [-20, 20], [-20, 20]])),
        table_to_hdu(
            Table(
                names=names,  # Trace 1_A
                data=[
                    wA, s0, s1, [-30, -30], [-20, -20], [-50, 50], [-50, 50]
                ])),
        table_to_hdu(
            Table(
                names=names,  # Trace 1_B
                data=[wB, s0, s1, [30, 30], [40, 40], [-20, 20], [-20, 20]]))
    ]
    hdu_list = fits.HDUList([pri_hdu, idx_hdu] + trace_hdus)
    kwargs = {}

    spt_list = efs.SpectralTraceList(hdulist=hdu_list, **kwargs)

    return spt_list
示例#4
0
def mock_spectral_trace_list_single():
    pri_hdu = fits.PrimaryHDU()
    pri_hdu.header.update({"ECAT": 1, "EDATA": 2})
    idx_hdu = table_to_hdu(
        Table(names=[
            'description', 'extension_id', 'aperture_id', 'image_plane_id'
        ],
              data=[["0"], [2], [0], [0]]))
    n = 11
    names = ["wavelength", "s0", "s1", "x0", "x1", "y0", "y1"]
    wA, wB = np.linspace(1., 2., n), np.linspace(1.8, 2.4, n)
    s0, s1 = -5 * np.ones(n), 5 * np.ones(n)
    x0 = np.linspace(-25, 25, n)
    x1 = x0 + 10
    y0 = np.linspace(-50, 50, n)
    y1 = y0 + 2

    trace_hdu = table_to_hdu(
        Table(names=names, data=[wA, s0, s1, x0, x1, y0, y1]))
    hdu_list = fits.HDUList([pri_hdu, idx_hdu, trace_hdu])
    spt_list = efs.SpectralTraceList(hdulist=hdu_list)

    return spt_list
示例#5
0
def mock_spectral_trace_list_shear():
    """
    2 apertures, each with two traces. The main traces [0_A, 1_A] cover the
    waverange [1, 2]um, and are on the left of the image plane, spanning two
    detectors. The secondary traces cover [1.8, 2.4]um and are right of centre
    """

    pri_hdu = fits.PrimaryHDU()
    pri_hdu.header.update({"ECAT": 1, "EDATA": 2})
    idx_hdu = table_to_hdu(
        Table(names=[
            'description', 'extension_id', 'aperture_id', 'image_plane_id'
        ],
              data=[["0_A", "0_B", "1_A", "1_B"], [2, 3, 4, 5], [1, 1, 1, 1],
                    [0] * 4]))
    n = 11
    names = ["wavelength", "s0", "s1", "x0", "x1", "y0", "y1"]
    wA, wB = np.linspace(1., 2., n), np.linspace(1.8, 2.4, n)
    s0, s1 = -5 * np.ones(n), 5 * np.ones(n)

    # diagonal
    y_A = np.linspace(-50, 50, n)
    x0_0A = np.linspace(-50, -40, n)
    x1_0A = x0_0A + 10

    # straight
    x0_1A = -20 * np.ones(n)
    x1_1A = x0_1A + 10

    # sheared
    x0_0B = np.linspace(0, 10, n)
    y0_0B = np.linspace(-20, 20, n)
    x1_0B = x0_0B + 10
    y1_0B = y0_0B + 10

    # horizontal
    x0_1B = np.linspace(20, 50, n)
    y0_1B = -5 * np.ones(n)
    x1_1B = x0_1B
    y1_1B = y0_1B + 10

    trace_hdus = [
        table_to_hdu(
            Table(
                names=names,  # Trace 0_A
                data=[wA, s0, s1, x0_0A, x1_0A, y_A, y_A])),
        table_to_hdu(
            Table(
                names=names,  # Trace 0_B
                data=[wB, s0, s1, x0_0B, x1_0B, y0_0B, y1_0B])),
        table_to_hdu(
            Table(
                names=names,  # Trace 1_A
                data=[wA, s0, s1, x0_1A, x1_1A, y_A, y_A])),
        table_to_hdu(
            Table(
                names=names,  # Trace 1_B
                data=[wB, s0, s1, x0_1B, x1_1B, y0_1B, y1_1B]))
    ]
    hdu_list = fits.HDUList([pri_hdu, idx_hdu] + trace_hdus)
    kwargs = {}

    spt_list = efs.SpectralTraceList(hdulist=hdu_list, **kwargs)

    return spt_list