Climate Module

The climate module provides an interface that other objects may use to include weather data in their calculations; it provides weather and solar data to other modules and objects. Objects such as houses and buildings rely on this data to factor outdoor weather into their calculations for internal temperature. The climate data includes temperature, humidity, and solar radiation, which is used to calculate temperature gain that is the result of heat gained from direct exposure of a surface to sunlight.

The climate module supports manual control, TMY2/TMY3-style file parsing, and CSV-driven weather feeds through a csv_reader object.

Climate Object

The climate object is the top-level weather data container and runtime provider. At initialization, it can:

  • operate in manual/FNCS/HELICS mode when no weather file is specified,
  • load TMY/TMY2/TMY3-compatible weather data, or
  • read CSV weather data using a linked csv_reader object.

During synchronization, the climate object updates weather and solar values for the current simulation time. Optional interpolation modes can smooth values between discrete samples.

Input Data Modes

Manual mode

If tmyfile is empty, climate runs in manual control mode and initializes at simulation start.

TMY/TMY2/TMY3 file mode

If tmyfile ends with .tmy or .tmy2, climate uses the TMY reader path. TMY3-style rows are also parsed by the same reader logic when the input format matches the TMY3 CSV row structure.

Notes:

  • TMY2 DST handling has caveats in code; TMY3-style data is preferred for DST-corrected behavior.
  • Solar values are converted internally from W/m^2 to W/sf.
  • Temperature is converted from degC to degF for published temperature.

CSV reader mode

If tmyfile ends with .csv, climate requires a reader object of class csv_reader.

The CSV reader supports:

  • property lines ($name=value),
  • header-driven column mapping,
  • multiple timestamp formats,
  • weather sample scheduling via get_data.

Read more about the csv_reader.

Core Properties

Published climate properties include the following groups.

Location and source

Property Units Description
city none City name metadata.
tmyfile none Input weather filename.
reader object Linked csv_reader object (required for .csv input).
forecast none Forecasting specifications
tz_meridian deg Time-zone meridian used in solar-time calculations.
update_time s Current update timestamp.

Weather state

Property Units Description
temperature degF Air temperature.
humidity pu Relative humidity.
pressure mbar Atmospheric pressure.
wind_speed mph Wind speed.
wind_dir deg Wind direction.
wind_gust mph Wind gust speed.
rainfall in/h Rain rate.
snowdepth in Snow depth.

Solar state

Property Units Description
solar_direct W/sf Direct normal solar irradiance.
solar_diffuse W/sf Diffuse solar irradiance.
solar_global W/sf Global horizontal irradiance.
solar_raw W/sf Raw solar input value.
solar_flux W/sf Directional solar array (H, N, NE, E, SE, S, SW, W, NW).
solar_horiz W/sf Alias of solar_flux[H].
solar_north W/sf Alias of solar_flux[N].
solar_northeast W/sf Alias of solar_flux[NE].
solar_east W/sf Alias of solar_flux[E].
solar_southeast W/sf Alias of solar_flux[SE].
solar_south W/sf Alias of solar_flux[S].
solar_southwest W/sf Alias of solar_flux[SW].
solar_west W/sf Alias of solar_flux[W].
solar_northwest W/sf Alias of solar_flux[NW].
solar_elevation rad Solar elevation angle.
solar_azimuth rad Solar azimuth angle.
solar_zenith rad Solar zenith angle.
extraterrestrial_global_horizontal W/sf Extraterrestrial GHI.
extraterrestrial_direct_normal W/sf Extraterrestrial DNI.
ground_reflectivity pu Ground reflectivity factor.

Record values

Property Units Description
record.low degF Minimum observed temperature.
record.low_day day-of-year Day of minimum observed temperature.
record.high degF Maximum observed temperature.
record.high_day day-of-year Day of maximum observed temperature.
record.solar W/sf Peak observed solar value.

Interpolation

Property Values Description
interpolate NONE, LINEAR, QUADRATIC Weather interpolation mode between source samples.

Mode behavior:

  • NONE: hold source sample values until next sample.
  • LINEAR: linear interpolation between adjacent samples.
  • QUADRATIC: quadratic interpolation using successive samples.

Cloud Model

The climate class includes an optional cloud model.

