Skip to content

Commit

Permalink
Black 24
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanconn committed Mar 4, 2024
1 parent 4caadd6 commit b062c0c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
31 changes: 18 additions & 13 deletions proseco/acq.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def box_overlap(y1, z1, halfw1, y2, z2, halfw2, overlap_pad=20):
)



def load_maxmags() -> dict:
"""
Load maxmags from disk.
Expand Down Expand Up @@ -711,19 +710,22 @@ def select_best_p_acqs(self, cand_acqs, min_p_acq, acq_indices, box_sizes):

# If this box size could overlap with the box of an already selected star
# then skip it.
if (os.environ.get("PROSECO_ACQ_OVERLAP_PENALTY") == "True"):
if os.environ.get("PROSECO_ACQ_OVERLAP_PENALTY") == "True":
has_overlap = False
for other_idx, halfw2 in zip(acq_indices, box_sizes):
other_acq = cand_acqs[other_idx]
halfw1 = box_size
y1, z1 = acq["yang"], acq["zang"]
y2, z2 = other_acq["yang"], other_acq["zang"]
if box_overlap(y1, z1, halfw1, y2, z2, halfw2):
self.log(f"Skipping Star {acq_idx:2d} box {box_size:3d}, "
"possible overlap with already selected star "
f"{other_acq['id']}", level=2)
has_overlap = True
break
self.log(
f"Skipping Star {acq_idx:2d} box {box_size:3d}, "
"possible overlap with already selected star "
f"{other_acq['id']}",
level=2,
)
has_overlap = True
break
if has_overlap:
continue

Expand Down Expand Up @@ -939,12 +941,15 @@ def calc_p_safe(self, verbose=False):

# Check for overlapping boxes and if so, reduce the probability of
# acquiring the star.
if (os.environ.get("PROSECO_ACQ_OVERLAP_PENALTY") == "True"):
penalties = self.get_overlap_penalties()
if np.count_nonzero(penalties):
self.log("Overlapping boxes detected, applying penalty", level=1)
self.log(f"{penalties}", level=1)
p_acqs = [p_acq * (1 - penalty) for p_acq, penalty in zip(p_acqs, penalties)]
if os.environ.get("PROSECO_ACQ_OVERLAP_PENALTY") == "True":
penalties = self.get_overlap_penalties()
if np.count_nonzero(penalties):
self.log("Overlapping boxes detected, applying penalty", level=1)
self.log(f"{penalties}", level=1)
p_acqs = [
p_acq * (1 - penalty)
for p_acq, penalty in zip(p_acqs, penalties)
]

p_n_cum = prob_n_acq(p_acqs)[1] # This returns (p_n, p_n_cum)

Expand Down
6 changes: 3 additions & 3 deletions proseco/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,9 +669,9 @@ def dark(self, value):
# Set pixel regions from ACA.bad_pixels to have acqs.dark=700000 (5.0 mag
# star) per pixel.
for r0, r1, c0, c1 in ACA.bad_pixels:
self._dark[
r0 + 512 : r1 + 513, c0 + 512 : c1 + 513
] = ACA.bad_pixel_dark_current
self._dark[r0 + 512 : r1 + 513, c0 + 512 : c1 + 513] = (
ACA.bad_pixel_dark_current
)

def set_attrs_from_kwargs(self, **kwargs):
for name, val in kwargs.items():
Expand Down
6 changes: 3 additions & 3 deletions proseco/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ def process_monitors(self):
"MFX" if monitor["function"] == MonFunc.MON_FIXED else "MTR"
)
mon["sz"] = "8x8"
mon[
"dim"
] = -999 # Set an obviously bad value for DTS, gets fixed later.
mon["dim"] = (
-999
) # Set an obviously bad value for DTS, gets fixed later.
mon["res"] = 0
mon["halfw"] = 20
mon["maxmag"] = ACA.monitor_maxmag
Expand Down

0 comments on commit b062c0c

Please sign in to comment.