LSST Applications g0d97872fb5+4fd969bb9d,g1653933729+34a971ddd9,g28da252d5a+072f89fe25,g2bbee38e9b+a99b0ab4cd,g2bc492864f+a99b0ab4cd,g2ca4be77d2+c0e3b27cd8,g2cdde0e794+704103fe75,g3156d2b45e+6e87dc994a,g347aa1857d+a99b0ab4cd,g35bb328faa+34a971ddd9,g3a166c0a6a+a99b0ab4cd,g3e281a1b8c+8ec26ec694,g4005a62e65+ba0306790b,g414038480c+9ed5ed841a,g569e0e2b34+cb4faa46ad,g5a97de2502+520531a62c,g717e5f8c0f+29153700a5,g7ede599f99+367733290c,g80478fca09+17051a22cc,g82479be7b0+f2f1ea0a87,g858d7b2824+29153700a5,g8b782ad322+29153700a5,g8cd86fa7b1+05420e7f7d,g9125e01d80+34a971ddd9,ga5288a1d22+e7f674aaf3,gae0086650b+34a971ddd9,gae74b0b5c6+45ef5cdc51,gb58c049af0+ace264a4f2,gc28159a63d+a99b0ab4cd,gcf0d15dbbd+8051a81198,gda6a2b7d83+8051a81198,gdaeeff99f8+7774323b41,gdf4d240d4a+34a971ddd9,ge2409df99d+cb167bac99,ge33fd446bb+29153700a5,ge79ae78c31+a99b0ab4cd,gf0baf85859+890af219f9,gf5289d68f6+9faa5c5784,w.2024.36
LSST Data Management Base Package
Loading...
Searching...
No Matches
Functions | Variables
test_image Namespace Reference

Functions

 test_Image ()
 
 test_numpy_Image ()
 
 test_ImageArray ()
 
 gaussians ()
 
 convolved_gaussian (gaussians)
 
 convolved_gaussians (convolved_gaussian)
 
 test_GaussianEvaluator (convolved_gaussians)
 
 test_make_gaussians_pixel (convolved_gaussians)
 

Variables

str prefix_namespace = "lsst.gauss2d."
 
str check_str_repr = "linux" in sys.platform
 

Function Documentation

◆ convolved_gaussian()

test_image.convolved_gaussian ( gaussians)

Definition at line 106 of file test_image.py.

106def convolved_gaussian(gaussians):
107 gauss_conv = g2d.ConvolvedGaussian(gaussians[0], gaussians[1])
108 return gauss_conv
109
110
111@pytest.fixture(scope="module")
A convolution of a Gaussian source and kernel.
Definition gaussian.h:220

◆ convolved_gaussians()

test_image.convolved_gaussians ( convolved_gaussian)

Definition at line 112 of file test_image.py.

112def convolved_gaussians(convolved_gaussian):
113 gaussians_conv = g2d.ConvolvedGaussians([
114 convolved_gaussian, g2d.ConvolvedGaussian(convolved_gaussian.kernel, convolved_gaussian.source)
115 ])
116 return gaussians_conv
117
118
A collection of ConvolvedGaussian objects.
Definition gaussian.h:249

◆ gaussians()

test_image.gaussians ( )

Definition at line 99 of file test_image.py.

99def gaussians():
100 gauss1 = g2d.Gaussian(centroid=None, ellipse=g2d.Ellipse(3, 6, 0))
101 gauss2 = g2d.Gaussian(centroid=None, ellipse=g2d.Ellipse(4, 8, 0))
102 return gauss1, gauss2
103
104
105@pytest.fixture(scope="module")
An Ellipse with sigma_x, sigma_y, and rho values.
Definition ellipse.h:283
A 2D Gaussian with a Centroid, Ellipse, and integral.
Definition gaussian.h:99

◆ test_GaussianEvaluator()

test_image.test_GaussianEvaluator ( convolved_gaussians)

Definition at line 119 of file test_image.py.

