LSST Applications g0f08755f38+9c285cab97,g1635faa6d4+13f3999e92,g1653933729+a8ce1bb630,g1a0ca8cf93+bf6eb00ceb,g28da252d5a+0829b12dee,g29321ee8c0+5700dc9eac,g2bbee38e9b+9634bc57db,g2bc492864f+9634bc57db,g2cdde0e794+c2c89b37c4,g3156d2b45e+41e33cbcdc,g347aa1857d+9634bc57db,g35bb328faa+a8ce1bb630,g3a166c0a6a+9634bc57db,g3e281a1b8c+9f2c4e2fc3,g414038480c+077ccc18e7,g41af890bb2+fde0dd39b6,g5fbc88fb19+17cd334064,g781aacb6e4+a8ce1bb630,g80478fca09+55a9465950,g82479be7b0+d730eedb7d,g858d7b2824+9c285cab97,g9125e01d80+a8ce1bb630,g9726552aa6+10f999ec6a,ga5288a1d22+2a84bb7594,gacf8899fa4+c69c5206e8,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc28159a63d+9634bc57db,gcf0d15dbbd+4b7d09cae4,gda3e153d99+9c285cab97,gda6a2b7d83+4b7d09cae4,gdaeeff99f8+1711a396fd,ge2409df99d+5e831397f4,ge79ae78c31+9634bc57db,gf0baf85859+147a0692ba,gf3967379c6+41c94011de,gf3fb38a9a8+8f07a9901b,gfb92a5be7c+9c285cab97,w.2024.46
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.