Progress Solar Module

class progress.mod_solar.Solar(site_data, directory)

Bases: object

A class to handle solar generation data by downloading weather data from the NSRDB, calculating solar generation using PVLib, and preparing data for Monte Carlo Simulation (MCS).

Parameters:
  • site_data (str) – Path to the CSV file containing site data (site name, latitude, longitude, etc.).

  • directory (str) – Directory for saving and reading solar-related data files.

GetSolarProfiles(solar_prob_data)

Extracts and organizes solar data from clustered CSVs for use in Monte Carlo Simulation (MCS). Each cluster directory contains daily solar generation profiles for all sites; these are stacked into a 4D array of shape (cluster, day, hour, site). Probability data for each cluster is also read from the given CSV.

Parameters:

solar_prob_data (str) – Path to the CSV file containing solar probability data (cluster probabilities).

Returns:

A 5-element tuple containing:

  • n_sites (int): Number of solar sites.

  • s_zone_no (pd.Series): Zone numbers corresponding to each site.

  • MW (pd.Series): Rated capacity (in MW) for each site.

  • s_profiles (list[np.ndarray]): A list of 3D NumPy arrays, one per cluster, with shape (days, hours, sites).

  • solar_prob (np.ndarray): Probability values for each cluster.

Return type:

tuple

Raises:

FileNotFoundError – If cluster directories or CSV files are missing.

SolarGen(api_key, your_name, your_affiliation, your_email, year_start, year_end)

Downloads weather data from NREL NSRDB and calculates solar generation using PVLib for each site.

This method:
  1. Iterates through each site and year in the specified range.

  2. Downloads weather data (DNI, GHI, DHI, etc.) from the NSRDB using HTTP requests.

  3. Uses PVLib’s ModelChain with a simple PVWatts-based system to convert the weather data into AC power output.

  4. Writes both the satellite-based and clearsky-based generation profiles to CSV files.

Parameters:
  • api_key (str) – Your personal API key for the NREL NSRDB.

  • your_name (str) – Your full name (required by the NSRDB API).

  • your_affiliation (str) – Your organizational affiliation (required by the NSRDB API).

  • your_email (str) – Your email address (required by the NSRDB API).

  • year_start (int) – Start year for data downloads.

  • year_end (int) – End year (inclusive) for data downloads.

Returns:

None

Return type:

None

Raises:
  • requests.exceptions.RequestException – If there is a network-related error during the download.

  • OSError – If writing to the local file system fails for any reason.

SolarGenGather(year_start, year_end)

Gathers and processes solar generation data from all sites and years, concatenating each site’s satellite-based and clearsky-based generation files into single CSVs. It then computes a clearsky index (CSI) and stores the final data in an Excel file.

Parameters:
  • year_start (int) – Start year (inclusive) for gathering solar generation data.

  • year_end (int) – End year (inclusive) for gathering solar generation data.

Returns:

None

Return type:

None

Raises:
  • FileNotFoundError – If expected CSV files do not exist in the specified directory.

  • OSError – If any file operation (read/write/remove) fails.