How to use the starry.core.math.cast function in starry

To help you get started, we’ve selected a few starry examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rodluger / starry / starry / kepler.py View on Github external
if sec.map._mu is None or sec.map._L is None:
                    raise ValueError(
                        "Please provide a prior for the map "
                        + "of secondary #%d with `set_prior()`." % (k + 1)
                    )
                elif sec.map._L.kind in ["matrix", "cholesky"]:
                    dense_L = True
        YXXinds = np.arange(Y00inds[-1])
        Y00inds = np.array(Y00inds[:-1], dtype=int)
        YXXinds = np.delete(YXXinds, Y00inds)

        # Get the design matrix
        if design_matrix is None:
            assert t is not None, "Please provide a time vector `t`."
            design_matrix = self.design_matrix(t)
        X = math.cast(design_matrix)
        X0 = X[:, Y00inds]
        X1 = X[:, YXXinds]

        # Subtract out the constant term & divide out the amplitude
        f = self._flux - math.sum(X0, axis=-1)

        # Stack our priors
        mu = math.concatenate(
            [
                body.map._mu
                for body in [self._primary] + list(self._secondaries)
                if body.map.ydeg > 0
            ]
        )

        # Compute the likelihood
github rodluger / starry / starry / kepler.py View on Github external
def r(self, value):
        self._r = math.cast(value * self._length_factor)
github rodluger / starry / starry / kepler.py View on Github external
def w(self, value):
        self._w = math.cast(value * self._angle_factor)
github rodluger / starry / starry / kepler.py View on Github external
def Omega(self, value):
        self._Omega = math.cast(value * self._angle_factor)
github rodluger / starry / starry / kepler.py View on Github external
if sec.map._mu is None or sec.map._L is None:
                    raise ValueError(
                        "Please provide a prior for the map "
                        + "of secondary #%d with `set_prior()`." % (k + 1)
                    )
                elif sec.map._L.kind in ["matrix", "cholesky"]:
                    dense_L = True
        YXXinds = np.arange(Y00inds[-1])
        Y00inds = np.array(Y00inds[:-1], dtype=int)
        YXXinds = np.delete(YXXinds, Y00inds)

        # Get the design matrix
        if design_matrix is None:
            assert t is not None, "Please provide a time vector `t`."
            design_matrix = self.design_matrix(t)
        X = math.cast(design_matrix)
        X0 = X[:, Y00inds]
        X1 = X[:, YXXinds]

        # Subtract out the constant term & divide out the amplitude
        f = self._flux - math.sum(X0, axis=-1)

        # Stack our priors
        mu = math.concatenate(
            [
                body.map._mu
                for body in [self._primary] + list(self._secondaries)
                if body.map.ydeg > 0
            ]
        )

        if not dense_L:
github rodluger / starry / starry / kepler.py View on Github external
in the system given a dataset and a prior, provided both are described
        as multivariate Gaussians.

        Args:
            flux (vector): The observed system light curve.
            C (scalar, vector, or matrix): The data covariance. This may be
                a scalar, in which case the noise is assumed to be
                homoscedastic, a vector, in which case the covariance
                is assumed to be diagonal, or a matrix specifying the full
                covariance of the dataset. Default is None. Either `C` or
                `cho_C` must be provided.
            cho_C (matrix): The lower Cholesky factorization of the data
                covariance matrix. Defaults to None. Either `C` or
                `cho_C` must be provided.
        """
        self._flux = math.cast(flux)
        self._C = linalg.Covariance(C=C, cho_C=cho_C, N=self._flux.shape[0])
github rodluger / starry / starry / kepler.py View on Github external
def a(self, value):
        self._a = math.cast(value * self._length_factor)
        self._porb = 0.0
github rodluger / starry / starry / kepler.py View on Github external
LInv = math.concatenate(
                    [
                        body.map._L.inverse * math.ones(body.map.Ny - 1)
                        for body in [self._primary] + list(self._secondaries)
                        if body.map.ydeg > 0
                    ]
                )
            else:
                LInv = math.block_diag(
                    *[
                        body.map._L.inverse * math.eye(body.map.Ny - 1)
                        for body in [self._primary] + list(self._secondaries)
                        if body.map.ydeg > 0
                    ]
                )
            lndetL = math.cast(
                [
                    body.map._L.lndet
                    for body in [self._primary] + list(self._secondaries)
                    if body.map.ydeg > 0
                ]
            )
            return linalg.lnlike_woodbury(
                X1, f, self._C.inverse, mu, LInv, self._C.lndet, lndetL
            )
        else:
            if not dense_L:
                # We can just concatenate vectors
                L = math.concatenate(
                    [
                        body.map._L.value * math.ones(body.map.Ny - 1)
                        for body in [self._primary] + list(self._secondaries)
github rodluger / starry / starry / kepler.py View on Github external
def m(self, value):
        self._m = math.cast(value * self._mass_factor)
github rodluger / starry / starry / kepler.py View on Github external
def prot(self, value):
        self._prot = math.cast(value * self._time_factor)