
    R1iB                         d Z ddlmZ ddlmZmZmZ ddlmZm	Z	 ddl
mZ ddlmZmZ dZdZdZeeefZd	Z G d
 de      Z G d de      Z G d de      Zy)zThe Satellite class.    )from_alpha5)wgs72oldwgs72wgs84)invjdayjday)
twoline2rv)sgp4sgp4init      g     @c                   d    e Zd ZdZdZdZed        Zed        Ze	e
fd       Zd Zd Zd	 Zd
 Zy)Satrecz1Slow Python-only version of the satellite object.)~Omaaltaaltpamargpdotargpoatimeaycofbstarcc1cc4cc5classificationcon41d2d2201d2211d3d3210d3222d4d4410d4422d5220d5232d5421d5433dedtdel1del2del3delmodidtdmdtdnodtdomdte3eccoee2elnumemephtypeepoch	epochdaysepochyrerrorerror_messageetagstoimincloinitintldesgirezisimpj2j3j3oj2j4
jdsatepochmdotmethodmmmomunddotndotnmno_kozai
no_unkozainodecfnodedotnodeoomomgcofoperationmodepeopghophopincoploradiusearthkmrevnum
satnum_strse2se3sgh2sgh3sgh4sh2sh3si2si3sinmaosl2sl3sl4tt2coft3coft4coft5coftuminx1mth2x7thm1xfactxgh2xgh3xgh4xh2xh3xi2xi3xkexl2xl3xl4xlamoxlcofxlixmcofxnizmolzmosjdsatepochFNc                     | j                   S N)rU   selfs    N/home/cursorai/projects/iching/venv/lib/python3.12/site-packages/sgp4/model.pynoz	Satrec.no-   s    }}    c                 ,    t        | j                        S r   )r   rd   r   s    r   satnumzSatrec.satnum1   s    4??++r   c                    t         |   } |        }t        |||d|       t        |j                  j	                         xs d      |_        t        |j
                        |_        |j                  }t        |j                  d      \  }}|dz  |dz
  dz  z   |z   dz   |_	        t        |d      |_        |`|xj                  d	z  c_        |S )
Ni0      ?im  r      g   B:A   d   )gravity_constantsr	   intr:   striprc   r=   divmodr<   rL   roundr   r;   )clsline1line2
whichconstr   yeardaysfractions           r   r	   zSatrec.twoline2rv5   s    &z2
u5%S$7 4<<--/637$++& ||4h*qQ6=	I 1- J 	r   c                 @   t         |   }t        |d      \  }}|dz   }t        |d      |k(  rt        |d      }|| _        || _        t        |      \  }}}}}}t        |ddddd      }|dz  | _        ||z
  |z   | _        d| _	        t        |||||||||	|
||||        y )	Nr   g   BAr   r   r           r   U)r   r   r   rL   r   r   r   r=   r<   r   r   )r   r   opsmoder   r;   r   rS   rR   r6   r   rC   rP   rU   rY   wholer   whole_jdymdHMSjan0s                           r   r   zSatrec.sgp4initN   s    &z2
 ,x9$
 ?e#Xq)H"#"8,1aAqAq!Q3'3w!D83!WfeUD%ueR5$	@r   c                     || j                   z
  t        z  || j                  z
  t        z  z   }t        | |      \  }}| j                  ||fS r   )rL   minutes_per_dayr   r
   r>   )r   jdfrtsincervs         r   r
   zSatrec.sgp4g   sN    '?:(((O;<D&!1zz1ar   c                 >    t        | |      \  }}| j                  ||fS r   )r
   r>   )r   r   r   r   s       r   sgp4_tsincezSatrec.sgp4_tsincem   s#    D&!1zz1ar   c                 H   | j                   }|ddlm } |t        _         g }t        t	        ||            }|D ]&  \  }}|j                  | j                  ||             ( t	        | \  }}	}
 ||      } ||	      } ||
      }t        |      dfx|_        |_        |||fS )a  Compute positions and velocities for the times in a NumPy array.

        Given NumPy arrays ``jd`` and ``fr`` of the same length that
        supply the whole part and the fractional part of one or more
        Julian dates, return a tuple ``(e, r, v)`` of three vectors:

        * ``e``: nonzero for any dates that produced errors, 0 otherwise.
        * ``r``: position vectors in kilometers.
        * ``v``: velocity vectors in kilometers per second.

        r   array   )	r   numpyr   listzipappendr
   lenshape)r   r   r   r   resultszjd_ifr_ielistrlistvlister   r   s                 r   
sgp4_arrayzSatrec.sgp4_arrayq   s     

=# FLRJD$NN499T401 !7mue%L%L%LGQJ&!'!Qwr   )__name__
__module____qualname____doc__	__slots__r   propertyr   r   classmethodWGS72r	   r   r
   r   r    r   r   r   r      se    ;I( E  , , 16  0@2  r   r   c                   $    e Zd ZdZdZdZd Zd Zy)SatrecArrayz0Slow Python-only version of the satellite array.)_satrecsNc                 N    || _         | j                  ddlm} |t        _        y y )Nr   r   )r   r   r   r   )r   satrecsr   s      r   __init__zSatrecArray.__init__   s#    ::# %K r   c                    g }t        t        ||            }| j                  D ]-  }|D ]&  \  }}|j                  |j	                  ||             ( / t        | \  }}	}
| j                  |      }| j                  |	      }| j                  |
      }t        |      }t        | j                        }||f|_        ||dfx|_        |_        |||fS )a  Compute positions and velocities for the satellites in this array.

        Given NumPy scalars or arrays ``jd`` and ``fr`` supplying the
        whole part and the fractional part of one or more Julian dates,
        return a tuple ``(e, r, v)`` of three vectors that are each as
        long as ``jd`` and ``fr``:

        * ``e``: nonzero for any dates that produced errors, 0 otherwise.
        * ``r``: (x,y,z) position vector in kilometers.
        * ``v``: (dx,dy,dz) velocity vector in kilometers per second.

        r   )r   r   r   r   r
   r   r   r   )r   r   r   r   r   satrecr   r   r   r   r   r   r   r   jdlenmylens                   r   r
   zSatrecArray.sgp4   s     RmmF
dv{{467   $ "7mueJJuJJuJJuBDMM"%."E1--!'!Qwr   )r   r   r   r   r   r   r   r
   r   r   r   r   r      s    :IE&r   r   c                   L    e Zd ZdZdZddZej                  Zej                  Zy)	Satellitez:The old Satellite object, for compatibility with sgp4 1.x.r   c                 t    t        ||||||      }|| j                  z
  t        z  }t        | |      \  }	}
|	|
fS )z@Return a position and velocity vector for a given date and time.)r   rL   r   r
   )r   r   monthdayhourminutesecondjr   r   r   s              r   	propagatezSatellite.propagate   sC     uc48 O3D!}1!tr   N)r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   r   r   r   r   r      s#    DK 
B]]Fr   r   N)r   sgp4.alpha5r   sgp4.earth_gravityr   r   r   sgp4.extr   r   sgp4.ior	   sgp4.propagationr
   r   WGS72OLDr   WGS84r   r   objectr   r   r   r   r   r   <module>r      sc     # 5 5 "  +		eU* V B+& +Z r   