Skip to content

Commit

Permalink
Merge pull request #690 from dirac-institute/runner/masking
Browse files Browse the repository at this point in the history
Obsolete the old masking
  • Loading branch information
DinoBektesevic authored Aug 29, 2024
2 parents a8e9663 + d74a124 commit cce30c5
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 282 deletions.
28 changes: 0 additions & 28 deletions src/kbmod/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,6 @@ class SearchConfiguration:
def __init__(self):
self._required_params = set()

default_mask_bits_dict = {
"BAD": 0,
"CLIPPED": 9,
"CR": 3,
"CROSSTALK": 10,
"DETECTED": 5,
"DETECTED_NEGATIVE": 6,
"EDGE": 4,
"INEXACT_PSF": 11,
"INTRP": 2,
"NOT_DEBLENDED": 12,
"NO_DATA": 8,
"REJECTED": 13,
"SAT": 1,
"SENSOR_EDGE": 14,
"SUSPECT": 7,
"UNMASKEDNAN": 15,
}
default_flag_keys = ["BAD", "EDGE", "NO_DATA", "SUSPECT", "UNMASKEDNAN"]
default_repeated_flag_keys = []

self._params = {
"ang_arr": [math.pi / 15, math.pi / 15, 128],
"average_angle": None,
Expand All @@ -53,7 +32,6 @@ def __init__(self):
"do_stamp_filter": True,
"eps": 0.03,
"encode_num_bytes": -1,
"flag_keys": default_flag_keys,
"generator_config": None,
"gpu_filter": False,
"ind_output_files": True,
Expand All @@ -62,11 +40,6 @@ def __init__(self):
"known_obj_thresh": None,
"known_obj_jpl": False,
"lh_level": 10.0,
"mask_bits_dict": default_mask_bits_dict,
"mask_bit_vector": None,
"mask_grow": 10,
"mask_num_images": 2,
"mask_threshold": None,
"max_lh": 1000.0,
"mjd_lims": None,
"mom_lims": [35.5, 35.5, 2.0, 0.3, 0.3],
Expand All @@ -75,7 +48,6 @@ def __init__(self):
"peak_offset": [2.0, 2.0],
"psf_val": 1.4,
"psf_file": None,
"repeated_flag_keys": default_repeated_flag_keys,
"res_filepath": None,
"result_filename": None,
"results_per_pixel": 8,
Expand Down
122 changes: 0 additions & 122 deletions src/kbmod/masking.py

This file was deleted.

5 changes: 3 additions & 2 deletions src/kbmod/run_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from .filters.clustering_filters import apply_clustering
from .filters.sigma_g_filter import apply_clipped_sigma_g, SigmaGClipping
from .filters.stamp_filters import append_all_stamps, append_coadds, get_coadds_and_filter_results
from .masking import apply_mask_operations

from .results import Results
from .trajectory_generator import create_trajectory_generator, KBMODV1SearchConfig
from .wcs_utils import calc_ecliptic_angle
Expand Down Expand Up @@ -233,7 +233,8 @@ def run_search(self, config, stack, trj_generator=None):

# Apply the mask to the images.
if config["do_mask"]:
stack = apply_mask_operations(config, stack)
for i in range(stack.img_count()):
stack.get_single_image(i).apply_mask(0xFFFFFF)

# Perform the actual search.
if trj_generator is None:
Expand Down
5 changes: 0 additions & 5 deletions src/kbmod/trajectory_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from kbmod.configuration import SearchConfiguration
from kbmod.filters.sigma_g_filter import apply_clipped_sigma_g, SigmaGClipping
from kbmod.masking import apply_mask_operations
from kbmod.results import Results
from kbmod.search import StackSearch, StampCreator, Logging
from kbmod.filters.stamp_filters import append_all_stamps, append_coadds
Expand Down Expand Up @@ -48,10 +47,6 @@ def initialize_data(self):
if self._data_initalized:
return

# Check if we need to apply legacy masking.
if self.config["do_mask"]:
self.im_stack = apply_mask_operations(self.config, self.im_stack)

# If we are using an encoded image representation on GPU, enable it and
# set the parameters.
if self.config["encode_num_bytes"] > 0:
Expand Down
11 changes: 0 additions & 11 deletions tests/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def test_to_hdu(self):
"im_filepath": "Here2",
"num_obs": 5,
"cluster_type": None,
"mask_bits_dict": {"bit1": 1, "bit2": 2},
"do_clustering": False,
"res_filepath": "There",
"ang_arr": [1.0, 2.0, 3.0],
Expand All @@ -82,7 +81,6 @@ def test_to_hdu(self):
self.assertEqual(hdu.data["im_filepath"][0], "Here2\n...")
self.assertEqual(hdu.data["num_obs"][0], "5\n...")
self.assertEqual(hdu.data["cluster_type"][0], "null\n...")
self.assertEqual(hdu.data["mask_bits_dict"][0], "{bit1: 1, bit2: 2}")
self.assertEqual(hdu.data["res_filepath"][0], "There\n...")
self.assertEqual(hdu.data["ang_arr"][0], "[1.0, 2.0, 3.0]")

Expand All @@ -91,7 +89,6 @@ def test_to_yaml(self):
"im_filepath": "Here2",
"num_obs": 5,
"cluster_type": None,
"mask_bits_dict": {"bit1": 1, "bit2": 2},
"do_clustering": False,
"res_filepath": "There",
"ang_arr": [1.0, 2.0, 3.0],
Expand All @@ -103,8 +100,6 @@ def test_to_yaml(self):
self.assertEqual(yaml_dict["im_filepath"], "Here2")
self.assertEqual(yaml_dict["num_obs"], 5)
self.assertEqual(yaml_dict["cluster_type"], None)
self.assertEqual(yaml_dict["mask_bits_dict"]["bit1"], 1)
self.assertEqual(yaml_dict["mask_bits_dict"]["bit2"], 2)
self.assertEqual(yaml_dict["res_filepath"], "There")
self.assertEqual(yaml_dict["ang_arr"][0], 1.0)
self.assertEqual(yaml_dict["ang_arr"][1], 2.0)
Expand All @@ -117,7 +112,6 @@ def test_save_and_load_yaml(self):
# Overwrite some defaults.
config.set("im_filepath", "Here")
config.set("output_suffix", "txt")
config.set("mask_grow", 5)

with tempfile.TemporaryDirectory() as dir_name:
file_path = os.path.join(dir_name, "tmp_config_data.yaml")
Expand All @@ -139,7 +133,6 @@ def test_save_and_load_yaml(self):
self.assertEqual(len(config2._params), num_defaults)
self.assertEqual(config2["im_filepath"], "Here")
self.assertEqual(config2["res_filepath"], None)
self.assertEqual(config2["mask_grow"], 5)
self.assertEqual(config2["output_suffix"], "txt")

def test_save_and_load_fits(self):
Expand All @@ -149,8 +142,6 @@ def test_save_and_load_fits(self):
# Overwrite some defaults.
config.set("im_filepath", "Here2")
config.set("output_suffix", "csv")
config.set("mask_grow", 7)
config.set("mask_bits_dict", {"bit1": 1, "bit2": 2})

with tempfile.TemporaryDirectory() as dir_name:
file_path = os.path.join(dir_name, "test.fits")
Expand All @@ -172,11 +163,9 @@ def test_save_and_load_fits(self):

self.assertEqual(len(config2._params), num_defaults)
self.assertEqual(config2["im_filepath"], "Here2")
self.assertEqual(config2["mask_grow"], 7)
self.assertEqual(config2["output_suffix"], "csv")

# Check that we correctly parse dictionaries and Nones.
self.assertEqual(len(config2["mask_bits_dict"]), 2)
self.assertIsNone(config2["res_filepath"])


Expand Down
Loading

0 comments on commit cce30c5

Please sign in to comment.