Skip to content

Commit

Permalink
fix: clip at 1e-9 instead of 1e-5 and enable njit again
Browse files Browse the repository at this point in the history
  • Loading branch information
zonca committed Dec 21, 2024
1 parent f6d6424 commit 9afa982
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/pysm3/models/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ def aggregate(index, array, values):
for i, v in zip(index, values):
array[i] += v


@njit
def fwhm2sigma(fwhm):
"""Converts the Full Width Half Maximum of a Gaussian beam to its standard deviation"""
return fwhm / (2.0 * np.sqrt(2.0 * np.log(2.0)))


# njit fails with the np.clip function
@njit
def flux2amp(flux, fwhm):
"""Converts the total flux of a radio source to the peak amplitude of its Gaussian
beam representation, taking into account the width of the beam as specified
Expand All @@ -65,8 +65,9 @@ def flux2amp(flux, fwhm):
sigma = fwhm2sigma(fwhm)
amp = flux / (2 * np.pi * sigma**2)
# sim_objects fails if amp is zero
amp[np.logical_and(amp < 1e-5, amp > 0)] = 1e-5
amp[np.logical_and(amp > -1e-5, amp < 0)] = -1e-5
c = 1e-9 # minimum amplitude
amp[np.logical_and(amp < c, amp > 0)] = c
amp[np.logical_and(amp > -c, amp < 0)] = -c
return amp


Expand Down

0 comments on commit 9afa982

Please sign in to comment.