Package 'msdrought'

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

Help Index


Finding indices for Dates Relevant to the MSD Calculations

Description

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.

Usage

msdDates(x, peakwindow1, minwindow1, minwindow2, peakwindow2)

Arguments

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

Value

Vector containing the indices corresponding to each year's beginning date, end date, and the critical MSD dates

Examples

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")

msdFilter – A triangular Filter for smoothing data

Description

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.

Usage

msdFilter(x, window = 31, quantity = 2)

Arguments

x

TimeSeries or numeric vector

window

Size of Filter [Default = 31]

quantity

Number of passes to apply filter [Default = 2]

Value

Vector of Yearly data

Examples

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)

Mid Summer Drought Time Series Graphs

Description

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.

Usage

msdGraph(x, year, peakwindow1, minwindow1,
minwindow2, peakwindow2, quantity,
window, timeVector)

Arguments

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)

Value

Graph of Time Series Data

Examples

## Not run: 
data("timeseries")
ts <- timeseries
msdrought::msdGraph(ts, 1982)

## End(Not run)

Mid Summer Drought Function

Description

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.

Usage

msdMain(x, peakwindow1, minwindow1,
minwindow2, peakwindow2, quantity,
window, timeVector)

Arguments

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)

Value

Data frame of all relevant MSD Statistics

Examples

data("timeseries")
ts <- timeseries
df <- msdrought::msdMain(ts)

Main Mid Summer Drought Calculation Function

Description

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.

Usage

msdStats(x, dates, fcn)

Arguments

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'.

Value

SpatRaster or TimeSeries of Yearly data

Examples

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")

msdrought package included timeseries data

Description

A subset of data from the UCSB CHIRPS data set

Usage

timeseries

Format

## 'timeseries' An xts object with precipitation data over a series of five years:

Date

date in YYYY-MM-DD format

Precipitation

daily precipitation in millimeters (mm)

...

Source

<https://www.chc.ucsb.edu/data/chirps>