orbix.observatory
=================

.. py:module:: orbix.observatory

.. autoapi-nested-parse::

   Observatory geometry: L2 halo orbit, keepout, planetary ephemerides.



Submodules
----------

.. toctree::
   :maxdepth: 1

   /autoapi/orbix/observatory/keepout/index
   /autoapi/orbix/observatory/observatory/index
   /autoapi/orbix/observatory/orbit/index
   /autoapi/orbix/observatory/solar_system/index


Classes
-------

.. autoapisummary::

   orbix.observatory.Observatory
   orbix.observatory.ObservatoryL2Halo


Functions
---------

.. autoapisummary::

   orbix.observatory.body_angle
   orbix.observatory.is_observable


Package Contents
----------------

.. py:function:: body_angle(obs_pos_eclip, body_pos_eclip, ra_rad, dec_rad, mjd)

   Angle between a solar system body and a target as seen from the observatory.

   :param obs_pos_eclip: Observatory heliocentric ecliptic position (AU).
   :param body_pos_eclip: Body heliocentric ecliptic position (AU).
   :param ra_rad: Target RA in radians.
   :param dec_rad: Target Dec in radians.
   :param mjd: MJD for coordinate conversion.

   :returns: Angular separation in radians.


.. py:function:: is_observable(obs_pos_eclip, ra_rad, dec_rad, mjd, ko_sun_min_deg = 45.0, ko_sun_max_deg = 180.0, ko_earth_min_deg = 0.0, ko_earth_max_deg = 180.0)

   Check if a target is observable (outside all keepout zones).

   :param obs_pos_eclip: Observatory heliocentric ecliptic position (AU), shape ``(3,)``.
   :param ra_rad: Target right ascension in radians.
   :param dec_rad: Target declination in radians.
   :param mjd: Modified Julian Date.
   :param ko_sun_min_deg: Minimum Sun keepout angle (degrees).
   :param ko_sun_max_deg: Maximum Sun keepout angle (degrees).
   :param ko_earth_min_deg: Minimum Earth keepout angle (degrees).
   :param ko_earth_max_deg: Maximum Earth keepout angle (degrees).

   :returns: True if the target is observable, False if it falls in a keepout zone.


.. py:class:: Observatory

   Bases: :py:obj:`equinox.Module`


   Space telescope observatory platform.

   Composes an :class:`ObservatoryL2Halo` orbit model with operational
   scalars (thermal state, overheads, wavefront stability, keepout
   limits). All scalar fields have sensible defaults so a bare
   ``Observatory(orbit=orbit)`` constructs a reasonable HWO-like
   platform.

   :param orbit: L2 halo orbit model.
   :param temperature_K: Telescope equilibrium temperature in Kelvin.
   :param settling_time_d: Slew-settling time in days.
   :param overhead_multi: Multiplicative overhead factor on science time.
   :param overhead_fixed_s: Fixed overhead in seconds per observation.
   :param stability_fact: Wavefront stability factor (EXOSIMS speckle model).
   :param keepout_min_deg: Minimum allowed solar elongation in degrees.
   :param keepout_max_deg: Maximum allowed solar elongation in degrees.


   .. py:attribute:: orbit
      :type:  orbix.observatory.orbit.ObservatoryL2Halo


   .. py:attribute:: temperature_K
      :type:  float
      :value: 270.0



   .. py:attribute:: settling_time_d
      :type:  float
      :value: 1.0



   .. py:attribute:: overhead_multi
      :type:  float
      :value: 1.0



   .. py:attribute:: overhead_fixed_s
      :type:  float
      :value: 0.0



   .. py:attribute:: stability_fact
      :type:  float
      :value: 1.0



   .. py:attribute:: keepout_min_deg
      :type:  float
      :value: 0.0



   .. py:attribute:: keepout_max_deg
      :type:  float
      :value: 180.0



