@@ -826,34 +826,43 @@ 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 )
831-
832- Refract [(Elevation > 5 ) & (Elevation <= 85 )] = (
833- 58.1 / TanEl - 0.07 / (TanEl ** 3 ) + 8.6e-05 / (TanEl ** 5 ))
834-
835- Refract [(Elevation > - 0.575 ) & (Elevation <= 5 )] = (
836- Elevation *
837- (- 518.2 + Elevation * (103.4 + Elevation * (- 12.79 + Elevation * 0.711 ))) +
838- 1735 )
829+ TanEl = np .tan (np .radians (Elevation ))
830+ Refract = np .zeros (len (time_utc ))
831+
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 ))
835+
836+ mask = (Elevation > - 0.575 ) & (Elevation <= 5 )
837+ Refract [mask ] = (
838+ Elevation [mask ] * (
839+ - 518.2 + Elevation [mask ]* (
840+ 103.4 + Elevation [mask ]* (- 12.79 + Elevation [mask ]* 0.711 )
841+ )
842+ ) + 1735
843+ )
839844
840- Refract [(Elevation > - 1 ) & (Elevation <= - 0.575 )] = - 20.774 / TanEl
845+ mask = (Elevation > - 1 ) & (Elevation <= - 0.575 )
846+ Refract [mask ] = - 20.774 / TanEl [mask ]
841847
842848 Refract *= (283 / (273. + temperature )) * (pressure / 101325. ) / 3600.
843849
844850 ApparentSunEl = SunEl + Refract
845851
846852 # 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
853+ result = pd .DataFrame (
854+ {
855+ "apparent_elevation" : ApparentSunEl ,
856+ "elevation" : SunEl ,
857+ "azimuth" : SunAz ,
858+ "apparent_zenith" : 90 - ApparentSunEl ,
859+ "zenith" : 90 - SunEl ,
860+ "solar_time" : SolarTime ,
861+ },
862+ index = time
863+ )
864+
865+ return result
857866
858867
859868def calc_time (lower_bound , upper_bound , latitude , longitude , attribute , value ,
0 commit comments