@@ -835,24 +835,24 @@ def equation_of_time(sun_mean_longitude, geocentric_sun_right_ascension,
835835 return E
836836
837837
838- @jcompile ('void(float64[:], float64[:], float64[:,: ])' , nopython = True ,
839- nogil = True )
840- def solar_position_loop (unixtime , loc_args , out ):
838+ @jcompile ('void(float64[:], float64[:], float64[:], float64[:,: ])' ,
839+ nopython = True , nogil = True )
840+ def solar_position_loop (unixtime , delta_t , loc_args , out ):
841841 """Loop through the time array and calculate the solar position"""
842842 lat = loc_args [0 ]
843843 lon = loc_args [1 ]
844844 elev = loc_args [2 ]
845845 pressure = loc_args [3 ]
846846 temp = loc_args [4 ]
847- delta_t = loc_args [5 ]
848- atmos_refract = loc_args [6 ]
849- sst = loc_args [7 ]
850- esd = loc_args [8 ]
847+ atmos_refract = loc_args [5 ]
848+ sst = loc_args [6 ]
849+ esd = loc_args [7 ]
851850
852851 for i in range (unixtime .shape [0 ]):
853852 utime = unixtime [i ]
853+ dT = delta_t [i ]
854854 jd = julian_day (utime )
855- jde = julian_ephemeris_day (jd , delta_t )
855+ jde = julian_ephemeris_day (jd , dT )
856856 jc = julian_century (jd )
857857 jce = julian_ephemeris_century (jde )
858858 jme = julian_ephemeris_millennium (jce )
@@ -920,8 +920,11 @@ def solar_position_numba(unixtime, lat, lon, elev, pressure, temp, delta_t,
920920 and multiple threads. Very slow if functions are not numba compiled.
921921 """
922922 # these args are the same for each thread
923- loc_args = np .array ([lat , lon , elev , pressure , temp , delta_t ,
924- atmos_refract , sst , esd ])
923+ loc_args = np .array ([lat , lon , elev , pressure , temp ,
924+ atmos_refract , sst , esd ], dtype = np .float64 )
925+
926+ # turn delta_t into an array if it isn't already
927+ delta_t = np .full_like (unixtime , delta_t )
925928
926929 # construct dims x ulength array to put the results in
927930 ulength = unixtime .shape [0 ]
@@ -942,13 +945,17 @@ def solar_position_numba(unixtime, lat, lon, elev, pressure, temp, delta_t,
942945 numthreads = ulength
943946
944947 if numthreads <= 1 :
945- solar_position_loop (unixtime , loc_args , result )
948+ solar_position_loop (unixtime , delta_t , loc_args , result )
946949 return result
947950
948951 # split the input and output arrays into numthreads chunks
949952 split0 = np .array_split (unixtime , numthreads )
953+ split1 = np .array_split (delta_t , numthreads )
950954 split2 = np .array_split (result , numthreads , axis = 1 )
951- chunks = [[a0 , loc_args , split2 [i ]] for i , a0 in enumerate (split0 )]
955+ chunks = [
956+ [a0 , a1 , loc_args , a2 ]
957+ for i , (a0 , a1 , a2 ) in enumerate (zip (split0 , split1 , split2 ))
958+ ]
952959 # Spawn one thread per chunk
953960 threads = [threading .Thread (target = solar_position_loop , args = chunk )
954961 for chunk in chunks ]
@@ -1048,7 +1055,7 @@ def solar_position(unixtime, lat, lon, elev, pressure, temp, delta_t,
10481055 temp : int or float
10491056 avg. yearly temperature at location in
10501057 degrees C; used for atmospheric correction
1051- delta_t : float
1058+ delta_t : float or array
10521059 Difference between terrestrial time and UT1.
10531060 atmos_refrac : float
10541061 The approximate atmospheric refraction (in degrees)
@@ -1113,7 +1120,7 @@ def transit_sunrise_sunset(dates, lat, lon, delta_t, numthreads):
11131120 Latitude of location to perform calculation for
11141121 lon : float
11151122 Longitude of location
1116- delta_t : float
1123+ delta_t : float or array
11171124 Difference between terrestrial time and UT. USNO has tables.
11181125 numthreads : int
11191126 Number to threads to use for calculation (if using numba)
@@ -1215,7 +1222,7 @@ def earthsun_distance(unixtime, delta_t, numthreads):
12151222 Array of unix/epoch timestamps to calculate solar position for.
12161223 Unixtime is the number of seconds since Jan. 1, 1970 00:00:00 UTC.
12171224 A pandas.DatetimeIndex is easily converted using .astype(np.int64)/10**9
1218- delta_t : float
1225+ delta_t : float or array
12191226 Difference between terrestrial time and UT. USNO has tables.
12201227 numthreads : int
12211228 Number to threads to use for calculation (if using numba)
@@ -1242,9 +1249,6 @@ def calculate_deltat(year, month):
12421249 """Calculate the difference between Terrestrial Dynamical Time (TD)
12431250 and Universal Time (UT).
12441251
1245- Note: This function is not yet compatible for calculations using
1246- Numba.
1247-
12481252 Equations taken from http://eclipse.gsfc.nasa.gov/SEcat5/deltatpoly.html
12491253 """
12501254
0 commit comments