From 4e59b2eb4d8f7970c83dc34adbfd714d56c52128 Mon Sep 17 00:00:00 2001 From: DinoBektesevic Date: Sun, 24 Sep 2023 23:48:35 -0700 Subject: [PATCH] Fix further missed renamed references in the new code. It seems there were more than a few items I missed renaming during the rebase and I fat-fingered a couple of , instead of a . Fixes bindings for add_pixel_interp in RawImage. --- src/kbmod/fake_data_creator.py | 2 +- src/kbmod/search/layered_image.cpp | 2 +- src/kbmod/search/pydocs/raw_image_docs.h | 7 ++++++- src/kbmod/search/raw_image.cpp | 11 ++++++----- src/kbmod/search/raw_image.h | 4 ++-- tests/test_layered_image.py | 4 ++-- tests/test_psf.py | 2 +- tests/test_search.py | 4 ++-- 8 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/kbmod/fake_data_creator.py b/src/kbmod/fake_data_creator.py index 69d70fb6..9f2cb16e 100644 --- a/src/kbmod/fake_data_creator.py +++ b/src/kbmod/fake_data_creator.py @@ -31,7 +31,7 @@ def add_fake_object(img, x, y, flux, psf=None): psf : PointSpreadFunc The PSF for the image. """ - if type(img) is layered_image: + if type(img) is LayeredImage: sci = img.get_science() else: sci = img diff --git a/src/kbmod/search/layered_image.cpp b/src/kbmod/search/layered_image.cpp index 23b98200..f741957e 100644 --- a/src/kbmod/search/layered_image.cpp +++ b/src/kbmod/search/layered_image.cpp @@ -247,7 +247,7 @@ namespace search { .def("set_mask", &li::set_mask, pydocs::DOC_LayeredImage_set_mask) .def("set_variance", &li::set_variance, pydocs::DOC_LayeredImage_set_variance) .def("convolve_psf", &li::convolve_psf, pydocs::DOC_LayeredImage_convolve_psf) - .def("convolve_given_psf", &li::convolve_psf, pydocs::DOC_LayeredImage_convolve_given_psf) + .def("convolve_given_psf", &li::convolve_given_psf, pydocs::DOC_LayeredImage_convolve_given_psf) .def("grow_mask", &li::grow_mask, pydocs::DOC_LayeredImage_grow_mask) .def("get_name", &li::get_name, pydocs::DOC_LayeredImage_get_name) .def("get_width", &li::get_width, pydocs::DOC_LayeredImage_get_width) diff --git a/src/kbmod/search/pydocs/raw_image_docs.h b/src/kbmod/search/pydocs/raw_image_docs.h index 91d92fec..dead1012 100644 --- a/src/kbmod/search/pydocs/raw_image_docs.h +++ b/src/kbmod/search/pydocs/raw_image_docs.h @@ -59,7 +59,12 @@ namespace pydocs{ )doc"; static const auto DOC_RawImage_add_pixel = R"doc( - Add to the value of a given pixel. + Add to the raw value of a given pixel. + )doc"; + + static const auto DOC_RawImage_add_pixel_interp = R"doc( + Add to the value calculated by bilinear interpolation + of the neighborhood of the given pixel position. )doc"; static const auto DOC_RawImage_apply_mask = R"doc( diff --git a/src/kbmod/search/raw_image.cpp b/src/kbmod/search/raw_image.cpp index d981132d..af4ef2e5 100644 --- a/src/kbmod/search/raw_image.cpp +++ b/src/kbmod/search/raw_image.cpp @@ -307,7 +307,7 @@ namespace search { } } - std::vector RawImage::bilinearInterp(float x, float y) const { + std::vector RawImage::bilinear_interp(float x, float y) const { // Linear interpolation // Find the 4 pixels (aPix, bPix, cPix, dPix) // that the corners (a, b, c, d) of the @@ -346,13 +346,13 @@ namespace search { // make sure the right amount has been distributed float diff = std::abs(a_amt + b_amt + c_amt + d_amt - 1.0); - if (diff > 0.01) std::cout << "warning: bilinearInterpSum == " << diff << "\n"; + if (diff > 0.01) std::cout << "warning: bilinear_interpSum == " << diff << "\n"; return {a_px, a_py, a_amt, b_px, b_py, b_amt, c_px, c_py, c_amt, d_px, d_py, d_amt}; } - void RawImage::addPixelInterp(float x, float y, float value) { + void RawImage::add_pixel_interp(float x, float y, float value) { // Interpolation values - std::vector iv = bilinearInterp(x, y); + std::vector iv = bilinear_interp(x, y); add_to_pixel(iv[0], iv[1], value * iv[2]); add_to_pixel(iv[3], iv[4], value * iv[5]); @@ -370,7 +370,7 @@ namespace search { float RawImage::get_pixel_interp(float x, float y) const { if ((x < 0.0 || y < 0.0) || (x > static_cast(width) || y > static_cast(height))) return NO_DATA; - std::vector iv = bilinearInterp(x, y); + std::vector iv = bilinear_interp(x, y); float a = get_pixel(iv[0], iv[1]); float b = get_pixel(iv[3], iv[4]); float c = get_pixel(iv[6], iv[7]); @@ -653,6 +653,7 @@ namespace search { .def("create_stamp", &ri::create_stamp, pydocs:: DOC_RawImage_create_stamp) .def("set_pixel", &ri::set_pixel, pydocs:: DOC_RawImage_set_pixel) .def("add_pixel", &ri::add_to_pixel, pydocs:: DOC_RawImage_add_pixel) + .def("add_pixel_interp", &ri::add_pixel_interp, pydocs:: DOC_RawImage_add_pixel_interp) .def("apply_mask", &ri::apply_mask, pydocs:: DOC_RawImage_apply_mask) .def("grow_mask", &ri::grow_mask, pydocs:: DOC_RawImage_grow_mask) .def("pixel_has_data", &ri::pixel_has_data, pydocs:: DOC_RawImage_pixel_has_data) diff --git a/src/kbmod/search/raw_image.h b/src/kbmod/search/raw_image.h index e2c487f7..cf43d0cf 100644 --- a/src/kbmod/search/raw_image.h +++ b/src/kbmod/search/raw_image.h @@ -75,8 +75,8 @@ namespace search { void set_all_pix(float value); void add_to_pixel(float fx, float fy, float value); - void addPixelInterp(float x, float y, float value); - std::vector bilinearInterp(float x, float y) const; + void add_pixel_interp(float x, float y, float value); + std::vector bilinear_interp(float x, float y) const; // Grow the area of masked pixels. void grow_mask(int steps); diff --git a/tests/test_layered_image.py b/tests/test_layered_image.py index ece678d5..8dbcd702 100644 --- a/tests/test_layered_image.py +++ b/tests/test_layered_image.py @@ -79,10 +79,10 @@ def test_convolve_psf(self): msk0 = self.image.get_mask() # Create a copy of the image. - img_b = layered_image(sci0, var0, msk0, self.p) + img_b = LayeredImage(sci0, var0, msk0, self.p) # A no-op PSF does not change the image. - img_b.convolve_given_psf(psf()) + img_b.convolve_given_psf(PSF()) sci1 = img_b.get_science() var1 = img_b.get_variance() for y in range(img_b.get_height()): diff --git a/tests/test_psf.py b/tests/test_psf.py index 4c7fad70..f8cecb58 100644 --- a/tests/test_psf.py +++ b/tests/test_psf.py @@ -10,7 +10,7 @@ def setUp(self): self.psf_list = [PSF(x / 5 + 0.2) for x in sigma_list] def test_make_noop(self): - psf0 = psf() + psf0 = PSF() self.assertEqual(psf0.get_size(), 1) self.assertEqual(psf0.get_dim(), 1) self.assertEqual(psf0.get_radius(), 0) diff --git a/tests/test_search.py b/tests/test_search.py index 054ba0b9..e06a76d8 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -60,7 +60,7 @@ def setUp(self): add_fake_object( im, self.start_x + time * self.vxel + 0.5, - self.start_y + time * self.vyvel + 0.5, + self.start_y + time * self.vyel + 0.5, self.object_flux, self.p, ) @@ -100,7 +100,7 @@ def test_psiphi(self): # Image2 has a single object and a masked pixel. image2 = LayeredImage("test2", 5, 10, 2.0, 4.0, 2.0, p) add_fake_object(image2, 2.5, 4.5, 400.0, p) - + mask = image2.get_mask() mask.set_pixel(4, 9, 1) image2.set_mask(mask)