Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Point Source handling #55

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
22 changes: 21 additions & 1 deletion coolest/template/classes/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,26 @@ def set_point_estimate(self, point_estimate):
if max_val is not None and np.any(np.asarray(val) > np.asarray(max_val)):
raise ValueError(f"Value cannot be larger than {self.definition_range.max_value}.")

def set_flag(self, flag):
"""Set the parameter as a flag.

Parameters
----------
flag : bool, string
Flag value

Raises
------
ValueError
If the provided flag has not a supported type.
"""
if isinstance(flag, (bool, str)):
self.point_estimate = flag
else:
raise ValueError("Flag value must be either a boolean or a string (bool or str).")



def remove_point_estimate(self):
"""Remove the current point estimate of the parameter.
"""
Expand Down Expand Up @@ -272,4 +292,4 @@ class IrregularGridParameter(IrregularGrid):
def __init__(self, documentation, **kwargs_grid) -> None:
self.documentation = documentation
super().__init__(**kwargs_grid)


47 changes: 33 additions & 14 deletions coolest/template/classes/profiles/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,24 +135,43 @@ class LensedPS(AnalyticalProfile):
"""Surface brightness of a set of point sources after being lensed.
gvernard marked this conversation as resolved.
Show resolved Hide resolved

This profile is described by the following parameters:

- 'ra_list': list of coordinates along the x axis
- 'dec_list': list of coordinates along the y axis
- 'amps': list of amplitudes
- 'x_true': the value of the true, unlensed x-axis position of the source
- 'y_true': the value of the true, unlensed y-axis position of the source
- 'm_true': the value of the true, unlensed magnitude of the source
- 'x_lensed': list of coordinates along the x axis of the multiple images
- 'y_lensed': list of coordinates along the y axis of the multiple images
- 'm_lensed': list of magnitudes of the multiple images
- 'flag_contains' ('true','lensed','both'): whether the profile contains only the lensed properties, only the true ones, or both
- 'flag_coupled': a boolean indicating whether the true positions of the source are coupled to the lensed ones ('flag_contains' must be set to 'both')
"""

def __init__(self):
documentation = "Set of lensed point sources"
documentation = "Set of point source and lensed multiple images"
gvernard marked this conversation as resolved.
Show resolved Hide resolved
parameters = {
'ra_list': NonLinearParameterSet("RA positions of the lensed point sources",
DefinitionRange(),
latex_str=r"$ra$"),
'dec_list': NonLinearParameterSet("DEC positions of the lensed point sources",
DefinitionRange(),
latex_str=r"$dec$"),
'amps': LinearParameterSet("Set of amplitude values for the lensed point sources",
DefinitionRange(min_value=0.0),
latex_str=r"$A$"),
'x_true': NonLinearParameter("X-axis position of the true, unlensed point source",
gvernard marked this conversation as resolved.
Show resolved Hide resolved
DefinitionRange(),
latex_str=r"$ra$"),
'y_true': NonLinearParameter("Y-axis position of the true, unlensed point source",
DefinitionRange(),
latex_str=r"$dec$"),
'm_true': LinearParameter("Magnitude of the true, unlensed point sources",
DefinitionRange(min_value=0.0),
latex_str=r"$A$"),
'x_lensed': NonLinearParameterSet("X-axis positions of the multiple images",
DefinitionRange(),
latex_str=r"$ra$"),
'y_lensed': NonLinearParameterSet("Y-axis positions of the multiple images",
DefinitionRange(),
latex_str=r"$dec$"),
'm_lensed': LinearParameterSet("Set of magnitude values of the multiple images",
gvernard marked this conversation as resolved.
Show resolved Hide resolved
DefinitionRange(min_value=0.0),
latex_str=r"$A$"),
'flag_contains': LinearParameter("Flag contains",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are the flags actual parameters of the light profile?
They could just be additional attributes of the class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know exactly how to implement this. I looked but didn't find any example to follow in profiles/light.py or profiles/mass.py. Can you fix this?

DefinitionRange(),
latex_str=r"Contains"),
'flag_coupled': LinearParameter("Flag coupled",
DefinitionRange(),
latex_str=r"Coupled")
}
super().__init__(parameters)

Expand Down