.. py:class:: ObservatoryL2Halo

   Bases: :py:obj:`equinox.Module`


   Space telescope on an L2 halo orbit.

   This is an equinox module that stores the halo orbit state and provides
   JIT-compatible methods for position and geometry queries.

   The orbit is parameterized as a periodic interpolation of a ~6-month halo
   around the Sun-Earth L2 point.

   :param equinox_mjd: Reference equinox epoch in MJD (default: 60575.25).
   :param halo_start_day: Offset into halo orbit at mission start (days).

   .. rubric:: Example

   >>> obs = ObservatoryL2Halo.from_default()
   >>> pos = obs.position_ecliptic(60000.0)  # AU, shape (3,)


   .. py:attribute:: _interp_x
      :type:  interpax.Interpolator1D


   .. py:attribute:: _interp_y
      :type:  interpax.Interpolator1D


   .. py:attribute:: _interp_z
      :type:  interpax.Interpolator1D


   .. py:attribute:: _period_yr
      :type:  float


   .. py:attribute:: _L2_dist_AU
      :type:  float


   .. py:attribute:: _mu
      :type:  float


   .. py:attribute:: _equinox_mjd
      :type:  float


   .. py:attribute:: _halo_start_yr
      :type:  float


   .. py:attribute:: _d2yr
      :type:  float
      :value: 0.0027378507871321013



   .. py:method:: from_default(equinox_mjd = 60575.25, halo_start_day = 0.0)
      :classmethod:


      Create from bundled L2 halo orbit data.

      :param equinox_mjd: Reference equinox epoch in MJD.
      :param halo_start_day: Offset into halo orbit at mission start (days).

      :returns: Configured ObservatoryL2Halo instance.



   .. py:method:: from_npz(npz_path, equinox_mjd = 60575.25, halo_start_day = 0.0)
      :classmethod:


      Create from a custom .npz file.

      :param npz_path: Path to .npz file with halo orbit data.
      :param equinox_mjd: Reference equinox epoch in MJD.
      :param halo_start_day: Offset into halo orbit at mission start (days).

      :returns: Configured ObservatoryL2Halo instance.



   .. py:property:: period_yr
      :type: float


      Halo orbital period in years.


   .. py:property:: L2_dist_AU
      :type: float


      Sun-L2 distance in AU.


   .. py:method:: _halo_time(mjd)

      Convert MJD to periodic halo time in years.



   .. py:method:: position_ecliptic(mjd)

      Heliocentric ecliptic position of the telescope at time ``mjd``.

      :param mjd: Modified Julian Date (scalar).

      :returns: Position vector in heliocentric ecliptic frame (AU), shape ``(3,)``.



   .. py:method:: sun_angle(mjd, ra_rad, dec_rad)

      Angular separation between Sun and target as seen from the telescope.

      :param mjd: Modified Julian Date.
      :param ra_rad: Target right ascension in radians.
      :param dec_rad: Target declination in radians.

      :returns: Angular separation in radians.



   .. py:method:: solar_elongation_deg(mjd, ra_rad, dec_rad)

      3D solar elongation in degrees.

      Identical to :meth:`sun_angle` converted to degrees. This is the
      angular distance between the Sun and target as seen from the
      observer, NOT the Leinert helio-ecliptic longitude difference
      ``Delta_lambda_sun``. For the latter use
      :meth:`helio_ecliptic_longitude_deg`.

      :param mjd: Modified Julian Date.
      :param ra_rad: Target right ascension in radians.
      :param dec_rad: Target declination in radians.

      :returns: Solar elongation in degrees, [0, 180].



   .. py:method:: helio_ecliptic_longitude_deg(mjd, ra_rad, dec_rad)

      Helio-ecliptic longitude difference ``|lambda_target - lambda_sun|``.

      This is the Leinert+1998 ``Delta_lambda_sun`` coordinate used to
      index Table 17 (together with ecliptic latitude). It is the
      absolute difference between the target's ecliptic longitude and
      the Sun's apparent ecliptic longitude (as seen from the observer,
      which is parallax-negligible for distant targets), wrapped onto
      [0, 180] deg.

      For ecliptic-plane targets this equals the 3D solar elongation;
      for high-latitude targets the two diverge -- only this quantity
      is correct as the Leinert table lookup.

      :param mjd: Modified Julian Date.
      :param ra_rad: Target right ascension in radians.
      :param dec_rad: Target declination in radians.

      :returns: ``|lambda_target - lambda_sun|`` in degrees, [0, 180].



   .. py:method:: ecliptic_latitude_deg(mjd, ra_rad, dec_rad)

      Target ecliptic latitude in degrees.

      Argument order matches :meth:`sun_angle`, :meth:`solar_elongation_deg`,
      and :meth:`helio_ecliptic_longitude_deg` so the four geometry
      helpers are interchangeable at call sites.

      :param mjd: Modified Julian Date (used for obliquity at this epoch).
      :param ra_rad: Target right ascension in radians.
      :param dec_rad: Target declination in radians.

      :returns: Ecliptic latitude in degrees, [-90, 90].



