@@ -826,34 +826,40 @@ def ephemeris(time, latitude, longitude, pressure=101325.0, temperature=12.0):
826826
827827 # Calculate refraction correction
828828 Elevation = SunEl
829- TanEl = pd . Series ( np .tan (np .radians (Elevation )), index = time_utc )
830- Refract = pd . Series ( 0. , index = time_utc )
829+ TanEl = np .tan (np .radians (Elevation ))
830+ Refract = np . zeros ( len ( time_utc ) )
831831
832- Refract [(Elevation > 5 ) & (Elevation <= 85 )] = (
833- 58.1 / TanEl - 0.07 / (TanEl ** 3 ) + 8.6e-05 / (TanEl ** 5 ))
832+ mask = (Elevation > 5 ) & (Elevation <= 85 )
833+ Refract [mask ] = (
834+ 58.1 / TanEl [mask ] - 0.07 / (TanEl [mask ]** 3 ) + 8.6e-05 / (TanEl [mask ]** 5 ))
834835
835- Refract [(Elevation > - 0.575 ) & (Elevation <= 5 )] = (
836- Elevation *
837- (- 518.2 + Elevation * (103.4 + Elevation * (- 12.79 + Elevation * 0.711 ))) +
836+ mask = (Elevation > - 0.575 ) & (Elevation <= 5 )
837+ Refract [mask ] = (
838+ Elevation [mask ] *
839+ (- 518.2 + Elevation [mask ]* (103.4 + Elevation [mask ]* (- 12.79 + Elevation [mask ]* 0.711 ))) +
838840 1735 )
839841
840- Refract [(Elevation > - 1 ) & (Elevation <= - 0.575 )] = - 20.774 / TanEl
842+ mask = (Elevation > - 1 ) & (Elevation <= - 0.575 )
843+ Refract [mask ] = - 20.774 / TanEl [mask ]
841844
842845 Refract *= (283 / (273. + temperature )) * (pressure / 101325. ) / 3600.
843846
844847 ApparentSunEl = SunEl + Refract
845848
846849 # make output DataFrame
847- DFOut = pd .DataFrame (index = time_utc )
848- DFOut ['apparent_elevation' ] = ApparentSunEl
849- DFOut ['elevation' ] = SunEl
850- DFOut ['azimuth' ] = SunAz
851- DFOut ['apparent_zenith' ] = 90 - ApparentSunEl
852- DFOut ['zenith' ] = 90 - SunEl
853- DFOut ['solar_time' ] = SolarTime
854- DFOut .index = time
855-
856- return DFOut
850+ result = pd .DataFrame (
851+ {
852+ "apparent_elevation" : ApparentSunEl ,
853+ "elevation" : SunEl ,
854+ "azimuth" : SunAz ,
855+ "apparent_zenith" : 90 - ApparentSunEl ,
856+ "zenith" : 90 - SunEl ,
857+ "solar_time" : SolarTime ,
858+ },
859+ index = time
860+ )
861+
862+ return result
857863
858864
859865def calc_time (lower_bound , upper_bound , latitude , longitude , attribute , value ,
0 commit comments