prereise.gather.solardata.nsrdb package

Subpackages

Submodules

prereise.gather.solardata.nsrdb.naive module

prereise.gather.solardata.nsrdb.naive.retrieve_data(solar_plant, email, api_key, year='2016')[source]

Retrieve irradiance data from NSRDB and calculate the power output using a simple normalization.

Parameters:
  • solar_plant (pandas.DataFrame) – plant data frame.

  • email (str) – email used to sign up.

  • api_key (str) – API key.

  • year (str) – year.

Returns:

(pandas.DataFrame) – data frame with ‘Pout’, ‘plant_id’, ‘ts’ and ‘ts_id’ as columns. Values are power output for a 1MW generator.

prereise.gather.solardata.nsrdb.nrel_api module

class prereise.gather.solardata.nsrdb.nrel_api.NrelApi(email, api_key, rate_limit=None)[source]

Bases: object

Provides an interface to the NREL API for PSM3 data. It supports downloading this data in csv format, which we use to calculate solar output of a set of plants. The user will need to provide an API key.

Parameters:
  • email (str) –

    email used for API key sign up.

  • api_key (str) – API key.

  • rate_limit (int/float) – minimum seconds to wait between requests to NREL

get_psm3_at(lat, lon, attributes, year, leap_day, dates=None, cache_dir=None)[source]

Get PSM3 data at a given point for the specified year.

Parameters:
  • lat (str) – latitude of the plant

  • lon (str) – longitude of the plant

  • attributes (str) – comma separated list of attributes to query

  • year (str) – the year

  • leap_day (bool) – whether to use a leap day

  • dates (pd.DatetimeIndex) – if provided, use to index the downloaded data frame

  • cache_dir (str) – directory to cache downloaded data. If None, don’t cache.

Returns:

(prereise.gather.solardata.nsrdb.nrel_api.Psm3Data) – a data class containing metadata and time series for the given year and location

class prereise.gather.solardata.nsrdb.nrel_api.Psm3Data(lat: float, lon: float, tz: float, elevation: float, data_resource: DataFrame)[source]

Bases: object

Wrapper class for PSM3 data retrieved from NREL’s API. Contains metadata from the first csv row and a data frame representing the remaining time series

allowed_attrs = {'air_temperature': 'Temperature', 'dhi': 'DHI', 'dni': 'DNI', 'ghi': 'GHI', 'wind_speed': 'Wind Speed'}
static check_attrs(attributes)[source]
data_resource: DataFrame
elevation: float
lat: float
lon: float
rename_attrs = {'DHI': 'df', 'DNI': 'dn', 'Temperature': 'tdry', 'Wind Speed': 'wspd'}
to_dict()[source]

Convert the data to the format expected by nrel-pysam for running SAM simulations

Returns:

(dict) – a dictionary which can be passed to the pvwattsv7 module

tz: float

prereise.gather.solardata.nsrdb.sam module

prereise.gather.solardata.nsrdb.sam.calculate_power(solar_data, pv_dict)[source]

Use PVWatts to translate weather data into power.

Parameters:
  • solar_data (dict) – weather data as returned by Psm3Data.to_dict().

  • pv_dict (dict) – solar plant attributes.

Returns:

(numpy.array) hourly power output.

prereise.gather.solardata.nsrdb.sam.generate_timestamps_without_leap_day(year)[source]

For a given year, return timestamps for each non-leap-day hour, and the timestamp of the beginning of the leap day (if there is one).

Parameters:

year (int/str) – year to generate timestamps for.

Returns:

(tuple) – pandas.DatetimeIndex: for each non-leap-day-hour of the given year. pandas.Timestamp/None: timestamp for the first hour of the leap day (if any).

prereise.gather.solardata.nsrdb.sam.retrieve_data_blended(email, api_key, grid=None, solar_plant=None, interconnect_to_state_abvs=None, year='2016', rate_limit=0.5, cache_dir=None)[source]

Retrieves irradiance data from NSRDB and calculate the power output using the System Adviser Model (SAM). Either a Grid object needs to be passed to grid, or (a data frame needs to be passed to solar_plant and a dictionary needs to be passed to interconnect_to_state_abvs).

Parameters:
  • email (str) – email used to`sign up <https://developer.nrel.gov/signup/>`_.

  • api_key (str) – API key.

  • powersimdata.input.grid.Grid – grid instance.

  • solar_plant (pandas.DataFrame) – plant data frame.

  • interconnect_to_state_abvs (dict/pandas.Series) – mapping of interconnection name to state abbreviations, used to look up average parameters by interconnect when average parameters by state are not available.

  • year (int/str) – year.

  • rate_limit (int/float) – minimum seconds to wait between requests to NREL

  • cache_dir (str) – directory to cache downloaded data. If None, don’t cache.

Returns:

(pandas.DataFrame) – data frame with ‘Pout’, ‘plant_id’, ‘ts’ and ‘ts_id’ as columns. Values are power output for a 1MW generator.

prereise.gather.solardata.nsrdb.sam.retrieve_data_individual(email, api_key, solar_plant, year='2016', rate_limit=0.5, cache_dir=None)[source]

Retrieves irradiance data from NSRDB and calculate the power output using the System Adviser Model (SAM). Either a Grid object needs to be passed to grid, or (a data frame needs to be passed to solar_plant and a string needs to be passed to grid_model.

Parameters:
  • email (str) – email used to`sign up <https://developer.nrel.gov/signup/>`_.

  • api_key (str) – API key.

  • solar_plant (pandas.DataFrame) – plant data frame, plus additional boolean columns ‘Single-Axis Tracking?’, ‘Dual-Axis Tracking?’, ‘Fixed Tilt?’, and float columns ‘Tilt Angle’, ‘Nameplate Capacity (MW)’, and ‘DC Net Capacity (MW)’.

  • year (int/str) – year.

  • rate_limit (int/float) – minimum seconds to wait between requests to NREL

  • cache_dir (str) – directory to cache downloaded data. If None, don’t cache.

Returns:

(pandas.DataFrame) – data frame with ‘Pout’, ‘plant_id’, ‘ts’ and ‘ts_id’ as columns. Values are power output for a 1MW generator.

Module contents