forked from lenstronomy/lenstronomy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding total_flux() for Hernquist light profiles
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from lenstronomy.LightModel.Profiles.hernquist import Hernquist, HernquistEllipse | ||
from lenstronomy.Util.util import make_grid | ||
import numpy as np | ||
import numpy.testing as npt | ||
|
||
|
||
class TestHernquist(object): | ||
|
||
def setup_method(self): | ||
self.hernquist = Hernquist() | ||
self.hernquist_ellipse = HernquistEllipse() | ||
|
||
def test_total_flux(self): | ||
delta_pix = 0.2 | ||
x, y = make_grid(numPix=1000, deltapix=delta_pix) | ||
|
||
rs, amp = 1, 1 | ||
total_flux = self.hernquist.total_flux(amp=amp, Rs=rs) | ||
flux = self.hernquist.function(x, y, amp=amp, Rs=rs) | ||
total_flux_numerics = np.sum(flux) * delta_pix**2 | ||
npt.assert_almost_equal(total_flux_numerics/total_flux, 1, decimal=1) | ||
|
||
total_flux_ellipse = self.hernquist_ellipse.total_flux(amp=amp, Rs=rs) | ||
npt.assert_almost_equal(total_flux_ellipse, total_flux) | ||
|
||
|