Skip to content

Commit

Permalink
Added a new function to Parameter (set_flag).
Browse files Browse the repository at this point in the history
  • Loading branch information
gvernard committed Nov 3, 2023
1 parent 41655dc commit 69139e0
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 19 deletions.
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)


42 changes: 24 additions & 18 deletions coolest/template/classes/profiles/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,24 +148,30 @@ class LensedPS(AnalyticalProfile):
def __init__(self):
documentation = "Set of point source and lensed multiple images"
parameters = {
'ra_true': NonLinearParameter("X-axis position of the true, unlensed point source",
DefinitionRange(),
latex_str=r"$ra$"),
'dec_lensed': NonLinearParameter("Y-axis position of the true, unlensed point source",
DefinitionRange(),
latex_str=r"$dec$"),
'mag_lensed': LinearParameter("Magnitude of the true, unlensed point sources",
DefinitionRange(min_value=0.0),
latex_str=r"$A$"),
'ra_lensed': NonLinearParameterSet("X-axis positions of the multiple images",
DefinitionRange(),
latex_str=r"$ra$"),
'dec_lensed': NonLinearParameterSet("Y-axis positions of the multiple images",
DefinitionRange(),
latex_str=r"$dec$"),
'mag_lensed': LinearParameterSet("Set of magnitude values of the multiple images",
DefinitionRange(min_value=0.0),
latex_str=r"$A$"),
'x_true': NonLinearParameter("X-axis position of the true, unlensed point source",
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",
DefinitionRange(min_value=0.0),
latex_str=r"$A$"),
'flag_contains': LinearParameter("Flag contains",
DefinitionRange(),
latex_str=r"Contains"),
'flag_coupled': LinearParameter("Flag coupled",
DefinitionRange(),
latex_str=r"Coupled")
}
super().__init__(parameters)

Expand Down

0 comments on commit 69139e0

Please sign in to comment.