def assert_mos_acquisition(acqimage, centers, tolerance):
    print acqimage.unbinned_pixel_scale()
    assert acqimage.has_mos_mask()
    assert_equals(acqimage.get_num_mos_boxes(), len(centers))

    data = acqimage.get_science_data()
    assert_equals(*data.shape)

    boxes = []
    z1 = Ellipsis
    z2 = None
    for box in acqimage.get_mos_boxes():
        acqbox = find_optimal_box(box, display=True)
        boxes.append(acqbox)
        box_z1, box_z2 = acqbox.get_zscale()

        z1 = min(box_z1, z1)
        z2 = max(box_z2, z2)

    ui.display(data, z1=z1, z2=z2, zscale=False)

    for border in acqimage.get_mos_box_borders():
        ui.polyline(points=border, color=ui.BLUE)

    for box in boxes:
        ui.polyline(points=box.get_mosaic_predicted_borders(), color=ui.MAGENTA)

        x_center, y_center = box.get_mosaic_center()
        assert 0 <= x_center < data.shape[1] 
        assert 0 <= y_center < data.shape[0]

    detector_centers = [b.get_detector_center() for b in boxes]
    assert_tolerance(detector_centers, centers, tolerance=tolerance)
def test_gmos_north_ifu_R_imaging_on_a_stamp():
    add_cursor_position(154.0, 152.0, "a")
    add_cursor_position(0.0, 0.0, "q")

    ret = main(["gacq_test", testutil.get_data_file_name("N20111126S0353.fits")])

    offsets = testutil.get_offsets()
    testutil.assert_tolerance(offsets[0],  31.014, tolerance=0.040)
    testutil.assert_tolerance(offsets[1],  -1.457, tolerance=0.006)
def test_gmos_south_ifu_R_imaging():
    add_cursor_position(302.0, 1160.0, "a")
    add_cursor_position(0.0, 0.0, "q")

    ret = main(["gacq_test", "-v", testutil.get_data_file_name("S20090326S0024.fits")])

    offsets = testutil.get_offsets()
    testutil.assert_tolerance(offsets[0], 2.471, tolerance=0.004)
    testutil.assert_tolerance(offsets[1], 1.035, tolerance=0.007)
def test_gmos_north_ifu_2_imaging():
    add_cursor_position(516.0, 1154.0, "a")
    add_cursor_position(0.0, 0.0, "q")

    ret = main(["gacq_test", testutil.get_data_file_name("N20120122S0030.fits")])

    offsets = testutil.get_offsets()
    testutil.assert_tolerance(offsets[0],  29.013, tolerance=0.004)
    testutil.assert_tolerance(offsets[1],  -1.457, tolerance=0.01)
Пример #5
0
def test_finding_an_easier_center():
    ad = AstroData(get_data_file_name("N20060131S0012.fits"))
    selection = get_selection_peak(ad.data, (489.07, 478.99), float(ad.pixel_scale()))

    predicted_center = selection.get_center()

    assert_tolerance(predicted_center,
                     (489.11025833697016, 478.68088198208636),
                     tolerance=0.02)
Пример #6
0
def test_out_of_bound_aperture():
    ad = AstroData(get_data_file_name("N20060131S0012.fits"))
    selection = get_selection_peak(ad.data, (10.0, 10.0), float(ad.pixel_scale()))

    predicted_center = selection.get_center()

    # should be rather non-sense that is returned
    assert_tolerance(predicted_center,
                     (50.0, 50.0),
                     tolerance=50.0)
Пример #7
0
def test_move_single_object_to_center_of_slit():
    add_cursor_position(498.0, 1146.0, "a")
    add_cursor_position(0.0, 0.0, "q")

    ret = main(["gacq_test", testutil.get_data_file_name("N20060131S0014.fits")])

    offsets = testutil.get_offsets()

    testutil.assert_tolerance(offsets[0], 1.994888, tolerance=0.02)
    testutil.assert_tolerance(offsets[1], 0.929106, tolerance=0.08)
Пример #8
0
def test_finding_the_center_of_titan():
    ad = AstroData(get_data_file_name("N20060131S0011.fits"))
    selection = get_selection_peak(ad.data, (391.0, 539.0), float(ad.pixel_scale()))

    predicted_center = selection.get_center()

    # the object is titan, doesn't have a very clearly defined center
    assert_tolerance(predicted_center,
                     (384.87060478881705, 542.73266988305159),
                     tolerance=0.07)
