Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Commit

Permalink
feat: Add _meta_params to cosmology, lenses, and sources for use in y…
Browse files Browse the repository at this point in the history
…aml validation
  • Loading branch information
uwcdc committed Feb 28, 2024
1 parent 412dabd commit 23c6d61
Show file tree
Hide file tree
Showing 12 changed files with 241 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/caustics/lenses/epl.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,36 @@ class EPL(ThinLens):
"t": 1.0,
}

_meta_params = {
**ThinLens._meta_params,
**{
"x0": {
"default": 0.0,
"description": "X coordinate of the lens center.",
},
"y0": {
"default": 0.0,
"description": "Y coordinate of the lens center.",
},
"q": {
"default": 0.5,
"description": "Axis ratio of the lens.",
},
"phi": {
"default": 0.0,
"description": "Position angle of the lens.",
},
"b": {
"default": 1.0,
"description": "Scale length of the lens.",
},
"t": {
"default": 1.0,
"description": "Power law slope of the lens.",
},
},
}

def __init__(
self,
cosmology: Cosmology,
Expand Down
22 changes: 22 additions & 0 deletions src/caustics/lenses/external_shear.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,28 @@ class ExternalShear(ThinLens):
"gamma_2": 0.1,
}

_meta_params = {
**ThinLens._meta_params,
**{
"x0": {
"default": 0.0,
"description": "x-coordinate of the shear center in the lens plane",
},
"y0": {
"default": 0.0,
"description": "y-coordinate of the shear center in the lens plane",
},
"gamma_1": {
"default": 0.1,
"description": "Shear component in the x-direction",
},
"gamma_2": {
"default": 0.1,
"description": "Shear component in the y-direction",
},
},
}

def __init__(
self,
cosmology: Cosmology,
Expand Down
18 changes: 18 additions & 0 deletions src/caustics/lenses/mass_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ class MassSheet(ThinLens):
"surface_density": 0.1,
}

_meta_params = {
**ThinLens._meta_params,
**{
"x0": {
"default": 0.0,
"description": "x-coordinate of the shear center in the lens plane",
},
"y0": {
"default": 0.0,
"description": "y-coordinate of the shear center in the lens plane",
},
"surface_density": {
"default": 0.1,
"description": "Surface density",
},
},
}

