# Introduction to climatrends

#### Kauê de Sousa

# Summary

Understanding how climate variability influences ecological processes is a key approach to provide recommendations for climate adaptation and biodiversity conservation. climatrends provides methods to compute precipitation and temperature indices that serves as input for crop modelling, ecological modelling and trends in climate change. The climate variables available in climatrends were previously used to identify climate patterns in crop growing cycles1, regional climate change assessment2–5, crowdsourcing citizen science in agriculture6 and trends in climate change compared with farmers’ perceptions7.

# Usage

By default, the functions in climatrends requires a vector with climate data, and optionally a vector of dates that can be linked to the data for time series analysis. The package also provides methods for objects of classes `array` (or `matrix`), `sf` and `data.frame`, where the last two are designed to be used to request remote data from `R` packages that uses API clients, such as nasapower8. This vignette presents the main functions and the methods available in climatrends. Overall, these applications can be generalized to all functions.

## Temperature

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

    library("climatrends")

    data("innlandet", package = "climatrends")

    temp1 <- temperature(innlandet$tmax, innlandet$tmin)

    temp1

    ##    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

With the argument `timeseries = TRUE`, temperature() returns the indices for a time series based on `intervals`. Here we compute the indices for intervals of 30 days:

    temp2 <- temperature(innlandet$tmax, innlandet$tmin,
                         dates = innlandet$dates,
                         timeseries = TRUE,
                         intervals = 30)

    temp2

    ##        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

## Growing degree-days

Growing degree-days is a heuristic tool in phenology, it is a measure of heat accumulation used to predict plant and animal development rates9. With the function `GDD()` we can compute the growing degree-days over a time series. In this case we apply an adjusted equation designed for cold areas with the argument `equation`:

    gdd <- GDD(innlandet$tmax, innlandet$tmin, tbase = 2, equation = "b")

    gdd

    ##         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

Additionally, the function may return the daily values of degree-days or the number of days that a given organism required to reach a certain number of accumulated degree-days. These values are defined by ‘daily’ or ‘ndays’ and can be adjusted using the argument `return.as`. The required accumulated gdd is defined with argument `degree.days`. For example, the Korean pine (Pinus koraiensis) requires 105 \(^\circ C\) accumulated gdd to onset of photosynthesis10. In that case, the function will calculate the growing degree-days and sum up the values until it reaches the defined gdd (105 \(^\circ C\)) and return the number of days needed in the given season, as follows.

    lonlat <- data.frame(lon = 129.19,
                         lat = 36.39)

    GDD(lonlat,
        day.one = "2019-04-01",
        last.day = "2019-10-01",
        degree.days = 150,
        return.as = "ndays")

This means that 45 days were required to reach 150 degree-days from April 2019.

## Late spring frost

Late frost is a freezing event occurring after a substantial accumulation of warmth. These events can be tracked using the function `late_frost()`. The function returns a data.frame with the duration and gdd accumulated during the `events` of frost, latency (where there is no frost event, but also there is no GDD), and warming (where GDD is accumulated).

    lf <- late_frost(innlandet$tmax,
                     innlandet$tmin,
                     dates = innlandet$date,
                     base = 2)

    lf

    ##           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  0.98 warming        6
    ## 7:  2019-05-01  0.00   frost       14
    ## 8:  2019-05-15 19.14 warming       11
    ## 9:  2019-05-26  0.00   frost        6
    ## 10: 2019-06-01 82.48 warming       31

## Rainfall

Precipitation indices are computed in the same way as the `temperature()` indices using the function `rainfall()`. But here, we fetch data from NASA POWER using the nasapower package passed to the `data.frame` method.

    library("nasapower")

    lonlat <- data.frame(lon = c(-73.3, -74.5),
                         lat = c(-6.1, - 6.2))

    rain <- rainfall(lonlat,
                     day.one = "2018-11-01",
                     last.day = "2018-12-31")

    rain

## Crop sensitive indices

These indices are designed to capture variability in sensitive stages of crop development3,4 and can be computed using the function `crop_sensitive()`. Here we use the `sf` method with 5 random points across the Sinop municipality in Brazil.

    library("sf")
    data("lonlatsf", package = "climatrends")

    crop_sensitive(lonlatsf,
                   day.one = "2018-12-01",
                   last.day = "2019-01-31",
                   as.sf = FALSE)

