FANFARE main module

power_class submodule

source.power_class.d_plot = 'plots/'
class source.power_class.PowerData(**kwargs)

Bases: object

This class defines an object that contains the hourly power system timeseries data to be used

Parameters
  • data_type (str/bool) – type of data, ‘energinet’ for loading Energinet data, default : False

  • load (bool) – if True, load data previously stored as pandas dataframe, if False, download data from url site, default : False

  • year (str/bool) – year to cut out of data, default: False

  • time_cut (list/bool) – start and endtime in np.datetime64-readable format, default: False

  • d_data (str) – path to where data will be stored, default: ‘data/’

  • file_name (str/bool) – file name used to load/save dataset as pandas dataframe, default: False

  • line_limit (int) – max number of lines to read from url site, default: 5

info(verbose=True)

Prints basic info about this dataset.

AddHighPenetrationIndex(**kwargs)

Add index to separate high wind penetration from low

Parameters
  • alpha_cuts (list/bool) – min and max VRE hourly share, used to print diagnostics of data, default: False

  • time_cut (list/bool) – start and endtime in np.datetime64-readable format, default: False

  • power_name (str/bool) – name of the column containing power data to use, default: False

  • load_name (str/bool) – name of the column containing gross electricity consumption data to use, default: False

  • overwrite (bool) – if True, overwrite any previous calculations of VRE hourly share, default: False

AddPenetrationFraction(**kwargs)

Calculates wind penetration in percent of total consumption, and adds result in dataframe.

Parameters
  • time_cut (list/bool) – start and endtime in np.datetime64-readable format, default: False

  • power_names (list) – names of the columns containing power data to use, default: []

  • load_names (list) – names of the columns containing gross electricity consumption data to use, default: []

  • yearly (bool) – if True, calculate annual VRE penetration instead of VRE hourly share, default: False

  • time_cut – start and endtime in np.datetime64-readable format, default: False

  • verbose (bool) – if True, print some status updates, default: False

SetFrequencySetup(**kwargs)

Derive frequency intervals. this method will add frequency cut information, color-coding and labels as attributes to data object.

Parameters
  • duration_cuts (list/bool) – list of duration cuts (each a 2-element list) in hours, default: False

  • labels (list) – list of labels to describe the timescales, default: False

  • labels_verbose (list) – list of more verbose labels to use in plots etc, default: False

GetFluctuations(**kwargs)

Calculates durations and integrated energy of fluctuations within given epoch, returns in dictionary

Parameters
  • col_name (str/bool) – name of the column containing data to use, default: False

  • season (str/bool) – can be ‘summer’ or ‘winter’, default: False

  • time_cut (list/bool) – start and endtime in np.datetime64-readable format, default: False

  • verbose (bool) – if True, print some status updates, default: False

  • overwrite (bool) – if True, overwrite any previous calculations of VRE hourly share, default: False

AddFFT(**kwargs)

Calculates discrete (fast) Fourier transform (DFT) for wind power and adds as attribute to data object.

Parameters
  • power_name (str/bool) – name of the column containing power data to use, default: False

  • verbose (bool) – if True, print some status updates, default: False

AddiFFT(**kwargs)

Calculates inverse Fast Fourier Transform (iFFT) for dataframe data_df and inserts it back into dataframe data_df.

Parameters
  • power_name (str/bool) – name of the column containing power data to use, default: False

  • freq_cut (list) – list of frequency cuts to use in Hz, default: [False]

  • freq_cut_number (int/bool) – actual frequency cut number to use in self.freq_cuts: False

  • verbose (bool) – if True, print some status updates, default: False

  • overwrite (bool) – if True, overwrite any previous calculations of DFT, default: False

GetPowerReqFromiFFT(**kwargs)

Derive power requirements from iDFTs of different frequency intervals, and return as matrix.

Parameters
  • col_names (list) – names of the columns containing residual load data to use, default: []

  • freq_cut_numbers (list) – list of frequency cut numbers to use in self.freq_cuts: []

  • time_cut (list/bool) – start and endtime in np.datetime64-readable format, default: False

  • verbose (bool) – if True, print some status updates, default: False

GetCapacityReq(**kwargs)

Calculate storage capacity needs based on accumulated sum of energy

Parameters
  • col_name (str) – name of the column containing residual load data to use, default: False

  • time_cut (list/bool) – start and endtime in np.datetime64-readable format, default: False

  • plot (bool) – if True, plot the capacity requirements as function of frequency interval, default: False

  • legend (bool) – if True, add legend to plot, default: False

  • verbose (bool) – if True, print some status updates, default: False

PlotHisto(**kwargs)

Plot histogram of an attribute, a column in the dataframe or a supplied data array.

