Unverified Commit f2b6197e authored by Akke Viitanen's avatar Akke Viitanen
Browse files

add option to retrieve damped random walk parameters

parent aa9707b9
Loading
Loading
Loading
Loading
+26 −10
Original line number Diff line number Diff line
@@ -740,6 +740,9 @@ class CatalogAGN:

        """

        return_tau_sf_inf = kwargs.get("return_tau_sf_inf", False)

        if not return_tau_sf_inf:
            # Short-circuit for non-AGN
            is_agn = self["is_agn"][i]
            if not is_agn:
@@ -751,7 +754,6 @@ class CatalogAGN:
                return np.load(filename)

        mjd = util.get_mjd_vec()

        kwargs.update(
            {
                "mjd0": 0.0,
@@ -767,8 +769,12 @@ class CatalogAGN:
                "seed": self._get_seed("get_lightcurve") + i,
            }
        )
        logger.info(f"Estimating AGN lightcurve {i} {band}")

        logger.info(f"Estimating AGN lightcurve {i=} {band=} {kwargs=}")
        lc = lightcurve.get_lightcurve_agn(*args, **kwargs)
        if return_tau_sf_inf:
            tau, sf_inf = lc
            return tau, sf_inf

        logger.info(f"Writing AGN lightcurve {filename}")
        util.create_directory(filename)
@@ -813,3 +819,13 @@ class CatalogAGN:
        if lc is None:
            return None
        return np.interp(mjd - mjd0, util.get_mjd_vec(), lc)

    def get_tau(self, band="lsst-r"):
        """Return the Damped Random Walk characteristic timescale tau."""
        ret = self.get_lightcurve(0, band, return_tau_sf_inf=True)
        return ret[0]

    def get_sf_inf(self, band="lsst-r", divide_sf_inf_by_z1=False):
        """Return the Damped Random Walk parameter structure function at infinity."""
        ret = self.get_lightcurve(0, band, return_tau_sf_inf=True, divide_sf_inf_by_z1=divide_sf_inf_by_z1)
        return ret[1]
+3 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ def get_lightcurve_agn(
    meanmag=None,
    lambda_rest=None,
    divide_sf_inf_by_z1=False,
    return_tau_sf_inf=False,
):
    """Return an AGN light-curve in flux units."""
    # Initialize the time vector
@@ -64,6 +65,8 @@ def get_lightcurve_agn(
        meanmag=meanmag,
        divide_sf_inf_by_z1=divide_sf_inf_by_z1,
    )
    if return_tau_sf_inf:
        return tau, sf_inf

    # Convert from magnitudes to fluxes
    yy = util.mag_to_flux(yy)