How to use the starry.Map.utils.is_theano 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 / Map / bases / doppler.py View on Github external
def _get_rv_filter(self, inc, obl, alpha, veq):
        """

        """
        # Theano or numpy?
        if is_theano(inc, obl, veq, alpha):
            math = tt
        else:
            math = np

        # Define some angular quantities
        rad = np.pi / 180
        cosi = math.cos(inc * rad)
        sini = math.sin(inc * rad)
        cosl = math.cos(obl * rad)
        sinl = math.sin(obl * rad)
        A = sini * cosl
        B = -sini * sinl
        C = cosi

        # Compute the Ylm expansion of the RV field
        f = math.reshape([
github rodluger / starry / starry / Map / bases / ylm.py View on Github external
# Raise warnings for some combinations
        if (orbit is not None) and (t is None):
            raise ValueError("Please provide a set of times `t`.")
        if (orbit is None or t is None):
            use_in_transit = False
            if texp is not None:
                warnings.warn("Exposure time integration enabled only when an `orbit` instance is provided.") 
        if (to_tensor(theta).ndim != 0):
            use_in_transit = False
        for kwarg in kwargs.keys():
            warnings.warn("Unrecognized kwarg: %s. Ignoring..." % kwarg)

        # Figure out if this is a Theano Op call
        if (orbit is not None and t is not None) or \
            is_theano(u, f, inc, obl, theta, xo, yo, zo, ro):

            # Limb darkening coeffs
            if u is None:
                if self.udeg == 0:
                    u = []
                else:
                    if self._spectral:
                        u = self[1:, :]
                    else:
                        u = self[1:]
            u = to_tensor(u)

            # Filter coeffs
            if f is None:
                if self.fdeg == 0:
                    f = []
github rodluger / starry / starry / Map / bases / doppler.py View on Github external
veq: The equatorial velocity of the object in arbitrary units. \
                Default is the map's current velocity.
            alpha: The rotational shear. Default is the map's current shear.

        Returns:
            The radial velocity, either a timeseries or a ``Theano`` op.
        """
        # Ingest op-specific kwargs
        # Other kwargs get ingested in call to `flux` below
        inc = kwargs.get("inc", None)
        obl = kwargs.get("obl", None)
        veq = kwargs.pop("veq", None)
        alpha = kwargs.pop("alpha", None)
        if inc is None:
            inc = self.inc
        elif not is_theano(inc):
            self.inc = inc
        if obl is None:
            obl = self.obl
        elif not is_theano(obl):
            self.obl = obl
        if veq is None:
            veq = self.veq
        elif not is_theano(veq):
            self.veq = veq
        if alpha is None:
            alpha = self.alpha
        elif not is_theano(alpha):
            self.alpha = alpha

        # Compute the velocity-weighted intensity
        kwargs["f"] = self._get_rv_filter(inc, obl, alpha, veq)
github rodluger / starry / starry / Map / bases / ylm.py View on Github external
Additional kwargs accepted by this method:
            y: The vector of spherical harmonic coefficients. Default \
                is the map's current spherical harmonic vector.

        Returns:
            The flux, either a timeseries or a ``Theano`` op.
        """
        # Ingest the map coefficients
        if self.ydeg:
            y = kwargs.get("y", None)
            if y is None:
                if self._scalar:
                    y = self[1:, :]
                else:
                    y = self[1:, :, :]
            elif not is_theano(y):
                if self._scalar:
                    self[1:, :] = y
                else:
                    self[1:, :, :] = y
        else:
            y = []
            
        # Compute the design matrix
        X = self.X(**kwargs)

        # Dot it into the map
        if is_theano(X):
            if self.ydeg > 0:
                return tt.dot(X, tt.join(0, [1.0], y))
            else:
                return X[tuple((slice(None), 0))]
github rodluger / starry / starry / Map / bases / doppler.py View on Github external
veq = self.veq
        elif not is_theano(veq):
            self.veq = veq
        if alpha is None:
            alpha = self.alpha
        elif not is_theano(alpha):
            self.alpha = alpha

        # Compute the velocity-weighted intensity
        kwargs["f"] = self._get_rv_filter(inc, obl, alpha, veq)
        Iv = self.flux(**kwargs)

        # Compute the inverse of the intensity
        kwargs["f"] = np.append([np.pi], np.zeros(self.Nf - 1))
        invI = np.array([1.0]) / self.flux(**kwargs)
        if is_theano(invI):
            invI = tt.where(tt.isinf(invI), 0.0, invI)
        else:
            invI[np.isinf(invI)] = 0.0

        # The RV signal is just the product        
        return Iv * invI
github rodluger / starry / starry / Map / bases / doppler.py View on Github external
Returns:
            The radial velocity, either a timeseries or a ``Theano`` op.
        """
        # Ingest op-specific kwargs
        # Other kwargs get ingested in call to `flux` below
        inc = kwargs.get("inc", None)
        obl = kwargs.get("obl", None)
        veq = kwargs.pop("veq", None)
        alpha = kwargs.pop("alpha", None)
        if inc is None:
            inc = self.inc
        elif not is_theano(inc):
            self.inc = inc
        if obl is None:
            obl = self.obl
        elif not is_theano(obl):
            self.obl = obl
        if veq is None:
            veq = self.veq
        elif not is_theano(veq):
            self.veq = veq
        if alpha is None:
            alpha = self.alpha
        elif not is_theano(alpha):
            self.alpha = alpha

        # Compute the velocity-weighted intensity
        kwargs["f"] = self._get_rv_filter(inc, obl, alpha, veq)
        Iv = self.flux(**kwargs)

        # Compute the inverse of the intensity
        kwargs["f"] = np.append([np.pi], np.zeros(self.Nf - 1))
github rodluger / starry / starry / Map / bases / ylm.py View on Github external
y = self[1:, :]
                else:
                    y = self[1:, :, :]
            elif not is_theano(y):
                if self._scalar:
                    self[1:, :] = y
                else:
                    self[1:, :, :] = y
        else:
            y = []
            
        # Compute the design matrix
        X = self.X(**kwargs)

        # Dot it into the map
        if is_theano(X):
            if self.ydeg > 0:
                return tt.dot(X, tt.join(0, [1.0], y))
            else:
                return X[tuple((slice(None), 0))]
        else:
            if self.ydeg > 0:
                return np.dot(X, np.append([1.0], y))
            else:
                return X[tuple((slice(None), 0))]
github rodluger / starry / starry / Map / bases / ld.py View on Github external
oversample = kwargs.pop("oversample", 7)
        order = kwargs.pop("order", 0)

        # Raise warnings for some combinations
        if (orbit is not None) and (t is None):
            raise ValueError("Please provide a set of times `t`.")
        if (orbit is None or t is None):
            use_in_transit = False
            if texp is not None:
                warnings.warn("Exposure time integration enabled only " +
                              "when an `orbit` instance is provided.") 
        for kwarg in kwargs.keys():
            warnings.warn("Unrecognized kwarg: %s. Ignoring..." % kwarg)

        # Figure out if this is a Theano Op call
        if (orbit is not None and t is not None) or is_theano(u, b, zo, ro):

            # Limb darkening coeffs
            if u is None:
                if self.udeg == 0:
                    u = []
                else:
                    if self._spectral:
                        u = self[1:, :]
                    else:
                        u = self[1:]
            u = to_tensor(u)

            # Figure out the coords from the orbit
            if orbit is not None and t is not None:
                
                # Tensorize the time array