Additionally the thresholds for each index can be adjusted using the argument `*.threshold` (where * is replaced by the index abbreviation).

## Reference evapotranspiration

Evapotranspiration can be defined as the sum of evaporation and plant transpiration from the Earth’s surface to the atmosphere. This is also an important index to include in models for ecological interactions. In **climatrends* this index can be calculate using the function `ETo()` which computes the evapotranspiration based on the Blaney-Criddle method11, an ideal equation when only air-temperature data sets are available for a site. Here we use the `array` method to compute the reference evapotranspiration. And the duration of the time series in each row is adjusted with the argument `span` based on the duration of the anthesis period in the latitude 25N, adjusted with argument `lat`.

    data("temp_dat", package = "climatrends")

    eto <- ETo(temp_dat,
               day.one = "2013-10-28",
               span = c(9, 10, 11, 12, 8, 10, 11, 11, 12, 10),
               lat = rep(25, 10),
               Kc = 0.92)

    eto

    ##       ETo
    ##     <dbl>
    ## 1:   4.21
    ## 2:   4.34
    ## 3:   4.13
    ## 4:   3.50
    ## 5:   4.02
    ## 6:   3.75
    ## 7:   4.02
    ## 8:   3.89
    ## 9:   3.91
    ## 10:  3.65

## References

1.
Kehel, Z., Crossa, J. & Reynolds, M. Identifying Climate Patterns during the Crop-Growing Cycle from 30 Years of CIMMYT Elite Spring Wheat International Yield Trials. in Applied mathematics and omics to assess crop genetic resources for climate change adaptive traits (eds. Bari, A., Damania, A. B., Mackay, M. & Dayanandan, S.) 151–174 (CRC Press, 2016).
2.
Aguilar, E., Peterson, T. C., Obando, P. R., Frutos, R., et al. Changes in precipitation and temperature extremes in Central America and northern South America, 1961–2003. Journal of Geophysical Research 110, D23107 (2005).
3.
Challinor, A. J., Koehler, A.-K., Ramirez-Villegas, J., Whitfield, S. & Das, B. Current warming will reduce yields unless maize breeding and seed systems adapt immediately. Nature Climate Change 6, 954–958 (2016).
4.
Trnka, M., Rötter, R. P., Ruiz-Ramos, M., Kersebaum, K. C., et al. Adverse weather conditions for European wheat production will become more frequent with climate change. Nature Climate Change 4, 637–643 (2014).
5.
Zohner, C. M., Mo, L., Renner, S. S., Svenning, J.-C., et al. Late-spring frost risk between 1959 and 2017 decreased in North America but increased in Europe and Asia. Proceedings of the National Academy of Sciences 201920816 (2020). doi:10.1073/pnas.1920816117
6.
van Etten, J., de Sousa, K., Aguilar, A., Barrios, M., et al. Crop variety management for climate adaptation supported by citizen science. Proceedings of the National Academy of Sciences 116, 4194–4199 (2019).
7.
de Sousa, K., Casanoves, F., Sellare, J., Ospina, A., et al. How climate awareness influences farmers’ adaptation decisions in Central America? Journal of Rural Studies 64, 11–19 (2018).
8.
Sparks, A. H. nasapower: A NASA POWER Global Meteorology, Surface Solar Energy and Climatology Data Client for R. Journal of Open Source Software 3, 1035 (2018).
9.
Prentice, I. C., Cramer, W., Harrison, S. P., Leemans, R., et al. Special Paper: A Global Biome Model Based on Plant Physiology and Dominance, Soil Properties and Climate. Journal of Biogeography 19, 117 (1992).
10.
Wu, J., Guan, D., Yuan, F., Wang, A. & Jin, C. Soil Temperature Triggers the Onset of Photosynthesis in Korean Pine. PLoS ONE 8, e65401 (2013).
11.
Brouwer, C. & Heibloem, M. Irrigation water management: Irrigation water needs. (Food; Agriculture Organization of The United Nations, 1986).