How to use the starry.core.math.to_array_or_tensor 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
),
            math.to_array_or_tensor(
                [sec._map._f for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._alpha for sec in self._secondaries]
            ),
        )

        # Convert to units of the primary radius
        fac = np.reshape(
            [sec._length_factor for sec in self._secondaries], [-1, 1]
        )
        fac = fac * self._primary._r
        x, y, z = x / fac, y / fac, z / fac
        r = math.to_array_or_tensor([sec._r for sec in self._secondaries])
        r = r / self._primary._r

        # Evaluate if needed
        if config.lazy:
            img_pri = img_pri.eval()
            img_sec = img_sec.eval()
            x = x.eval()
            y = y.eval()
            z = z.eval()
            r = r.eval()

        # We need this to be of shape (nplanet, nframe)
        x = x.T
        y = y.T
        z = z.T
github rodluger / starry / starry / kepler.py View on Github external
math.to_array_or_tensor(
                [sec._map._inc for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._obl for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._y for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._u for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._f for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._alpha for sec in self._secondaries]
            ),
github rodluger / starry / starry / kepler.py View on Github external
math.to_array_or_tensor(
                [sec._map._amp for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._inc for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._obl for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._u for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._f for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._alpha for sec in self._secondaries]
            ),
github rodluger / starry / starry / kepler.py View on Github external
self._primary._map._u,
            self._primary._map._f,
            self._primary._map._alpha,
            math.to_array_or_tensor([sec._r for sec in self._secondaries]),
            math.to_array_or_tensor([sec._m for sec in self._secondaries]),
            math.to_array_or_tensor([sec._prot for sec in self._secondaries]),
            math.to_array_or_tensor([sec._t0 for sec in self._secondaries]),
            math.to_array_or_tensor(
                [sec._theta0 for sec in self._secondaries]
            ),
            self._get_periods(),
            math.to_array_or_tensor([sec._ecc for sec in self._secondaries]),
            math.to_array_or_tensor([sec._w for sec in self._secondaries]),
            math.to_array_or_tensor([sec._Omega for sec in self._secondaries]),
            math.to_array_or_tensor([sec._inc for sec in self._secondaries]),
            math.to_array_or_tensor(
                [sec._map._amp for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._inc for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._obl for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._u for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._f for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._alpha for sec in self._secondaries]
github rodluger / starry / starry / kepler.py View on Github external
def _get_periods(self):
        periods = [None for sec in self._secondaries]
        for i, sec in enumerate(self._secondaries):
            if sec.porb:
                periods[i] = sec.porb
            else:
                periods[i] = (
                    (2 * np.pi)
                    * sec._a ** (3 / 2)
                    / (math.sqrt(G_grav * (self._primary._m + sec._m)))
                )
        return math.to_array_or_tensor(periods)
github rodluger / starry / starry / kepler.py View on Github external
),
            self._get_periods(),
            math.to_array_or_tensor([sec._ecc for sec in self._secondaries]),
            math.to_array_or_tensor([sec._w for sec in self._secondaries]),
            math.to_array_or_tensor([sec._Omega for sec in self._secondaries]),
            math.to_array_or_tensor([sec._inc for sec in self._secondaries]),
            math.to_array_or_tensor(
                [sec._map._amp for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._inc for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._obl for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._u for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._f for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._alpha for sec in self._secondaries]
            ),
github rodluger / starry / starry / kepler.py View on Github external
math.to_array_or_tensor([sec._t0 for sec in self._secondaries]),
            math.to_array_or_tensor(
                [sec._theta0 for sec in self._secondaries]
            ),
            self._get_periods(),
            math.to_array_or_tensor([sec._ecc for sec in self._secondaries]),
            math.to_array_or_tensor([sec._w for sec in self._secondaries]),
            math.to_array_or_tensor([sec._Omega for sec in self._secondaries]),
            math.to_array_or_tensor([sec._inc for sec in self._secondaries]),
            math.to_array_or_tensor(
                [sec._map._amp for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._inc for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._obl for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._u for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._f for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._alpha for sec in self._secondaries]
            ),
github rodluger / starry / starry / kepler.py View on Github external
math.to_array_or_tensor([sec._w for sec in self._secondaries]),
            math.to_array_or_tensor([sec._Omega for sec in self._secondaries]),
            math.to_array_or_tensor([sec._inc for sec in self._secondaries]),
            math.to_array_or_tensor(
                [sec._map._amp for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._inc for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._obl for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._u for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._f for sec in self._secondaries]
            ),
            math.to_array_or_tensor(
                [sec._map._alpha for sec in self._secondaries]
            ),
github rodluger / starry / starry / kepler.py View on Github external
def position(self, t):
        """Compute the Cartesian positions of all bodies at times ``t``.

        Args:
            t (scalar or vector): An array of times at which to evaluate
                the position in units of :py:attr:`time_unit`.
        """
        x, y, z = self.ops.position(
            math.reshape(math.to_array_or_tensor(t), [-1]) * self._time_factor,
            self._primary._m,
            self._primary._t0,
            math.to_array_or_tensor([sec._m for sec in self._secondaries]),
            math.to_array_or_tensor([sec._t0 for sec in self._secondaries]),
            self._get_periods(),
            math.to_array_or_tensor([sec._ecc for sec in self._secondaries]),
            math.to_array_or_tensor([sec._w for sec in self._secondaries]),
            math.to_array_or_tensor([sec._Omega for sec in self._secondaries]),
            math.to_array_or_tensor([sec._inc for sec in self._secondaries]),
        )
        fac = np.reshape(
            [self._primary._length_factor]
            + [sec._length_factor for sec in self._secondaries],
            [-1, 1],
        )
        return (x / fac, y / fac, z / fac)