Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/sphinx/source/whatsnew/v0.15.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Enhancements
~~~~~~~~~~~~
* Use ``k`` and ``cap_adjustment`` from :py:func:`pvlib.pvsystem.Array.module_parameters` in :py:func:`pvlib.pvsystem.PVSystem.pvwatts_dc`
(:issue:`2714`, :pull:`2715`)
* Accelerate the internals of :py:func:`~pvlib.solarpostion.ephemeris`. (:pull:`2626`)

Documentation
~~~~~~~~~~~~~
Expand Down Expand Up @@ -84,4 +84,5 @@ Contributors
* Rohan Saxena (:ghuser:`r0hansaxena`)
* Marco Fumagalli (:ghuser:`fuma900`)
* Jean-Baptiste Pasquier (:ghuser:`pasquierjb`)
* James Fulton (:ghuser:`dfulu`)

51 changes: 30 additions & 21 deletions pvlib/solarposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,34 +826,43 @@ def ephemeris(time, latitude, longitude, pressure=101325.0, temperature=12.0):

# Calculate refraction correction
Elevation = SunEl
TanEl = pd.Series(np.tan(np.radians(Elevation)), index=time_utc)
Refract = pd.Series(0., index=time_utc)

Refract[(Elevation > 5) & (Elevation <= 85)] = (
58.1/TanEl - 0.07/(TanEl**3) + 8.6e-05/(TanEl**5))

Refract[(Elevation > -0.575) & (Elevation <= 5)] = (
Elevation *
(-518.2 + Elevation*(103.4 + Elevation*(-12.79 + Elevation*0.711))) +
1735)
TanEl = np.tan(np.radians(Elevation))
Refract = np.zeros(len(time_utc))

mask = (Elevation > 5) & (Elevation <= 85)
Refract[mask] = (
58.1/TanEl[mask] - 0.07/(TanEl[mask]**3) + 8.6e-05/(TanEl[mask]**5))

mask = (Elevation > -0.575) & (Elevation <= 5)
Refract[mask] = (
Elevation[mask] * (
-518.2 + Elevation[mask]*(
103.4 + Elevation[mask]*(-12.79 + Elevation[mask]*0.711)
)
) + 1735
)

Refract[(Elevation > -1) & (Elevation <= -0.575)] = -20.774 / TanEl
mask = (Elevation > -1) & (Elevation <= -0.575)
Refract[mask] = -20.774 / TanEl[mask]

Refract *= (283/(273. + temperature)) * (pressure/101325.) / 3600.

ApparentSunEl = SunEl + Refract

# make output DataFrame
DFOut = pd.DataFrame(index=time_utc)
DFOut['apparent_elevation'] = ApparentSunEl
DFOut['elevation'] = SunEl
DFOut['azimuth'] = SunAz
DFOut['apparent_zenith'] = 90 - ApparentSunEl
DFOut['zenith'] = 90 - SunEl
DFOut['solar_time'] = SolarTime
DFOut.index = time

return DFOut
result = pd.DataFrame(
{
"apparent_elevation": ApparentSunEl,
"elevation": SunEl,
"azimuth": SunAz,
"apparent_zenith": 90 - ApparentSunEl,
"zenith": 90 - SunEl,
"solar_time": SolarTime,
},
index=time
)

return result


def calc_time(lower_bound, upper_bound, latitude, longitude, attribute, value,
Expand Down
Loading