![]() |
0.1.33
|
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 119 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 radians. | |
| float | getSunZenith (self) |
| Get the sun zenith angle in radians. | |
| float | getSunAzimuth (self) |
| Get the sun azimuth angle in radians. | |
| vec3 | getSunDirectionVector (self) |
| Get the sun direction as a 3D unit vector. | |
| SphericalCoord | getSunDirectionSpherical (self) |
| Get the sun direction as spherical coordinates. | |
| setSunDirection (self, SphericalCoord sundirection) | |
| Override the computed solar position with a prescribed sun direction. | |
| 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. | |
| float | 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 (-14 to +12). Helios counts the offset positive moving West, which inverts the real-world UTC-12..UTC+14 span, so the range is asymmetric. 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 143 of file SolarPosition.py.
| pyhelios.SolarPosition.SolarPosition.__del__ | ( | self | ) |
Destructor to ensure C++ resources freed even without 'with' statement.
Definition at line 212 of file SolarPosition.py.
| pyhelios.SolarPosition.SolarPosition.__enter__ | ( | self | ) |
Context manager entry.
Definition at line 202 of file SolarPosition.py.
| pyhelios.SolarPosition.SolarPosition.__exit__ | ( | self, | |
| exc_type, | |||
| exc_val, | |||
| exc_tb ) |
Context manager exit - cleanup resources.
Definition at line 206 of file SolarPosition.py.
|
protected |
Raise if the owning Context has been destroyed (see Context.check_context_alive).
Definition at line 198 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 1044 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 1000 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 1090 of file SolarPosition.py.
| float pyhelios.SolarPosition.SolarPosition.calibrateTurbidityFromTimeseries | ( | self, | |
| str | timeseries_label ) |
Calibrate atmospheric turbidity using timeseries data.
| timeseries_label | Label of timeseries data in Context. The data should be global shortwave radiation flux on a horizontal plane in W/m^2, and should contain at least one day of clear-sky conditions. |
| ValueError | If timeseries label is invalid |
| SolarPositionError | If calibration fails |
Definition at line 797 of file SolarPosition.py.
| pyhelios.SolarPosition.SolarPosition.disableCloudCalibration | ( | self | ) |
Disable cloud calibration.
| SolarPositionError | If operation fails |
Definition at line 839 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 820 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 869 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 679 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 287 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 626 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 475 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 578 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 532 of file SolarPosition.py.
| float pyhelios.SolarPosition.SolarPosition.getSunAzimuth | ( | self | ) |
Get the sun azimuth angle in radians.
| SolarPositionError | If calculation fails |
Definition at line 352 of file SolarPosition.py.
| SphericalCoord pyhelios.SolarPosition.SolarPosition.getSunDirectionSpherical | ( | self | ) |
Get the sun direction as spherical coordinates.
| SolarPositionError | If calculation fails |
Definition at line 394 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 373 of file SolarPosition.py.
| float pyhelios.SolarPosition.SolarPosition.getSunElevation | ( | self | ) |
Get the sun elevation angle in radians.
| SolarPositionError | If calculation fails |
Definition at line 309 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 744 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 765 of file SolarPosition.py.
| float pyhelios.SolarPosition.SolarPosition.getSunZenith | ( | self | ) |
Get the sun zenith angle in radians.
| SolarPositionError | If calculation fails |
Definition at line 330 of file SolarPosition.py.
| bool pyhelios.SolarPosition.SolarPosition.is_available | ( | self | ) |
Check if SolarPosition is available in current build.
Definition at line 1108 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 890 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 954 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 252 of file SolarPosition.py.
| pyhelios.SolarPosition.SolarPosition.setSunDirection | ( | self, | |
| SphericalCoord | sundirection ) |
Override the computed solar position with a prescribed sun direction.
By default the sun position is computed from the date, time and location set in the Context. Calling this method overrides that calculation, so all subsequent sun queries (elevation, zenith, azimuth, direction vectors) and flux calculations use the prescribed direction instead.
| sundirection | SphericalCoord giving the direction of the sun. Elevation and azimuth are in radians. |
| ValueError | If sundirection is not a SphericalCoord |
| SolarPositionError | If the override fails |
Definition at line 429 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 921 of file SolarPosition.py.
|
protected |
Definition at line 184 of file SolarPosition.py.
| pyhelios.SolarPosition.SolarPosition.context = context |
Definition at line 183 of file SolarPosition.py.