Skip to content

Commit

Permalink
Be more strict about bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanconn committed Nov 25, 2024
1 parent 7567d50 commit 1489787
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions chandra_aca/aca_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,9 @@ def get_aca_images(
- 'IMG_DARK': dark current image
- 'T_CCD_SMOOTH': smoothed CCD temperature
The IMG_DARK individual values are only calculated if within the 1024x1024
dark current map, otherwise they are set to 0. In practice this is not an
issue in that IMG and IMG_BGSUB must be within the CCD to be tracked.
Parameters
----------
Expand Down
10 changes: 8 additions & 2 deletions chandra_aca/dark_subtract.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,20 @@ def get_dark_backgrounds(raw_dark_img, imgrow0, imgcol0, size=8):
imgs_dark : np.array
The dark backgrounds in e-/s for the ACA images sampled from raw_dark_img.
This will have the same length as imgrow0 and imgcol0, with shape
(len(imgrow0), size, size). These pixels have not been scaled.
(len(imgrow0), size, size). These pixels have not been scaled. Pixels
outside the raw_dark_img are set to 0.
"""

# Borrowed from the agasc code
@numba.jit(nopython=True)
def staggered_aca_slice(array_in, array_out, row, col):
for i in np.arange(len(row)):
if row[i] + size < 1024 and col[i] + size < 1024:
if (
row[i] >= 0
and row[i] + size < 1024
and col[i] >= 0
and col[i] + size < 1024
):
array_out[i] = array_in[row[i] : row[i] + size, col[i] : col[i] + size]

imgs_dark = np.zeros([len(imgrow0), size, size], dtype=np.float64)
Expand Down

0 comments on commit 1489787

Please sign in to comment.