Skip to content

Commit

Permalink
Merge pull request #35 from astjoephysics/maxBrightness
Browse files Browse the repository at this point in the history
Add Maximum brightness functions
  • Loading branch information
mschwamb authored Jan 14, 2025
2 parents 06b23d2 + f9514a3 commit 51fc358
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/sorcha_addons/activity/lsst_comet/lsst_comet_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def __init__(
) -> None:
super().__init__(required_column_names)

def checkPhysical(self, df: pd.DataFrame):
if (df.k > 0).any():
raise ValueError("Check complex parameters file. k > 0 is not a physical value")

def compute(
self,
df: pd.DataFrame,
Expand Down Expand Up @@ -63,6 +67,7 @@ def compute(
"""

self._validate_column_names(df)
self.checkPhysical(df)

com = Comet(k=df.k, afrho1=df.afrho1)

Expand Down Expand Up @@ -95,3 +100,35 @@ def name_id() -> str:
Unique identifier for this cometary activity model
"""
return "lsst_comet"

def maxBrightness(
self,
df: pd.DataFrame,
observing_filters: List[str],
q: List[float],
delta: List[float],
alpha: List[float],
):

self._validate_column_names(df)
self.checkPhysical(df)

com = Comet(k=df.k, afrho1=df.afrho1)

# this is the geometrical data
g = {"rh": q, "delta": delta, "phase": alpha}

# this calculates the coma magnitude in each filter
try:
for filt in observing_filters:
# here rap is the aperture width, hardcoded here to 1.0 arcsec
# the code assumes an infinite coma so is thus only accurate for small apertures
df.loc[df["optFilter"] == filt, "coma_magnitude"] = com.mag(g, filt, rap=1.0)
except KeyError as err:
self._log_exception(err)

brightestMag = -2.5 * np.log10(
10 ** (-0.4 * df["coma_magnitude"]) + 10 ** (-0.4 * df["trailedSourceMagTrue"])
)

return brightestMag
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ def name_id() -> str:
Unique identifier for this light curve calculator
"""
return "sinusoidal"

def maxBrightness(self, df: pd.DataFrame) -> float:
return -df["LCA"] # note this - because magnitudes are weird

0 comments on commit 51fc358

Please sign in to comment.