示例#1
0
 def test_constructor_background_cropped_high(self, get_image):
     hdr, im = get_image
     ap = image.PointSourceAp(im,
                              xy_center=(3060, 2035),
                              foreground_radius=9,
                              gap=6,
                              background_width=5)  # no source there.
     # Quality criteria:
     assert ap.is_valid is True
     assert ap.all_inside_image is False
     assert ap.all_outside_image is False
     assert ap.any_foreground_outside_image is False
     assert ap.mask_overlap_pixel_count == 0
     # Shapes and pixel counts:
     assert ap.cutout.shape == ap.foreground_mask.shape == ap.background_mask.shape == (
         34, 34)
     assert ap.foreground_pixel_count == np.sum(
         ap.foreground_mask == False) == 253
     assert ap.background_pixel_count == np.sum(
         ap.background_mask == False) == 261
     # ADUs and fluxes:
     assert ap.background_level == pytest.approx(245, abs=1)
     assert ap.background_std == pytest.approx(18, abs=1)
     assert ap.foreground_max == 300
     assert ap.foreground_min == 193
     assert ap.raw_flux == pytest.approx(61791, abs=10)
示例#2
0
 def test_constructor_ids(self, get_image):
     hdr, im = get_image
     ap = image.PointSourceAp(im,
                              xy_center=(1476.3, 1243.7),
                              foreground_radius=9,
                              gap=6,
                              background_width=5,
                              source_id='haha',
                              obs_id='hoho')
     assert (ap.source_id, ap.obs_id) == ('haha', 'hoho')
示例#3
0
 def test_constructor_ap_all_outside(self, get_image):
     hdr, im = get_image
     ap = image.PointSourceAp(im,
                              xy_center=(2568, 2100),
                              foreground_radius=9,
                              gap=6,
                              background_width=5)
     # Quality criteria:
     assert ap.is_valid is False
     assert ap.all_inside_image is False
     assert ap.all_outside_image is True
     assert ap.any_foreground_outside_image is True
     assert ap.mask_overlap_pixel_count is None
示例#4
0
 def test_recenter(self, get_image):
     """ This will test class Ap.recenter() for all subclasses. """
     hdr, im = get_image
     ap = image.PointSourceAp(im,
                              xy_center=(1476.3, 1243.7),
                              foreground_radius=9,
                              gap=6,
                              background_width=5)
     ap2 = ap.recenter()
     assert ap2.is_valid
     assert ap2.xy_center == pytest.approx((1476.296, 1243.276), abs=0.002)
     assert ap2.xy_centroid == pytest.approx((1476.295, 1243.275),
                                             abs=0.002)
     ap = image.PointSourceAp(im,
                              xy_center=(1478, 1245),
                              foreground_radius=9,
                              gap=6,
                              background_width=5)
     ap2 = ap.recenter()
     assert ap2.is_valid
     assert ap2.xy_center == pytest.approx((1476.296, 1243.276), abs=0.002)
     assert ap2.xy_centroid == pytest.approx((1476.295, 1243.275),
                                             abs=0.002)
示例#5
0
 def test_make_new_object(self, get_image):
     hdr, im = get_image
     ap = image.PointSourceAp(im,
                              xy_center=(1476, 1244),
                              foreground_radius=9,
                              gap=6,
                              background_width=5)
     ap2 = ap.make_new_object(new_xy_center=(2086, 1570))
     assert ap2.xy_center == (2086, 1570)
     assert np.array_equal(ap.foreground_mask, ap2.foreground_mask)
     assert np.array_equal(ap.background_mask, ap2.background_mask)
     assert ap2.xy_centroid[0] == pytest.approx(2085.70, abs=0.02)
     assert ap2.xy_centroid[1] == pytest.approx(1569.12, abs=0.02)
     assert ap2.foreground_max == 3414
示例#6
0
 def test_constructor_masks_inside_image(self, get_image):
     hdr, im = get_image
     ap = image.PointSourceAp(im,
                              xy_center=(1476.3, 1243.7),
                              foreground_radius=9,
                              gap=6,
                              background_width=5)
     # Quality criteria:
     assert ap.is_valid is True
     assert ap.all_inside_image is True
     assert ap.all_outside_image is False
     assert ap.any_foreground_outside_image is False
     assert ap.mask_overlap_pixel_count == 0
     # Values as input:
     assert (ap.foreground_radius, ap.gap, ap.background_width) == (9, 6, 5)
     assert ap.annulus_inner_radius == ap.foreground_radius + ap.gap
     assert ap.annulus_outer_radius == ap.foreground_radius + ap.gap + ap.background_width
     assert np.array_equal(ap.image, im)
     assert ap.xy_center == XY(1476.3, 1243.7)
     assert ap.input_foreground_mask.shape == (44, 44)
     assert ap.input_background_mask.shape == ap.input_foreground_mask.shape
     # Shapes and pixel counts:
     assert ap.cutout.shape == ap.foreground_mask.shape == ap.background_mask.shape == (
         44, 44)
     assert ap.foreground_pixel_count == np.sum(
         ap.input_foreground_mask == False) == 255
     assert ap.background_pixel_count == np.sum(
         ap.input_background_mask == False) == 549
     # ADUs and fluxes:
     assert ap.background_level == pytest.approx(257, abs=1)
     assert ap.background_std == pytest.approx(13.84, abs=0.1)
     assert ap.foreground_max == 1065
     assert ap.foreground_min == 234
     assert ap.raw_flux == pytest.approx(96364, abs=10)
     assert ap.net_flux == pytest.approx(30829, abs=10)
     assert ap.flux_stddev(gain=1.57) == pytest.approx(247.95, abs=0.1)
     # Source flux position & shape:
     assert ap.xy_centroid[0] == pytest.approx(1476.23, abs=0.01)
     assert ap.xy_centroid[1] == pytest.approx(1243.39, abs=0.01)
     assert ap.sigma == pytest.approx(2.81, abs=0.1)
     assert ap.fwhm == pytest.approx(6.37, abs=0.1)
     assert ap.elongation == pytest.approx(1.086, abs=0.02)