gsod2ki: Convert GSOD data to Julendat standard format

View source: R/gsod2ki.R

gsod2kiR Documentation

Convert GSOD data to Julendat standard format

Description

This function converts GSOD data from native format to standard KiLi SP1 format (Julendat, see https://code.google.com/archive/p/julendat/) and, optionally, to an object of class ki.data.

Usage

gsod2ki(
  data,
  date_col = "YEARMODA",
  prm_col = "TEMP",
  timezone = "NA",
  aggtime = "-999",
  plot_id = "NA",
  ep_plot_id = "xxx",
  station_id = "NA",
  proc_level = -999,
  qual_flag = "NA",
  save_output = FALSE,
  df2ki = FALSE,
  ...
)

Arguments

data

data.frame. Input data, e.g. from dlGsodStations.

date_col

Character or numeric, default is "YEARMODA". Indicates the date column.

prm_col

Character or numeric, default is "TEMP". Indicates the parameter column(s).

timezone

Character, default is "NA".

aggtime

Character, default is "-999".

plot_id

Character, default is "NA".

ep_plot_id

Character, default is "xxx".

station_id

Character, default is "NA".

proc_level

Numeric, default is -999.

qual_flag

Numeric, default is "NA".

save_output

Logical, default is FALSE. If TRUE, a local copy of the reformatted GSOD data will be created based on the settings provided to ...

df2ki

Logical, default is FALSE. If TRUE, the reformatted data is converted to an object of class ki.data.

...

Additional arguments passed to write.csv.

Value

An object of class data.frame or, if df2ki = TRUE, an object of class ki.data.

Author(s)

Florian Detsch

See Also

as.ki.data

Examples

## Not run: 
moshi <- subset(gsodstations, `STATION NAME` == "MOSHI")

gsod_moshi <- dlGsodStations(usaf = moshi$USAF, 
                             start_year = 1990, end_year = 1995, 
                             dsn = tempdir(), 
                             unzip = TRUE)

# Conversion to KiLi SP1 Julendat standard format
jul_moshi <- gsod2ki(data = gsod_moshi, 
                     prm_col = c("TEMP", "MIN", "MAX"), 
                     df2ki = FALSE)

plot(jul_moshi$TEMP, type = "l", lwd = 2, 
     ylim = c(min(jul_moshi$MIN, na.rm = TRUE), max(jul_moshi$MAX, na.rm = TRUE)))
lines(jul_moshi$MIN, col = "blue", lty = 2)
lines(jul_moshi$MAX, col = "red", lty = 2)

# Conversion to `ki.data` object
ki_moshi <- gsod2ki(data = gsod_moshi, 
                    prm_col = c("TEMP", "MIN", "MAX"), 
                    df2ki = TRUE)

str(ki_moshi)

## End(Not run)


environmentalinformatics-marburg/GSODTools documentation built on Jan. 5, 2024, 12:19 a.m.