-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #299 from Ciela-Institute/dev
Dev
- Loading branch information
Showing
9 changed files
with
1,595 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,7 @@ jobs: | |
ls -ltrh | ||
ls -ltrh dist | ||
- name: Publish to Test PyPI | ||
uses: pypa/[email protected].2 | ||
uses: pypa/[email protected].3 | ||
with: | ||
repository-url: https://test.pypi.org/legacy/ | ||
verbose: true | ||
|
@@ -95,5 +95,5 @@ jobs: | |
name: artifact | ||
path: dist | ||
|
||
- uses: pypa/[email protected].2 | ||
- uses: pypa/[email protected].3 | ||
if: startsWith(github.ref, 'refs/tags') |
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
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,50 @@ | ||
import torch | ||
import numpy as np | ||
import lenstronomy.Util.param_util as param_util | ||
from lenstronomy.LensModel.lens_model import LensModel | ||
|
||
import caustics | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize("q", [0.5, 0.7, 0.9]) | ||
@pytest.mark.parametrize("phi", [0.0, np.pi / 3, np.pi / 2]) | ||
@pytest.mark.parametrize("bx,by", [(0.1, -0.05), (0.2, 0.1), (0.0, 0.0)]) | ||
def test_time_delay_pointsource(q, phi, bx, by): | ||
|
||
# configuration parameters | ||
bx = torch.tensor(bx) | ||
by = torch.tensor(by) | ||
z_l = torch.tensor(0.5) | ||
z_s = torch.tensor(1.0) | ||
|
||
# Define caustics lens | ||
cosmo = caustics.FlatLambdaCDM(name="cosmo") | ||
lens = caustics.SIE(cosmology=cosmo, z_l=z_l, x0=0.0, y0=0.0, q=q, phi=phi, b=1.0) | ||
x, y = lens.forward_raytrace(bx, by, z_s) | ||
|
||
# Define lenstronomy lens | ||
lens_model_list = ["SIE"] | ||
lens_ls = LensModel( | ||
lens_model_list=lens_model_list, z_lens=z_l.item(), z_source=z_s.item() | ||
) | ||
e1, e2 = param_util.phi_q2_ellipticity(phi=phi, q=q) | ||
kwargs_ls = [{"theta_E": 1.0, "e1": e1, "e2": e2, "center_x": 0.0, "center_y": 0.0}] | ||
|
||
# Compute time delay caustics | ||
tdc = lens.time_delay(x, y, z_s).detach().cpu().numpy() | ||
tdc = tdc - np.min(tdc) | ||
np.sort(tdc) | ||
|
||
# Compute time delay lenstronomy | ||
time_delays = lens_ls.arrival_time( | ||
x.detach().cpu().numpy(), | ||
y.detach().cpu().numpy(), | ||
kwargs_ls, | ||
) | ||
time_delays = time_delays - np.min(time_delays) | ||
np.sort(time_delays) | ||
|
||
# Compare time delays | ||
assert np.allclose(tdc, time_delays, atol=1e-3) |