diff --git a/README.md b/README.md index 1539129..7d3e8ea 100755 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ [![CRAN status](https://www.r-pkg.org/badges/version/climatrends)](https://cran.r-project.org/package=climatrends) [![cran checks](https://cranchecks.info/badges/worst/climatrends)](https://cran.r-project.org/web/checks/check_results_climatrends.html) [![Downloads](https://cranlogs.r-pkg.org/badges/climatrends)](https://cran.r-project.org/package=climatrends) -[![Build Status](https://travis-ci.org/agrdatasci/climatrends.svg?branch=master)](https://travis-ci.org/agrdatasci/climatrends) [![codecov](https://codecov.io/gh/agrdatasci/climatrends/master.svg)](https://codecov.io/github/agrdatasci/climatrends?branch=master) [![Project Status](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) [![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing) diff --git a/docs/404.html b/docs/404.html index a3b9513..7ef4453 100755 --- a/docs/404.html +++ b/docs/404.html @@ -79,7 +79,7 @@ climatrends - 0.1.11 + 0.2 diff --git a/docs/CODE_OF_CONDUCT.html b/docs/CODE_OF_CONDUCT.html index debd63d..342df72 100755 --- a/docs/CODE_OF_CONDUCT.html +++ b/docs/CODE_OF_CONDUCT.html @@ -79,7 +79,7 @@ climatrends - 0.1.11 + 0.2 diff --git a/docs/CONTRIBUTING.html b/docs/CONTRIBUTING.html index 93254c5..e97d6de 100755 --- a/docs/CONTRIBUTING.html +++ b/docs/CONTRIBUTING.html @@ -79,7 +79,7 @@ climatrends - 0.1.11 + 0.2 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 9c007de..4913b8a 100755 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -79,7 +79,7 @@ climatrends - 0.1.11 + 0.2 diff --git a/docs/articles/Overview.html b/docs/articles/Overview.html old mode 100755 new mode 100644 index 3f941ef..e7f1bfb --- a/docs/articles/Overview.html +++ b/docs/articles/Overview.html @@ -38,7 +38,7 @@ climatrends - 0.1.11 + 0.2 @@ -92,9 +92,9 @@

climatrends: Climate Variability Indices for Ecological Modelling

Kauê de Sousa

- Department of Agricultural Sciences, Inland Norway University, Hamar, Norway; and Bioversity International, Rome, Italy

Jacob van Etten

+ Department of Agricultural Sciences, Inland Norway University, Hamar, Norway; and Bioversity International, Montpellier, France

Jacob van Etten

- Bioversity International, Rome, Italy

Svein Ø. Solberg

+ Bioversity International, Montpellier, France

Svein Ø. Solberg

Department of Agricultural Sciences, Inland Norway University, Hamar, Norway
Source: vignettes/Overview.Rmd @@ -120,7 +120,7 @@

Temperature

Here we compute temperature indices for the first semester of 2019 in the Innlandet county in Norway:

-library("climatrends")
+library("climatrends")
 
 data("innlandet", package = "climatrends")
 
diff --git a/docs/articles/Overview_files/header-attrs-2.11/header-attrs.js b/docs/articles/Overview_files/header-attrs-2.11/header-attrs.js
old mode 100755
new mode 100644
diff --git a/docs/articles/index.html b/docs/articles/index.html
index 0bfec29..5712157 100755
--- a/docs/articles/index.html
+++ b/docs/articles/index.html
@@ -79,7 +79,7 @@
       
       
         climatrends
-        0.1.11
+        0.2
       
     
diff --git a/docs/authors.html b/docs/authors.html index f0db7b9..5dab9fe 100755 --- a/docs/authors.html +++ b/docs/authors.html @@ -79,7 +79,7 @@ climatrends - 0.1.11 + 0.2 @@ -135,12 +135,12 @@

Citation

Kauê de Sousa, Jacob van Etten and Svein Ø. Solberg (2020). climatrends: Climate Variability - Indices for Ecological Modelling. R package version 0.1.6. https://CRAN.R-project.org/package=climatrends

+ Indices for Ecological Modelling. R package version 0.2. https://CRAN.R-project.org/package=climatrends

@Manual{,
   title = {climatrends: Climate Variability Indices for Ecological Modelling},
   author = {Kauê {de Sousa} and Jacob {van Etten} and Svein Ø. Solberg},
   year = {2020},
-  note = {R package version 0.1.6},
+  note = {R package version 0.2},
   url = {https://CRAN.R-project.org/package=climatrends},
 }
diff --git a/docs/index.html b/docs/index.html index 0cbafaf..b82a3d1 100755 --- a/docs/index.html +++ b/docs/index.html @@ -38,7 +38,7 @@ climatrends - 0.1.11 + 0.2 @@ -224,7 +224,6 @@

Dev status

  • CRAN status
  • cran checks
  • Downloads
  • -
  • Build Status
  • codecov
  • Project Status
  • lifecycle
  • diff --git a/docs/news/index.html b/docs/news/index.html index e19ada1..429fbd5 100755 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -79,7 +79,7 @@ climatrends - 0.1.11 + 0.2 diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 9208598..7a72d71 100755 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -3,5 +3,5 @@ pkgdown: 1.6.1 pkgdown_sha: ~ articles: Overview: Overview.html -last_built: 2021-11-17T20:48Z +last_built: 2022-02-14T12:02Z diff --git a/docs/reference/ETo.html b/docs/reference/ETo.html index 7a88397..2c473dc 100755 --- a/docs/reference/ETo.html +++ b/docs/reference/ETo.html @@ -82,7 +82,7 @@ climatrends - 0.1.11 + 0.2 @@ -244,7 +244,7 @@

    R

    Brouwer C. & Heibloem M. (1986). Irrigation water management: Irrigation water needs. Food and Agriculture Organization of The United Nations, Rome, Italy. -http://www.fao.org/3/S2022E/s2022e00.htm

    +https://www.fao.org/3/S2022E/s2022e00.htm

    See also

    Other temperature functions: @@ -253,53 +253,24 @@

    See a temperature()

    Examples

    -
    # the default method
    -set.seed(78)
    -tmax <- runif(50, 37, 47)
    -set.seed(79)
    -tmin <- runif(50, 31, 34)
    -
    -ETo(tmax, tmin, lat = 22, month = 10)
    -#>      ETo
    -#>    <dbl>
    -#> 1:  6.52
    -
    -###############################################
    -
    -# the array method
    -data("temp_dat", package = "climatrends")
    -
    -ETo(temp_dat, 
    -    day.one = "2013-10-28",
    -    span = 10,
    -    Kc = 0.92)
    -#>       ETo
    -#>     <dbl>
    -#> 1:   4.37
    -#> 2:   4.51
    -#> 3:   4.29
    -#> 4:   3.63
    -#> 5:   4.17
    -#> 6:   3.89
    -#> 7:   4.17
    -#> 8:   4.04
    -#> 9:   4.06
    -#> 10:  3.79
    -    
    -# \donttest{
    -#######################################
    -library("nasapower")
    -library("sf")
    -#> Linking to GEOS 3.8.1, GDAL 3.2.1, PROJ 7.2.1
    -data("lonlatsf", package = "climatrends")
    -
    -ETo(lonlatsf,
    -    day.one = "2015-04-22",
    -    last.day = "2015-06-22",
    -    pars = c("T10M_MAX", "T10M_MIN"))
    -#> Getting climate data from NASA POWER 
    -#> Error: Something went wrong with the query, no data were returned. Please see <https://power.larc.nasa.gov> for potential server issues.
    -# }
    +    
    # the default method
    +set.seed(78)
    +tmax <- runif(50, 37, 47)
    +set.seed(79)
    +tmin <- runif(50, 31, 34)
    +
    +ETo(tmax, tmin, lat = 22, month = 10)
    +
    +###############################################
    +
    +# the array method
    +data("temp_dat", package = "climatrends")
    +
    +ETo(temp_dat, 
    +    day.one = "2013-10-28",
    +    span = 10,
    +    Kc = 0.92)
    +    
     
    @@ -237,9 +237,9 @@

    Details

    References

    Prentice I. C., et al. (1992) Journal of Biogeography, 19(2), 117. -
    https://doi.org/10.2307/2845499

    +doi: 10.2307/2845499

    Baskerville, G., & Emin, P. (1969). Ecology, 50(3), 514-517. -
    https://doi.org/10.2307/1933912

    +doi: 10.2307/1933912

    See also

    Other temperature functions: @@ -250,87 +250,30 @@

    See a late_frost()

    Examples

    -
    data("innlandet", package = "climatrends")
    -
    -# use the default equation
    -GDD(innlandet$tmax, innlandet$tmin, tbase = 2)
    -#>         gdd
    -#>       <dbl>
    -#> 1:     0.00
    -#> 2:     0.00
    -#> 3:     0.00
    -#> 4:     0.00
    -#> 5:     0.00
    -#> ---        
    -#> 178: 130.98
    -#> 179: 135.32
    -#> 180: 141.84
    -#> 181: 150.12
    -#> 182: 152.30
    -
    -# set the equation "b", which is a better option for this case
    -# tmin = tbase if tmin < tbase 
    -# tmax = tbase if tmax < tbase
    -GDD(innlandet$tmax, innlandet$tmin, tbase = 2, equation = "b")
    -#>         gdd
    -#>       <dbl>
    -#> 1:     0.00
    -#> 2:     0.00
    -#> 3:     0.00
    -#> 4:     0.00
    -#> 5:     0.00
    -#> ---        
    -#> 178: 143.04
    -#> 179: 147.38
    -#> 180: 153.89
    -#> 181: 162.18
    -#> 182: 164.89
    -
    -
    -#####################################################
    -
    -# return as the number of days required to reach a certain accumulated GDD
    -# use equation "c", which adjusts tmax base on a tbase_max
    -data("temp_dat", package = "climatrends")
    -
    -GDD(temp_dat, 
    -    day.one = "2013-10-27", 
    -    degree.days = 90, 
    -    return.as = "ndays", 
    -    tbase_max = 32,
    -    equation = "c")
    -#>       gdd
    -#>     <int>
    -#> 1:      8
    -#> 2:      8
    -#> 3:      8
    -#> 4:     10
    -#> 5:      8
    -#> 6:     10
    -#> 7:      8
    -#> 8:      8
    -#> 9:      8
    -#> 10:     9
    -
    -# \donttest{
    -#####################################################
    -
    -# use the S3 method for data.frame to fetch data from nasapower
    -
    -library("nasapower")
    -
    -lonlat <- data.frame(lon = c(-73.3, -74.5),
    -                     lat = c(-6.1, - 6.2))
    -
    -GDD(lonlat, 
    -    day.one = "2015-05-01", 
    -    last.day = "2015-09-30",
    -    equation = "c",
    -    tbase_max = 35)
    -#> Getting climate data from NASA POWER 
    -#> Error: Something went wrong with the query, no data were returned. Please see <https://power.larc.nasa.gov> for potential server issues.
    -
    -# }
    +    
    data("innlandet", package = "climatrends")
    +
    +# use the default equation
    +GDD(innlandet$tmax, innlandet$tmin, tbase = 2)
    +
    +# set the equation "b", which is a better option for this case
    +# tmin = tbase if tmin < tbase 
    +# tmax = tbase if tmax < tbase
    +GDD(innlandet$tmax, innlandet$tmin, tbase = 2, equation = "b")
    +
    +
    +#####################################################
    +
    +# return as the number of days required to reach a certain accumulated GDD
    +# use equation "c", which adjusts tmax base on a tbase_max
    +data("temp_dat", package = "climatrends")
    +
    +GDD(temp_dat, 
    +    day.one = "2013-10-27", 
    +    degree.days = 90, 
    +    return.as = "ndays", 
    +    tbase_max = 32,
    +    equation = "c")
    +
     
    @@ -150,10 +150,11 @@

    SourceFunk, C. et al. (2015). The climate hazards infrared precipitation with stations—a new environmental record for monitoring extremes. -Scientific Data, 2, 150066. https://doi.org/10.1038/sdata.2015.66

    +Scientific Data, 2, 150066. doi: 10.1038/sdata.2015.66

    Wan Z, Hook S, Hulley G (2015) MYD11A1 MODIS/Aqua Land Surface Temperature/Emissivity 8-Day L3 Global 1km -SIN Grid V006 http://dx.doi.org/10.5067/MODIS/MYD11A2.006.

    +SIN Grid V006 doi: 10.5067/MODIS/MYD11A2.006 +.

    Details

    temp_dat: array with two layers 1) day temperature and 2) night temperature. diff --git a/docs/reference/climatrends.html b/docs/reference/climatrends.html index 0201f48..0ff76c1 100755 --- a/docs/reference/climatrends.html +++ b/docs/reference/climatrends.html @@ -81,7 +81,7 @@ climatrends - 0.1.11 + 0.2 diff --git a/docs/reference/crop_sensitive.html b/docs/reference/crop_sensitive.html index 21f8f45..0233949 100755 --- a/docs/reference/crop_sensitive.html +++ b/docs/reference/crop_sensitive.html @@ -82,7 +82,7 @@ climatrends - 0.1.11 + 0.2 @@ -230,9 +230,9 @@

    Details

    References

    Challinor et al. (2016). Nature Climate Change 6(10):6954-958 -
    https://doi.org/10.1038/nclimate3061

    +doi: 10.1038/nclimate3061

    Trnka et al. (2014). Nature Climate Change 4(7):637–43. -
    https://doi.org/10.1038/nclimate2242

    +doi: 10.1038/nclimate2242

    See also

    Other temperature functions: @@ -241,99 +241,30 @@

    See a temperature()

    Examples

    -
    # the default method
    -set.seed(78)
    -tmax <- runif(50, 37, 47)
    -set.seed(79)
    -tmin <- runif(50, 31, 34)
    -
    -crop_sensitive(tmax, tmin)
    -#>    hts_mean_32 hts_mean_35 hts_mean_38 hts_max_36 hts_max_39 hts_max_42 hse_31
    -#>          <dbl>       <dbl>       <dbl>      <dbl>      <dbl>      <dbl>  <dbl>
    -#> 1:        1.00        0.94        0.30       1.00       0.82       0.44   1.00
    -#>    hse_ms_31 cdi_mean_22 cdi_mean_23 cdi_mean_24 cdi_max_27 cdi_max_28
    -#>        <dbl>       <dbl>       <dbl>       <dbl>      <dbl>      <dbl>
    -#> 1:     50.00       19.74       18.74       17.74      10.10       9.10
    -#>    cdi_max_29 lethal_43 lethal_46 lethal_49
    -#>         <dbl>     <dbl>     <dbl>     <dbl>
    -#> 1:       8.10      0.00      0.00      0.00
    -
    -###############################################
    -
    -# the array method
    -data("temp_dat", package = "climatrends")
    -
    -# use the default thresholds
    -crop_sensitive(temp_dat,
    -               day.one = "2013-10-27",
    -               last.day = "2013-11-04")
    -#>     hts_mean_32 hts_mean_35 hts_mean_38 hts_max_36 hts_max_39 hts_max_42 hse_31
    -#>           <dbl>       <dbl>       <dbl>      <dbl>      <dbl>      <dbl>  <dbl>
    -#> 1:         0.00        0.00        0.00       0.00       0.00       0.00   1.00
    -#> 2:         0.00        0.00        0.00       0.00       0.00       0.00   1.00
    -#> 3:         0.00        0.00        0.00       0.00       0.00       0.00   1.00
    -#> 4:         0.00        0.00        0.00       0.00       0.00       0.00   0.00
    -#> 5:         0.00        0.00        0.00       0.00       0.00       0.00   1.00
    -#> 6:         0.00        0.00        0.00       0.00       0.00       0.00   0.00
    -#> 7:         0.00        0.00        0.00       0.00       0.00       0.00   1.00
    -#> 8:         0.00        0.00        0.00       0.00       0.00       0.00   1.00
    -#> 9:         0.00        0.00        0.00       0.00       0.00       0.00   1.00
    -#> 10:        0.00        0.00        0.00       0.00       0.00       0.00   0.00
    -#>     hse_ms_31 cdi_mean_22 cdi_mean_23 cdi_mean_24 cdi_max_27 cdi_max_28
    -#>         <dbl>       <dbl>       <dbl>       <dbl>      <dbl>      <dbl>
    -#> 1:       9.00       11.40       10.40        9.40       0.00       0.00
    -#> 2:       9.00       12.81       11.81       10.81       0.00       0.00
    -#> 3:       9.00        9.88        8.88        7.88       0.00       0.00
    -#> 4:       0.00        5.23        4.23        3.23       0.00       0.00
    -#> 5:       9.00       10.47        9.47        8.47       0.00       0.00
    -#> 6:       0.00        5.29        4.29        3.29       0.00       0.00
    -#> 7:       9.00       10.47        9.47        8.47       0.00       0.00
    -#> 8:       9.00        9.41        8.41        7.41       0.00       0.00
    -#> 9:       9.00       10.04        9.04        8.04       0.00       0.00
    -#> 10:      0.00        6.36        5.36        4.36       0.00       0.00
    -#>     cdi_max_29 lethal_43 lethal_46 lethal_49
    -#>          <dbl>     <dbl>     <dbl>     <dbl>
    -#> 1:        0.00      0.00      0.00      0.00
    -#> 2:        0.00      0.00      0.00      0.00
    -#> 3:        0.00      0.00      0.00      0.00
    -#> 4:        0.00      0.00      0.00      0.00
    -#> 5:        0.00      0.00      0.00      0.00
    -#> 6:        0.00      0.00      0.00      0.00
    -#> 7:        0.00      0.00      0.00      0.00
    -#> 8:        0.00      0.00      0.00      0.00
    -#> 9:        0.00      0.00      0.00      0.00
    -#> 10:       0.00      0.00      0.00      0.00
    -
    -# or change the thresholds based on the crop physiology
    -crop_sensitive(temp_dat,
    -               day.one = "2013-10-27",
    -               last.day = "2013-11-04",
    -               hts_mean.threshold = c(24),
    -               hts_max.threshold = c(31, 33))
    -#>     hts_mean_24 hts_max_31 hts_max_33 hse_31 hse_ms_31 cdi_mean_22 cdi_mean_23
    -#>           <dbl>      <dbl>      <dbl>  <dbl>     <dbl>       <dbl>       <dbl>
    -#> 1:         0.00       1.00       1.00   1.00      9.00       11.40       10.40
    -#> 2:         0.00       1.00       1.00   1.00      9.00       12.81       11.81
    -#> 3:         0.00       1.00       0.00   1.00      9.00        9.88        8.88
    -#> 4:         0.00       0.00       0.00   0.00      0.00        5.23        4.23
    -#> 5:         0.00       1.00       0.00   1.00      9.00       10.47        9.47
    -#> 6:         0.00       0.00       0.00   0.00      0.00        5.29        4.29
    -#> 7:         0.00       1.00       0.00   1.00      9.00       10.47        9.47
    -#> 8:         0.00       1.00       0.00   1.00      9.00        9.41        8.41
    -#> 9:         0.00       1.00       0.00   1.00      9.00       10.04        9.04
    -#> 10:        0.00       0.00       0.00   0.00      0.00        6.36        5.36
    -#>     cdi_mean_24 cdi_max_27 cdi_max_28 cdi_max_29 lethal_43 lethal_46 lethal_49
    -#>           <dbl>      <dbl>      <dbl>      <dbl>     <dbl>     <dbl>     <dbl>
    -#> 1:         9.40       0.00       0.00       0.00      0.00      0.00      0.00
    -#> 2:        10.81       0.00       0.00       0.00      0.00      0.00      0.00
    -#> 3:         7.88       0.00       0.00       0.00      0.00      0.00      0.00
    -#> 4:         3.23       0.00       0.00       0.00      0.00      0.00      0.00
    -#> 5:         8.47       0.00       0.00       0.00      0.00      0.00      0.00
    -#> 6:         3.29       0.00       0.00       0.00      0.00      0.00      0.00
    -#> 7:         8.47       0.00       0.00       0.00      0.00      0.00      0.00
    -#> 8:         7.41       0.00       0.00       0.00      0.00      0.00      0.00
    -#> 9:         8.04       0.00       0.00       0.00      0.00      0.00      0.00
    -#> 10:        4.36       0.00       0.00       0.00      0.00      0.00      0.00
    +    
    # the default method
    +set.seed(78)
    +tmax <- runif(50, 37, 47)
    +set.seed(79)
    +tmin <- runif(50, 31, 34)
    +
    +crop_sensitive(tmax, tmin)
    +
    +###############################################
    +
    +# the array method
    +data("temp_dat", package = "climatrends")
    +
    +# use the default thresholds
    +crop_sensitive(temp_dat,
    +               day.one = "2013-10-27",
    +               last.day = "2013-11-04")
    +
    +# or change the thresholds based on the crop physiology
    +crop_sensitive(temp_dat,
    +               day.one = "2013-10-27",
    +               last.day = "2013-11-04",
    +               hts_mean.threshold = c(24),
    +               hts_max.threshold = c(31, 33))
     
    @@ -142,7 +142,7 @@

    Cumulative sum of rainfall

    the maximum length of wet spell (MLWS)

    -
    cumMLWS(object, ...)
    +
    cumMLWS(object)

    Arguments

    @@ -158,27 +158,25 @@

    Value

    a vector with the cumulative sum of MLWS

    Examples

    -
    
    -# Example 1
    -
    -rain <- c(0,0.2,1.4,6.1,1.4,5.1,1.5,1.6,0.1,0,7,6,4,6,1.1,1.2,1.5,0)
    -
    -cumMLWS(rain)
    -#>  [1] 0 0 1 2 3 4 5 6 6 6 6 6 6 6 6 6 7 7
    -
    -# should return this vector
    -# raincum <- c(0,0,1,2,3,4,5,6,6,6,6,6,6,6,6,6,7,7)
    -
    -# Example 2
    -
    -rain2 <- c(1,0,1,1,0,0,1,1,1,0,0,1,1)
    -
    -cumMLWS(rain2)
    -#>  [1] 1 1 1 2 2 2 2 2 3 3 3 3 3
    -
    -# should return this 
    -# raincum2 <- c(1,1,1,2,2,2,2,2,3,3,3,3,3)
    -
    +    
    +# Example 1
    +
    +rain <- c(0,0.2,1.4,6.1,1.4,5.1,1.5,1.6,0.1,0,7,6,4,6,1.1,1.2,1.5,0)
    +
    +cumMLWS(rain)
    +
    +# should return this vector
    +# raincum <- c(0,0,1,2,3,4,5,6,6,6,6,6,6,6,6,6,7,7)
    +
    +# Example 2
    +
    +rain2 <- c(1,0,1,1,0,0,1,1,1,0,0,1,1)
    +
    +cumMLWS(rain2)
    +
    +# should return this 
    +# raincum2 <- c(1,1,1,2,2,2,2,2,3,3,3,3,3)
    +
     
    @@ -225,89 +225,33 @@

    Details included in the timespan.

    Examples

    -
    # Using local sources
    -# an array with temperature data
    -data("temp_dat", package = "climatrends")
    -
    -set.seed(9271)
    -span <- as.integer(runif(10, 6, 15))
    -
    -get_timeseries(temp_dat, "2013-10-28", span = span)
    -#> [[1]]
    -#>        id       date value
    -#>     <int>     <date> <dbl>
    -#> 1:      1 2013-10-28 33.20
    -#> 2:      1 2013-10-29 33.40
    -#> 3:      1 2013-10-30 33.50
    -#> 4:      1 2013-10-31 33.50
    -#> 5:      1 2013-11-01 33.50
    -#> ---                       
    -#> 87:    10 2013-11-01 28.20
    -#> 88:    10 2013-11-02 28.20
    -#> 89:    10 2013-11-03 28.10
    -#> 90:    10 2013-11-04 28.10
    -#> 91:    10 2013-11-05 28.10
    -#> 
    -#> [[2]]
    -#>        id       date value
    -#>     <int>     <date> <dbl>
    -#> 1:      1 2013-10-28  8.20
    -#> 2:      1 2013-10-29  8.20
    -#> 3:      1 2013-10-30  8.30
    -#> 4:      1 2013-10-31  8.30
    -#> 5:      1 2013-11-01  8.30
    -#> ---                       
    -#> 87:    10 2013-11-01  3.20
    -#> 88:    10 2013-11-02  3.40
    -#> 89:    10 2013-11-03  3.50
    -#> 90:    10 2013-11-04  3.70
    -#> 91:    10 2013-11-05  3.90
    -#> 
    -#> attr(,"class")
    -#> [1] "clima_ls" "list"    
    -
    -# matrix with precipitation data
    -data("rain_dat", package = "climatrends")
    -
    -get_timeseries(rain_dat, "2013-10-28", span = span)
    -#> [[1]]
    -#>        id       date value
    -#>     <int>     <date> <dbl>
    -#> 1:      1 2013-10-28  0.00
    -#> 2:      1 2013-10-29  0.00
    -#> 3:      1 2013-10-30  0.00
    -#> 4:      1 2013-10-31  0.00
    -#> 5:      1 2013-11-01  0.00
    -#> ---                       
    -#> 87:    10 2013-11-01  0.00
    -#> 88:    10 2013-11-02  0.00
    -#> 89:    10 2013-11-03  0.00
    -#> 90:    10 2013-11-04  0.00
    -#> 91:    10 2013-11-05  0.00
    -#> 
    -#> attr(,"class")
    -#> [1] "clima_ls" "list"    
    -
    -########################################################
    -# \donttest{
    -library("nasapower")
    -library("sf")
    -# Fetch data from NASA POWER using 'sf' method
    -data("lonlatsf", package = "climatrends")
    -
    -g <- get_timeseries(lonlatsf, 
    -                    day.one = "2018-05-16", 
    -                    last.day = "2018-05-30",
    -                    pars = c("PRECTOT", "T2M", "T10M"))
    -#> Getting climate data from NASA POWER 
    -#> Error: PRECTOT is/are not valid in 'pars'.
    -#> Check that the 'pars', 'community' and 'temporal_api' align.
    -
    -
    -g
    -#> Error in eval(expr, envir, enclos): object 'g' not found
    -# }
    -
    +    
    # Using local sources
    +# an array with temperature data
    +data("temp_dat", package = "climatrends")
    +
    +set.seed(9271)
    +span <- as.integer(runif(10, 6, 15))
    +
    +get_timeseries(temp_dat, "2013-10-28", span = span)
    +
    +# matrix with precipitation data
    +data("rain_dat", package = "climatrends")
    +
    +get_timeseries(rain_dat, "2013-10-28", span = span)
    +
    +# library("nasapower")
    +# library("sf")
    +# # Fetch data from NASA POWER using 'sf' method
    +# data("lonlatsf", package = "climatrends")
    +# 
    +# g <- get_timeseries(lonlatsf, 
    +#                     day.one = "2018-05-16", 
    +#                     last.day = "2018-05-30",
    +#                     pars = c("PRECTOT", "T2M", "T10M"))
    +# 
    +# 
    +# g
    +
     
    diff --git a/docs/reference/late_frost.html b/docs/reference/late_frost.html index 4c702c3..52fd27a 100755 --- a/docs/reference/late_frost.html +++ b/docs/reference/late_frost.html @@ -81,7 +81,7 @@ climatrends - 0.1.11 + 0.2 @@ -217,103 +217,42 @@

    Details

    References

    Trnka et al. (2014). Nature Climate Change 4(7):637–43. -
    https://doi.org/10.1038/nclimate2242

    +doi: 10.1038/nclimate2242

    Zohner et al. (2020). PNAS. -
    https://doi.org/10.1073/pnas.1920816117

    +doi: 10.1073/pnas.1920816117

    See also

    Other GDD functions: GDD()

    Examples

    -
    # default method
    -data("innlandet", package = "climatrends")
    -
    -# equation b is set by default
    -# where tmin and tmax are adjusted if below tbase
    -late_frost(innlandet$tmax, 
    -           innlandet$tmin, 
    -           dates = innlandet$date, 
    -           tbase = 2, 
    -           tfrost = -2)
    -#>          date    gdd   event duration
    -#>        <date>  <dbl>   <fct>    <int>
    -#> 1: 2019-01-01   0.00   frost      108
    -#> 2: 2019-04-19   0.66 warming        1
    -#> 3: 2019-04-20   0.00   frost        1
    -#> 4: 2019-04-21   5.23 warming       10
    -#> 5: 2019-05-01   0.00   frost       14
    -#> 6: 2019-05-15  34.71 warming       13
    -#> 7: 2019-05-28   0.00   frost        4
    -#> 8: 2019-06-01 124.29 warming       31
    -
    -# slightly different series if equation a is used
    -late_frost(innlandet$tmax, 
    -           innlandet$tmin, 
    -           dates = innlandet$date, 
    -           tbase = 2,
    -           tfrost = -2,
    -           equation = "a")
    -#>           date    gdd   event duration
    -#>         <date>  <dbl>   <fct>    <int>
    -#> 1:  2019-01-01   0.00   frost      108
    -#> 2:  2019-04-19   0.00  latent        1
    -#> 3:  2019-04-20   0.00   frost        1
    -#> 4:  2019-04-21   0.00  latent        2
    -#> 5:  2019-04-23   0.00   frost        2
    -#> 6:  2019-04-25   2.80 warming        6
    -#> 7:  2019-05-01   0.00   frost       14
    -#> 8:  2019-05-15  31.38 warming       11
    -#> 9:  2019-05-26   0.00   frost        6
    -#> 10: 2019-06-01 118.12 warming       31
    -
    -#####################################################
    -
    -# demo of the array method but no frost event is returned 
    -# because the data comes from the tropics
    -data("temp_dat", package = "climatrends")
    -
    -late_frost(temp_dat, day.one = "2013-10-27")
    -#>        id       date    gdd   event duration
    -#>     <int>     <date>  <dbl>   <fct>    <int>
    -#> 1:      1 2013-10-27 236.15 warming       14
    -#> 2:      2 2013-10-27 251.90 warming       14
    -#> 3:      3 2013-10-27 225.75 warming       14
    -#> 4:      4 2013-10-27 162.70 warming       14
    -#> 5:      5 2013-10-27 212.25 warming       14
    -#> 6:      6 2013-10-27 178.60 warming       14
    -#> 7:      7 2013-10-27 212.25 warming       14
    -#> 8:      8 2013-10-27 196.15 warming       14
    -#> 9:      9 2013-10-27 198.90 warming       14
    -#> 10:    10 2013-10-27 171.15 warming       14
    -
    -#####################################################
    -
    -# \donttest{
    -# Some random points in Norway
    -# get data from NASA Power
    -library("nasapower")
    -lonlat <- data.frame(lon = c(10.93, 10.57, 11.21),
    -                     lat = c(60.77, 61.10, 60.33))
    -
    -late_frost(lonlat, day.one = "2019-01-01", last.day = "2019-07-01")
    -#> Getting climate data from NASA POWER 
    -#>        id       date    gdd   event duration
    -#>     <int>     <date>  <dbl>   <fct>    <int>
    -#> 1:      1 2019-01-01   0.00   frost       48
    -#> 2:      1 2019-02-18   0.00  latent        1
    -#> 3:      1 2019-02-19   0.00   frost       38
    -#> 4:      1 2019-03-29   0.00  latent        2
    -#> 5:      1 2019-03-31   0.00   frost        4
    -#> ---                                         
    -#> 29:     3 2019-03-27   5.96 warming        4
    -#> 30:     3 2019-03-31   0.00   frost        2
    -#> 31:     3 2019-04-02   8.39 warming        6
    -#> 32:     3 2019-04-08   0.00   frost        4
    -#> 33:     3 2019-04-12 567.46 warming       81
    -     
    -# }
    -
    +    
    # default method
    +data("innlandet", package = "climatrends")
    +
    +# equation b is set by default
    +# where tmin and tmax are adjusted if below tbase
    +late_frost(innlandet$tmax, 
    +           innlandet$tmin, 
    +           dates = innlandet$date, 
    +           tbase = 2, 
    +           tfrost = -2)
    +
    +# slightly different series if equation a is used
    +late_frost(innlandet$tmax, 
    +           innlandet$tmin, 
    +           dates = innlandet$date, 
    +           tbase = 2,
    +           tfrost = -2,
    +           equation = "a")
    +
    +#####################################################
    +
    +# demo of the array method but no frost event is returned 
    +# because the data comes from the tropics
    +data("temp_dat", package = "climatrends")
    +
    +late_frost(temp_dat, day.one = "2013-10-27")
    +
     
    @@ -233,90 +233,29 @@

    Details

    References

    Aguilar E., et al. (2005). Journal of Geophysical Research, -110(D23), D23107.
    https://doi.org/10.1029/2005JD006119

    +110(D23), D23107. doi: 10.1029/2005JD006119

    Examples

    -
    # A vector with precipitation data
    -set.seed(987219)
    -rain <- runif(50, min = 0, max = 6)
    -
    -rainfall(rain)
    -#>     MLDS  MLWS R10mm R20mm Rx1day Rx5day  R95p  R99p Rtotal  SDII
    -#>    <int> <int> <int> <int>  <dbl>  <dbl> <dbl> <dbl>  <dbl> <dbl>
    -#> 1:     2    15     0     0   5.79  21.31 17.02  5.79 153.17  3.55
    -
    -# Return as timeseries with intervals of 7 days
    -dates <- 17650:17699
    -rainfall(rain, dates = dates, timeseries = TRUE, intervals = 7)
    -#>        id       date  index value
    -#>     <int>     <date>  <chr> <dbl>
    -#> 1:      1 2018-04-29   MLDS  1.00
    -#> 2:      1 2018-04-29   MLWS  4.00
    -#> 3:      1 2018-04-29  R10mm  0.00
    -#> 4:      1 2018-04-29  R20mm  0.00
    -#> 5:      1 2018-04-29 Rx1day  5.04
    -#> ---                              
    -#> 66:     1 2018-06-10 Rx5day 15.99
    -#> 67:     1 2018-06-10   R95p  5.79
    -#> 68:     1 2018-06-10   R99p  5.79
    -#> 69:     1 2018-06-10 Rtotal 20.14
    -#> 70:     1 2018-06-10   SDII  3.49
    -
    -######################################################
    -
    -# the matrix method
    -data("rain_dat", package = "climatrends")
    -
    -rainfall(rain_dat,
    -         day.one = "2013-10-28",
    -         span = 12)
    -#>      MLDS  MLWS R10mm R20mm Rx1day Rx5day  R95p  R99p Rtotal  SDII
    -#>     <int> <int> <int> <int>  <dbl>  <dbl> <dbl> <dbl>  <dbl> <dbl>
    -#> 1:      9     1     0     0   2.41   2.41  2.41  2.41   2.41  2.41
    -#> 2:      9     1     0     0   2.87   2.87  2.87  2.87   2.87  2.87
    -#> 3:     12     0     0     0   0.00   0.00  0.00  0.00   0.00  0.00
    -#> 4:     12     0     0     0   0.00   0.00  0.00  0.00   0.00  0.00
    -#> 5:     12     0     0     0   0.00   0.00  0.00  0.00   0.00  0.00
    -#> 6:     12     0     0     0   0.00   0.00  0.00  0.00   0.00  0.00
    -#> 7:     12     0     0     0   0.00   0.00  0.00  0.00   0.00  0.00
    -#> 8:     12     0     0     0   0.00   0.00  0.00  0.00   0.00  0.00
    -#> 9:     12     0     0     0   0.00   0.00  0.00  0.00   0.00  0.00
    -#> 10:    12     0     0     0   0.00   0.00  0.00  0.00   0.00  0.00
    -
    -#####################################################
    -# \donttest{
    -# Using remote sources of climate data
    -library("nasapower")
    -library("sf")
    -data("lonlatsf", package = "climatrends")
    -
    -# some random dates provided as integers and coerced to Dates internally
    -set.seed(2718279)
    -dates <- as.integer(runif(5, 17660, 17675))
    -
    -# get precipitation indices for 30 days after day.one
    -# return a data.frame
    -rain1 <- rainfall(lonlatsf,
    -                  day.one = dates,
    -                  span = 30,
    -                  as.sf = FALSE)
    -#> Getting climate data from NASA POWER 
    -#> Error: PRECTOT is/are not valid in 'pars'.
    -#> Check that the 'pars', 'community' and 'temporal_api' align.
    -rain1
    -#> Error in eval(expr, envir, enclos): object 'rain1' not found
    -
    -# get precipitation indices from "2010-12-01" to "2011-01-31"
    -rain2 <- rainfall(lonlatsf,
    -                  day.one = "2010-12-01",
    -                  last.day = "2011-01-31")
    -#> Getting climate data from NASA POWER 
    -#> Error: PRECTOT is/are not valid in 'pars'.
    -#> Check that the 'pars', 'community' and 'temporal_api' align.
    -rain2
    -#> Error in eval(expr, envir, enclos): object 'rain2' not found
    -# }
    -
    +    
    # A vector with precipitation data
    +set.seed(987219)
    +rain <- runif(50, min = 0, max = 6)
    +
    +rainfall(rain)
    +
    +# Return as timeseries with intervals of 7 days
    +dates <- 17650:17699
    +rainfall(rain, dates = dates, timeseries = TRUE, intervals = 7)
    +
    +######################################################
    +
    +# the matrix method
    +data("rain_dat", package = "climatrends")
    +
    +rainfall(rain_dat,
    +         day.one = "2013-10-28",
    +         span = 12)
    +
    +
     
    @@ -256,7 +256,7 @@

    Details

    References

    Aguilar E., et al. (2005). Journal of Geophysical Research, -110(D23), D23107.
    https://doi.org/10.1029/2005JD006119

    +110(D23), D23107. doi: 10.1029/2005JD006119

    See also

    Other temperature functions: @@ -265,89 +265,29 @@

    See a crop_sensitive()

    Examples

    -
    # the default method
    -data("innlandet", package = "climatrends")
    -
    -# a single temporal observation
    -temperature(innlandet$tmax, innlandet$tmin)
    -#>    maxDT  minDT maxNT  minNT   DTR    SU    TR   CFD  WSDI  CSDI   T10p  T90p
    -#>    <dbl>  <dbl> <dbl>  <dbl> <int> <int> <int> <int> <int> <int>  <dbl> <dbl>
    -#> 1: 15.13 -14.86  6.77 -19.25     6     0     0   115     4     5 -15.81  9.09
    -
    -# return as timeseries with 30-day intervals
    -temperature(innlandet$tmax, 
    -            innlandet$tmin, 
    -            dates = innlandet$dates,
    -            timeseries = TRUE, 
    -            intervals = 30)
    -#>        id       date index  value
    -#>     <int>     <date> <chr>  <dbl>
    -#> 1:      1 2019-01-01 maxDT  -0.15
    -#> 2:      1 2019-01-01 minDT -14.86
    -#> 3:      1 2019-01-01 maxNT  -3.41
    -#> 4:      1 2019-01-01 minNT -18.67
    -#> 5:      1 2019-01-01   DTR   4.35
    -#> ---                              
    -#> 68:     1 2019-05-31   CFD   3.00
    -#> 69:     1 2019-05-31  WSDI   2.00
    -#> 70:     1 2019-05-31  CSDI   3.00
    -#> 71:     1 2019-05-31  T10p   0.20
    -#> 72:     1 2019-05-31  T90p  11.14
    -
    -#####################################################
    -
    -# array method
    -data("temp_dat", package = "climatrends")
    -
    -temperature(temp_dat,
    -            day.one = "2013-10-28",
    -            span = 12)
    -#>     maxDT minDT maxNT minNT   DTR    SU    TR   CFD  WSDI  CSDI  T10p  T90p
    -#>     <dbl> <dbl> <dbl> <dbl> <int> <int> <int> <int> <int> <int> <dbl> <dbl>
    -#> 1:  33.50 33.20  8.40  8.20    25    12     0     0     5     2  8.21 33.50
    -#> 2:  34.90 34.60  9.50  8.90    25    12     0     0     6     2  8.91 34.90
    -#> 3:  32.30 31.70  8.50  8.00    23    12     0     0     8     2  8.01 32.00
    -#> 4:  27.50 26.90  2.10  1.50    25     0     0     0     2     5  1.60 27.40
    -#> 5:  32.80 32.00  6.40  5.70    26    12     0     0     2     3  5.70 32.58
    -#> 6:  27.60 26.90  6.50  5.90    20     0     0     0     2     2  6.01 27.40
    -#> 7:  32.80 32.00  6.40  5.70    26    12     0     0     2     3  5.70 32.58
    -#> 8:  31.90 31.00  4.90  4.60    26    12     0     0     2     2  4.61 31.57
    -#> 9:  32.60 31.30  5.10  4.30    27    12     0     0     2     3  4.30 32.27
    -#> 10: 28.70 28.00  4.40  2.70    24     0     0     0     2     2  2.81 28.50
    -
    -# \donttest{
    -#####################################################
    -
    -# Using remote sources of climate data
    -library("nasapower")
    -library("sf")
    -data("lonlatsf", package = "climatrends")
    -
    -# some random dates provided as integers and coerced to Dates internally
    -set.seed(2718279)
    -dates <- as.integer(runif(5, 17660, 17675))
    -
    -# get temperature indices for 30 days after day.one
    -# return a data.frame
    -temp1 <- temperature(lonlatsf,
    -                     day.one = dates,
    -                     span = 30,
    -                     as.sf = FALSE)
    -#> Getting climate data from NASA POWER 
    -#> Error: Something went wrong with the query, no data were returned. Please see <https://power.larc.nasa.gov> for potential server issues.
    -temp1
    -#> Error in eval(expr, envir, enclos): object 'temp1' not found
    -
    -# get temperature indices from "2010-12-01" to "2011-01-31"
    -temp2 <- temperature(lonlatsf,
    -                     day.one = "2010-12-01",
    -                     last.day = "2011-01-31")
    -#> Getting climate data from NASA POWER 
    -#> Error: Something went wrong with the query, no data were returned. Please see <https://power.larc.nasa.gov> for potential server issues.
    -temp2
    -#> Error in eval(expr, envir, enclos): object 'temp2' not found
    -
    -# }
    +    
    # the default method
    +data("innlandet", package = "climatrends")
    +
    +# a single temporal observation
    +temperature(innlandet$tmax, innlandet$tmin)
    +
    +# return as timeseries with 30-day intervals
    +temperature(innlandet$tmax, 
    +            innlandet$tmin, 
    +            dates = innlandet$dates,
    +            timeseries = TRUE, 
    +            intervals = 30)
    +
    +#####################################################
    +
    +# array method
    +data("temp_dat", package = "climatrends")
    +
    +temperature(temp_dat,
    +            day.one = "2013-10-28",
    +            span = 12)
    +
    +