uniform_data: Converting observation data to uniform time series

Description Usage Arguments Value Examples

View source: R/uniform_data.R

Description

Citizen weather observations do not have uniform standards, this function converts the time series of observations by various citizen weather stations into the same unified form.

Usage

1
2
3
4
5
6
7
8
9
uniform_data(
  data,
  data.column,
  datetime.column,
  timeseq,
  freq = 600,
  method = "average",
  position = "past"
)

Arguments

data

a data.frame that includes observation data with datetime information.

data.column

a character, the selected column name in the data.frame that represents observation data to be checked.

datetime.column

a character, the selected column name in the data.frame that represents dates and times of observations to be checked.

timeseq

a date and time vector, indicating the standard reporting timestamps. timeseq must have the same length with data.

freq

a number, the standard reporting interval time, the unit is "second". We typically use 10 (min) for forecast use, and 60 (min) for analysis use.

method

the matching method, choosing from "average", "maximum", "nearest", or "angle.average". "average": the average value of observations in each time interval with length freq. "maximum": the maximum value of observations in each time interval with length freq. "nearest": the nearest observation to timeseq in each time interval with length freq. "angle.average": the circular average value of angle observations in each time interval with length freq.

position

the time window considered to match the standard 10-min timestamps: "centre" means the time window is centred at the standard timestamps; "past" means the time window is the past 10-min interval of the standard timestamps.

Value

a new matched time series, with standard reporting time every interval minutes.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
library(tidyverse)
datetime = as.POSIXlt(seq(0,30000,300), origin = "2017-02-03 08:00:00")
datetime_seq_standard = as.POSIXlt(seq(0,30000,600), origin = "2017-02-03 08:00:00")
test = tibble(datetime = datetime,
              windspeed = c(rep(10.2,5),seq(10,15,0.1),rep(9.3,45)))
standard_ts = uniform_data(data = test, data.column = 'windspeed',
                           datetime.column = 'datetime',
                           timeseq = datetime_seq_standard,
                           method = "average")
str(standard_ts)
head(standard_ts)

jieyu97/QCwind documentation built on June 18, 2021, 3:37 a.m.