breos.weather.fetch_tmy_nsrdb#

breos.weather.fetch_tmy_nsrdb(latitude, longitude, api_key=None, email=None, year='tmy', location_name=None, freq='h', save_to_file=False)[source]#

Fetch TMY data from NREL’s NSRDB (National Solar Radiation Database) via pvlib.

Uses pvlib.iotools.get_nsrdb_psm4_tmy (PSM4 API). Requires NREL_API_KEY and NREL_EMAIL environment variables, or pass them directly. Get a free key at https://developer.nrel.gov/signup/

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

  • longitude (float) – Longitude of the location

  • api_key (Optional[str]) – NREL API key (falls back to NREL_API_KEY env var)

  • email (Optional[str]) – Email for NREL API (falls back to NREL_EMAIL env var)

  • year (str) – TMY variant — ‘tmy’ for TMY, or a specific year string like ‘2020’

  • location_name (Optional[str]) – Location name for the output filename

  • freq (str) – Output frequency (‘h’ for hourly, ‘15min’ for 15-minute)

  • save_to_file (bool) – Whether to save the data to CSV

Return type:

Tuple[DataFrame, dict]

Returns:

Tuple of (weather DataFrame, metadata dict)

Raises:

ValueError – If API key or email not provided