Пример #9
0
def test_gmos_south_longslit():
    add_cursor_position(511.0, 1145.0, "a")
    add_cursor_position(0.0, 0.0, "q")

    ret = main(["gacq_test", testutil.get_data_file_name("S20071017S0003.fits")])

    offsets = testutil.get_offsets()

    testutil.assert_tolerance(offsets[0], -0.117, tolerance=0.06)
    testutil.assert_tolerance(offsets[1],  0.632, tolerance=0.06)
Пример #10
0
def test_target_is_very_far_from_slit():
    add_cursor_position(526.0, 1186.0, "r")
    add_cursor_position(0.0, 0.0, "q")

    ret = main(["gacq_test", testutil.get_data_file_name("S00000000S0001.fits")])

    offsets = testutil.get_offsets()

    testutil.assert_tolerance(offsets[0], -2.095, tolerance=0.02)
    testutil.assert_tolerance(offsets[1],  4.925, tolerance=0.005)
def test_mdf_box_detector_offset():
    acqimage = AcquisitionImage(get_data_file_name("N20121108S0357.fits"), mosmask="6")

    box_mosaic = acqimage.box_mosaic

    pnt = (10, 10)
    detsec = box_mosaic.detsec_finder.find_detector_section(pnt)
    box_size = box_mosaic.detsec_finder.get_box_size()

    box = Box(detsec, pnt, box_size, (0, 0))
    assert_tolerance(box.get_detector_offset(), (2, 2), tolerance=0.00001)
def test_measuring_longslit_from_image():
    add_cursor_position(152.0, 144.0, "a")
    add_cursor_position(0.0, 0.0, "q")
    add_cursor_position(0.0, 0.0, "q") # slit measurement is ok

    ret = main(["gacq_test", testutil.get_data_file_name("N20111127S0001.fits")]) # N20111127S0002.fits is the image of the slit

    offsets = testutil.get_offsets()

    testutil.assert_tolerance(offsets[0], -0.210, tolerance=0.08)
    testutil.assert_tolerance(offsets[1],  0.342, tolerance=0.003)
Пример #13
0
def test_gmos_south_ifu_2_bright_star():
    add_cursor_position(10.0, 108.0, "a")
    add_cursor_position(0.0, 0.0, "q")
    add_cursor_position(19.0, 13.0, "r")
    add_cursor_position(0.0, 0.0, "q")

    ret = main(["gacq_test", testutil.get_data_file_name("S20130227S0313.fits")])

    offsets = testutil.get_offsets()
    testutil.assert_tolerance(offsets[0],  0.315, tolerance=0.1)
    testutil.assert_tolerance(offsets[1], -0.150, tolerance=0.1)
Пример #14
0
def test_gmos_south_ifu_2_diffuse_object():
    add_cursor_position(10.5, 106.0, "a")
    add_cursor_position(0.0, 0.0, "q")
    add_cursor_position(20.0, 10.0, "r")
    add_cursor_position(0.0, 0.0, "q")

    ret = main(["gacq_test", testutil.get_data_file_name("S20130421S0035.fits")])

    offsets = testutil.get_offsets()
    testutil.assert_tolerance(offsets[0], 0.615, tolerance=0.1)
    testutil.assert_tolerance(offsets[1], 0.094, tolerance=0.1)
def test_move_object_far_to_slit():
    add_cursor_position(526.0, 1186.0, "a")
    add_cursor_position(0.0, 0.0, "q")
    add_cursor_position(0.0, 0.0, "q") # slit measurement is ok

    ret = main(["gacq_test", testutil.get_data_file_name("S20110804S0046.fits")]) # S20110804S0047.fits is the image of the slit

    offsets = testutil.get_offsets()

    testutil.assert_tolerance(offsets[0], -1.749, tolerance=0.1)
    testutil.assert_tolerance(offsets[1],  4.925, tolerance=0.005)
Пример #16
0
def test_gmos_north_extended_fuzzy_object():
    add_cursor_position(8.6, 98.0, "a")
    add_cursor_position(0.0, 0.0, "q")
    add_cursor_position(8.0, 14.0, "r")
    add_cursor_position(0.0, 0.0, "q")

    ret = main(["gacq_test", testutil.get_data_file_name("N20130716S0160.fits")])

    offsets = testutil.get_offsets()
    testutil.assert_tolerance(offsets[0],  0.328, tolerance=0.1)
    testutil.assert_tolerance(offsets[1], -0.442, tolerance=0.1)
