![]() |
0.1.26
|
High-level interface for solar position calculations and radiation modeling. More...
High-level interface for solar position calculations and radiation modeling.
SolarPosition provides comprehensive solar angle calculations, radiation flux modeling, sunrise/sunset time calculations, and atmospheric turbidity calibration. The plugin automatically uses Context time/date for calculations or can be initialized with explicit coordinates.
This class requires the native Helios library built with SolarPosition support. Use context managers for proper resource cleanup.
Definition at line 50 of file SolarPosition.py.
Public Member Functions | |
| __init__ (self, Context context, Optional[float] utc_offset=None, Optional[float] latitude=None, Optional[float] longitude=None) | |
| Initialize SolarPosition with a Helios context. | |
| __enter__ (self) | |
| Context manager entry. | |
| __exit__ (self, exc_type, exc_val, exc_tb) | |
| Context manager exit - cleanup resources. | |
| __del__ (self) | |
| Destructor to ensure C++ resources freed even without 'with' statement. | |
| None | setAtmosphericConditions (self, float pressure_Pa, float temperature_K, float humidity_rel, float turbidity) |
| Set atmospheric conditions for subsequent flux calculations (modern API). | |
| Tuple[float, float, float, float] | getAtmosphericConditions (self) |
| Get currently set atmospheric conditions from Context. | |
| float | getSunElevation (self) |
| Get the sun elevation angle in degrees. | |
| float | getSunZenith (self) |
| Get the sun zenith angle in degrees. | |
| float | getSunAzimuth (self) |
| Get the sun azimuth angle in degrees. | |
| vec3 | getSunDirectionVector (self) |
| Get the sun direction as a 3D unit vector. | |
| SphericalCoord | getSunDirectionSpherical (self) |
| Get the sun direction as spherical coordinates. | |
| float | getSolarFlux (self, Optional[float] pressure_Pa=None, Optional[float] temperature_K=None, Optional[float] humidity_rel=None, Optional[float] turbidity=None) |
| Calculate total solar flux (supports legacy and modern APIs). | |
| float | getSolarFluxPAR (self, Optional[float] pressure_Pa=None, Optional[float] temperature_K=None, Optional[float] humidity_rel=None, Optional[float] turbidity=None) |
| Calculate PAR (Photosynthetically Active Radiation) solar flux. | |
| float | getSolarFluxNIR (self, Optional[float] pressure_Pa=None, Optional[float] temperature_K=None, Optional[float] humidity_rel=None, Optional[float] turbidity=None) |
| Calculate NIR (Near-Infrared) solar flux. | |
| float | getDiffuseFraction (self, Optional[float] pressure_Pa=None, Optional[float] temperature_K=None, Optional[float] humidity_rel=None, Optional[float] turbidity=None) |
| Calculate the diffuse fraction of solar radiation. | |
| float | getAmbientLongwaveFlux (self, Optional[float] temperature_K=None, Optional[float] humidity_rel=None) |
| Calculate the ambient (sky) longwave radiation flux. | |
| Time | getSunriseTime (self) |
| Calculate sunrise time for the current date and location. | |
| Time | getSunsetTime (self) |
| Calculate sunset time for the current date and location. | |
| calibrateTurbidityFromTimeseries (self, str timeseries_label) | |
| Calibrate atmospheric turbidity using timeseries data. | |
| enableCloudCalibration (self, str timeseries_label) | |
| Enable cloud calibration using timeseries data. | |
| disableCloudCalibration (self) | |
| Disable cloud calibration. | |
| enablePragueSkyModel (self) | |
| Enable Prague Sky Model for physically-based sky radiance calculations. | |
| bool | isPragueSkyModelEnabled (self) |
| Check if Prague Sky Model is currently enabled. | |
| updatePragueSkyModel (self, float ground_albedo=0.33) | |
| Update Prague Sky Model and store spectral-angular parameters in Context. | |
| bool | pragueSkyModelNeedsUpdate (self, float ground_albedo=0.33, float sun_tolerance=0.01, float turbidity_tolerance=0.02, float albedo_tolerance=0.05) |
| Check if Prague Sky Model needs updating based on changed conditions. | |
| calculateDirectSolarSpectrum (self, str label, float resolution_nm=1.0) | |
| Calculate direct beam solar spectrum using SSolar-GOA model. | |
| calculateDiffuseSolarSpectrum (self, str label, float resolution_nm=1.0) | |
| Calculate diffuse solar spectrum using SSolar-GOA model. | |
| calculateGlobalSolarSpectrum (self, str label, float resolution_nm=1.0) | |
| Calculate global (total) solar spectrum using SSolar-GOA model. | |
| bool | is_available (self) |
| Check if SolarPosition is available in current build. | |
Public Attributes | |
| context = context | |
Protected Member Functions | |
| _check_context_alive (self) | |
| Raise if the owning Context has been destroyed (see Context.check_context_alive). | |
Protected Attributes | |
| _solar_pos | |
| pyhelios.SolarPosition.SolarPosition.__init__ | ( | self, | |
| Context | context, | ||
| Optional[float] | utc_offset = None, | ||
| Optional[float] | latitude = None, | ||
| Optional[float] | longitude = None ) |
Initialize SolarPosition with a Helios context.
| context | Active Helios Context instance |
| utc_offset | UTC time offset in hours (-12 to +12). If provided with latitude/longitude, creates plugin with explicit coordinates. |
| latitude | Latitude in degrees (-90 to +90). Required if utc_offset provided. |
| longitude | Longitude in degrees (-180 to +180). Required if utc_offset provided. |
| SolarPositionError | If plugin not available in current build |
| ValueError | If coordinate parameters are invalid or incomplete |
| RuntimeError | If plugin initialization fails |
Definition at line 72 of file SolarPosition.py.
| pyhelios.SolarPosition.SolarPosition.__del__ | ( | self | ) |
Destructor to ensure C++ resources freed even without 'with' statement.
Definition at line 138 of file SolarPosition.py.
| pyhelios.SolarPosition.SolarPosition.__enter__ | ( | self | ) |
Context manager entry.
Definition at line 128 of file SolarPosition.py.
| pyhelios.SolarPosition.SolarPosition.__exit__ | ( | self, | |
| exc_type, | |||
| exc_val, | |||
| exc_tb ) |
Context manager exit - cleanup resources.
Definition at line 132 of file SolarPosition.py.
|
protected |
Raise if the owning Context has been destroyed (see Context.check_context_alive).
Definition at line 124 of file SolarPosition.py.
| pyhelios.SolarPosition.SolarPosition.calculateDiffuseSolarSpectrum | ( | self, | |
| str | label, | ||
| float | resolution_nm = 1.0 ) |
Calculate diffuse solar spectrum using SSolar-GOA model.
Computes the spectral irradiance of diffuse (scattered) solar radiation across 300-2600 nm wavelength range using the SSolar-GOA model. Results are stored in Context global data as a vector of (wavelength, irradiance) pairs.
| label | Label to store the spectrum data in Context global data |
| resolution_nm | Wavelength resolution in nanometers (1.0-2300.0). Lower values give finer spectral resolution but require more computation. Default is 1.0 nm. |
| ValueError | If label is empty or resolution is out of valid range |
| SolarPositionError | If calculation fails |
Definition at line 914 of file SolarPosition.py.
| pyhelios.SolarPosition.SolarPosition.calculateDirectSolarSpectrum | ( | self, | |
| str | label, | ||
| float | resolution_nm = 1.0 ) |
Calculate direct beam solar spectrum using SSolar-GOA model.
Computes the spectral irradiance of direct beam solar radiation across 300-2600 nm wavelength range using the SSolar-GOA (Global Ozone and Atmospheric) spectral model. Results are stored in Context global data as a vector of (wavelength, irradiance) pairs.
| label | Label to store the spectrum data in Context global data |
| resolution_nm | Wavelength resolution in nanometers (1.0-2300.0). Lower values give finer spectral resolution but require more computation. Default is 1.0 nm. |
| ValueError | If label is empty or resolution is out of valid range |
| SolarPositionError | If calculation fails |
Definition at line 870 of file SolarPosition.py.
| pyhelios.SolarPosition.SolarPosition.calculateGlobalSolarSpectrum | ( | self, | |
| str | label, | ||
| float | resolution_nm = 1.0 ) |
Calculate global (total) solar spectrum using SSolar-GOA model.
Computes the spectral irradiance of total solar radiation (direct + diffuse) across 300-2600 nm wavelength range using the SSolar-GOA model. Results are stored in Context global data as a vector of (wavelength, irradiance) pairs.
| label | Label to store the spectrum data in Context global data |
| resolution_nm | Wavelength resolution in nanometers (1.0-2300.0). Lower values give finer spectral resolution but require more computation. Default is 1.0 nm. |
| ValueError | If label is empty or resolution is out of valid range |
| SolarPositionError | If calculation fails |
Definition at line 960 of file SolarPosition.py.
| pyhelios.SolarPosition.SolarPosition.calibrateTurbidityFromTimeseries | ( | self, | |
| str | timeseries_label ) |
Calibrate atmospheric turbidity using timeseries data.
| timeseries_label | Label of timeseries data in Context |
| ValueError | If timeseries label is invalid |
| SolarPositionError | If calibration fails |
Definition at line 669 of file SolarPosition.py.
| pyhelios.SolarPosition.SolarPosition.disableCloudCalibration | ( | self | ) |
Disable cloud calibration.
| SolarPositionError | If operation fails |
Definition at line 711 of file SolarPosition.py.
| pyhelios.SolarPosition.SolarPosition.enableCloudCalibration | ( | self, | |
| str | timeseries_label ) |
Enable cloud calibration using timeseries data.
| timeseries_label | Label of cloud timeseries data in Context |
| ValueError | If timeseries label is invalid |
| SolarPositionError | If calibration setup fails |
Definition at line 692 of file SolarPosition.py.
| pyhelios.SolarPosition.SolarPosition.enablePragueSkyModel | ( | self | ) |
Enable Prague Sky Model for physically-based sky radiance calculations.
The Prague Sky Model provides high-quality spectral and angular sky radiance distribution for accurate diffuse radiation modeling. It accounts for Rayleigh and Mie scattering to produce realistic sky radiance patterns across the 360-1480 nm spectral range.
| SolarPositionError | If operation fails |
Definition at line 741 of file SolarPosition.py.
| float pyhelios.SolarPosition.SolarPosition.getAmbientLongwaveFlux | ( | self, | |
| Optional[float] | temperature_K = None, | ||
| Optional[float] | humidity_rel = None ) |
Calculate the ambient (sky) longwave radiation flux.
This method supports both legacy and modern APIs: - **Legacy API**: Pass temperature and humidity explicitly - **Modern API**: Pass no parameters, uses atmospheric conditions from setAtmosphericConditions()
| temperature_K | Temperature in Kelvin [optional] |
| humidity_rel | Relative humidity as fraction (0.0-1.0) [optional] |
| ValueError | If one parameter provided but not the other |
| SolarPositionError | If calculation fails |
Modern API (uses temperature and humidity from setAtmosphericConditions): >>> solar.setAtmosphericConditions(101325, 288.15, 0.6, 0.1) >>> lw_flux = solar.getAmbientLongwaveFlux()
Definition at line 561 of file SolarPosition.py.
| Tuple[float, float, float, float] pyhelios.SolarPosition.SolarPosition.getAtmosphericConditions | ( | self | ) |
Get currently set atmospheric conditions from Context.
| SolarPositionError | If operation fails |
Definition at line 213 of file SolarPosition.py.
| float pyhelios.SolarPosition.SolarPosition.getDiffuseFraction | ( | self, | |
| Optional[float] | pressure_Pa = None, | ||
| Optional[float] | temperature_K = None, | ||
| Optional[float] | humidity_rel = None, | ||
| Optional[float] | turbidity = None ) |
Calculate the diffuse fraction of solar radiation.
Supports both legacy (parameter-based) and modern (state-based) APIs.
| pressure_Pa | Atmospheric pressure in Pascals [optional] |
| temperature_K | Temperature in Kelvin [optional] |
| humidity_rel | Relative humidity as fraction (0.0-1.0) [optional] |
| turbidity | Atmospheric turbidity coefficient [optional] |
| ValueError | If some parameters provided but not all |
| SolarPositionError | If calculation fails |
Definition at line 508 of file SolarPosition.py.
| float pyhelios.SolarPosition.SolarPosition.getSolarFlux | ( | self, | |
| Optional[float] | pressure_Pa = None, | ||
| Optional[float] | temperature_K = None, | ||
| Optional[float] | humidity_rel = None, | ||
| Optional[float] | turbidity = None ) |
Calculate total solar flux (supports legacy and modern APIs).
This method supports both legacy and modern APIs: - **Legacy API**: Pass all 4 atmospheric parameters explicitly - **Modern API**: Pass no parameters, uses atmospheric conditions from setAtmosphericConditions()
| pressure_Pa | Atmospheric pressure in Pascals (e.g., 101325 for sea level) [optional] |
| temperature_K | Temperature in Kelvin (e.g., 288.15 for 15°C) [optional] |
| humidity_rel | Relative humidity as fraction (0.0-1.0) [optional] |
| turbidity | Atmospheric turbidity coefficient (typically 0.02-0.5) [optional] |
| ValueError | If some parameters provided but not all, or if values are invalid |
| SolarPositionError | If calculation fails or atmospheric conditions not set (modern API) |
Definition at line 357 of file SolarPosition.py.
| float pyhelios.SolarPosition.SolarPosition.getSolarFluxNIR | ( | self, | |
| Optional[float] | pressure_Pa = None, | ||
| Optional[float] | temperature_K = None, | ||
| Optional[float] | humidity_rel = None, | ||
| Optional[float] | turbidity = None ) |
Calculate NIR (Near-Infrared) solar flux.
Supports both legacy (parameter-based) and modern (state-based) APIs.
| pressure_Pa | Atmospheric pressure in Pascals [optional] |
| temperature_K | Temperature in Kelvin [optional] |
| humidity_rel | Relative humidity as fraction (0.0-1.0) [optional] |
| turbidity | Atmospheric turbidity coefficient [optional] |
| ValueError | If some parameters provided but not all |
| SolarPositionError | If calculation fails |
Definition at line 460 of file SolarPosition.py.
| float pyhelios.SolarPosition.SolarPosition.getSolarFluxPAR | ( | self, | |
| Optional[float] | pressure_Pa = None, | ||
| Optional[float] | temperature_K = None, | ||
| Optional[float] | humidity_rel = None, | ||
| Optional[float] | turbidity = None ) |
Calculate PAR (Photosynthetically Active Radiation) solar flux.
Supports both legacy (parameter-based) and modern (state-based) APIs.
| pressure_Pa | Atmospheric pressure in Pascals [optional] |
| temperature_K | Temperature in Kelvin [optional] |
| humidity_rel | Relative humidity as fraction (0.0-1.0) [optional] |
| turbidity | Atmospheric turbidity coefficient [optional] |
| ValueError | If some parameters provided but not all |
| SolarPositionError | If calculation fails |
Definition at line 414 of file SolarPosition.py.
| float pyhelios.SolarPosition.SolarPosition.getSunAzimuth | ( | self | ) |
Get the sun azimuth angle in degrees.
| SolarPositionError | If calculation fails |
Definition at line 274 of file SolarPosition.py.
| SphericalCoord pyhelios.SolarPosition.SolarPosition.getSunDirectionSpherical | ( | self | ) |
Get the sun direction as spherical coordinates.
| SolarPositionError | If calculation fails |
Definition at line 316 of file SolarPosition.py.
| vec3 pyhelios.SolarPosition.SolarPosition.getSunDirectionVector | ( | self | ) |
Get the sun direction as a 3D unit vector.
| SolarPositionError | If calculation fails |
Definition at line 295 of file SolarPosition.py.
| float pyhelios.SolarPosition.SolarPosition.getSunElevation | ( | self | ) |
Get the sun elevation angle in degrees.
| SolarPositionError | If calculation fails |
Definition at line 234 of file SolarPosition.py.
| Time pyhelios.SolarPosition.SolarPosition.getSunriseTime | ( | self | ) |
Calculate sunrise time for the current date and location.
| SolarPositionError | If calculation fails |
Definition at line 626 of file SolarPosition.py.
| Time pyhelios.SolarPosition.SolarPosition.getSunsetTime | ( | self | ) |
Calculate sunset time for the current date and location.
| SolarPositionError | If calculation fails |
Definition at line 647 of file SolarPosition.py.
| float pyhelios.SolarPosition.SolarPosition.getSunZenith | ( | self | ) |
Get the sun zenith angle in degrees.
| SolarPositionError | If calculation fails |
Definition at line 254 of file SolarPosition.py.
| bool pyhelios.SolarPosition.SolarPosition.is_available | ( | self | ) |
Check if SolarPosition is available in current build.
Definition at line 978 of file SolarPosition.py.
| bool pyhelios.SolarPosition.SolarPosition.isPragueSkyModelEnabled | ( | self | ) |
Check if Prague Sky Model is currently enabled.
| SolarPositionError | If operation fails |
Definition at line 761 of file SolarPosition.py.
| bool pyhelios.SolarPosition.SolarPosition.pragueSkyModelNeedsUpdate | ( | self, | |
| float | ground_albedo = 0.33, | ||
| float | sun_tolerance = 0.01, | ||
| float | turbidity_tolerance = 0.02, | ||
| float | albedo_tolerance = 0.05 ) |
Check if Prague Sky Model needs updating based on changed conditions.
Enables lazy evaluation to avoid expensive Prague updates when conditions haven't changed significantly. Compares current state against cached values.
| ground_albedo | Current ground albedo (default: 0.33) |
| sun_tolerance | Threshold for sun direction changes (default: 0.01 ≈ 0.57°) |
| turbidity_tolerance | Relative threshold for turbidity (default: 0.02 = 2%) |
| albedo_tolerance | Threshold for albedo changes (default: 0.05 = 5%) |
| SolarPositionError | If check fails |
Definition at line 824 of file SolarPosition.py.
| None pyhelios.SolarPosition.SolarPosition.setAtmosphericConditions | ( | self, | |
| float | pressure_Pa, | ||
| float | temperature_K, | ||
| float | humidity_rel, | ||
| float | turbidity ) |
Set atmospheric conditions for subsequent flux calculations (modern API).
This method sets global atmospheric conditions in the Context that are used by parameter-free flux methods (modern API). Once set, you can call getSolarFlux(), getSolarFluxPAR(), etc. without passing atmospheric parameters.
| pressure_Pa | Atmospheric pressure in Pascals (e.g., 101325 for sea level) |
| temperature_K | Temperature in Kelvin (e.g., 288.15 for 15°C) |
| humidity_rel | Relative humidity as fraction (0.0-1.0) |
| turbidity | Atmospheric turbidity coefficient (typically 0.02-0.5) |
| ValueError | If atmospheric parameters are out of valid ranges |
| SolarPositionError | If operation fails |
Definition at line 178 of file SolarPosition.py.
| pyhelios.SolarPosition.SolarPosition.updatePragueSkyModel | ( | self, | |
| float | ground_albedo = 0.33 ) |
Update Prague Sky Model and store spectral-angular parameters in Context.
This is a computationally intensive operation (~1100 model queries with OpenMP parallelization) that computes sky radiance distribution for current atmospheric and solar conditions. Use pragueSkyModelNeedsUpdate() for lazy evaluation to avoid unnecessary updates.
| ground_albedo | Ground surface albedo (default: 0.33 for typical soil/vegetation) |
| SolarPositionError | If update fails |
Definition at line 792 of file SolarPosition.py.
|
protected |
Definition at line 110 of file SolarPosition.py.
| pyhelios.SolarPosition.SolarPosition.context = context |
Definition at line 109 of file SolarPosition.py.