acept.weather_profile_api

Module for getting weather profiles from the PVGIS API.

A typical meteorological year (TMY) is a set of meteorological data with data values for every hour in a year for a given geographical location. The data are selected from hourly data for the full time period available, currently 2005-2020 in PVGIS 5.2 for the PVGIS-SARAH2 data source. The data set has been produced by choosing for each month the most “typical” month out of the full time period available.

Default DB for Europe, Asia, Africa and South America (below 20 S):
  • PVGIS-SARAH2: from satellite images

  • time period: 2005-2020

  • spatial resolution: 0.05° x 0.05° (~ 5 km)

Use this module to:
  • send a request to the PVGIS API for a typical meteorological year

  • get TMY weather profiles from the PVGIS API for a given location

  • get TMY temperature profiles from the PVGIS API for a given location

  • calculate GSEE input weather from raw weather data from the PVGIS API for a given location

Explanation of PVGIS fields:
  • T2m: 2-m air temperature (degree Celsius)

  • RH: relative humidity (%)

  • H_sun: Solar elevation angle (degree)

  • G(h): Global irradiance on the horizontal plane (W/m2)

  • Gb(n): Beam/direct irradiance on a plane always normal to sun rays (W/m2)

  • Gd(h): Diffuse irradiance on the horizontal plane (W/m2)

  • IR(h): Surface infrared (thermal) irradiance on a horizontal plane (W/m2)

  • WS10m: 10-m total wind speed (m/s)

  • WD10m: 10-m wind direction (0 = N, 90 = E) (degree)

  • SP: Surface (air) pressure (Pa)

Module Contents

Functions

send_request_to_pvgis(→ dict)

Sends a request to the PVGIS API for a typical meteorological year and returns the response.

build_weather_profile_for_typical_meteorological_year(...)

Build weather profile for a typical meteorological year (TMY) from the PVGIS API.

build_temperature_profile_for_tmy(→ pandas.DataFrame)

Build temperature profile for a typical meteorological year (TMY) from the PVGIS API using the maximal time period

build_temperature_profile_for_tmy_to_uhp_csv(...)

Create CSV with temperature profile for a typical meteorological year (TMY) from the PVGIS API using the maximal

