Title: | Producing Load Shape with Target Peak and Load Factor |
---|---|
Description: | Modifying a load shape to match specific peak and load factor is a fundamental component for various power system planning and operation studies. This package is an efficient tool to modify a reference load shape while matching the desired peak and load factor. The package offers both linear and non-linear method, described in <https://rpubs.com/riazakhan94/load_shape_match_peak_energy>. The user can control the shape of the final load shape by regulating certain parameters. The package provides validation metrics for assessing the derived load shape in terms of preserving time series properties. It also offers powerful graphics, that allows the user to visually assess the derived load shape. |
Authors: | Md Riaz Ahmed Khan [aut, cre] |
Maintainer: | Md Riaz Ahmed Khan <[email protected]> |
License: | GPL-3 |
Version: | 1.1.1 |
Built: | 2025-01-29 04:07:54 UTC |
Source: | https://github.com/riazakhan94/loadshaper |
Hourly load data of different operational areas of Electric Reliability Council of Texas (ERCOT) for year 2019 - 2021. The extra day (2/29/2020) from 2020 was intentionally omitted to have 8760 data for each year.
ercot
ercot
A data frame with 26280 rows and 15 variables.
https://www.ercot.com/gridinfo/load/load_hist/
loads <- ercot[ercot$Year == 2019, ]$COAST plot(loads, type = "l") linear_loadshape <- lslin(loads, target_lf = 0.50) summary(linear_loadshape) #------------------------------------- loads2 <- ercot[ercot$Year == 2020, ]$ERCOT plot(loads2, type = "l") linear_loadshape2 <- lslin(loads2, target_lf = 0.7) summary(linear_loadshape2)
loads <- ercot[ercot$Year == 2019, ]$COAST plot(loads, type = "l") linear_loadshape <- lslin(loads, target_lf = 0.50) summary(linear_loadshape) #------------------------------------- loads2 <- ercot[ercot$Year == 2020, ]$ERCOT plot(loads2, type = "l") linear_loadshape2 <- lslin(loads2, target_lf = 0.7) summary(linear_loadshape2)
lscore
provides a diagnostic score
for evaluating the derived load shape in
retaining time series properties.
lscore(ls, type = "acf", output = 2, lag = NULL)
lscore(ls, type = "acf", output = 2, lag = NULL)
ls |
An object of class |
type |
Type of correlation to be
evaluate, either |
output |
Type of output to be used, either 1 or 2;
uses |
lag |
Maximum lag at which to calculate the acf or pacf.
Same as |
The diagnostic measure is calculated
as a weighted mean absolute percent error (MAPE)
of auto correlation or partial auto correlation
values of the derived series with respect to the original.
The values are calculated for given lag. Lag = 0 is omitted
from calculation for auto correlation as it would be always 1.
If and
are the correlation values of
original and derived load shape at lag
, then weighted
MAPE is calculated as
where
Since wmape
is a measure of error, lower value
indicates better preservation of time
series property.
A list of the followings:
wmape
: Weighted MAPE.
lag
: Lags at which ACF or PACF
values were evaluated and used in calculating wmape
.
type
: Type of Correlation (ACF or PACF)
cor_x
: ACF/PACF values of the original load.
cor_y
: ACF/PACF values of the derived load.
weight
: Weights at different lags used to
calculate wmape
.
loads <- ercot[ercot$Year == 2019, ]$COAST linear_loadshape <- lslin(loads, target_lf = 0.4) # -------------- scores_1 <- lscore(linear_loadshape, type = "acf", lag = 20) print(scores_1) # -------------- scores_2 <- lscore(linear_loadshape, type = "pacf") print(scores_2)
loads <- ercot[ercot$Year == 2019, ]$COAST linear_loadshape <- lslin(loads, target_lf = 0.4) # -------------- scores_1 <- lscore(linear_loadshape, type = "acf", lag = 20) print(scores_1) # -------------- scores_2 <- lscore(linear_loadshape, type = "pacf") print(scores_2)
lslin
applies linear method to a reference load
shape to match the peak and load factor to target values. See "Details"
for the algorithm.
lslin(x, target_max = 10000, target_lf = 0.7)
lslin(x, target_max = 10000, target_lf = 0.7)
x |
A numeric array, representing reference load shape.
All values must be strictly positive containing no |
target_max |
Target peak value of resultant load shape, must be > 0. |
target_lf |
Target load factor of resultant load shape, must be numeric in between 0 and 1 (exclusive). |
The algorithm first evaluates the load factor of the
reference load shape x
, which is
defined by the ratio of average to peak value. If the target load
factor is greater than reference level, then all base
values are multiplied by a number > 1
. If the target
load factor is less than reference level, then all base values are
multiplied by a number < 1
. The multipliers increase/decrease
linearly and are applied to the based values after ordered.
If is the ordered version of
, then
will be multiplied by
, where
is
a constant calculated as:
The load factor of the derived series matches the target.
For ,
is positive and vice-versa.
The algorithm attempts hard to match the load factor of the derived
load shape to the base load factor. becomes large in
magnitude for large difference of base and target load factor.
In case
, it is possible to get negative
multipliers which force the values to be negative. This particular
situation can occur when target load factor is significantly smaller
than the base load factor.
If the target load factor is much bigger than the base load factor, one/both of the followings can occur:
As a linearly increasing function is multiplied
by a decreasing function (), it is possible
that the maximum of the product can exceed the maximum value
of the base (
), resulting in a different load factor.
As a linearly increasing function is multiplied
by a decreasing function (), it is possible
that the product is not strictly decreasing. The product
array is re-ordered to produce the final values.
The return object contains a data frame df
, having the
following columns:
x_index
: An index given to the original load
shape x
, starting from 1 to length(x)
.
x
: The original array x
, unaltered.
x_rank
: The rank of the data points of the
given array x
, from 1 for the peak to
length(x)
for the lowest value.
x_ordered
: Sorted x
(largest to smallest).
x_pu
: Per unit x
, derived by diving x
by max(x)
.
x_ordered_pu
: Per unit x
, sorted from largest
to smallest.
mult
: Derived multipliers, would be applied to
sorted per unit x
.
y_ordered_pu
: Product of per unit sorted x
and mult
.
y_ordered_pu2
: y_ordered_pu
, sorted again,
in case y_ordered_pu
does not become decreasing.
y_pu
: Resultant load shape in per unit. This is
derived by re-ordering y_ordered_pu2
with respect to their
original rank.
y
: Resultant load shape. This is derived by
multiplying y_pu
by taget_max
/ base_max
A list of class "lslin"
, having following elements:
df
: A data frame. See "Details".
beta
: Slope of the linearly increasing/decreasing multipliers.
See "Details".
max_mult
: Maximum of the multipliers.
min_mult
: Minimum of the multipliers.
base_load_factor
: Load factor of the reference load
shape x
.
target_load_factor
: Target load factor.
derived_load_factor
: Load factor of the derived load shape
(object$df$y
).
base_max
: Peak value of the base load shape, x
target_max
: Target peak value of the new load shape.
derived_max
: Peak value of the derived load shape
(object$df$y
)
base_min
: Minimum value of the base load shape, x
derived_min
: Minimum value of the derived load shape
(object$df$y
)
dec_flag
: A logical flag stating
whether the multipliers resulted in strictly decreasing values.
TRUE
indicates the order was not preserved.
Only applicable for target_max
> base_max
.
See "Details".
lf_flag
: A logical flag indicating if the
load factor of the derived shape differs from the target
by more than 1%.
min_pu_flag
: A logical flag indicating existence of
negative values in the derived load shape. TRUE
indicates
the existence of negative values.
Only applicable for target_max
< base_max
.
See "Details".
lslog
,
print.lslin
,
summary.lslin
,
plot.lslin
,
lscore
loads <- ercot[ercot$Year == 2019, ]$COAST plot(loads, type = "l") linear_loadshape <- lslin(loads, target_lf = 0.50) summary(linear_loadshape) #------------------------------------- loads2 <- ercot[ercot$Year == 2020, ]$ERCOT plot(loads2, type = "l") linear_loadshape2 <- lslin(loads2, target_lf = 0.7) summary(linear_loadshape2)#' #------------------------------------- loads3 <- ercot[ercot$Year == 2020, ]$ERCOT plot(loads3, type = "l") linear_loadshape3 <- lslin(loads3, target_lf = 0.95) summary(linear_loadshape3) #------------------------------------- loads4 <- ercot[ercot$Year == 2020, ]$SCENT plot(loads3, type = "l") linear_loadshape4 <- lslin(loads4, target_lf = 0.3) summary(linear_loadshape4)
loads <- ercot[ercot$Year == 2019, ]$COAST plot(loads, type = "l") linear_loadshape <- lslin(loads, target_lf = 0.50) summary(linear_loadshape) #------------------------------------- loads2 <- ercot[ercot$Year == 2020, ]$ERCOT plot(loads2, type = "l") linear_loadshape2 <- lslin(loads2, target_lf = 0.7) summary(linear_loadshape2)#' #------------------------------------- loads3 <- ercot[ercot$Year == 2020, ]$ERCOT plot(loads3, type = "l") linear_loadshape3 <- lslin(loads3, target_lf = 0.95) summary(linear_loadshape3) #------------------------------------- loads4 <- ercot[ercot$Year == 2020, ]$SCENT plot(loads3, type = "l") linear_loadshape4 <- lslin(loads4, target_lf = 0.3) summary(linear_loadshape4)
Logistic Method for Matching Peak and Load Factor
lslog( x, target_max = 10000, target_lf = 0.7, k = 1, inf_pos = 0.5, iter = 500, def_l = 1 )
lslog( x, target_max = 10000, target_lf = 0.7, k = 1, inf_pos = 0.5, iter = 500, def_l = 1 )
x |
A numeric array, representing reference load shape.
All values must be strictly positive containing no |
target_max |
Target peak value of resultant load shape, must be > 0. |
target_lf |
Target load factor of resultant load shape, must be numeric in between 0 and 1 (exclusive). |
k |
Steepness parameter, must be a positive number. See "Details". |
inf_pos |
Inflection point parameter. See "Details". |
iter |
Number of iterations for solving certain parameter. Must be >= 30. See "Details". |
def_l |
Start parameter for solving |
The algorithm first evaluates the load factor of the
reference load shape x
, which is
defined by the ratio of average to peak value. If the target load
factor is greater than reference level, then all base
values are multiplied by a number > 1
. If the target
load factor is less than reference level, then all base values are
multiplied by a number < 1
. The multipliers
increase or decrease with a sigmoid pattern.
The sigmoid function is a transformed version of
Parameter is shape parameter, shaping the
"sigmoidness" of the function. Larger value of
k
indicates more steepness in the function and lower value
results in changes in multipliers in more linear fashion.
Location parameter controls the inflection point
of the function and derived from
inf_pos
.
inf_pos = 0.5
indicates the inflection point of
the sigmoid multipliers is halfway.
The parameter in the sigmoid is numerically solved.
The number of iterations is equal to the
iter
argument,
optimized based on the minimum difference between the derived
and target load factor.
The return object contains a data frame df
, having the
following columns:
x_index
: An index given to the original load
shape x
, starting from 1 to length(x)
.
x
: The original array x
, unaltered.
x_rank
: The rank of the data points of the
given array x
, from 1 for the peak to
length(x)
for the lowest value.
x_ordered
: Sorted x
(largest to smallest).
x_pu
: Per unit x
, derived by diving x
by max(x)
.
x_ordered_pu
: Per unit x
, sorted from largest
to smallest.
mult
: Derived multipliers, would be applied to
sorted per unit x
.
y_ordered_pu
: Product of per unit sorted x
and mult
.
y_ordered_pu2
: y_ordered_pu
, sorted again,
in case y_ordered_pu
does not become decreasing.
y_pu
: Resultant load shape in per unit. This is
derived by re-ordering y_ordered_pu2
with respect to their
original rank.
y
: Resultant load shape. This is derived by
multiplying y_pu
by taget_max
/ base_max
A list of class "lslog"
, having following elements:
df
: A data frame. See "Details".
k
: Steepness parameter. See "Details".
inf_pos
: Inflection point parameter.
See "Details".
L
: Numerically solved optimized L parameter.
See "Details".
max_mult
: Maximum of the multipliers.
min_mult
: Minimum of the multipliers.
base_load_factor
: Load factor of the reference load
shape x
.
target_load_factor
: Target load factor.
derived_load_factor
: Load factor of the derived load shape
(object$df$y
).
base_max
: Peak value of the base load shape, x
target_max
: Target peak value of the new load shape.
derived_max
: Peak value of the derived load shape
(object$df$y
)
base_min
: Minimum value of the base load shape, x
derived_min
: Minimum value of the derived load shape
(object$df$y
)
dec_flag
: A logical flag stating
whether the multipliers resulted in strictly decreasing values.
TRUE
indicates the order was not preserved.
Only applicable for target_max
> base_max
.
See "Details".
lf_flag
: A logical flag indicating if the
load factor of the derived shape differs from the target
by more than 1%.
min_pu_flag
: A logical flag indicating existence of
negative values in the derived load shape. TRUE
indicates
the existence of negative values.
Only applicable for target_max
< base_max
.
See "Details".
lslin
,
print.lslog
,
summary.lslog
,
plot.lslog
,
lscore
loads <- ercot[ercot$Year == 2019, ]$COAST plot(loads, type = "l") logistic_loadshape <- lslog(loads, target_lf = 0.50, k = 0.5) summary(logistic_loadshape) #--------------------------------------------------- loads2 <- ercot[ercot$Year == 2020, ]$ERCOT plot(loads2, type = "l") logistic_loadshape2 <- lslog(loads2, target_lf = 0.6, k = 0.5, inf_pos = 0.4) summary(logistic_loadshape2) #--------------------------------------------------- loads3 <- ercot[ercot$Year == 2020, ]$ERCOT plot(loads3, type = "l") logistic_loadshape3 <- lslog(loads3, target_lf = 0.9) summary(logistic_loadshape3)
loads <- ercot[ercot$Year == 2019, ]$COAST plot(loads, type = "l") logistic_loadshape <- lslog(loads, target_lf = 0.50, k = 0.5) summary(logistic_loadshape) #--------------------------------------------------- loads2 <- ercot[ercot$Year == 2020, ]$ERCOT plot(loads2, type = "l") logistic_loadshape2 <- lslog(loads2, target_lf = 0.6, k = 0.5, inf_pos = 0.4) summary(logistic_loadshape2) #--------------------------------------------------- loads3 <- ercot[ercot$Year == 2020, ]$ERCOT plot(loads3, type = "l") logistic_loadshape3 <- lslog(loads3, target_lf = 0.9) summary(logistic_loadshape3)
Plot method of lslin
object
## S3 method for class 'lslin' plot( x, case = 1, col = c(1, 2), scatter = FALSE, legend = TRUE, leg_pos = "topright", ... = NULL )
## S3 method for class 'lslin' plot( x, case = 1, col = c(1, 2), scatter = FALSE, legend = TRUE, leg_pos = "topright", ... = NULL )
x |
An object of class |
case |
A numeric value from {1, 2, 3} to select the type of plot. See "Details". |
col |
Color of the plots. Can be numeric or
text or mixed as in |
scatter |
Logical. Scatter plot if |
legend |
Logical indicating if legend to be displayed. |
leg_pos |
A text value for position/location
of the legend. Default is |
... |
|
If scatter = FALSE
then per unit load duration curve for case = 1
,
per unit load for case = 2
, actual load (in original
unit) for case = 3
. If scatter = TRUE
then per unit scatter plot for case = 1 or 2
,
actual load scatter plot for case = 3
.
NULL
.
loads <- ercot[ercot$Year == 2019, ]$COAST linear_loadshape <- lslin(loads, target_lf = 0.5) # -------------- plot(linear_loadshape, col = c(2, 4)) plot(linear_loadshape, case = 2, col = c(2, 4)) plot(linear_loadshape, case = 3, col = c("salmon", "deepskyblue"), leg_pos = "topleft")
loads <- ercot[ercot$Year == 2019, ]$COAST linear_loadshape <- lslin(loads, target_lf = 0.5) # -------------- plot(linear_loadshape, col = c(2, 4)) plot(linear_loadshape, case = 2, col = c(2, 4)) plot(linear_loadshape, case = 3, col = c("salmon", "deepskyblue"), leg_pos = "topleft")
Plot method of lslog
object
## S3 method for class 'lslog' plot( x, case = 1, col = c(1, 2), scatter = FALSE, legend = TRUE, leg_pos = "topright", ... = NULL )
## S3 method for class 'lslog' plot( x, case = 1, col = c(1, 2), scatter = FALSE, legend = TRUE, leg_pos = "topright", ... = NULL )
x |
An object of class |
case |
A numeric value from {1, 2, 3} to select the type of plot. See "Details". |
col |
Color of the plots. Can be numeric or
text or mixed as in |
scatter |
Logical. Scatter plot if |
legend |
Logical indicating if legend to be displayed. |
leg_pos |
A text value for position/location
of the legend. Default is |
... |
|
If scatter = FALSE
then per unit load duration curve for case = 1
,
per unit load for case = 2
, actual load (in original
unit) for case = 3
. If scatter = TRUE
then per unit scatter plot for case = 1 or 2
,
actual load scatter plot for case = 3
.
NULL
.
loads <- ercot[ercot$Year == 2019, ]$COAST loads <- ercot[ercot$Year == 2019, ]$COAST log_loadshape <- lslog(loads, target_lf = 0.5, inf_pos = 0.3, k = 0.8) # -------------- plot(log_loadshape, col = c(2, 4)) plot(log_loadshape, case = 2, col = c(2, 4)) plot(log_loadshape, case = 3, col = c("salmon", "deepskyblue"), leg_pos = "topleft")
loads <- ercot[ercot$Year == 2019, ]$COAST loads <- ercot[ercot$Year == 2019, ]$COAST log_loadshape <- lslog(loads, target_lf = 0.5, inf_pos = 0.3, k = 0.8) # -------------- plot(log_loadshape, col = c(2, 4)) plot(log_loadshape, case = 2, col = c(2, 4)) plot(log_loadshape, case = 3, col = c("salmon", "deepskyblue"), leg_pos = "topleft")
Print Summary of Load Shape Score
## S3 method for class 'lscore' print(x, ... = NULL)
## S3 method for class 'lscore' print(x, ... = NULL)
x |
An object of class |
... |
|
NULL
. Prints the summary of the load shape score.
Same as summary.lscore
loads <- ercot[ercot$Year == 2019, ]$SOUTH # -------------- log_loadshape <- lslog(loads, target_lf = 0.5) print(lscore(log_loadshape, type = "acf")) print(lscore(log_loadshape, type = "pacf")) # -------------- lin_loadshape <- lslin(loads, target_lf = 0.5) print(lscore(lin_loadshape, type = "acf")) print(lscore(lin_loadshape, type = "pacf"))
loads <- ercot[ercot$Year == 2019, ]$SOUTH # -------------- log_loadshape <- lslog(loads, target_lf = 0.5) print(lscore(log_loadshape, type = "acf")) print(lscore(log_loadshape, type = "pacf")) # -------------- lin_loadshape <- lslin(loads, target_lf = 0.5) print(lscore(lin_loadshape, type = "acf")) print(lscore(lin_loadshape, type = "pacf"))
Print method for summarizing
lslin
object
## S3 method for class 'lslin' print(x, ... = NULL)
## S3 method for class 'lslin' print(x, ... = NULL)
x |
An object of class |
... |
|
NULL
. Prints the summary of the derived
load shape using linear method.
Same as summary.lslin
# --------------------- loads <- ercot[ercot$Year == 2019, ]$COAST linear_loadshape <- lslog(loads, target_lf = 0.5, k = 0.5) print(linear_loadshape) # --------------------- loads2 <- ercot[ercot$Year == 2019, ]$ERCOT linear_loadshape2 <- lslog(loads2, target_lf = 0.75, k = 1) print(linear_loadshape2)
# --------------------- loads <- ercot[ercot$Year == 2019, ]$COAST linear_loadshape <- lslog(loads, target_lf = 0.5, k = 0.5) print(linear_loadshape) # --------------------- loads2 <- ercot[ercot$Year == 2019, ]$ERCOT linear_loadshape2 <- lslog(loads2, target_lf = 0.75, k = 1) print(linear_loadshape2)
Print method of lslog
object
## S3 method for class 'lslog' print(x, ... = NULL)
## S3 method for class 'lslog' print(x, ... = NULL)
x |
An object of class |
... |
|
NULL
. Prints the summary of the derived
load shape using linear method.
Same as summary.lslog
# --------------------- loads <- ercot[ercot$Year == 2019, ]$COAST logistic_loadshape <- lslog(loads, target_lf = 0.5, k = 0.5) print(logistic_loadshape) # --------------------- loads2 <- ercot[ercot$Year == 2019, ]$ERCOT logistic_loadshape2 <- lslog(loads2, target_lf = 0.75, k = 1) print(logistic_loadshape2)
# --------------------- loads <- ercot[ercot$Year == 2019, ]$COAST logistic_loadshape <- lslog(loads, target_lf = 0.5, k = 0.5) print(logistic_loadshape) # --------------------- loads2 <- ercot[ercot$Year == 2019, ]$ERCOT logistic_loadshape2 <- lslog(loads2, target_lf = 0.75, k = 1) print(logistic_loadshape2)
Summary method of lscore
object
## S3 method for class 'lscore' summary(object, ... = NULL)
## S3 method for class 'lscore' summary(object, ... = NULL)
object |
An object of class |
... |
|
NULL
. Prints the summary of the load shape score.
Same as print.lscore
loads <- ercot[ercot$Year == 2019, ]$SOUTH # -------------- log_loadshape <- lslog(loads, target_lf = 0.5) summary(lscore(log_loadshape, type = "acf")) summary(lscore(log_loadshape, type = "pacf")) # -------------- lin_loadshape <- lslin(loads, target_lf = 0.5) summary(lscore(lin_loadshape, type = "acf")) summary(lscore(lin_loadshape, type = "pacf"))
loads <- ercot[ercot$Year == 2019, ]$SOUTH # -------------- log_loadshape <- lslog(loads, target_lf = 0.5) summary(lscore(log_loadshape, type = "acf")) summary(lscore(log_loadshape, type = "pacf")) # -------------- lin_loadshape <- lslin(loads, target_lf = 0.5) summary(lscore(lin_loadshape, type = "acf")) summary(lscore(lin_loadshape, type = "pacf"))
Summary method of lslin
object
## S3 method for class 'lslin' summary(object, ... = NULL)
## S3 method for class 'lslin' summary(object, ... = NULL)
object |
An object of class |
... |
|
NULL
. Prints the summary of the derived
load shape using linear method.
Same as print.lslin
# --------------------- loads <- ercot[ercot$Year == 2019, ]$COAST linear_loadshape <- lslog(loads, target_lf = 0.5, k = 0.5) summary(linear_loadshape) # --------------------- loads2 <- ercot[ercot$Year == 2019, ]$ERCOT linear_loadshape2 <- lslog(loads2, target_lf = 0.75, k = 1) summary(linear_loadshape2)
# --------------------- loads <- ercot[ercot$Year == 2019, ]$COAST linear_loadshape <- lslog(loads, target_lf = 0.5, k = 0.5) summary(linear_loadshape) # --------------------- loads2 <- ercot[ercot$Year == 2019, ]$ERCOT linear_loadshape2 <- lslog(loads2, target_lf = 0.75, k = 1) summary(linear_loadshape2)
Print method for summarizing
lslog
object
## S3 method for class 'lslog' summary(object, ... = NULL)
## S3 method for class 'lslog' summary(object, ... = NULL)
object |
An object of class |
... |
|
NULL
. Prints the summary of the derived
load shape using linear method.
Same as print.lslog
# --------------------- loads <- ercot[ercot$Year == 2019, ]$COAST logistic_loadshape <- lslog(loads, target_lf = 0.5, k = 0.5) summary(logistic_loadshape) # --------------------- loads2 <- ercot[ercot$Year == 2019, ]$ERCOT logistic_loadshape2 <- lslog(loads2, target_lf = 0.75, k = 1) summary(logistic_loadshape2)
# --------------------- loads <- ercot[ercot$Year == 2019, ]$COAST logistic_loadshape <- lslog(loads, target_lf = 0.5, k = 0.5) summary(logistic_loadshape) # --------------------- loads2 <- ercot[ercot$Year == 2019, ]$ERCOT logistic_loadshape2 <- lslog(loads2, target_lf = 0.75, k = 1) summary(logistic_loadshape2)