
    R1i                         d dl mZmZmZmZ ddlmZmZmZm	Z	 ddl
mZmZmZ g dZdddd	d
dddddddZ	 ddZd Zd Zd Zy)    )abseinsumsqrtwhere   )CAU_MC_AUDAYGS)_AVOID_DIVIDE_BY_ZEROdots	length_of)sunjupitersaturnmoonvenusuranusneptuneg    lVAgq=
.Ag4HRAg    *GAged]@gS@gQ]@g(\@g    A      ?gV3ƑyA)mercuryr   earthmarsr   r   r   r   plutor   r   c                 R   t        |       t        z  }|j                  }|j                  }t        d| D ]  }		 ||	   }
|
j                  |j                  |            j                  j                  }||z
  }t        | |      }|}t        |dkD  ||z
  |      }t        ||k  ||z
  |      }|
j                  |j                  |            j                  j                  }t        |	   }t        | |||        |j                         r|d   }
|
j                  |j                              j                  j                  }t        d   }| j                         }t        ||||       |j                  r|dd|f   | dd|f<   y|dd | dd yy# t
        $ r ||	dz      }
Y hw xY w)aR  Update `position` for how solar system masses will deflect its light.

    Given the ICRS `position` |xyz| of an object (au) that is being
    viewed from the `observer` also expressed as |xyz|, and given an
    ephemeris that can be used to determine solar system body positions,
    and given the time `t` and Boolean `apply_earth` indicating whether
    to worry about the effect of Earth's mass, and a `count` of how many
    major solar system bodies to worry about, this function updates
    `position` in-place to show how the masses in the solar system will
    deflect its image.

    Nz barycenter)jd        r   )r   r
   tdbts
deflectorsKeyErroratpositionaulight_time_differencer   rmasses_add_deflectionanycopyshape)r#   observer	ephemeristinclude_earth_deflectioncounttltjd_tdbr   name	deflector	bpositiongpvdlttclosermassdeflected_positions                    W/home/cursorai/projects/iching/venv/lib/python3.12/site-packages/skyfield/relativity.pyadd_deflectionr;      s     H

'C UUF	
B6E"	8!$I LL6!23<<??	 ("
 $Hc2
 
 sSy&3,7sSy&3,7
 LL6!23<<??	(Iu=G #N  ##%g&	LL6!23<<??	  &]]_*HiG#))"1%=#=> Q//0 -Q/HQK &I  	8!$"67I	8s   FF&%F&c                 \    t        |       }| |t        z   z  }t        d||      t        z  }|S )zReturns the difference in light-time, for a star,
      between the barycenter of the solar system and the observer (or
      the geocenter).

    z	a...,a...)r   r   r   r
   )r#   observer_positiondisu1diflts        r:   r%   r%   b   s9     H
C	S00	1B
 ;$56@EL    c           	         || z   |z
  }||z
  }t        |       }t        |      }t        |      }| t        ||d      z  }	|t        ||d      z  }
|t        ||d      z  }t        |	|
      }t        |
|      }t        ||	      }t        |      dkD  }dt        z  t
        t
        z  |z  t        z  |z  z  }d|z   }| t        |d|||z  ||
z  z
  z  |z  |z        z  } y)ah  Correct a position vector for how one particular mass deflects light.

    Given the ICRS `position` |xyz| of an object (AU) together with
    the positions of an `observer` and a `deflector` of reciprocal mass
    `rmass`, this function updates `position` in-place to show how much
    the presence of the deflector will deflect the image of the object.

    r   g(?g       @r   N)r   r   r   r   r   r   r	   )r#   r+   r3   r8   pqpepmagqmagemagphatqhatehatpdotqqdoteedotpmake_no_correctionfac1fac2s                     r:   r'   r'   t   s    
H	y	(B	I	B XDR=DR=DeD$,,DdD#&&DdD#&&D tEtEtE Um3 8q1ut|d*U23D;D (#edlUT\9:TADHJ JHrA   c                     |t         z  }t        |      }|t         z  }t        | |      }|||z  t        z   z  }t	        d||z  z
        }||z  }	d|	d|z   z  z   |z  }
d|	z   }| |z  } | |
|z  z  } | |z  } y)a  Correct a relative position vector for aberration of light.

    Given the relative `position` |xyz| of an object (AU) from a
    particular observer, the `velocity` [dx,dy,dz] at which the observer
    is traveling (AU/day), and the light propagation delay `light_time`
    to the object (days), this function updates `position` in-place to
    give the object's apparent position due to the aberration of light.

    r   N)r
   r   r   r   r   )r#   velocity
light_timep1magvemagbetadotcosdgammaipqrs               r:   add_aberrationr]      s      EhE7?D
x
"C%%-"778D#t#$FtA	qC&L!	!Z/AaAHHHMHrA   N)   )numpyr   r   r   r   	constantsr   r	   r
   r   	functionsr   r   r   r    r&   r;   r%   r'   r]    rA   r:   <module>rc      sc    * * + + = =O
   45J0X$-J^rA   