Skip to content

Commit

Permalink
Fix further missed renamed references in the new code.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DinoBektesevic committed Sep 25, 2023
1 parent c3de134 commit 470ace2
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/kbmod/fake_data_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/kbmod/search/layered_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion src/kbmod/search/pydocs/raw_image_docs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
11 changes: 6 additions & 5 deletions src/kbmod/search/raw_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ namespace search {
}
}

std::vector<float> RawImage::bilinearInterp(float x, float y) const {
std::vector<float> 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
Expand Down Expand Up @@ -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<float> iv = bilinearInterp(x, y);
std::vector<float> 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]);
Expand All @@ -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<float>(width) || y > static_cast<float>(height)))
return NO_DATA;
std::vector<float> iv = bilinearInterp(x, y);
std::vector<float> 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]);
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/kbmod/search/raw_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<float> bilinearInterp(float x, float y) const;
void add_pixel_interp(float x, float y, float value);
std::vector<float> bilinear_interp(float x, float y) const;

// Grow the area of masked pixels.
void grow_mask(int steps);
Expand Down
4 changes: 2 additions & 2 deletions tests/test_layered_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_psf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 470ace2

Please sign in to comment.