
    IR-e4                     T   d dl Z d dlmZmZ d dlmZ d dlmZ d dl	m
Z
mZ d dlmZ d dlmZmZ d dlmZ  ed	          Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d Z#d Z$d Z%d Z&d Z'd Z(d Z)e j*        +                    d eeg          d!             Z,dS )"    N)assert_allcloseassert_equal)units)assert_quantity_allclose)Time	TimeDelta)BinnedTimeSeries)BoxLeastSquaresLombScargle)get_pkg_data_filenamezdata/binned.csvc                  N    t                      } t          g dd          | d<   d S )N         mjdformattime_bin_start)r	   r   tss    Dlib/python3.11/site-packages/astropy/timeseries/tests/test_binned.pytest_empty_initializationr      s/    			B			%888B    c                      t                      } t          j        t          d          5  g d| d<   d d d            d S # 1 swxY w Y   d S )NzcBinnedTimeSeries object is invalid - expected 'time_bin_start' as the first column but found 'flux'matchr   flux)r	   pytestraises
ValueErrorr   s    r   !test_empty_initialization_invalidr"      s     
		B	.
 
 
   YY6
                 s   ?AAc                  "   t          j        t          d          5  t          g dg           d d d            n# 1 swxY w Y   t          j        t          d          5  t          dg dg           d d d            d S # 1 swxY w Y   d S )Nz''time_bin_start' has not been specifiedr   r      r   )data<Either 'time_bin_size' or 'time_bin_end' should be specified2016-03-22T12:30:31)r   r&   )r   r    	TypeErrorr	    r   r   $test_initialization_time_bin_invalidr+   #   s9    
