solar¶
solar
¶
Compute Swift (1976) clear-sky potential solar radiation on sloped surfaces.
Port pywatershed's PRMSSolarGeometry.compute_soltab() into a standalone
pure-function module for use in hydro-param's derivation step 9 (soltab).
The algorithm computes potential clear-sky direct-beam solar radiation on
sloped and horizontal surfaces for every day of the year (1--366) using
the equivalent-slope method of Lee (1963) with Swift's (1976) extensions.
The module is vectorised over HRUs: all public functions accept arrays of
shape (nhru,) for slope, aspect, and latitude, and return arrays of
shape (366, nhru) -- one row per day of the year.
Units
- Radiation: Langleys (cal/cm\ :sup:
2/day) - Sunlight duration: hours
- Slope: decimal fraction (rise/run)
- Aspect: degrees clockwise from north
- Latitude: decimal degrees
Notes
This is a faithful port of the Fortran-origin algorithm preserved in
pywatershed's Python codebase. Array aliasing behaviour (e.g.,
t3 = t7 sharing the same ndarray) is intentionally replicated to
match pywatershed's results exactly.
References
Swift, L.W., 1976, Algorithm for solar radiation on mountain slopes: Water Resources Research, v. 12, no. 1, p. 108--112. Lee, R., 1963, Evaluation of solar beam irradiation as a climatic parameter of mountain watersheds: Colorado State University Hydrology Papers, no. 2.
See Also
hydro_param.derivations.pywatershed : Derivation step 9 calls compute_soltab.
solar_declination
module-attribute
¶
solar_declination: NDArray[floating] = (
0.006918
- 0.399912 * cos(_yy)
+ 0.070257 * sin(_yy)
- 0.006758 * cos(2 * _yy)
+ 0.000907 * sin(2 * _yy)
- 0.002697 * cos(3 * _yy)
+ 0.00148 * sin(3 * _yy)
)
Solar declination angle (radians) for each day of the year, shape (366,).
r1
module-attribute
¶
Extraterrestrial irradiance corrected for Earth-Sun distance (Langleys/hr), shape (366,).
compute_soltab
¶
compute_soltab(
slopes: NDArray[floating],
aspects: NDArray[floating],
lats: NDArray[floating],
) -> tuple[
NDArray[np.floating],
NDArray[np.floating],
NDArray[np.floating],
]
Compute potential clear-sky solar radiation tables for PRMS.
Implement the Swift (1976) algorithm for potential direct-beam solar radiation on sloped and horizontal surfaces for every day of the year (1--366). This is the public entry point for derivation step 9 (soltab) in the pywatershed parameterization pipeline.
The function runs the core algorithm twice: once for horizontal surfaces (zero slope, zero aspect) and once for the actual sloped surfaces. Both results are needed by PRMS -- the horizontal radiation is used as a reference for computing the slope correction factor.
| PARAMETER | DESCRIPTION |
|---|---|
slopes
|
Slope as decimal fraction (rise/run), non-negative. Values above 10.0 trigger a warning since they likely indicate degree input rather than fractional.
TYPE:
|
aspects
|
Aspect in degrees, 0--360 clockwise from north (0 = north, 180 = south). Flat HRUs conventionally use aspect = 0.
TYPE:
|
lats
|
Latitude in decimal degrees, range [-90, 90].
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
soltab_potsw
|
Potential solar radiation on the sloped surface (Langleys, cal/cm2/day).
TYPE:
|
soltab_horad_potsw
|
Potential solar radiation on a horizontal surface (Langleys, cal/cm2/day).
TYPE:
|
soltab_sunhrs
|
Hours of direct sunlight on the sloped surface.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If input arrays have mismatched lengths, are empty, contain NaN, or have out-of-range values (latitude outside [-90, 90] or negative slopes). |
Notes
Input validation is strict: NaN values, mismatched array lengths,
and out-of-range latitudes all raise ValueError rather than
producing silently incorrect output. Slopes > 10 produce a warning
but do not error, in case extreme terrain is intentional.
References
Swift, L.W., 1976, Algorithm for solar radiation on mountain slopes: Water Resources Research, v. 12, no. 1, p. 108--112.
See Also
hydro_param.derivations.pywatershed : Step 9 calls this function.
Source code in src/hydro_param/solar.py
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 | |