def test_really_long_longslit_measuring():
    add_cursor_position(513.0, 1150.0, "a")
    add_cursor_position(0.0, 0.0, "q")
    add_cursor_position(0.0, 0.0, "q") # slit measurement is ok

    ret = main(["gacq_test", testutil.get_data_file_name("N20120216S0231.fits")]) # N20120216S0232 is the image of the slit

    offsets = testutil.get_offsets()

    testutil.assert_tolerance(offsets[0], -0.121, tolerance=0.06)
    testutil.assert_tolerance(offsets[1],  0.285, tolerance=0.02)
Пример #18
0
def test_gmos_south_ifu_R():
    add_cursor_position(9.0, 101.0, "a")
    add_cursor_position(0.0, 0.0, "q")
    add_cursor_position(19.0, 16.0, "r")
    add_cursor_position(0.0, 0.0, "q")

    ret = main(["gacq_test", testutil.get_data_file_name("S20071017S0002.fits")])

    offsets = testutil.get_offsets()
    testutil.assert_tolerance(offsets[0],  0.235, tolerance=0.1)
    testutil.assert_tolerance(offsets[1], -0.920, tolerance=0.1)
Пример #19
0
def test_gmos_north_ifu_2():
    add_cursor_position(12.0, 97.0, "a")
    add_cursor_position(0.0, 0.0, "q")
    add_cursor_position(39.0, 14.0, "a")
    add_cursor_position(0.0, 0.0, "q")

    ret = main(["gacq_test", testutil.get_data_file_name("N20120122S0031.fits")])

    offsets = testutil.get_offsets()

    testutil.assert_tolerance(offsets[0],  0.242, tolerance=0.1)
    testutil.assert_tolerance(offsets[1], -0.344, tolerance=0.1)
Пример #20
0
def test_gmos_north_ifu_R():
    add_cursor_position(10.0, 101.0, "a")
    add_cursor_position(0.0, 0.0, "q")
    add_cursor_position(20.0, 12.0, "r")
    add_cursor_position(0.0, 0.0, "q")

    ret = main(["gacq_test", testutil.get_data_file_name("N20111126S0354.fits")])

    offsets = testutil.get_offsets()

    testutil.assert_tolerance(offsets[0],  0.142, tolerance=0.1)
    testutil.assert_tolerance(offsets[1],  0.169, tolerance=0.1)
Пример #21
0
def test_gmos_north_ifu_R_long_object():
    add_cursor_position(12.0, 98.0, "a")
    add_cursor_position(0.0, 0.0, "q")
    add_cursor_position(19.0, 12.0, "a")
    add_cursor_position(0.0, 0.0, "q")

    ret = main(["gacq_test", testutil.get_data_file_name("N20130605S0153.fits")])

    offsets = testutil.get_offsets()

    testutil.assert_tolerance(offsets[0],  0.281, tolerance=0.1)
    testutil.assert_tolerance(offsets[1], -0.161, tolerance=0.1)
def test_mdf_box_locations_are_unchanged_by_acquisition_image():
    acqimage = AcquisitionImage(get_data_file_name("N20121108S0357.fits"), mosmask="6")

    box_centers = [(4370.9898354,   339.18367075),
                   (1948.16935825,  712.01011175),
                   (1384.48997275, 1181.42130025),
                   (1451.827332,   2218.3127036 )]

    assert len(box_centers) == len(acqimage.get_mos_boxes())

    for refcenter, box in zip(box_centers, acqimage.get_mos_boxes()):
        box_detector_center = box.get_mdf_detector_center() 
        assert_tolerance(refcenter, box_detector_center, tolerance=0.0001)
def test_gmos_south_bright_object_in_the_slit():
    add_cursor_position(505.0, 1145.0, "a")
    add_cursor_position(0.0, 0.0, "q")
    add_cursor_position(0.0, 0.0, "q") # slit measurement is ok

    ret = main(["gacq_test", testutil.get_data_file_name("S20110428S0015.fits")]) # S20110428S0016.fits is the image of the slit

    offsets = testutil.get_offsets()

    # low tolerance is because gacq.cl wasn't actually doing a good
    # job of detecting the slit, gacq.py does much better
    testutil.assert_tolerance(offsets[0],  0.916, tolerance=0.001)
    testutil.assert_tolerance(offsets[1],  0.979, tolerance=0.01)