def __init__(
self,
cosmology: Cosmology,
Expand Down
10 changes: 10 additions & 0 deletions src/caustics/lenses/multiplane.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ class Multiplane(ThickLens):
List of thin lenses.
"""

_meta_params = {
**ThickLens._meta_params,
**{
"lenses": {
"default": [],
"description": "List of thin lenses.",
}
},
}

def __init__(
self, cosmology: Cosmology, lenses: list[ThinLens], name: Optional[str] = None
):
Expand Down
22 changes: 22 additions & 0 deletions src/caustics/lenses/nfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,28 @@ class NFW(ThinLens):
"c": 5.0,
}

_meta_params = {
**ThinLens._meta_params,
**{
"x0": {
"default": 0.0,
"description": "x-coordinate of the lens center in the lens plane",
},
"y0": {
"default": 0.0,
"description": "y-coordinate of the lens center in the lens plane",
},
"m": {
"default": 1e13,
"description": "Mass of the lens",
},
"c": {
"default": 5.0,
"description": "Concentration parameter of the lens",
},
},
}

def __init__(
self,
cosmology: Cosmology,
Expand Down
18 changes: 18 additions & 0 deletions src/caustics/lenses/pixelated_convergence.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@ class PixelatedConvergence(ThinLens):
"convergence_map": np.logspace(0, 1, 100, dtype=np.float32).reshape(10, 10),
}

_meta_params = {
**ThinLens._meta_params,
**{
"x0": {
"default": 0.0,
"description": "x-coordinate of the shear center in the lens plane",
},
"y0": {
"default": 0.0,
"description": "y-coordinate of the shear center in the lens plane",
},
"convergence_map": {
"default": np.logspace(0, 1, 100, dtype=np.float32).reshape(10, 10),
"description": "The convergence map",
},
},
}

def __init__(
self,
pixelscale: float,
Expand Down
18 changes: 18 additions & 0 deletions src/caustics/lenses/point.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,24 @@ class Point(ThinLens):
"th_ein": 1.0,
}

_meta_params = {
**ThinLens._meta_params,
**{
"x0": {
"default": 0.0,
"description": "x-coordinate of the center of the lens",
},
"y0": {
"default": 0.0,
"description": "y-coordinate of the center of the lens",
},
"th_ein": {
"default": 1.0,
"description": "Einstein radius of the lens",
},
},
}

def __init__(
self,
cosmology: Cosmology,
Expand Down
26 changes: 26 additions & 0 deletions src/caustics/lenses/pseudo_jaffe.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,32 @@ class PseudoJaffe(ThinLens):
"scale_radius": 1.0,
}

_meta_params = {
**ThinLens._meta_params,
**{
"x0": {
"default": 0.0,
"description": "x-coordinate of the center of the lens",
},
"y0": {
"default": 0.0,
"description": "y-coordinate of the center of the lens",
},
"mass": {
"default": 1e12,
"description": "Total mass of the lens (Msol)",
},
"core_radius": {
"default": 0.1,
"description": "Core radius of the lens (arcsec)",
},
"scale_radius": {
"default": 1.0,
"description": "Scaling radius of the lens (arcsec)",
},
},
}

def __init__(
self,
cosmology: Cosmology,
Expand Down
10 changes: 10 additions & 0 deletions src/caustics/lenses/singleplane.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ class SinglePlane(ThinLens):
A list of ThinLens objects that are being combined into a single lensing plane.
"""

_meta_params = {
**ThinLens._meta_params,
**{
"lenses": {
"default": [],
"description": "A list of ThinLens objects that are being combined into a single lensing plane.",
},
},
}

def __init__(
self,
cosmology: Cosmology,
Expand Down
18 changes: 18 additions & 0 deletions src/caustics/lenses/sis.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ class SIS(ThinLens):
"th_ein": 1.0,
}

_meta_params = {
**ThinLens._meta_params,
**{
"x0": {
"default": 0.0,
"description": "x-coordinate of the center of the lens",
},
"y0": {
"default": 0.0,
"description": "y-coordinate of the center of the lens",
},
"th_ein": {
"default": 1.0,
"description": "Einstein radius of the lens",
},
},
}

def __init__(
self,
cosmology: Cosmology,
Expand Down
26 changes: 26 additions & 0 deletions src/caustics/lenses/tnfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,32 @@ class TNFW(ThinLens):
"tau": 3.0,
}

_meta_params = {
**ThinLens._meta_params,
**{
"x0": {
"default": 0.0,
"description": "x-coordinate of the center of the lens",
},
"y0": {
"default": 0.0,
"description": "y-coordinate of the center of the lens",
},
"mass": {
"default": 1e13,
"description": "Mass of the lens (Msol)",
},
"scale_radius": {
"default": 1.0,
"description": "Scale radius of the TNFW lens (arcsec)",
},
"tau": {
"default": 3.0,
"description": "Truncation scale. Ratio of truncation radius to scale radius (rt/rs)",
},
},
}

def __init__(
self,
cosmology: Cosmology,
Expand Down
23 changes: 23 additions & 0 deletions src/caustics/light/pixelated.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,29 @@ class Pixelated(Source):
The shape of the source image.
"""

_meta_params = {
"x0": {
"default": None,
"description": "The x-coordinate of the source image's center.",
},
"y0": {
"default": None,
"description": "The y-coordinate of the source image's center.",
},
"image": {
"default": None,
"description": "The source image from which brightness values will be interpolated.",
},
"pixelscale": {
"default": None,
"description": "The pixelscale of the source image in the lens plane in units of arcsec/pixel.",
},
"shape": {
"default": None,
"description": "The shape of the source image.",
},
}

def __init__(
self,
image: Optional[Tensor] = None,
Expand Down

0 comments on commit 23c6d61

Please sign in to comment.