Title: | Seasonal Mid-Summer Drought Characteristics |
---|---|
Description: | Characterization of a mid-summer drought (MSD) with precipitation based statistics. The MSD is a phenomenon of decreased rainfall during a typical rainy season. It is a feature of rainfall in much of Central America and is also found in other locations, typically those with a Mediterranean climate. Details on the metrics are in Maurer et al. (2022) <doi:10.5194/hess-26-1425-2022>. |
Authors: | Turner Uyeda [aut], Ed Maurer [aut, cre, cph], Kenneth Joseph [aut], Alex Avila [aut] |
Maintainer: | Ed Maurer <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2024-10-25 05:02:44 UTC |
Source: | https://github.com/turner-scu/msdrought |
This function pulls the indices associated with the dates that correspond with the Mid Summer Drought, as well as the indices that indicate first and last day of each year. This function is used in conjunction with the MSD function.
msdDates(x, peakwindow1, minwindow1, minwindow2, peakwindow2)
msdDates(x, peakwindow1, minwindow1, minwindow2, peakwindow2)
x |
Date vector |
peakwindow1 |
desired date in MMDD format to begin search for early peak |
minwindow1 |
desired date in MMDD format to begin search for minimum |
minwindow2 |
desired date in MMDD format to end search for minimum |
peakwindow2 |
desired date in MMDD format to end search for late peak |
Vector containing the indices corresponding to each year's beginning date, end date, and the critical MSD dates
x <- seq(from = as.Date("1981-01-01"), to = as.Date("1985-12-31"), by = "day") output <- msdDates(x, peakwindow1 = "05-01", minwindow1 = "06-01", minwindow2 = "08-31", peakwindow2 = "10-31")
x <- seq(from = as.Date("1981-01-01"), to = as.Date("1985-12-31"), by = "day") output <- msdDates(x, peakwindow1 = "05-01", minwindow1 = "06-01", minwindow2 = "08-31", peakwindow2 = "10-31")
The filter will take a weighted average of a specified number of points around the point of interest to create a smoother time series. For example, if the size of the filter is set to 31, the filter will take the 15 points before and after the point of interest (for a total of 31 points), and calculate a weighted average based on how far away the points are from the point of interest.
msdFilter(x, window = 31, quantity = 2)
msdFilter(x, window = 31, quantity = 2)
x |
TimeSeries or numeric vector |
window |
Size of Filter [Default = 31] |
quantity |
Number of passes to apply filter [Default = 2] |
Vector of Yearly data
dates <- seq(from = as.Date("1981-01-01"), to = as.Date("1982-12-31"), by = "day") ts <- xts::xts(runif(length(dates), 0, 50),dates) filteredData <- msdrought::msdFilter(ts, window = 31, quantity = 2)
dates <- seq(from = as.Date("1981-01-01"), to = as.Date("1982-12-31"), by = "day") ts <- xts::xts(runif(length(dates), 0, 50),dates) filteredData <- msdrought::msdFilter(ts, window = 31, quantity = 2)
Plots the Time Series of Mid Summer Drought data. The input must be in the form of daily data, with the first data point being January 1st of a respective year.
msdGraph(x, year, peakwindow1, minwindow1, minwindow2, peakwindow2, quantity, window, timeVector)
msdGraph(x, year, peakwindow1, minwindow1, minwindow2, peakwindow2, quantity, window, timeVector)
x |
vector of data or xts |
year |
year of interest |
peakwindow1 |
date in MMDD format to begin analysis (window 1) |
minwindow1 |
date in MMDD format to end analysis (window 1) |
minwindow2 |
date in MMDD format to begin analysis (window 2) |
peakwindow2 |
date in MMDD format to end analysis (window 2) |
quantity |
number of times the filter is to be run |
window |
size of filter |
timeVector |
vector of dates (not needed for xts inputs) |
Graph of Time Series Data
## Not run: data("timeseries") ts <- timeseries msdrought::msdGraph(ts, 1982) ## End(Not run)
## Not run: data("timeseries") ts <- timeseries msdrought::msdGraph(ts, 1982) ## End(Not run)
Generates all relevant statistics for the Mid Summer Drought by running the msdStats function for every applicable metric. The output of msdMain is a dataframe containing every msdStats output for the available years of data.
msdMain(x, peakwindow1, minwindow1, minwindow2, peakwindow2, quantity, window, timeVector)
msdMain(x, peakwindow1, minwindow1, minwindow2, peakwindow2, quantity, window, timeVector)
x |
xts or vector of data |
peakwindow1 |
desired date in MMDD format to begin analysis (window 1) |
minwindow1 |
desired date in MMDD format to end analysis (window 1) |
minwindow2 |
desired date in MMDD format to begin analysis (window 2) |
peakwindow2 |
desired date in MMDD format to end analysis (window 2) |
quantity |
amount of times the filter is run |
window |
size of filter |
timeVector |
vector of dates (not needed for xts inputs) |
Data frame of all relevant MSD Statistics
data("timeseries") ts <- timeseries df <- msdrought::msdMain(ts)
data("timeseries") ts <- timeseries df <- msdrought::msdMain(ts)
This function calculates the different statistics of the mid summer drought from a Time Series. The input must be in the form of daily data, with the first data point being January 1st of a respective year.
msdStats(x, dates, fcn)
msdStats(x, dates, fcn)
x |
Filtered xts data (from msdFilter) |
dates |
Vector of Dates (from the msdDates function) |
fcn |
Specify what values to be pulled from the function. Options are 'duration', 'intensity', 'firstMaxValue', 'secondMaxValue', 'min', 'mindex'. |
SpatRaster or TimeSeries of Yearly data
data("timeseries") ts <- timeseries dates <- zoo::index(ts) filteredData <- msdrought::msdFilter(ts, window = 31, quantity = 2) keyDates <- msdDates(dates) msdrought::msdStats(filteredData, keyDates, fcn = "duration")
data("timeseries") ts <- timeseries dates <- zoo::index(ts) filteredData <- msdrought::msdFilter(ts, window = 31, quantity = 2) keyDates <- msdDates(dates) msdrought::msdStats(filteredData, keyDates, fcn = "duration")
A subset of data from the UCSB CHIRPS data set
timeseries
timeseries
## 'timeseries' An xts object with precipitation data over a series of five years:
date in YYYY-MM-DD format
daily precipitation in millimeters (mm)
...
<https://www.chc.ucsb.edu/data/chirps>