From 23c6d616647fe524470c8be09b8725b37b574b84 Mon Sep 17 00:00:00 2001 From: uwcdc <127983572+uwcdc@users.noreply.github.com> Date: Tue, 27 Feb 2024 16:18:09 -0800 Subject: [PATCH] feat: Add _meta_params to cosmology, lenses, and sources for use in yaml validation --- src/caustics/lenses/epl.py | 30 ++++++++++++++++++++ src/caustics/lenses/external_shear.py | 22 ++++++++++++++ src/caustics/lenses/mass_sheet.py | 18 ++++++++++++ src/caustics/lenses/multiplane.py | 10 +++++++ src/caustics/lenses/nfw.py | 22 ++++++++++++++ src/caustics/lenses/pixelated_convergence.py | 18 ++++++++++++ src/caustics/lenses/point.py | 18 ++++++++++++ src/caustics/lenses/pseudo_jaffe.py | 26 +++++++++++++++++ src/caustics/lenses/singleplane.py | 10 +++++++ src/caustics/lenses/sis.py | 18 ++++++++++++ src/caustics/lenses/tnfw.py | 26 +++++++++++++++++ src/caustics/light/pixelated.py | 23 +++++++++++++++ 12 files changed, 241 insertions(+) diff --git a/src/caustics/lenses/epl.py b/src/caustics/lenses/epl.py index d4b09577..fde32403 100644 --- a/src/caustics/lenses/epl.py +++ b/src/caustics/lenses/epl.py @@ -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, diff --git a/src/caustics/lenses/external_shear.py b/src/caustics/lenses/external_shear.py index 3f4c226a..746c9070 100644 --- a/src/caustics/lenses/external_shear.py +++ b/src/caustics/lenses/external_shear.py @@ -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, diff --git a/src/caustics/lenses/mass_sheet.py b/src/caustics/lenses/mass_sheet.py index 612e5e2d..63c041b8 100644 --- a/src/caustics/lenses/mass_sheet.py +++ b/src/caustics/lenses/mass_sheet.py @@ -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, diff --git a/src/caustics/lenses/multiplane.py b/src/caustics/lenses/multiplane.py index 90b6f812..f1bf3bad 100644 --- a/src/caustics/lenses/multiplane.py +++ b/src/caustics/lenses/multiplane.py @@ -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 ): diff --git a/src/caustics/lenses/nfw.py b/src/caustics/lenses/nfw.py index 148ac1ae..f578ef47 100644 --- a/src/caustics/lenses/nfw.py +++ b/src/caustics/lenses/nfw.py @@ -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, diff --git a/src/caustics/lenses/pixelated_convergence.py b/src/caustics/lenses/pixelated_convergence.py index af2b84f5..84cef66b 100644 --- a/src/caustics/lenses/pixelated_convergence.py +++ b/src/caustics/lenses/pixelated_convergence.py @@ -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, diff --git a/src/caustics/lenses/point.py b/src/caustics/lenses/point.py index 619a1482..a601b19a 100644 --- a/src/caustics/lenses/point.py +++ b/src/caustics/lenses/point.py @@ -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, diff --git a/src/caustics/lenses/pseudo_jaffe.py b/src/caustics/lenses/pseudo_jaffe.py index ebf1cb3b..d43d8dbe 100644 --- a/src/caustics/lenses/pseudo_jaffe.py +++ b/src/caustics/lenses/pseudo_jaffe.py @@ -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, diff --git a/src/caustics/lenses/singleplane.py b/src/caustics/lenses/singleplane.py index f9b858c1..bd517488 100644 --- a/src/caustics/lenses/singleplane.py +++ b/src/caustics/lenses/singleplane.py @@ -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, diff --git a/src/caustics/lenses/sis.py b/src/caustics/lenses/sis.py index df4f4d76..65c1096b 100644 --- a/src/caustics/lenses/sis.py +++ b/src/caustics/lenses/sis.py @@ -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, diff --git a/src/caustics/lenses/tnfw.py b/src/caustics/lenses/tnfw.py index cb613687..07c92c7c 100644 --- a/src/caustics/lenses/tnfw.py +++ b/src/caustics/lenses/tnfw.py @@ -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, diff --git a/src/caustics/light/pixelated.py b/src/caustics/light/pixelated.py index 7ea08408..729046cb 100644 --- a/src/caustics/light/pixelated.py +++ b/src/caustics/light/pixelated.py @@ -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,