Electricity demand

The functions in this module create simulations of hourly electricity demand with and without climate change impacts.

An isolated application and more details about the methods used in this part of the modeling framework are available at [14].

forecastZonalDemandWithReg(yr, genparam, curtailparam)

Forecast demand for given year using linear regression parameters

This function uses the parameters from the previously fitted regressions to estimated future hourly load at each zone.

Parameters
  • yr – (integer) Current year of analysis

  • genparam – object of class Generalparameters

  • curtailparam – object of class Curtailmentparameters

Returns

  • zonalDemand: nested dictionary with hourly load data for each zone in current year in each gcm. {gcm:zone:[hourly demand]}

  • zonalTempDfs: nested dictionary with data frames with meteo and load data for each zone in current year in each gcm. {gcm: zone: Df}

loadRegData(genparam, currYear, zone, curtailparam, idx_gcm, netcdf=False)

Load all necessary data into pandas DFs except intercept (just return value)

Parameters
  • genparam – object of class Generalparameters

  • currYear – (int) current year of simulation

  • zone – (string) ipm zone being simulated

  • curtailparam – object of class Curtailmentparameters

  • idx_gcm – (int) index of GCM being considered (within curtailparam.listgcms)

  • netcdf – (boolean) true if format of meteo data is netcdf

Returns

  • data: dataframe with weather data

  • tempCoefs: dataframe with temperature coefficients

  • intCoefs: dataframe with interactions coefficients (generally not used)

  • fixEffHr: dataframe with fixed effects for each hour of day

  • fixEffYr: data frame with fixed effects of each year

  • intercept: dataframe with intercept

  • holidays: dataframe with list of holidays

getCellForZone(dataDir, zone)

This functions reads a file that maps each zone to a grid cell that has the METEO data that will be used

Parameters
  • dataDir – path to folder with demand data

  • zone – string with symbol for subzone in SERC

Returns

tuple with cellLat, cellLon

getStationForZone(dataDir, zone)

This functions reads a file that maps each zone to a representative city that has the METEO data

Parameters
  • dataDir – path to folder with demand data

  • zone – string with symbol for subzone in SERC

Returns

name of city used for this zone

isolateYrData(data, yr)

Add datetime to each row of data, then isolate year and data of interest.

Parameters
  • data – dataframe with weather data

  • yr – (int) current year

Returns

dataframe with data of current year

addTimeDummies(dataYr, yr, holidays)

Add indicators for day of week, type of day (weekend versus weekday), and season to DF.

Parameters
  • dataYr – dataframe with data of current year

  • yr – (int) current year

  • holidays – dataframe with holidays

addWeekdayOrWeekend(dataYr, holidays)

Adds column that indicates whether weekday or weekend. Import list of holidays from Francisco that also are labeled as weekends.

Parameters
  • dataYr – dataframe with data of current year

  • holidays – dataframe with holidays

predictDemand(dataYr, tempCoefs, intCoefs, fixEffHr, fixEffYr, intercept, yr)

Predict hourly demand using regression function

Adds a column ‘load(MW)’ to data frame dataYr with simulated hourly load

Predict value as:

\[y=\beta_0+\beta_1*T_{bin}+\beta_2*[T_{bin}*dp]+FE_{yr}+FE_{hr}\]

All subfunctions return np array of 8760x1.

Parameters
  • dataYr – data frame with data for regression

  • tempCoefs – temperature coefficients

  • intCoefs – interaction coefficients

  • fixEffHr – fixed effect for hour

  • fixEffYr – fixed effect for year

  • intercept – intercept of regression equation

  • yr – current year

getTempVals(dataYr, tempCoefs)

Estimate temperature dependent load values by first putting T into bins (2d array), then multiplying by per-bin coefficients.

Parameters
  • dataYr – data frame with data for regression

  • tempCoefs – dataframe with coefficients for temperature

Returns

numoy array of estimated load values

getInteractionVals(dataYr, intCoefs)

Element-wise of binned T by dew pt, then dot w/ coefficients

Parameters
  • dataYr – data frame with data for regression

  • intCoefs – dataframe with coefficients for interaction temp * humidity

Returns

getFixEffHrVals(dataYr, fixEffHr)

Add FE hour vals (by season, time of day, and type of day) to DF, then return FEs

Parameters
  • dataYr – data frame with data for regression

  • fixEffHr – dataframe with fixed effect for hour of day

Returns

getFixEffYrVal(yr, fixEffYr, dataYr)

Return np array w/ FE for yr.

Parameters
  • yr – current year

  • fixEffYr – estimated fixed effects

  • dataYr – pandas data frame

Returns

np array with fixed effect for year yr.

createTempComponents(temp, temp_breaks=[0, 10, 20, 30])

Computes temperature components for piecewise linear model

Parameters
  • temp – vector of temperatures (degrees celsius)

  • temp_breaks – (list) temperature break points of piecewise linear function

Returns

matrix with components in columns

convertDewPoint2RelHum(dew_point, temp)

Converts dew point to relative humidity

Uses inverse of formula (8) in: http://journals.ametsoc.org/doi/pdf/10.1175/BAMS-86-2-225

OBS: if both arguments are vectors, they must be the same length

Parameters
  • dew_point – dew point value in Celsius. Can be a vector or an atomic

  • temp – air temperature in Celsius. Can be vector or atomic

Returns

relative humidity in %

convertRelHum2DewPoint(rh, temp)

Converts relative humidity to dew point

uses inverse of formula (8) in: http://journals.ametsoc.org/doi/pdf/10.1175/BAMS-86-2-225

OBS: if both arguments are vectors, they must be the same length

Parameters
  • rh – relative humidity value in % (0 to 100). Can be a vector or an atomic

  • temp – air temperature in Celsius. Can be vector or atomic

Returns

dew point in Celsius