@@ -456,9 +456,7 @@ def julian_ephemeris_millennium(julian_ephemeris_century):
456456@jcompile (nopython = True )
457457def sum_mult_cos_add_mult (arr , x ):
458458 # shared calculation used for heliocentric longitude, latitude, and radius
459- s = 0.
460- for row in range (arr .shape [0 ]):
461- s += arr [row , 0 ] * np .cos (arr [row , 1 ] + arr [row , 2 ] * x )
459+ s = (arr [:, [0 ]] * np .cos (arr [:, [1 ]] + arr [:, [2 ]] * np .expand_dims (x , axis = 0 ))).sum (axis = 0 )
462460 return s
463461
464462@jcompile ('float64(float64)' , nopython = True )
@@ -559,22 +557,20 @@ def moon_ascending_longitude(julian_ephemeris_century):
559557 nopython = True )
560558def longitude_obliquity_nutation (julian_ephemeris_century , x0 , x1 , x2 , x3 , x4 ,
561559 out ):
562- delta_psi_sum = 0.0
563- delta_eps_sum = 0.0
564- for row in range (NUTATION_YTERM_ARRAY .shape [0 ]):
565- a = NUTATION_ABCD_ARRAY [row , 0 ]
566- b = NUTATION_ABCD_ARRAY [row , 1 ]
567- c = NUTATION_ABCD_ARRAY [row , 2 ]
568- d = NUTATION_ABCD_ARRAY [row , 3 ]
569- arg = np .radians (
570- NUTATION_YTERM_ARRAY [row , 0 ]* x0 +
571- NUTATION_YTERM_ARRAY [row , 1 ]* x1 +
572- NUTATION_YTERM_ARRAY [row , 2 ]* x2 +
573- NUTATION_YTERM_ARRAY [row , 3 ]* x3 +
574- NUTATION_YTERM_ARRAY [row , 4 ]* x4
575- )
576- delta_psi_sum += (a + b * julian_ephemeris_century ) * np .sin (arg )
577- delta_eps_sum += (c + d * julian_ephemeris_century ) * np .cos (arg )
560+ a = NUTATION_ABCD_ARRAY [:, [0 ]]
561+ b = NUTATION_ABCD_ARRAY [:, [1 ]]
562+ c = NUTATION_ABCD_ARRAY [:, [2 ]]
563+ d = NUTATION_ABCD_ARRAY [:, [3 ]]
564+ arg = np .radians (
565+ NUTATION_YTERM_ARRAY [:, [0 ]]* np .expand_dims (x0 , axis = 0 ) +
566+ NUTATION_YTERM_ARRAY [:, [1 ]]* np .expand_dims (x1 , axis = 0 ) +
567+ NUTATION_YTERM_ARRAY [:, [2 ]]* np .expand_dims (x2 , axis = 0 ) +
568+ NUTATION_YTERM_ARRAY [:, [3 ]]* np .expand_dims (x3 , axis = 0 ) +
569+ NUTATION_YTERM_ARRAY [:, [4 ]]* np .expand_dims (x4 , axis = 0 )
570+ )
571+
572+ delta_psi_sum = ((a + b * julian_ephemeris_century ) * np .sin (arg )).sum (axis = 0 )
573+ delta_eps_sum = ((c + d * julian_ephemeris_century ) * np .cos (arg )).sum (axis = 0 )
578574 delta_psi = delta_psi_sum * 1.0 / 36000000
579575 delta_eps = delta_eps_sum * 1.0 / 36000000
580576 # seems like we ought to be able to return a tuple here instead
0 commit comments