build_weather_profile_for_tmy_to_csv(→ tuple[str, ...)

Create CSV with weather profile for a typical meteorological year (TMY) from the PVGIS API using the maximal time

get_units_for_pvgis_variables(→ pandas.DataFrame)

Get units of PVGIS variables from PVGIS API response metadata and return them as a pandas DataFrame.

Attributes

PVGIS_MIN_YEAR

The minimum year for the typical meteorological year (TMY) is 2005.

PVGIS_MAX_YEAR

The maximum year for the typical meteorological year (TMY) is 2020.

MAX_CALLS_PER_SECOND

The maximum number of calls per second is 30.

PVGIS_VARIABLE_MAP

Mapping of PVGIS variable names to acept variable names.

acept.weather_profile_api.PVGIS_MIN_YEAR = 2005[source]

The minimum year for the typical meteorological year (TMY) is 2005.

acept.weather_profile_api.PVGIS_MAX_YEAR = 2020[source]

The maximum year for the typical meteorological year (TMY) is 2020.

acept.weather_profile_api.MAX_CALLS_PER_SECOND = 30[source]

The maximum number of calls per second is 30.

acept.weather_profile_api.PVGIS_VARIABLE_MAP[source]

Mapping of PVGIS variable names to acept variable names.

acept.weather_profile_api.send_request_to_pvgis(lat: float, lon: float, start_year: int = PVGIS_MIN_YEAR, end_year: int = PVGIS_MAX_YEAR) dict[source]

Sends a request to the PVGIS API for a typical meteorological year and returns the response. As the PVGIS API is rate limited, the function will sleep and retry if the rate limit is exceeded.

Parameters:
  • lat (float) – latitude of the location as a float.

  • lon (float) – longitude of the location as a float.

  • start_year (int) – First year of the typical meteorological year.

  • end_year (int) – Last year of the typical meteorological year.

Raises:

ValueError – If the end year is less than 10 years after the start year.

Returns:

A dictionary containing the data, the months selected, the inputs, and the metadata.

Return type:

dict

acept.weather_profile_api.build_weather_profile_for_typical_meteorological_year(lat: float, lon: float, start_year: int = PVGIS_MIN_YEAR, end_year: int = PVGIS_MAX_YEAR, return_units: bool = False, debug: bool = True) tuple[pandas.DataFrame, pandas.DataFrame | None][source]

Build weather profile for a typical meteorological year (TMY) from the PVGIS API. The time period has to be at least 10 years and between 2005 and 2020 (see PVGIS_MIN_YEAR and PVGIS_MAX_YEAR).

Parameters:
  • lat (float) – latitude of the location as a float.

  • lon (float) – longitude of the location as a float.

  • start_year (int) – First year of the typical meteorological year, must be between 2005 and 2020.

  • end_year (int) – Last year of the typical meteorological year, must be between 2005 and 2020.

  • return_units (bool) – Whether to return the units of the returned DataFrame.

  • debug (bool) – Whether to print debug information.

Raises:

ValueError – If the end year is less than 10 years after the start year. If the start and end year are not between 2005 and 2020. If the latitude and longitude are not between -90 and 90 and -180 and 180.

Returns:

A pandas DataFrame with the weather profile and optionally the units of the fields in the DataFrame.

Return type:

tuple[pandas.DataFrame, pandas.DataFrame | None]

acept.weather_profile_api.build_temperature_profile_for_tmy(lat: float, lon: float) pandas.DataFrame[source]

Build temperature profile for a typical meteorological year (TMY) from the PVGIS API using the maximal time period of 2005 - 2020 (see PVGIS_MIN_YEAR and PVGIS_MAX_YEAR).

Parameters:
  • lat (float) – latitude of the location as a float.

  • lon (float) – longitude of the location as a float.

Returns:

A pandas DataFrame with the temperature profile.

Return type:

pandas.DataFrame

acept.weather_profile_api.build_temperature_profile_for_tmy_to_uhp_csv(lat: float, lon: float, area_id: str) tuple[str, pandas.DataFrame][source]

Create CSV with temperature profile for a typical meteorological year (TMY) from the PVGIS API using the maximal time period of 2005 - 2020 (see PVGIS_MIN_YEAR and PVGIS_MAX_YEAR).

Parameters:
  • lat (float) – latitude of the location as a float.

  • lon (float) – longitude of the location as a float.

  • area_id (str) – id of the area the location belongs to.

Returns:

Path to the created CSV and a pandas DataFrame with the temperature profile.

Return type:

tuple[str, pandas.DataFrame]

acept.weather_profile_api.build_weather_profile_for_tmy_to_csv(lat: float, lon: float, area_id: str) tuple[str, pandas.DataFrame][source]

Create CSV with weather profile for a typical meteorological year (TMY) from the PVGIS API using the maximal time period of 2005 - 2020 (see PVGIS_MIN_YEAR and PVGIS_MAX_YEAR).

Parameters:
  • lat (float) – latitude of the location as a float.

  • lon (float) – longitude of the location as a float.

  • area_id (str) – id of the area the location belongs to.

Returns:

Path to the created CSV and a pandas DataFrame with the weather profile.

Return type:

tuple[str, pandas.DataFrame]

acept.weather_profile_api.get_units_for_pvgis_variables(metadata: dict) pandas.DataFrame[source]

Get units of PVGIS variables from PVGIS API response metadata and return them as a pandas DataFrame.

Parameters:

metadata (dict) – PVGIS API response metadata.

Returns:

A pandas DataFrame with the units of PVGIS variables.

Return type:

pandas.DataFrame