119def test_GaussianEvaluator(convolved_gaussians):
120 output = g2d.ImageD(coordsys=g2d.CoordinateSystem(x_min=-5, y_min=-5), n_rows=11, n_cols=9)
121 evaluator = g2d.GaussianEvaluatorD(gaussians=convolved_gaussians, output=output)
122 result = evaluator.loglike_pixel()
123
124 assert result == 0
125 assert np.sum(output.data) > 0
126
127 sigma_inv = g2d.ImageD(coordsys=output.coordsys, data=np.ones_like(output.data))
128 evaluator_ll = g2d.GaussianEvaluatorD(gaussians=convolved_gaussians, data=output, sigma_inv=sigma_inv)
129
130 result = evaluator_ll.loglike_pixel()
131 assert result == 0
132
133 output += 1e-6
134 assert evaluator_ll.loglike_pixel() < 0
135
136 if check_str_repr:
137 assert str(evaluator_ll) == (
138 f"GaussianEvaluatorD(gaussians={str(convolved_gaussians)}, "
139 f"do_extra=0, do_output=0, do_residual=0, has_background=0, "
140 f"is_sigma_image=1, backgroundtype=0, get_likelihood=1, "
141 f"data={str(output)}, sigma_inv={str(sigma_inv)}, output=None, residual=None, "
142 f"grads=None, grad_param_map=None, grad_param_factor=None, "
143 f"extra_param_map=None, extra_param_factor=None, grad_extra=None, grad_param_idx=[], "
144 f"n_cols={output.n_cols}, n_rows={output.n_rows}, coordsys={str(output.coordsys)})"
145 )
146 assert repr(evaluator_ll) == (
147 f"{prefix_namespace}GaussianEvaluatorD(gaussians={repr(convolved_gaussians)}, "
148 f"data={repr(output)}, sigma_inv={repr(sigma_inv)}, output=None, residual=None, "
149 f"grads=None, grad_param_map=None, grad_param_factor=None, "
150 f"extra_param_map=None, extra_param_factor=None, background=None)"
151 )
152
153
A coordinate system specifying image scale and orientation.

◆ test_Image()

test_image.test_Image ( )

Definition at line 33 of file test_image.py.

33def test_Image():
34 img = g2d.ImageD(1, 1)
35 img.fill(1)
36 assert img.get_value(0, 0) == 1
37 img += 1
38 assert img.get_value(0, 0) == 2
39 img.set_value_unchecked(0, 0, -1)
40 assert img.get_value_unchecked(0, 0) == -1
41 str_coordsys = str(img.coordsys)
42 if check_str_repr:
43 assert str(img) == f"ImageD(coordsys={str_coordsys}, n_rows=1, n_cols=1)"
44 assert repr(img) == (
45 f"{prefix_namespace}python.ImageD(coordsys={prefix_namespace}{str_coordsys}, n_rows=1, n_cols=1)"
46 )
47 n_rows, n_cols = 11, 13
48 coordsys = g2d.CoordinateSystem(1.3, -0.7, -11.6, 365.1)
49 img = g2d.ImageF(n_rows=n_rows, n_cols=n_cols, coordsys=coordsys)
50 if check_str_repr:
51 assert str(img) == f"ImageF(coordsys={coordsys}, n_rows={n_rows}, n_cols={n_cols})"
52
53

◆ test_ImageArray()

test_image.test_ImageArray ( )

Definition at line 77 of file test_image.py.

77def test_ImageArray():
78 imgs = [g2d.ImageD(3, 2), g2d.ImageD(3, 2)]
79 img_arr = g2d.ImageArrayD(imgs)
80 assert img_arr.at(0) is imgs[0]
81 assert img_arr.size == len(imgs)
82 assert len(img_arr) == len(imgs)
83 assert img_arr[0] is imgs[0]
84
85 with pytest.raises(ValueError):
86 g2d.ImageArrayD([imgs[0], g2d.ImageD(2, 3)])
87
88 with pytest.raises(ValueError):
89 g2d.ImageArrayD([imgs[0], None])
90
91 if check_str_repr:
92 assert str(img_arr) == f"ImageArrayD(data=[{str(imgs[0])}, {str(imgs[1])}])"
93 assert repr(img_arr) == (
94 f"{prefix_namespace}ImageArrayD(data=[{repr(imgs[0])}, {repr(imgs[1])}])"
95 )
96
97
98@pytest.fixture(scope="module")

◆ test_make_gaussians_pixel()

test_image.test_make_gaussians_pixel ( convolved_gaussians)

Definition at line 154 of file test_image.py.

154def test_make_gaussians_pixel(convolved_gaussians):
155 output = g2d.make_gaussians_pixel_D(convolved_gaussians, n_rows=5, n_cols=7)
156 assert np.sum(output.data) > 0

◆ test_numpy_Image()

test_image.test_numpy_Image ( )

Definition at line 54 of file test_image.py.

54def test_numpy_Image():
55 data = np.arange(12).astype(np.int32).reshape((3, 4))
56 img = g2d.ImageI(data)
57
58 data[0, 0] = -1
59 assert img.get_value(0, 0) == -1
60 assert img.get_value_unchecked(0, 2) == 2
61 assert data[0, 2] == 2
62
63 assert (img.n_rows, img.n_cols) == data.shape
64 assert tuple(img.shape) == data.shape
65 assert img.size == data.size
66
67 with pytest.raises(IndexError):
68 img.get_value(3, 0)
69 with pytest.raises(IndexError):
70 img.get_value(0, 4)
71 with pytest.raises(TypeError):
72 img.get_value(0, -1)
73 with pytest.raises(TypeError):
74 img.get_value(-1, 0)
75
76

Variable Documentation

◆ check_str_repr

str test_image.check_str_repr = "linux" in sys.platform

Definition at line 30 of file test_image.py.

◆ prefix_namespace

str test_image.prefix_namespace = "lsst.gauss2d."

Definition at line 28 of file test_image.py.