Skip to content

Commit

Permalink
Merge pull request #1343 from rzellem/develop
Browse files Browse the repository at this point in the history
Release EXOTIC 4.2.3 Hotfix: Fix TypeError for noisy or drifting background imaging
  • Loading branch information
tamimfatahi authored Nov 5, 2024
2 parents 53b32e2 + 65def6a commit c0ff449
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions exotic/exotic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1245,16 +1245,28 @@ def fcn2min(pars):

# Method calculates the flux of the star (uses the skybg_phot method to do background sub)
def aperPhot(data, starIndex, xc, yc, r=5, dr=5):
if dr > 0 and not np.isnan(xc) and not np.isnan(yc):
# Check for invalid coordinates
if np.isnan(xc) or np.isnan(yc):
return 0, 0

# Calculate background if dr > 0
if dr > 0:
bgflux, sigmabg, Nbg = skybg_phot(data, starIndex, xc, yc, r + 2, dr)
else:
bgflux, sigmabg, Nbg = 0, 0, 0


# Create aperture and mask
aperture = CircularAperture(positions=[(xc, yc)], r=r)
mask = aperture.to_mask(method='exact')[0]
data_cutout = mask.cutout(data)

# Check if aperture is valid
if data_cutout is None:
# Aperture is partially or fully outside the image
return 0, bgflux # Return zero flux but valid background

# Calculate and return aperture sum
aperture_sum = (mask.data * (data_cutout - bgflux)).sum()

return aperture_sum, bgflux


Expand Down
2 changes: 1 addition & 1 deletion exotic/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '4.2.2'
__version__ = '4.2.3'

0 comments on commit c0ff449

Please sign in to comment.