y(R	S	S	S + +yyyk****+ + + + + + + + + + + + + + + 
X
 
 
 Q Q 	(=YYYKPPPPQ Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Qs!   <A A "BBBc                     d} t          j        t          |                     d                    5  t	          ddgid           d d d            n# 1 swxY w Y   t          j        t          |                     d                    5  t	          ddgidgt
          j        z             d d d            d S # 1 swxY w Y   d S )	Nz?'{}' has been given both in the table and as a keyword argumentr   r   r(   )r&   r   time_bin_sizer   )r&   r-   )r   r    r)   r   r	   us)MESSAGEs    r   !test_initialization_time_bin_bothr1   /   sZ   PG	y7G(H(H	I	I	I 
 
"%:$;<0	
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
y(G(G	H	H	H 
 
!$9#:;A3QRQT9	
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
s#   AAA#B;;B?B?c                  *   t          j        t          d          5  t          ddgidd           d d d            n# 1 swxY w Y   t          ddgidt	          dd                    } t          | j        t          j        j	                  sJ d S )	Nz3'time_bin_size' should be a Quantity or a TimeDeltar   timer(   r   )r&   r   r-   jdr   )
r   r    r)   r	   r   
isinstancer-   r.   quantityQuantityr   s    r   !test_initialization_time_bin_sizer8   ?   s     
O
 
 
 
 
 	0120	
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
,-.,$///
 
 
B
 b&
(;<<<<<<<s   >AAc            	          t          j        t          d          5  t          ddgit	          dd          t	          dd                     d d d            d S # 1 swxY w Y   d S )	Nz:'time_bin_start' is scalar, so 'time_bin_size' is requiredr   r3   r(   r   r   r   )r&   r   time_bin_end)r   r    r)   r	   r   r*   r   r   )test_initialization_time_bin_start_scalarr;   T   s     
V
 
 
 
 
 	012%000a...	
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
s   4AA!$A!c                      t          j        t          d          5  t          t	          g dd          dt
          j        z  d           d d d            d S # 1 swxY w Y   d S )	NzS'n_bins' cannot be specified if 'time_bin_start' or 'time_bin_size' are not scalar'r   r   cxcsecr   r   
   )r   r-   n_binsr   r    r)   r	   r   r.   r/   r*   r   r   ,test_initialization_n_bins_invalid_argumentsrA   a   s     

 
 
 
 
 				(;;;ac'	
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
s   1AA!Ac            
          t          j        t          d          5  t          ddgit	          dd          dt
          j        z  t	          dd          d	           d d d            d S # 1 swxY w Y   d S )
NzI'n_bins' has been given and it is not the same length as the input data\.r   r3   r(   r   r   r   r>   )r&   r   r-   r:   r?   r@   r*   r   r   test_initialization_n_binsrC   s   s     
X
 
 
 
 
 	012%000ac'a...	
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
s   AA,,A03A0c            
      j   t          j        t          d          5  t          ddgiddgdt          j        z  t          dd          	           d d d            n# 1 swxY w Y   t          j        t          d
          5  t          ddgidgd d 	           d d d            d S # 1 swxY w Y   d S )Nz@Length of 'time_bin_start' \(2\) should match table length \(1\)r   r3   r(   2016-03-22T12:30:32r   r   r   )r&   r   r-   r:   r'   )r   r    r!   r	   r.   r/   r   r)   r*   r   r   #test_initialization_non_scalar_timerF      sq    
Q
 
 
 	
 	
 	01213HIac'a...		
 	
 	
 	
		
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 
X
 
 
 
 
 	01212		
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
s#   5AA!$A!B((B,/B,c                      t          ddt          j        z  g dg          } t          | j        j        g d           t          | j        j        g d           t          | j        j        g d           d S )Nr(   r   r$   r   r-   r&   )2016-03-22T12:30:31.0002016-03-22T12:30:34.0002016-03-22T12:30:37.000)z2016-03-22T12:30:32.500z2016-03-22T12:30:35.500z2016-03-22T12:30:38.500)rJ   rK   2016-03-22T12:30:40.000r	   r.   r/   r   r   isottime_bin_centerr:   r   s    r   test_even_contiguousrP      s     
,AG999+
 
 
B 
	
 	
 	
   
	
 	
 	
   
	
 	
 	
    r   c                      t          g ddg dg          } t          | j        j        g d           t          | j        j        g d           t          | j        j        g d           d S )N)r(   rE   2016-03-22T12:30:40z2016-03-22T12:30:55r$   r   r:   r&   )rI   2016-03-22T12:30:32.000rL   )2016-03-22T12:30:31.5002016-03-22T12:30:36.000z2016-03-22T12:30:47.500)rT   rL   z2016-03-22T12:30:55.000r	   r   r   rN   rO   r:   r   s    r   test_uneven_contiguousrX      s     

 
 

 +ii[
 
 
B 
	
 	
 	
   
	
 	
 	
   
	
 	
 	
    r   c                      t          g dg dt          j        z  g dg          } t          | j        j        g d           t          | j        j        g d           t          | j        j        g d           d S )N)r(   z2016-03-22T12:30:38z2016-03-22T12:34:40)   d   r   r$   rH   )rI   z2016-03-22T12:30:38.000z2016-03-22T12:34:40.000)z2016-03-22T12:30:33.500z2016-03-22T12:31:28.000z2016-03-22T12:34:41.000)rV   z2016-03-22T12:32:18.000z2016-03-22T12:34:42.000rM   r   s    r   test_uneven_non_contiguousr\      s     

 
 

 "kkAC'ii[
 
 
B 
	
 	
 	
   
	
 	
 	
   
	
 	
 	
    r   c                      t          g dg dg dg          } t          | j        j        g d           t          | j        j        g d           t          | j        j        g d           d S )N)r(   z2016-03-22T12:30:33rR   )rE   z2016-03-22T12:30:35z2016-03-22T12:30:41r$   rS   )rI   z2016-03-22T12:30:33.000rL   )rU   rJ   z2016-03-22T12:30:40.500)rT   z2016-03-22T12:30:35.000z2016-03-22T12:30:41.000rW   r   s    r   test_uneven_non_contiguous_fullr^     s     

 
 


 
 

 ii[
 
 
B 
	
 	
 	
   
	
 	
 	
   
	
 	
 	
    r   c                      t          j        t          d          5  t          j        t
          d           d d d            d S # 1 swxY w Y   d S )Nz]``time_bin_start_column`` should be provided since the default Table readers are being used\.r   csvr   r   r    r!   r	   readCSV_FILEr*   r   r   test_read_emptyrd   D  s    	)
 
 
 6 6 	hu55556 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6s   AA	A	c                      t          j        t          d          5  t          j        t
          dd           d d d            d S # 1 swxY w Y   d S )NzKEither `time_bin_end_column` or `time_bin_size_column` should be provided\.r   
time_startr`   )time_bin_start_columnr   ra   r*   r   r   test_read_no_size_endrh   O  s    	
 
 
 	
 	
 	L	
 	
 	
 	
	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
s   AA
A
c                      t          j        t          d          5  t          j        t
          dddd           d d d            d S # 1 swxY w Y   d S )NzFCannot specify both `time_bin_end_column` and `time_bin_size_column`\.r   rf   ENDbin_sizer`   )rg   time_bin_end_columntime_bin_size_columnr   ra   r*   r   r   test_read_both_extra_binsrn   \  s    	W
 
 
 

 

 	". %!+	
 	
 	
 	
	

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

