Skip to content

Commit 382ca20

Browse files
authored
Merge pull request #60 from aymgal/pr-convergence-profile
Add new mass profile: convergence sheet
2 parents 0e33fc3 + 0d0c011 commit 382ca20

File tree

3 files changed

+64
-3
lines changed

3 files changed

+64
-3
lines changed

coolest/api/profiles/mass.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from scipy import special
66

77
from coolest.template.classes.profiles.mass import (PEMD as TemplatePEMD,
8-
ExternalShear as TemplateExternalShear)
8+
ExternalShear as TemplateExternalShear,
9+
ConvergenceSheet as TemplateConvergenceSheet)
910
from coolest.api.profiles import util
1011

1112

@@ -151,11 +152,13 @@ def hessian(self, x, y, theta_E=1., gamma=2., phi=0., q=1., center_x=0., center_
151152

152153

153154
class ExternalShear(BaseMassProfile):
155+
"""
156+
Coordinates of the origin for the external shear profile are assumed to be (0., 0.).
157+
"""
154158

155159
_template_class = TemplateExternalShear()
156160

157161
def deflection(self, x, y, gamma_ext=0., phi_ext=0.):
158-
"""coordinates of the origin for the external shear profile assumed to be (0., 0.)"""
159162
phi_ext_ = util.eastofnorth2normalradians(phi_ext)
160163
gamma1 = gamma_ext * np.cos(2.*phi_ext_)
161164
gamma2 = gamma_ext * np.sin(2.*phi_ext_)
@@ -178,3 +181,35 @@ def hessian(self, x, y, gamma_ext=0., phi_ext=0.):
178181
H_xy = gamma2
179182
H_yx = H_xy
180183
return H_xx, H_xy, H_yx, H_yy
184+
185+
186+
class ConvergenceSheet(BaseMassProfile):
187+
"""
188+
Coordinates of the origin for the convergence sheet are assumed to be (0., 0.).
189+
"""
190+
191+
_template_class = TemplateConvergenceSheet()
192+
193+
def potential(self, x, y, kappa_s=0.):
194+
x_ = x # no shift
195+
y_ = y # no shift
196+
r_ = np.hypot(x_, y_)
197+
return 0.5 * kappa_s * r_**2
198+
199+
def deflection(self, x, y, kappa_s=0.):
200+
x_ = x # no shift
201+
y_ = y # no shift
202+
return x_ * kappa_s, y_ * kappa_s
203+
204+
def convergence(self, x, y, kappa_s=0.):
205+
return np.full_like(x, kappa_s)
206+
207+
def hessian(self, x, y, kappa_s=0.):
208+
kappa = np.full_like(x, kappa_s)
209+
gamma1 = 0.
210+
gamma2 = 0.
211+
H_xx = kappa + gamma1
212+
H_yy = kappa - gamma1
213+
H_xy = gamma2
214+
H_yx = H_xy
215+
return H_xx, H_xy, H_yx, H_yy

coolest/template/classes/profiles/mass.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
'NFW',
1616
'Chameleon',
1717
'ExternalShear',
18+
'ConvergenceSheet',
1819
'PixelatedRegularGridPotential',
1920
]
2021
SUPPORTED_CHOICES = __all__
@@ -252,6 +253,7 @@ def __init__(self):
252253

253254
class ExternalShear(AnalyticalProfile):
254255
"""External shear defined with a strength and orientation.
256+
The 'origin' of the external shear is by convention fixed to coordinates (0, 0).
255257
256258
This profile is described by the following parameters:
257259
@@ -271,6 +273,26 @@ def __init__(self):
271273
super().__init__(parameters)
272274

273275

276+
class ConvergenceSheet(AnalyticalProfile):
277+
"""Convergence 'sheet', infinite and uniform mass density profile.
278+
The 'origin' of the convergence sheet is by convention fixed to coordinates (0, 0).
279+
280+
This profile is described by the following parameters:
281+
282+
- 'kappa_s': convergence of the uniform mass density sheet
283+
"""
284+
285+
def __init__(self):
286+
parameters = {
287+
'kappa_s': NonLinearParameter(
288+
"Convergence value of the uniform mass density sheet",
289+
DefinitionRange(min_value=0., max_value=1e8),
290+
latex_str=r"$\kappa_{\rm s}$"
291+
),
292+
}
293+
super().__init__(parameters)
294+
295+
274296
class PixelatedRegularGridPotential(Profile):
275297
"""Lens potential defined on a grid of regular pixels.
276298

test/template/json_test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ def test_dump_and_read(self):
4949
# Defines the external shear
5050
ext_shear = MassField('my lovely external shear', lens_1.redshift,
5151
mass_model=MassModel('ExternalShear'))
52+
53+
# Defines some convergence sheet
54+
conv_sheet = MassField('my mass sheet', lens_1.redshift,
55+
mass_model=MassModel('ConvergenceSheet'))
5256

5357
# Put them in a list, which will also create unique IDs for each profile
54-
entity_list = LensingEntityList(ext_shear, lens_1, source_1, source_2, source_3)
58+
entity_list = LensingEntityList(ext_shear, lens_1, source_1, source_2, source_3, conv_sheet)
5559

5660
# Define the origin of the coordinates system
5761
origin = CoordinatesOrigin('00h11m20.244s', '-08d45m51.48s') # <- in degrees (2.83435, )

0 commit comments

Comments
 (0)