calc_nd: Day Counter

Description Usage Arguments Examples

View source: R/calc_nd_deprecated.r View source: R/calc_nd.r

Description

Counts the number of days that meet a user-specified condition and returns a spatially-explicit result. This can be used to extract indices such as Growing Degree Days (tmin > 0), or days with precipitation (prcp != 0).

This tool counts the number of days in a given time period that meet a given set of criteria. This can be used to extract indices such as Growing Degree Days (tmin > 0), or days with precipitation (prcp != 0).

Usage

1
2
3
4
5
calc_nd(data = NULL, startday = 0, endday = 365, criteria = NULL,
  value = NULL, internal = FALSE)

calc_nd(data = NULL, startday = 0, endday = 365, criteria = NULL,
  value = NULL, internal = FALSE)

Arguments

data

string containing the name of a file containing the daily Daymet data to be evaluated

startday

numeric day of year at which counting should begin. Default = 0 (January 1)

endday

numeric day of year at which counting should end. Default = 365 (December 31)

criteria

A binary operator (e.g. ">") to be evaluated. This must be in quotes "".

value

numeric The value that the criteria is to be evaluated against.

internal

logical If FALSE, write the output to a tif file using the Daymet file format protocol.

file

string The name of the file to be processed. Use daily Daymet data.

start_day

numeric Day of year at which counting should begin. Default = 0 (January 1).

end_day

numeric Day of year at which counting should end. Default = 365 (usually December 31).

name

character An identifier to include in the name of the output file. Used only if internal = FALSE.

output_directory

vector (optional) A path to a directory where output files should be written. Used only if internal = FALSE.

criteria

logical expression (e.g. ">") to be evaluated

value

numeric the value that the criteria is to be evaluated against

internal

TRUE / FALSE (if FALSE, write the output to file) using the Daymet file format protocol.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 ## Not run: 
 # These examples demonstrate how calc_nd can be used to count 
 # Growing Degree Days and Freezing Degree Days.
 
 #In this example the data has already been downloaded using the 
 #download_daymet_ncss function.
 
 # First, set the working directory as the directory 
 # containing the file to be processed.
 setwd(tempdir())
 
 # Next, specify the name of the file.
 data_file <- "tmin_daily_1980_ncss.nc"
 
 # Finally, run the function.
 # Growing Degree Days are defined here as days in which the 
 # minimum temperature is greater than 2 C (tmin > 2).
 calc_nd(file = data_file,
         criteria = ">",
         value = 2,
         name = "GDD")
 
 # If you wish to write the  result into a separate directory 
 #then specify the path to that directory, then pass that 
 #directory to the function.
 out_dir <- "c:/.../results/"
 
 calc_nd(file = data_file,
         criteria = ">",
         value = 2,
         name = "GDD",
         output_directory = out_dir)
 
 # Freezing degree days are defined here as days in which the 
 # minimum temperature is less than 0 C (tmin < 0).
 calc_nd(file = data_file,
         criteria = "<",
         value = 0,
         name = "FDD")
 
 
## End(Not run) 

mastefan/messy documentation built on April 19, 2018, 12:22 a.m.