Parameters
  • histogram_values (list) – list of attributes or column names in data object to make a histogram of, default: []

  • data (list/numpy array / bool) – option to supply data that is not in datao bject, default: False

  • time_cut (list/bool) – start and endtime in np.datetime64-readable format, default: False

  • bins (int) – number of bins in histogram, default: 200

  • max_val (int/float) – max value allowed in data, default: 1000

  • remove_zeros (bool) – if True, remove zeros from histogram values before calculating histogram, default: False

  • log (bool) – if True, take logarithm of values before calculating histogram, default: False

  • ylog (bool) – if True, convert y axis to logarithmic, default: False

  • labels (list) – list of labels to describe the histograms, default: False

  • colors (list) – list of colors to plot the histograms, default: [‘b’]

  • ls (list) – list of linestyles to plot the histograms, default: [‘-‘]

  • alpha (int/float) – transparency index used to plot the histograms, default: 1

  • xlim (list/bool) – limits in x axis of plot, default: False

  • ylim (list/bool) – limits in y axis of plot, default: False

  • xlab (str) – x axis title, default: ‘’

  • ylab (str) – y axis title, default: ‘ower [MW]’

  • add (bool) – if True, add to existing axis object, default: False

  • legend (bool) – if True, add legend to plot, default: False

  • histo_counts (bool) – if True, plot counts on y axis otherwise percentages, default: False

  • fig_name (str/bool) – if True, save plot figure with this filename, in d_plot (see top), default: False

PlotPie(**kwargs)

Make pie chart of integrated power fractions.

Parameters
  • int_power (list / numpy array) – array of integrated power in different frequency intervals, default: False

  • add (bool) – if True, add to existing axis object, default: False

  • legend (bool) – if True, add legend to plot, default: False

  • alpha (int/float) – transparency index used to plot the histograms, default: 1

  • radius (int/float) – outer radius of pie chart, default: 1

  • width (int/float) – width of pie chart (allowing for ‘donuts’), default: 1

  • fig_name (str/bool) – if True, save plot figure with this filename, in d_plot (see top), default: False

PlotTimeSeries(**kwargs)

Plots time series of data for specific time period (all times by default).

Parameters
  • col_names (list) – names of the columns containing residual load data to use, default: []

  • ax (axis object / bool) – if an axis object is given, timeseries will be plotted on this axis, default: False

  • time_cut (list/bool) – start and endtime in np.datetime64-readable format, default: False

  • labels (list) – list of labels to describe the histograms, default: False

  • ylim (list/bool) – limits in y axis of plot, default: False

  • ylab (str) – y axis title, default: ‘ower [MW]’

  • alpha (int/float) – transparency index used to plot the histograms, default: 1

  • colors (list) – list of colors to plot the histograms, default: [‘b’]

  • add_shade (list / bool) – list of colors to optionally add shade under the graphs, default: False

  • ls (list) – list of linestyles to plot the histograms, default: [‘-‘]

  • two_axes (bool) – if True, add a 2nd y axis, default: False

  • xlim (list/bool) – limits in x axis of plot, default: False

  • add (bool) – if True, add to existing axis object, default: False

  • legend (bool) – if True, add legend to plot, default: False

  • fig_name (str/bool) – if True, save plot figure with this filename, in d_plot (see top), default: False

  • fig_format (str) – format of save figure, default: ‘png’

PlotPowerReqFromiFFT(**kwargs)

Plot power requirements from iDFTs on different frequency intervals

Parameters
  • matrices (numpy array / bool) – data to plot = output from GetPowerReqFromiFFT(), default: False

  • col_names (list) – names of the columns containing residual load data to use, default: []

  • freq_cut_number (int/bool) – actual frequency cut number to use in self.freq_cuts: False

  • yearly (bool) – if True, plot years on x axis, default: False

  • width (int/float) – width of each box, default: 1

  • offset (int/float) – offset from integer numbers of first box, default: 10

  • labels (list) – list of labels to describe the histograms, default: False

  • colors (list) – list of colors to plot the histograms, default: [‘b’]

  • ls (list) – list of linestyles to plot the histograms, default: [‘-‘]

  • xlabels (list) – list of labels to use on x axis, default: []

  • xlim (list/bool) – limits in x axis of plot, default: False

  • ylim (list/bool) – limits in y axis of plot, default: False

  • ylab (str) – y axis title, default: ‘ower [MW]’

  • add (bool) – if True, add to existing axis object, default: False

  • legend (bool) – if True, add legend to plot, default: False

  • fig_name (str/bool) – if True, save plot figure with this filename, in d_plot (see top), default: False

  • fig_format (str) – format of save figure, default: ‘png’

aux submodule

source.aux.handle_args(kwargs, argkeys_needed, verbose=False)

Make custom namespace containing the relevant parameters for a specific method

Parameters
  • kwargs (dictionary) – keyword arguments supplied to the function by the user

  • args_needed (dictionary) – arguments needed by the function

  • verbose (bool) – if True, print which arguments were not supplied by user and have been replaced by default value, default: False

source.aux.pretty_label(name, percent=False)

Creates a pretty label for plotting etc. for given column name.