Sun Position

solar_threshold_times(latitude, longitude, start_date, end_date, thresholds, timezone_offset=0)[source]

Find times when the solar elevation crosses specified thresholds.

Parameters:
  • latitude (float) – Latitude of the location.

  • longitude (float) – Longitude of the location.

  • start_date (str) – Start date in ‘YYYY-MM-DD’ format.

  • end_date (str) – End date in ‘YYYY-MM-DD’ format.

  • thresholds (list) – List of 1 or 2 solar elevation thresholds in degrees (e.g., [35] or [35, 50]).

  • timezone_offset (int) – Timezone offset from UTC in hours (e.g., -8 for PST, 1 for CET).

Returns:

DataFrame with reordered columns: [‘Date’, ‘Rise_<lower>’, ‘Rise_<upper>’, ‘Set_<upper>’, ‘Set_<lower>’].

Return type:

pandas.DataFrame

solar_azimuth(latitude, longitude, dt, elevation=0)[source]

Return the solar azimuth (in degrees) at a given latitude, longitude, and datetime.

Parameters:
  • latitude (float) – Latitude of the location.

  • longitude (float) – Longitude of the location.

  • dt (datetime) – The datetime for which to calculate the solar azimuth. This should be in UTC.

  • elevation (float, optional) – Elevation to use in the sunpos calculation (default 0).

Returns:

Solar azimuth in degrees.

Return type:

float

solar_position_increments(latitude, longitude, date, min_elevation, timezone_offset=0, increment='10min')[source]

Return the solar azimuth and solar elevation at user-specified increments for a given date and location, but only for times when the solar elevation exceeds the specified minimum.

Parameters:
  • latitude (float) – Latitude of the location.

  • longitude (float) – Longitude of the location.

  • date (str or datetime.date) – Date in ‘YYYY-MM-DD’ format or as a date object.

  • min_elevation (float) – Minimum solar elevation (in degrees) required to include the time.

  • timezone_offset (int, optional) – Timezone offset from UTC in hours (e.g., -8 for PST). Default is 0.

  • increment (str, optional) – Frequency increment for sampling times (e.g., ‘10min’). Default is ‘10min’.

Returns:

DataFrame with columns:
  • ’Time’: Local time (HH:MM:SS),

  • ’Solar Azimuth’: Solar azimuth in degrees,

  • ’Solar Elevation’: Solar elevation in degrees.

Return type:

pandas.DataFrame

plot_solar_positions(df_positions)[source]

Plot the solar azimuth and elevation for a given day.

Parameters:

df_positions (pd.DataFrame) – DataFrame containing the ‘Solar Azimuth’, ‘Time’, and ‘Elevation’ columns.