
    R1i                        d Z ddlZddlmZ  edj                  dd            Zdez  Zd	ez  Z	d
ddddddZ
d Zd Z G d de      Zd Zedk(  r		  e        yy# e$ r(Z ed        e ee              ed       Y dZ[ydZ[ww xY w)zTest harness for checking ``jplephem`` against actual JPL results.

This test can be invoked with a simple::

    python -m jplephem.jpltest

    N   )SPKz0.149597870700000000D+09DEgMbP?g{Gz?xyzvxvyvz)r                  c                    t        |      }t        |      j                         dk7  rd}d}t        | j                  D cg c]  }|j
                   c}      }|j                  d       |j                  d       |j                  d       |D ]<  }t        t        t        t        t        t        t        t        f|j                               D 	cg c]  \  }}	 ||	       c}	}\  }
}}}}}}||vs||vr|dk(  s|dk(  sJ |dk(  sJ |dz  }d|cxk  rdk  rn nt        | ||      }n&t        | ||      }t        | ||      }||z
  t        z  }||dz
     |z
  }t        |      t        k\  rVt!        d	|||||t"        |   fz         t!        d
|z         t!        d||dz
     z         t!        d|       t%        d       |dz  }? t!        dj'                  ||             yc c}w c c}	}w )zCCompare the positions we compute against those computed by the JPL.EOTr                  r   z%s %s %s->%s field %d (%s)z  JPL result: %.15fz  Our result: %.15fz    ERROR: difference = z#  {0} tests successful, {1} skippedN)iternextstripsetsegmentstargetaddzipstrfloatintsplit	_positionAUabsepsilonprintfield_namesexitformat)spktestpo_filelinesskips	successessegmenttargetslinefvdedatejedr   centernumbervaluertposcposdeltas                        T/home/cursorai/projects/iching/venv/lib/python3.12/site-packages/jplephem/jpltest.py
run_testporB      s    E
u+



&EI>g7>>>?G KKOKKOKKOCeS#sE:DJJLI8KI BFA!I8K4D#vvvu '!vW'<R<6R<//Q;;QJE2#sF+AS#v.DS#v.D"A&1*% u: .3F8KLM N'%/0'!FQJ-78%9:GQ	? B 

/
6
6y%
HIQ ?8Ks    G+G0c                    |dk(  r9| d   j                  |      \  }}| d   j                  |      \  }}||z   }||z   }n|dk(  r9| d   j                  |      \  }}| d   j                  |      \  }}||z   }||z   }nm|dk(  r| d   j                  |      \  }}nP|dk(  rt        j                  d	      S |d
k(  r| d   j                  |      \  }}n| d|f   j                  |      \  }}t        j                  ||f      S )zACompute position given a JPL test file target integer identifier.r   )r   r   )r   i  
   )r   i-  r   )r   rD   r   )r   r   r   )compute_and_differentiatenpzerosconcatenate)	r-   r9   r   p1v1p2v2pr6   s	            rA   r%   r%   E   s    {S33C8BU55c:BGG	2S33C8BU55c:BGG	24y22371	2xx~	23x11#611V8}66s;1>>1a&!!    c                       e Zd Zy)MissingFileN)__name__
__module____qualname__ rN   rA   rP   rP   ^   s    rN   rP   c                      d} d| z  }d| z  }	 t        j                  |      }	 t        |      }t	        ||       y # t        $ r t        d|z        w xY w# t        $ r t        d|z        w xY w)Ni  zde%d_test_excerpt.bspz	testpo.%dzcannot open: %s)r   openIOErrorrP   rB   )r;   spk_pathtestpo_pathr-   r.   s        rA   test_allrZ   b   s    F&/H&K8hhx ;;' sK   8+h6778  ;+k9::;s   < A AA/__main__a  
Cannot find the JPL SPK files or test files against which this test
suite validates that the positions it generates are correct. To fetch
them, run these commands in your current working directory:

  wget http://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/de430.bsp
  wget ftp://ssd.jpl.nasa.gov/pub/eph/planets/test-data/430/testpo.430

When you are done running the tests, you can remove the files.
)__doc__numpyrF   r-   r   evalreplacer&   meterr(   r*   rB   r%   	ExceptionrP   rZ   rQ   er)   r!   r+   rT   rN   rA   <module>rc      s     	
$
,
,S#
67

,##$4DA2Jj"2	) 	! z
    	 		 	c!fQs   A B BB