API Reference
This page provides detailed documentation for all public functions and classes in Sunwhere.
Main Functions
sites
sites(
times: ndarray[tuple[int], datetime64] | DatetimeIndex,
latitude: ndarray[tuple[int]] | Sequence[float] | float,
longitude: ndarray[tuple[int]]
| Sequence[float]
| float,
algorithm: Literal["psa", "nrel", "iqbal"] = "psa",
refraction: bool = True,
engine: Literal["numexpr", "numpy"] = "numexpr",
site_names: Sequence[str] | None = None,
) -> Sunpos
Compute solar position at arbitrarily dispersed locations over a common time series.
This function calculates solar position (zenith and azimuth angles, declination, etc.) for an arbitrary number of fixed geographic locations throughout a common time grid. All locations share the same time instants.
Parameters:
-
(timesarray-like of datetime-like, shape (K,)) –Time instants at which solar position is evaluated. Can be datetime.datetime, pandas.DatetimeIndex, numpy.datetime64, or any type accepted by pandas.to_datetime(). Timezone-naive inputs are assumed to be UTC.
-
(latitudefloat or array-like of float, shape (J,)) –Latitudes in degrees where solar position is evaluated. Valid range: [-90, 90]. Must have the same size as longitude.
-
(longitudefloat or array-like of float, shape (J,)) –Longitudes in degrees where solar position is evaluated. Valid range: [-180, 180). Must have the same size as latitude.
-
(algorithm(psa, nrel, iqbal), default:'psa') –Solar position algorithm to use: - 'psa': Plataforma Solar de Almería algorithm [1] with updated coefficients [2]. Fast and accurate (avg error ~0.002°). Default. - 'nrel': NREL's SPA algorithm [3]. Most accurate (±0.0003°) but slower. Valid for years -2000 to 6000. - 'iqbal': Iqbal's algorithm [4]. Lower accuracy, mainly for educational use.
-
(refractionbool, default:True) –If True (default), applies atmospheric refraction correction to zenith angle. Typically adds ~0.5° correction near the horizon.
-
(engine(numexpr, numpy), default:'numexpr') –Computation engine. 'numexpr' (default) is faster for large arrays, 'numpy' may be faster for small arrays.
-
(site_namesarray-like of str, shape (J,), default:None) –Custom names for each site. If provided, must have the same length as latitude and longitude. These names will be used as a coordinate for the 'site' dimension, enabling labeled selection like
result.sza.sel(site='Madrid'). If None (default), sites are indexed numerically (0, 1, 2, ...).
Returns:
-
sunpos(Sunpos) –Object containing solar position data as xarray DataArrays with dimensions:
- Time-dependent only (K,): dec, eot, ecf
- Time and location dependent (K, J): sza, saa, elevation, azimuth, zenith, cosz
Notes
- Latitude and longitude arrays must have the same length.
- For a single location, use scalar values for latitude and longitude.
- All times must be unique and monotonically increasing for best performance.
- The refraction correction uses a simple model suitable for standard atmospheric conditions at sea level.
Examples:
Calculate solar position for three cities over one day:
>>> import pandas as pd
>>> import sunwhere
>>>
>>> # Define locations: Madrid, New York, Tokyo
>>> cities = ['Madrid', 'New York', 'Tokyo']
>>> lats = [40.4168, 40.7128, 35.6762]
>>> lons = [-3.7038, -74.0060, 139.6503]
>>>
>>> # Create hourly time series for 2024-06-21 (summer solstice)
>>> times = pd.date_range('2024-06-21', periods=24, freq='h', tz='UTC')
>>>
>>> # Compute solar position with site names
>>> result = sunwhere.sites(times, lats, lons, site_names=cities)
>>>
>>> # Access solar zenith angle with labeled coordinates
>>> print(result.sza) # shape: (24, 3) with site names as coordinate
>>>
>>> # Select data for a specific city using name
>>> madrid_sza = result.sza.sel(site='Madrid')
>>>
>>> # Find solar noon (minimum zenith angle) for Madrid
>>> solar_noon_idx = result.sza.sel(site='Madrid').argmin()
>>> print(f"Solar noon in Madrid: {times[solar_noon_idx]}")
Single location example:
>>> # Single location (scalar coordinates)
>>> times = pd.date_range('2024-01-01', periods=365, freq='D', tz='UTC')
>>> result = sunwhere.sites(times, 40.0, -3.0, algorithm='nrel')
>>>
>>> # Get solar azimuth angle
>>> azimuth = result.saa # shape: (365, 1)
References
-
Blanco-Muriel, M. et al., 2001. Computing the solar vector. Solar Energy, 70(5), 431-441. https://doi.org/10.1016/S0038-092X(00)00156-0
-
Blanco, M. et al., 2020. Updating the PSA sun position algorithm. Solar Energy, 212, 339-341. https://doi.org/10.1016/j.solener.2020.10.084
-
Reda, I. and Andreas, A., 2003. Solar Position Algorithm for Solar Radiation Applications. NREL Report No. TP-560-34302. https://www.nrel.gov/docs/fy08osti/34302.pdf
-
Iqbal, M., 1983. An introduction to solar radiation. Academic Press.
See Also
regular_grid : Solar position over a regular lat-lon grid transect : Solar position along a moving path
Source code in src/sunwhere/usecases.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
regular_grid
regular_grid(
times: ndarray[tuple[int], datetime64] | DatetimeIndex,
latitude: ndarray[tuple[int]] | Sequence[float] | float,
longitude: ndarray[tuple[int]]
| Sequence[float]
| float,
algorithm: Literal["psa", "nrel", "iqbal"] = "psa",
refraction: bool = True,
engine: Literal["numexpr", "numpy"] = "numexpr",
) -> Sunpos
Compute solar position over a regular latitude-longitude grid.
This function calculates solar position for a regular 2D grid of latitudes and longitudes throughout a common time series. The output has shape (time, latitude, longitude), suitable for gridded climate data or maps.
Parameters:
-
(timesarray-like of datetime-like, shape (K,)) –Time instants at which solar position is evaluated. Can be datetime.datetime, pandas.DatetimeIndex, numpy.datetime64, or any type accepted by pandas.to_datetime(). Timezone-naive inputs are assumed to be UTC.
-
(latitudefloat or array-like of float, shape (J,)) –1-D array of latitudes in degrees defining the grid rows. Valid range: [-90, 90]. Can be a scalar for a single latitude.
-
(longitudefloat or array-like of float, shape (I,)) –1-D array of longitudes in degrees defining the grid columns. Valid range: [-180, 180). Can be a scalar for a single longitude.
-
(algorithm(psa, nrel, iqbal), default:'psa') –Solar position algorithm to use:
- 'psa': Plataforma Solar de Almería algorithm [2] with updated coefficients [3]. Fast and accurate (avg error ~0.002°). Default.
- 'nrel': NREL's SPA algorithm [1]. Most accurate (±0.0003°) but slower. Valid for years -2000 to 6000.
- 'iqbal': Iqbal's algorithm [4]. Lower accuracy, mainly for educational use.
-
(refractionbool, default:True) –If True (default), applies atmospheric refraction correction to zenith angle. Typically adds ~0.5° correction near the horizon.
-
(engine(numexpr, numpy), default:'numexpr') –Computation engine. 'numexpr' (default) is significantly faster for large grids (>1000 points), 'numpy' may be faster for small grids.
Returns:
-
sunpos(Sunpos) –Object containing solar position data as xarray DataArrays with dimensions:
- Time-dependent only (K,): dec, eot, ecf
- Time and space dependent (K, J, I): sza, saa, elevation, azimuth, zenith, cosz
Notes
- This function is optimized for regular grids where latitudes and longitudes form a rectangular mesh.
- For irregular or scattered points, use
sites()instead. - The grid is created using NumPy broadcasting: all combinations of lat×lon are computed for each time instant.
- Memory usage scales as K × J × I × 8 bytes per output variable.
Examples:
Create a global grid and compute solar zenith angle:
>>> import numpy as np
>>> import pandas as pd
>>> import sunwhere
>>>
>>> # Define a 5° resolution global grid
>>> lats = np.arange(-90, 91, 5.0)
>>> lons = np.arange(-180, 180, 5.0)
>>>
>>> # One day at noon UTC
>>> times = pd.date_range('2024-06-21 12:00', periods=1, freq='h', tz='UTC')
>>>
>>> # Compute solar position
>>> result = sunwhere.regular_grid(times, lats, lons)
>>>
>>> # Solar zenith angle has shape (1, 37, 72)
>>> print(result.sza.shape)
(1, 37, 72)
>>>
>>> # Create a map of solar zenith angle
>>> import matplotlib.pyplot as plt
>>> result.sza[0].plot(x='lon', y='lat')
>>> plt.title('Solar Zenith Angle at Summer Solstice Noon UTC')
>>> plt.show()
High-resolution regional grid:
>>> # European domain
>>> lats = np.linspace(35, 70, 141) # 0.25° resolution
>>> lons = np.linspace(-10, 40, 201)
>>>
>>> # Full year, daily resolution
>>> times = pd.date_range('2024-01-01', '2024-12-31', freq='D', tz='UTC')
>>>
>>> # Use NREL algorithm for highest accuracy
>>> result = sunwhere.regular_grid(times, lats, lons, algorithm='nrel')
>>>
>>> # Compute average zenith angle over the year
>>> annual_mean_sza = result.sza.mean(dim='time')
References
- Reda, I. and Andreas, A., 2003. Solar Position Algorithm for Solar Radiation Applications. NREL Report No. TP-560-34302. https://www.nrel.gov/docs/fy08osti/34302.pdf
- Blanco-Muriel, M. et al., 2001. Computing the solar vector. Solar Energy, 70(5), 431-441. https://doi.org/10.1016/S0038-092X(00)00156-0
- Blanco, M. et al., 2020. Updating the PSA sun position algorithm. Solar Energy, 212, 339-341. https://doi.org/10.1016/j.solener.2020.10.084
- Iqbal, M., 1983. An introduction to solar radiation. Academic Press.
See Also
sites : Solar position at multiple fixed locations transect : Solar position along a moving path
Source code in src/sunwhere/usecases.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | |
transect
transect(
times: ndarray[tuple[int], datetime64] | DatetimeIndex,
latitude: ndarray[tuple[int]] | Sequence[float] | float,
longitude: ndarray[tuple[int]]
| Sequence[float]
| float,
algorithm: Literal["psa", "nrel", "iqbal"] = "psa",
refraction: bool = True,
engine: Literal["numexpr", "numpy"] = "numexpr",
) -> Sunpos
Compute solar position along a moving path (transect).
This function calculates solar position for a trajectory where each time instant corresponds to a different geographic location. The output has shape (time,), suitable for moving observers like satellites, aircraft, or ships.
Parameters:
-
(timesarray-like of datetime-like, shape (K,)) –Time instants at which solar position is evaluated. Can be datetime.datetime, pandas.DatetimeIndex, numpy.datetime64, or any type accepted by pandas.to_datetime(). Timezone-naive inputs are assumed to be UTC.
-
(latitudefloat or array-like of float, shape (K,)) –Latitude in degrees for each time instant. Valid range: [-90, 90]. If scalar, the same latitude is used for all times (meridional transect).
-
(longitudefloat or array-like of float, shape (K,)) –Longitude in degrees for each time instant. Valid range: [-180, 180). If scalar, the same longitude is used for all times (zonal transect).
-
(algorithm(psa, nrel, iqbal), default:'psa') –Solar position algorithm to use: - 'psa': Plataforma Solar de Almería algorithm [2] with updated coefficients [3]. Fast and accurate (avg error ~0.002°). Default. - 'nrel': NREL's SPA algorithm [1]. Most accurate (±0.0003°) but slower. Valid for years -2000 to 6000. - 'iqbal': Iqbal's algorithm [4]. Lower accuracy, mainly for educational use.
-
(refractionbool, default:True) –If True (default), applies atmospheric refraction correction to zenith angle. Typically adds ~0.5° correction near the horizon.
-
(engine(numexpr, numpy), default:'numexpr') –Computation engine. 'numexpr' (default) is typically faster for long transects (>100 points), 'numpy' may be faster for short transects.
Returns:
-
sunpos(Sunpos) –Object containing solar position data as xarray DataArrays with dimension (K,) for all variables: dec, eot, ecf, sza, saa, elevation, azimuth, zenith, cosz.
Notes
- This function is designed for scenarios where position changes with time, such as satellite ground tracks, flight paths, or ship routes.
- If latitude and longitude are both scalars, all times share the same location (equivalent to a single site with varying times).
- For multiple fixed locations, use
sites()instead for better performance. - The time array and position arrays must have the same length if both are arrays.
Examples:
Satellite ground track over one orbit:
>>> import numpy as np
>>> import pandas as pd
>>> import sunwhere
>>>
>>> # ISS-like orbit: ~90 minute period
>>> times = pd.date_range('2024-01-15 00:00', periods=100, freq='54s', tz='UTC')
>>>
>>> # Simplified sinusoidal ground track (not physically accurate)
>>> lats = 51.6 * np.sin(2 * np.pi * np.arange(100) / 100)
>>> lons = np.linspace(-180, 180, 100, endpoint=False)
>>>
>>> # Compute solar position along the track
>>> result = sunwhere.transect(times, lats, lons)
>>>
>>> # Check when satellite is in sunlight (elevation > 0)
>>> in_sunlight = result.elevation > 0
>>> print(f"Sunlit for {in_sunlight.sum().item()} of {len(times)} points")
Aircraft flight path from New York to Tokyo:
>>> # Great circle approximation (10-hour flight)
>>> times = pd.date_range('2024-03-20 10:00', periods=121, freq='5min', tz='UTC')
>>>
>>> # Linear interpolation (simplified - not actual great circle)
>>> lats = np.linspace(40.7, 35.7, 121) # NYC to Tokyo
>>> lons = np.linspace(-74.0, 139.7, 121)
>>>
>>> # Compute solar position
>>> result = sunwhere.transect(times, lats, lons, algorithm='nrel')
>>>
>>> # Find solar elevation throughout flight
>>> import matplotlib.pyplot as plt
>>> result.elevation.plot()
>>> plt.axhline(0, color='k', linestyle='--', label='Horizon')
>>> plt.ylabel('Solar Elevation (degrees)')
>>> plt.title('Sun Position During NYC-Tokyo Flight')
>>> plt.legend()
>>> plt.show()
Meridional transect at fixed longitude:
>>> # Moving north along Prime Meridian
>>> times = pd.date_range('2024-06-21 12:00', periods=181, freq='h', tz='UTC')
>>> lats = np.linspace(-90, 90, 181) # South Pole to North Pole
>>> lon = 0.0 # Prime Meridian (scalar)
>>>
>>> result = sunwhere.transect(times, lats, lon)
>>> # Solar zenith angle variation from pole to pole
>>> result.sza.plot()
References
- Reda, I. and Andreas, A., 2003. Solar Position Algorithm for Solar Radiation Applications. NREL Report No. TP-560-34302. https://www.nrel.gov/docs/fy08osti/34302.pdf
- Blanco-Muriel, M. et al., 2001. Computing the solar vector. Solar Energy, 70(5), 431-441. https://doi.org/10.1016/S0038-092X(00)00156-0
- Blanco, M. et al., 2020. Updating the PSA sun position algorithm. Solar Energy, 212, 339-341. https://doi.org/10.1016/j.solener.2020.10.084
- Iqbal, M., 1983. An introduction to solar radiation. Academic Press.
See Also
sites : Solar position at multiple fixed locations regular_grid : Solar position over a latitude-longitude grid
Source code in src/sunwhere/usecases.py
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 | |
Output object
Sunpos
Sunpos(
times,
latitude,
longitude,
algorithm,
engine,
refraction,
usecase,
ecf,
eot,
declination,
zenith,
azimuth,
site_names=None,
)
Container class for sunwhere outputs.
Provides access to the solar geometry parameters, generally as xarray DataArrays.
Parameters:
-
(timesarray-like of datetime-like) –Times where solar geometry is evaluated. Can be numpy datetime64 or any type convertible to pandas DatetimeIndex.
-
(latitudearray-like of float) –Latitude of the locations where solar geometry is evaluated. Must be in the range [-90, 90].
-
(longitudearray-like of float) –Longitude of the locations where solar geometry is evaluated. Must be in the range [-180, 180).
-
(algorithmstr) –Solar position algorithm: 'nrel', 'psa', or 'iqbal'.
-
(enginestr) –Code implementation: 'numpy' or 'numexpr'.
-
(refractionbool) –Whether atmospheric refraction is considered.
-
(usecasestr) –Use case: 'sites', 'regular_grid', or 'transect'.
-
(ecfarray-like of float, shape (n_times,)) –Sun-earth distance (eccentricity) correction factor.
-
(eotarray-like of float, shape (n_times,)) –Equation of time, in minutes.
-
(declinationarray-like of float, shape (n_times,)) –Solar declination, in degrees.
-
(zenithndarray) –Solar zenith angle, in degrees. Shape varies by use case: 1-D for transect, 2-D for sites, 3-D for regular_grid.
-
(azimuthndarray) –Solar azimuth angle, in degrees. Shape varies by use case: 1-D for transect, 2-D for sites, 3-D for regular_grid.
-
(site_namesarray-like of str, default:None) –Names for each site (only used for 'sites' usecase).
Raises:
-
ValueError–If the inputs are not of the proper type or shape.
Methods:
-
airmass–Atmosphere relative optical air mass.
-
daylight_length–Daylight length, in hours.
-
eth–Extraterrestrial horizontal solar irradiance.
-
incidence–Cosine of the solar incidence angle.
-
sunrise–Sunrise angle or time.
-
sunset–Sunset angle or time.
Attributes:
-
algorithm–Solar position algorithm.
-
azimuth–Solar azimuth angle.
-
cosz–Cosine of solar zenith angle.
-
dec–Solar declination.
-
declination–Solar declination.
-
ecf–Sun-earth orbit's eccentricity correction factor.
-
elevation–Solar elevation angle.
-
engine–Calculation engine.
-
eot–Equation of time.
-
has_refraction–Whether solar zenith angle consideres atmospheric refraction.
-
latitude–Latitudes where solar geometry is evaluated, degrees.
-
local_standard_time–Local standard time.
-
longitude–Longitudes.
-
saa–Solar azimuth angle.
-
sza–Solar zenith angle.
-
times–Times where solar geometry is evaluated.
-
times_utc–Universal coordinated times where solar geometry is evaluated.
-
timezone–Timezone.
-
true_solar_time–True solar time.
-
usecase–Usage case.
-
zenith–Solar zenith angle.
Source code in src/sunwhere/_base.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |
azimuth
property
Solar azimuth angle.
Returns:
-
DataArray–Solar azimuth angle, in degrees [-180°, 180°], zero south.
dec
property
declination
property
Solar declination.
Returns:
-
xarray.DataArray:–Solar declination, in degrees.
ecf
property
Sun-earth orbit's eccentricity correction factor.
Returns:
-
xarray.DataArray:–Sun-earth distance correction factor.
elevation
property
has_refraction
property
Whether solar zenith angle consideres atmospheric refraction.
Returns:
-
bool(True if refraction is considered, False otherwise.) –
latitude
property
Latitudes where solar geometry is evaluated, degrees.
Returns:
-
xarray.DataArray:–Latitudes where solar geometry is evaluated, degrees.
local_standard_time
property
Local standard time.
Returns:
-
np.ndarray[tuple[int], np.datetime64]:–Local standard time.
longitude
property
Longitudes.
Returns:
-
xarray.DataArray:–Longitudes where solar geometry is evaluated, degrees.
saa
property
Solar azimuth angle.
Returns:
-
DataArray–Solar azimuth angle, in degrees [-180°, 180°], zero south. Alias for
azimuth.
sza
property
times
property
Times where solar geometry is evaluated.
Returns:
-
np.ndarray[tuple[int], np.datetime64]:–Times where solar geometry is evaluated.
times_utc
property
Universal coordinated times where solar geometry is evaluated.
Returns:
-
np.ndarray[tuple[int], np.datetime64]:–Universal coordinated times.
true_solar_time
property
True solar time.
Returns:
-
xarray.DataArray:–True solar time, known also to as local apparent time.
zenith
property
airmass
airmass(parameterization='gueymard_2003')
Atmosphere relative optical air mass.
Calculates the relative optical air mass of the atmosphere according to various parameterizations.
Parameters:
-
(parameterizationstr, default:'gueymard_2003') –Parameterization to use: 'kasten_1965', 'kasten_and_young_1989', 'gueymard_2001', or 'gueymard_2003'. Default is 'gueymard_2003'.
Returns:
-
DataArray–Relative optical air mass.
Raises:
-
ValueError–If the parameterization is unknown.
References
-
Table V in Kasten, F. (1965) A new table and approximation formula for the relative optical air mass. CRREL Tech. Report 136
-
Kasten, F. and Young, A.T. (1989) Revised optical air mass tables and approximation formula. Applied Optics. Vol. 28(22), pp. 4735-4738. https://doi.org/10.1364/AO.28.004735
-
Table A.1 in Gueymard, C.A. (2001) Parameterized transmittance model for direct bean and circumsolar spectral irradiance. Sol Energy, Vol. 71(5), pp. 325-346. https://doi.org/10.1016/S0038-092X(01)00054-8
-
Eq. B.8 in Gueymard, C.A. (2003) Direct solar transmittance and irradiance predictions with broadband models. Part I - Detailed theoretical performance assessment. Sol Energy, Vol. 74, pp. 355-379. https://doi.org/10.1016/S0038-092X(03)00195-6
Source code in src/sunwhere/_base.py
daylight_length
Daylight length, in hours.
Returns:
-
DataArray–Daylight length in hours.
References
- Eq. (1.5.5) in Iqbal, M., An Introduction to Solar Radiation, Academic Press, 1983.
Source code in src/sunwhere/_base.py
eth
eth(ISC=1361.1, am_correction='none')
Extraterrestrial horizontal solar irradiance.
Calculates the extraterrestrial horizontal solar irradiance, in W m⁻², with optional corrections to account for solar eclipse obscuration and for the effect of high optical airmass if eth is used to evaluate clearness index.
Parameters:
-
(ISCfloat, default:1361.1) –Solar constant, in W m⁻². Default is 1361.1.
-
(am_correctionstr, default:'none') –Whether to use airmass correction. Useful if eth is intended to evaluate the clearness index. Allowed values are 'none', 'perez_1990', 'skarveith_1998', and 'gonzalez_and_calbo_1999'. Default is 'none'.
Returns:
-
DataArray–Extraterrestrial horizontal solar irradiance.
Raises:
-
ValueError–If am_correction is unknown.
References
-
Perez et al. (1990) Making full use of the clearness index for parameterizing hourly insolation conditions. Sol Energy, Vol. 45(2), pp 111-114. https://doi.org/10.1016/0038-092X(90)90036-C
-
Skartveit et al. (1998) An hourly diffuse fraction model with correction for variability and surface albedo. Sol Energy, Vol. 63(3), pp. 173-183. https://doi.org/10.1016/S0038-092X(98)00067-X
-
González and Calbó (1999) Influence of the global radiation variability on the hourly diffuse fraction correlations. Sol Energy, Vol. 65(2), pp. 119-131. https://doi.org/10.1016/S0038-092X(98)00121-2
Source code in src/sunwhere/_base.py
incidence
incidence(sfc_slope, sfc_azimuth)
Cosine of the solar incidence angle.
Calculates the cosine of the solar incidence angle.
Parameters:
-
(sfc_slopefloat) –Surface slope, in degrees.
-
(sfc_azimuthfloat) –Surface orientation, in degrees (east positive).
Returns:
-
DataArray–Cosine of the angle of incidence.
References
- Eq. (1.6.5a) in Iqbal, M., An Introduction to Solar Radiation, Academic Press, 1983.
Source code in src/sunwhere/_base.py
sunrise
sunrise(units='deg')
Sunrise angle or time.
Calculates the sunrise angle or sunrise time.
Parameters:
-
(unitsstr, default:'deg') –Output units: 'deg' for sunrise angle in degrees, 'rad' for radians, 'tst' for true solar time sunrise, 'utc' for UTC, and 'local' for local time sunrise. Default is 'deg'.
Returns:
-
DataArray–Sunrise angle or time.
Raises:
-
ValueError–If units are unknown.
References
- Eq. (1.5.4) in Iqbal, M., An Introduction to Solar Radiation, Academic Press, 1983.
Source code in src/sunwhere/_base.py
603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 | |
sunset
sunset(units='deg')
Sunset angle or time.
Calculates the sunset angle or sunset time.
Parameters:
-
(unitsstr, default:'deg') –Output units: 'deg' for sunset angle in degrees, 'rad' for radians, 'tst' for true solar time sunset, 'utc' for UTC, and 'local' for local time sunset. Default is 'deg'.
Returns:
-
DataArray–Sunset angle or time.
Raises:
-
ValueError–If units are unknown.
References
- Eq. (1.5.4) in Iqbal, M., An Introduction to Solar Radiation, Academic Press, 1983.