s   AAAc                      t          j        t          d          5  t          j        t
          ddd           d d d            d S # 1 swxY w Y   d S NzWThe bin size unit should be specified as an astropy Unit using ``time_bin_size_unit``\.r   rf   rk   r`   )rg   rm   r   ra   r*   r   r   test_read_size_no_unitrq   j      	)
 
 
 
 
 	".!+		
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
   AAAc                      t          j        t          d          5  t          j        t
          ddt          j        d           d d d            d S # 1 swxY w Y   d S )Nz9Bin start time column 'abc' not found in the input data\.r   abcrk   r`   rg   rm   time_bin_size_unitr   r   r    r!   r	   rb   rc   r.   secondr*   r   r   test_read_start_time_missingrz   z  s    	V
 
 
 	
 	
 	"'!+ x	
 	
 	
 	
	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
   )AAAc                      t          j        t          d          5  t          j        t
          ddd           d d d            d S # 1 swxY w Y   d S )Nz;Bin end time column 'missing' not found in the input data\.r   rf   missingr`   rg   rl   r   ra   r*   r   r   test_read_end_time_missingr     s    	X
 
 
 
 
 	". )		
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
rs   c                      t          j        t          d          5  t          j        t
          ddt          j        d           d d d            d S # 1 swxY w Y   d S )Nz7Bin size column 'missing' not found in the input data\.r   rf   r}   r`   rv   rx   r*   r   r   test_read_size_missingr     s    	T
 
 
 	
 	
 	".!* x	
 	
 	
 	
	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
r{   c                      t          j        t          d          5  t          j        t
          ddd           d d d            d S # 1 swxY w Y   d S rp   ra   r*   r   r   test_read_time_unit_missingr     rr   rs   c                     t          j        t          ddd          } | j        g dk    sJ t	          |           dk    sJ | d                                         dk    sJ t          j        t          dd	t          j        d
          } | j        g dk    sJ t	          |           dk    sJ | d                                         dk    sJ d S )Nrf   time_endr`   r~   )	r   r-   rk   ABCDEFr>   r   g\(@rk   rv   )	r   r-   r   r   r   r   r   r   r   )r	   rb   rc   colnameslensumr.   ry   )
timeseriess    r   	test_readr     s   !&*&	  J  
# 
# 
# 
 
 
 
 z??b    c?  G++++!&*'8  J  
# 
# 
# 
 
 
 
 z??b    c?  G++++++r   clsc                    t          ddt          j        z  g dg dgddg          }|                     |d          }t	          ||           sJ t          |j        j        |j        j                   t          |j
        |d                    |j        J |                     |dd          }t          |j        |d                    |                     |dd	          }t          |j        d	           d S )
Nr(   r   r$   )r   r%   r   ab)r   r-   r&   names)uncertaintyg?)r	   r.   r/   from_timeseriesr5   r   tr4   rO   r   ydyr   )r   r   p1p2p3s        r   test_periodogramr     s    
,!#gii#Cj	
 
 
B 
		R	%	%Bb#BDGR/2333r#w5===			R#		6	6BRUBsG,,,			R#		6	6BBE3r   )-r   numpy.testingr   r   astropyr   r.   astropy.tests.helperr   astropy.timer   r   astropy.timeseries.binnedr	   astropy.timeseries.periodogramsr
   r   astropy.utils.datar   rc   r   r"   r+   r1   r8   r;   rA   rC   rF   rP   rX   r\   r^   rd   rh   rn   rq   rz   r   r   r   r   markparametrizer   r*   r   r   <module>r      sA    7 7 7 7 7 7 7 7       9 9 9 9 9 9 ( ( ( ( ( ( ( ( 6 6 6 6 6 6 H H H H H H H H 4 4 4 4 4 4  !2339 9 9
  	Q 	Q 	Q
 
 
 = = =*

 

 


 
 
$
 
 
$
 
 
2! ! !H' ' 'T' ' 'T+ + +\6 6 6

 

 


 
 

 
 
 

 

 

	
 	
 	


 

 


 
 
 (, (, (,V + >??    @?     r   