Skip to content

Commit

Permalink
Remove compute_fraction_masked
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremykubica committed Dec 16, 2024
1 parent 7791cfa commit 32db854
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 42 deletions.
15 changes: 0 additions & 15 deletions src/kbmod/search/layered_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,19 +196,6 @@ RawImage LayeredImage::generate_phi_image() {
return result;
}

double LayeredImage::compute_fraction_masked() const {
double masked_count = 0.0;
double total_count = 0.0;

for (int j = 0; j < height; ++j) {
for (int i = 0; i < width; ++i) {
if (!science_pixel_has_data({j, i})) masked_count += 1.0;
total_count++;
}
}
return masked_count / total_count;
}

#ifdef Py_PYTHON_H
static void layered_image_bindings(py::module& m) {
using li = search::LayeredImage;
Expand Down Expand Up @@ -268,8 +255,6 @@ static void layered_image_bindings(py::module& m) {
.def("get_npixels", &li::get_npixels, pydocs::DOC_LayeredImage_get_npixels)
.def("get_obstime", &li::get_obstime, pydocs::DOC_LayeredImage_get_obstime)
.def("set_obstime", &li::set_obstime, pydocs::DOC_LayeredImage_set_obstime)
.def("compute_fraction_masked", &li::compute_fraction_masked,
pydocs::DOC_LayeredImage_compute_fraction_masked)
.def("generate_psi_image", &li::generate_psi_image, pydocs::DOC_LayeredImage_generate_psi_image)
.def("generate_phi_image", &li::generate_phi_image, pydocs::DOC_LayeredImage_generate_phi_image);
}
Expand Down
3 changes: 0 additions & 3 deletions src/kbmod/search/layered_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ class LayeredImage {
RawImage generate_psi_image();
RawImage generate_phi_image();

// Debugging and statistics functions.
double compute_fraction_masked() const;

private:
unsigned width;
unsigned height;
Expand Down
10 changes: 0 additions & 10 deletions src/kbmod/search/pydocs/layered_image_docs.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,6 @@ static const auto DOC_LayeredImage_generate_phi_image = R"doc(
A ``RawImage`` of the same dimensions as the ``LayeredImage``.
)doc";

static const auto DOC_LayeredImage_compute_fraction_masked = R"doc(
Computes the fraction of pixels in the layered image that are masked.
This can be used for debugging purposes.
Returns
-------
value : `double`
The fraction of pixels in the science image that are masked.
)doc";

} // namespace pydocs

#endif /* LAYEREDIMAGE_DOCS */
14 changes: 0 additions & 14 deletions tests/test_layered_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,20 +181,6 @@ def test_mask_pixel(self):
self.assertEqual(pixel_value_valid(pix_val), expected)
self.assertEqual(self.image.science_pixel_has_data(y, x), expected)

def test_compute_fraction_masked(self):
total_pixels = self.width * self.height

# Mask 50 pixels
for y in range(0, 10):
for x in range(0, 5):
self.image.mask_pixel(y, x)
self.assertAlmostEqual(self.image.compute_fraction_masked(), 50.0 / total_pixels)

# Mask another 25 pixels.
for x in range(3, 28):
self.image.mask_pixel(12, x)
self.assertAlmostEqual(self.image.compute_fraction_masked(), 75.0 / total_pixels)

def test_binarize_mask(self):
# Mask out a range of pixels.
mask = self.image.get_mask()
Expand Down

0 comments on commit 32db854

Please sign in to comment.