def test_measuring_longslit_from_bright_object():
    add_cursor_position(149.0, 147.0, "a")
    add_cursor_position(0.0, 0.0, "q")
    add_cursor_position(0.0, 0.0, "q") # slit measurement is ok

    ret = main(["gacq_test", testutil.get_data_file_name("N20110501S0008.fits")]) # N20110501S0009.fits is the image of the slit

    offsets = testutil.get_offsets()

    # high tolerance is because gacq.cl wasn't getting the correct center from automatic detection
    # this calculation is better, but still not perfect, the next test will test the user interactivity
    testutil.assert_tolerance(offsets[0], -0.113, tolerance=0.14)
    testutil.assert_tolerance(offsets[1],  0.153, tolerance=0.001)
def test_i_scoff_at_the_bright_object_in_the_slit():
    add_cursor_position(149.0, 138.0, "a")
    add_cursor_position(0.0, 0.0, "q")
    add_cursor_position(0.0, 0.0, "q") # slit measurement is ok

    ret = main(["gacq_test", testutil.get_data_file_name("N20110529S0087.fits")]) # N20110529S0088.fits is the image of the slit

    offsets = testutil.get_offsets()

    # low tolerance is because gacq.cl wasn't actually doing a good
    # job of detecting the slit, gacq.py does much better
    testutil.assert_tolerance(offsets[0], -0.193, tolerance=0.001)
    testutil.assert_tolerance(offsets[1],  0.767, tolerance=0.005)
def test_gmos_south_slit_center_not_correctly_detected_the_first_time():
    add_cursor_position(514.0, 1153.0, "a")
    add_cursor_position(0.0, 0.0, "q")
    add_cursor_position(147.0, 114.0, "a") # slit measurement needs to be adjusted
    add_cursor_position(0.0, 0.0, "q") 

    ret = main(["gacq_test", testutil.get_data_file_name("S20090418S0109.fits")]) # S20090418S0110.fits is the image of the slit

    offsets = testutil.get_offsets()

    # low tolerance is because gacq.cl wasn't actually doing a good
    # job of detecting the slit, gacq.py does much better
    testutil.assert_tolerance(offsets[0], -0.461, tolerance=0.01)
    testutil.assert_tolerance(offsets[1], -0.160, tolerance=0.01)
def test_gmos_manual_slit_measurement():
    add_cursor_position(505.0, 1145.0, "a")
    add_cursor_position(0.0, 0.0, "q")
    add_cursor_position(144.073, 109.062, "x")
    add_cursor_position(155.008, 108.969, "x")
    add_cursor_position(0.0, 0.0, "q") 

    ret = main(["gacq_test", testutil.get_data_file_name("S20110428S0015.fits")]) # S20110428S0016.fits is the image of the slit

    offsets = testutil.get_offsets()

    # low tolerance is because gacq.cl wasn't actually doing a good
    # job of detecting the slit, gacq.py does much better
    testutil.assert_tolerance(offsets[0],  0.944, tolerance=0.001)
    testutil.assert_tolerance(offsets[1],  0.979, tolerance=0.01)
Пример #28
0
def test_gmos_south_with_a_weird_artifact():
    add_cursor_position(0.0, 0.0, "q")

    ret = main(["gacq_test", testutil.get_data_file_name("S20130114S0062.fits")])

    offsets = testutil.get_offsets()
    testutil.assert_tolerance(offsets[0], -0.028, tolerance=0.004)
    testutil.assert_tolerance(offsets[1],  0.171, tolerance=0.01)
    testutil.assert_tolerance(offsets[2],  0.015, tolerance=0.008)
Пример #29
0
def test_gmos_N20130616S0089():
    add_cursor_position(0.0, 0.0, "q")

    ret = main(["gacq_test", testutil.get_data_file_name("N20130616S0089.fits")])

    offsets = testutil.get_offsets()
    testutil.assert_tolerance(offsets[0], -0.219, tolerance=0.03)
    testutil.assert_tolerance(offsets[1],  0.102, tolerance=0.01)
    testutil.assert_tolerance(offsets[2],  0.010, tolerance=0.01)
Пример #30
0
def test_gmos_south_port_one():
    add_cursor_position(0.0, 0.0, "q")

    ret = main(["gacq_test", testutil.get_data_file_name("S20110804S0079.fits")])

    offsets = testutil.get_offsets()
    testutil.assert_tolerance(offsets[0],  0.321, tolerance=0.02)
    testutil.assert_tolerance(offsets[1], -0.004, tolerance=0.01)
    testutil.assert_tolerance(offsets[2],  0.027, tolerance=0.002)