Property Values/Units Description
cloud_model NONE, CUMULUS Cloud model selection.
cloud_opacity pu Cloud opacity factor used for direct irradiance attenuation.
cloud_speed_factor pu Multiplier on wind-driven cloud pattern translation speed.
cloud_alpha pu Fuzzy cloud shaping parameter.
cloud_num_layers pu Number of fuzzy cloud layers.
cloud_aerosol_transmissivity pu Aerosol transmissivity term.
opq_sky_cov pu Opaque sky cover fraction.
solar_cloud_direct W/sf Cloud-adjusted direct solar value.
solar_cloud_diffuse W/sf Cloud-adjusted diffuse solar value.
solar_cloud_global W/sf Cloud-adjusted global solar value.

Notes:

  • Cloud parameters are bounded in code (for example, opacity in [0,1]).
  • The cumulus cloud model can be computationally expensive.

Published Functions

The climate class publishes solar calculation functions:

  • calculate_solar_radiation_degrees
  • calculate_solar_radiation_radians
  • calculate_solar_radiation_shading_degrees
  • calculate_solar_radiation_shading_radians
  • calculate_solar_radiation_shading_position_radians
  • calculate_solpos_radiation_shading_position_radians
  • calc_solar_ideal_shading_position_radians

These functions provide multiple solar models and coordinate/angle conventions for module integration and custom irradiance calculations.

Solar Radiation Model Background

In the climate module, calculations are performed for solar radiation on a surface facing each of the eight major compass points (N, S, E, W, NE, NW, SE, SW) and a horizontal surface. For each surface, the total incident solar radiation is calculated by the following equation:

\[Q_{solar} = Q_{direct} \cos \left ( \alpha_{incident} \right ) + Q_{diffuse}\]

where

  • \(Q_{direct}\) is the direct normal radiation for time and day.
  • \(Q_{diffuse}\) is the diffuse horizontal radiation.
  • \(A_{incident}\) = the angle of the sun relative to the surface (assuming the surface to be perpendicular to the Earth at that point, excepting the horizontal surface).

The incident angle is calculated by first calculating the solar time, which accounts for the change in the tilt of the earth polar axis with respect to the plane of the orbit around the sun through the year. The solar time is combined with the latitude of the surface, the slope of the surface relative to the horizontal (90 deg for all surfaces except the horizontal surface), and the azimuth angle relative to south (+ east of south, - west of south), and the day of the year (which is used in a calculation of the solar declination angle) to produce the cosine of the incident angle as follows.

\[\begin{align} D_{solar} & = 23.45 \deg \frac{2 \pi}{360} \sin \left ( \frac{2 \pi 284 + D_{year}}{365} \right ) \\ & = 0.409280 \sin \left ( \frac{2 \pi 284 + D_{year}}{365} \right ) \end{align}\]
\[A_{hour} = - \frac{15 \pi}{180} \left ( H_{solar} - 12 \right )\]
\[\begin{align} \cos(A_{incident}) & = \sin(D_{solar}) \sin(L) cos(S) \\ & - \sin(D_{solar}) \cos(L) \sin(S) \cos(Z) \\ & + \cos(D_{solar}) \cos(L) \cos(S) \cos(A_{hour}) \\ & + \cos(D_{solar}) \sin(L) \sin(S) \cos(Z) \cos(A_{hour}) \\ & + \cos(D_{solar}) \sin(S) \sin(Z) \sin(A_{hour}) \end{align}\]

where:

  • \(S\) is the slope of the incident surface (90 deg is vertical);
  • \(Z\) is the surface azimuth angle (angle between the incident surface's origanization (zero is true south, east is positive, west is negative));
  • \(L\) is the latitude (north is positive);
  • \(A_{hour}\) is hour angle, solar noon is zero, and each hour represents 15 deg of longitude with mornings positive and afternoons negative;
  • \(D_{solar}\) is the declination of the sun (the angular position of the sun at solar noon with respect to the plane of the equator).

Leap years are handled by the fact that an hour of year calculation on February 29 would result in the same hour of year as March 1 on a normal year. March 1 would be used twice in a simulation involving a leap year.

Climate Data Sources

Climate data is commonly obtained from NREL NSRDB:

Useful references:

Reference

John A. Duffie and William A. Beckman, Solar Energy Thermal Processes, John Wiley and Sons, 1974.