Title: | Calculate Standardised Drought Indices Using NASA POWER Data |
---|---|
Description: | A set of functions designed to calculate the standardised precipitation and standardised precipitation evapotranspiration indices using NASA POWER data as described in Blain et al. (2023) <doi:10.2139/ssrn.4442843>. These indices are calculated using a reference data source. The functions verify if the indices' estimates meet the assumption of normality and how well NASA POWER estimates represent real-world data. Indices are calculated in a routine mode. Potential evapotranspiration amounts and the difference between rainfall and potential evapotranspiration are also calculated. The functions adopt a basic time scale that splits each month into four periods. Days 1 to 7, days 8 to 14, days 15 to 21, and days 22 to 28, 29, 30, or 31, where 'TS=4' corresponds to a 1-month length moving window (calculated 4 times per month) and 'TS=48' corresponds to a 12-month length moving window (calculated 4 times per month). |
Authors: | Gabriel Constantino Blain [aut, cre]
|
Maintainer: | Gabriel Constantino Blain <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.0.9000 |
Built: | 2025-02-18 05:12:32 UTC |
Source: | https://github.com/gabrielblain/powersdi |
Calculates scalar measures of accuracy.
Accuracy(obs_est, conf.int = "Yes", sig.level = 0.95)
Accuracy(obs_est, conf.int = "Yes", sig.level = 0.95)
obs_est |
A 2-column matrix. The reference or observed and the estimated or predicted
data. See |
conf.int |
A character variable ( |
sig.level |
A numeric variable (between 0.90 and 0.95) defining the significance level for parameter the confidence intervals. Default is 0.95. |
An object of class PowerSDI.Accuracy
, a list
, which contains:
Absolute mean error (AME),
square root of the mean squared error (RMSE),
Willmott's indices of agreement:
original (dorig),
modified (dmod) and
refined (dref)
Pearson determination coefficient (R2), and
if conf.int = "Yes"
, confidence intervals.
a <- Accuracy(obs_est = ObsEst, conf.int = "No") a # A generic plotting method is also supplied plot(a)
a <- Accuracy(obs_est = ObsEst, conf.int = "No") a # A generic plotting method is also supplied plot(a)
Contains parameters of the gamma and GEV distributions and the
Pr(Rain = 0)
, "probzero.rain".
DistPar
DistPar
A data.frame
with 13 variables and 48 rows.
longitude in decimal degrees
latitude in decimal degrees
The quartile of each month
Shape parameter of the gamma distribution
Scale parameter of the gamma distribution
Probability of rain=0
Location parameter of the GEV distribution, PE calculated by HS method
Scale parameter of the GEV distribution, PE calculated by HS method
Shape parameter of the GEV distribution, PE calculated by HS method
Location parameter of the GEV distribution, PE calculated by PM method
Scale parameter of the GEV distribution, PE calculated by PM method
Shape parameter of the GEV distribution, PE calculated by PM method
Time scale at which the SDIs will be calculated
Generated by the ScientSDI()
function using NASA
POWER data.
data(DistPar)
data(DistPar)
Contains pairs of reference and estimated data.
ObsEst
ObsEst
A data.frame
with 2 variables and 1434 rows.
PE data from a reference weather station
PE data from the NASA POWER project
Generated by the PowerSDI package using data from NASA POWER and Agronomic Institute.
data(ObsEst)
data(ObsEst)
Calculates the SPI (Standardized Precipitation Index) and SPEI (Standardized Precipitation-Evapotranspiration Index) using NASA POWER data.
OperatSDI( lon, lat, start.date, end.date, PEMethod = "HS", distr = "GEV", parms, TS = 4L )
OperatSDI( lon, lat, start.date, end.date, PEMethod = "HS", distr = "GEV", parms, TS = 4L )
lon |
longitude in decimal degrees. |
lat |
latitude in decimal degrees. |
start.date |
Date at each time when the calculation must start (“YYYY-MM-DD”). |
end.date |
Date at each time when the calculation must end (“YYYY-MM-DD”). |
PEMethod |
A character variable (“HS” (Hargreaves & Samani) or “PM” (Penman-Monteith) defining the potential evapotranspiration method. Default is “HS”. |
distr |
A character variable (“GEV” or “GLO”) defining which distribution is used to calculate the SPEI. Default is “GEV” (generalized extreme value) with “GLO” (generalized logistic distributions) as an option. |
parms |
Parameters required for calculating the SPI and
SPEI. It is provided by the |
TS |
Time scale on the “quart.month” basis (integer values between 1 and 96). |
A data frame with six columns
rainfall,
potential evapotranspiration (PE),
difference between rainfall and PE (in millimiters),
the NASA-SPI,
the NASA-SPEI and
the SDI categories corresponding to each indices estimates.
# This example is not run as it requires data to be downloaded from an API, # which may fail. It also uses data included in this package, "DistPar" for # `parms` here OperatSDI( lon = -47.3, lat = -22.67, start.date = "2023-06-01", end.date = "2023-06-30", PEMethod = "HS", distr = "GEV", parms = DistPar, TS = 4)
# This example is not run as it requires data to be downloaded from an API, # which may fail. It also uses data included in this package, "DistPar" for # `parms` here OperatSDI( lon = -47.3, lat = -22.67, start.date = "2023-06-01", end.date = "2023-06-30", PEMethod = "HS", distr = "GEV", parms = DistPar, TS = 4)
Custom plot()
method for PowerSDI.Accuracy
objects.
## S3 method for class 'PowerSDI.Accuracy' plot(x, ...)
## S3 method for class 'PowerSDI.Accuracy' plot(x, ...)
x |
a 'PowerSDI.Accuracy' object |
... |
Other parameters as passed to |
No return value, called for side effects. Using this will display a scatter plot of reference ETP data (x-axis) and estimated ETP (y-axis) in the active R session.
Plots rainfall and potential evapotranspiration, both Penman-Monteith and Hargreaves and Samani, amounts using NASA POWER data.
PlotData(lon, lat, start.date, end.date)
PlotData(lon, lat, start.date, end.date)
lon |
longitude in decimal degrees: (+) Eastern Hemisphere (-) Western Hemisphere. |
lat |
latitude in decimal degrees: (+) Northern Hemisphere (-) Southern Hemisphere. |
start.date |
date at which the indices estimates should start ("YYYY-MM-DD"). |
end.date |
date at which the indices estimates should end ("YYYY-MM-DD"). |
No return value, called for side effects. Using this will display scatter plots of rainfall and potential evapotranspiration accumulated at the 1-quart.month time scale in the active R session.
# This example requires an Internet connection to fetch data and so is only # run in interactive sessions PlotData( lon = -47.3, lat = -22.87, start.date = "2021-12-28", end.date = "2022-12-31" )
# This example requires an Internet connection to fetch data and so is only # run in interactive sessions PlotData( lon = -47.3, lat = -22.87, start.date = "2021-12-28", end.date = "2022-12-31" )
Custom print()
method for PowerSDI.Accuracy
objects.
## S3 method for class 'PowerSDI.Accuracy' print(x, digits = max(3L, getOption("digits") - 3L), ...)
## S3 method for class 'PowerSDI.Accuracy' print(x, digits = max(3L, getOption("digits") - 3L), ...)
x |
a |
digits |
The number of digits to be used after the decimal when displaying accuracy values. |
... |
ignored |
Nothing. Side-effect: pretty prints a PowerSDI.Accuracy
object
in the R console.
Calculates the Standardised Precipitation Index (SPI) and Standardised Precipitation-Evapotranspiration Index (SPEI) using a reference data source.
Reference(ref, distr = "GEV", PEMethod = "HS", TS = 4L)
Reference(ref, distr = "GEV", PEMethod = "HS", TS = 4L)
ref |
A data frame with the variables required for calculating the SDIs.
See |
distr |
A character variable (“GEV” or “GLO”) defining which distribution is used to calculate the SPEI. Default is “GEV”. |
PEMethod |
A character variable (“HS” or “PM”) defining the potential evapotranspiration method. Default is “HS”. |
TS |
Time scale on the “quart.month” basis (whole values between 1 and 96). Default is 4. |
A data frame with five columns
rain,
potential evapotranspiration,
difference between rainfall and potential evapotranspiration,
SPI calculated at the time scale selected by the user, and
SPIE calculated at the time scale selected by the user
Reference(ref = refHS, distr = "GEV", PEMethod = "HS", TS = 4)
Reference(ref = refHS, distr = "GEV", PEMethod = "HS", TS = 4)
Contains data for calculating the SPI and SPEI.
refHS
refHS
A data.frame
with 10950 rows and 8 variables.
Year
Month
Day
Daily average air temperature at 2 metres above the ground (degrees C)
Daily maximum air temperature at 2 metres above the ground (degrees C)
Daily minimum air temperature at 2 metres above the ground (degrees C)
Daily top of the atmosphere radiation (MJ/m^2/day)
Daily rainfall amounts (mm)
Agronomic Institute and NASA POWER.
data(refHS)
data(refHS)
Contains data for calculating the SPI and SPEI.
refPM
refPM
A data.frame
with 10958 rows and 11 variables.
Year
Month
Day
Daily average air temperature at 2 metres above the ground (degrees C)
Daily maximum air temperature at 2 metres above the ground (degrees C)
Daily minimum air temperature at 2 metres above the ground (degrees C)
Daily top of the atmosphere radiation (MJ/m^2/day)
Daily global horizontal irradiance (MJ/m^2/day)
Daily average wind speed at 2 metres above the ground (m/s)
Daily average relative humidity at 2 metres above the ground (in percentage)
Daily rainfall amounts (mm)
Agronomic Institute and NASA POWER.
data(refPM)
data(refPM)
Verifies concepts expected from SDI. The first step of the SPI and SPEI algorithms is to calculate the cumulative probabilities of their input variables (Guttman 1999). Function estimates the parameters of the gamma, generalized extreme value (GEV), or generalized logistic distributions (GLO) through the L-moments method are provided. This function also allows users to remove suspicious values from the data sample.
ScientSDI( lon, lat, start.date, end.date, distr = "GEV", TS = 4L, Good = "No", sig.level = 0.95, RainUplim = NULL, RainLowlim = NULL, PEUplim = NULL, PELowlim = NULL )
ScientSDI( lon, lat, start.date, end.date, distr = "GEV", TS = 4L, Good = "No", sig.level = 0.95, RainUplim = NULL, RainLowlim = NULL, PEUplim = NULL, PELowlim = NULL )
lon |
longitude in decimal degrees: (+) Eastern Hemisphere, (-) Western Hemisphere. |
lat |
latitude in decimal degrees: (+) Northern hemisphere, (-) Southern Hemisphere. |
start.date |
date at which the indices estimates should start. Format: “YYYY-MM-DD”. |
end.date |
date at which the indices estimates should end. Format: “YYYY-MM-DD”. |
distr |
A character variable (“GEV” or “GLO”) defining the distribution
to calculate the SPEI. Default is |
TS |
Time scale on the quart.month basis (integer values between 1 and 96). Default is 4. |
Good |
A character variable ("Yes" or "No") to calculate or not the goodness-of-fit and normality tests. Default is "No". |
sig.level |
A numeric variable (between 0.90 and 0.95) defining the significance level for parameter Good. Default is "0.95". |
RainUplim |
Optional. Upper limit in millimetres from which rainfall values larger than
it will be removed. Default is |
RainLowlim |
Optional. Lower limit in millimetres from which rainfall values smaller than
it will be removed. Default is |
PEUplim |
Optional. Upper limit in millimetres from which evapotranspiration values
larger than it will be removed. Valid for Hargreaves and Samani method
Default is |
PELowlim |
Optional. Lower limit in millimetres from which evapotranspiration values
smaller than it will be removed. Valid for Hargreaves and Samani method
Default is |
A list
object with data calculated at the time scale selected by the
user. If Good = "Yes"
, this list
object includes:
The “NASA-SPI”, “NASA-SPEI.HS” and “NASA-SPEI.PM.”
The parameters of the distributions (gamma and GEV) used to calculate the indices.
The Lilliefors and Anderson-Darling tests goodness-of-fit tests.
The outcomes of the two normality checking procedures (Wu et al., 2006 and Stagge et al., 2015).
If Good = "No"
, this list
object includes SDI and
DistPar.
This function also presents other data (in millimiters) calculated from the NASA POWER project:
Rainfall amounts (Rain),
potential evapotranspiration values estimated through the Hargreaves and Samani method (PEHS),
potential evapotranspiration values estimated through the FAO-56 Penman-Monteith method (PEPM), and
the difference between rainfall and potential evapotranspiration (PPEHS and PPEPM).
Guttman, N.B., 1999. Accepting the standardized precipitation index: a calculation algorithm 1. JAWRA Journal of the American Water Resources Association, 35(2), pp.311-322.
Stagge, J.H., Tallaksen, L.M., Gudmundsson, L., Van Loon, A.F. and Stahl, K., 2015. Candidate distributions for climatological drought indices (SPI and SPEI). International Journal of Climatology, 35(13), pp.4027-4040.
Wu, H., Svoboda, M.D., Hayes, M.J., Wilhite, D.A. and Wen, F., 2006. Appropriate application of the standardized precipitation index in arid locations and dry seasons. International Journal of Climatology: A Journal of the Royal Meteorological Society, 27(1), pp.65-79.
# This example requires an Internet connection to fetch data and takes >5s # to run, and so is only run in interactive sessions ScientSDI( lon = -47.3, lat = -22.87, start.date = "1993-01-01", end.date = "2022-12-31", TS = 1, Good = "no" )
# This example requires an Internet connection to fetch data and takes >5s # to run, and so is only run in interactive sessions ScientSDI( lon = -47.3, lat = -22.87, start.date = "1993-01-01", end.date = "2022-12-31", TS = 1, Good = "no" )