Download and Process 'ERA5', IMD, 'HadEX3' and 'CRU TS' Data

Download climate data for a bounding box, polygon or point and return tidy tables. Sources are the 'ERA5' reanalysis (Hersbach et al. (2020) ) from the 'Copernicus' Climate Data Store < https://cds.climate.copernicus.eu/>, India Meteorological Department (IMD) gridded rainfall and temperature (Pai et al. (2014) ), 'HadEX3' climate extremes (Dunn et al. (2020) ) and 'CRU TS' (Harris et al. (2020) ). Computes heat stress indices, including wet-bulb globe temperature (Liljegren et al. (2008) ) and the Universal Thermal Climate Index (Bröde et al. (2012) ), and heatwave indicators, including the Excess Heat Factor (Nairn and Fawcett (2015) ).


varunayanR varunayanR logo

R-CMD-check License: MIT

varunayan is an R package. It downloads and processes ERA5 reanalysis data from the Copernicus Climate Data Store. It also downloads and processes IMD gridded climate data from the Indian Meteorological Department. The package gives an easy R interface to get temperature, precipitation, and other climate variables for a region. You can specify the region with a bounding box, a GeoJSON polygon, or point coordinates.

Installation

# Install from GitHub
# install.packages("devtools")
devtools::install_github("saketlab/varunayan", subdir = "R")

Quick Start

ERA5 climate data

library(varunayan)

# Set the CDS credentials (one time only)
# Get your API key from this site: https://cds.climate.copernicus.eu/how-to-api
setup_cds_credentials(key = "your-cds-api-key")

# Download the ERA5 temperature and precipitation for Mumbai
temperature_data <- era5ify_bbox(
  request_id = "mumbai_temp",
  variables = c("2m_temperature", "total_precipitation"),
  start_date = "2023-01-01",
  end_date = "2023-12-31",
  north = 19.2, south = 18.9,
  east = 72.9, west = 72.8,
  frequency = "daily"
)

head(temperature_data)

IMD rainfall data

# Download the IMD gridded rainfall data for Maharashtra
rainfall_data <- imd_rainfall_bbox(
  request_id = "maharashtra_rain",
  start_year = 2023,
  end_year = 2024,
  north = 22, south = 16,
  east = 80, west = 73,
  resolution = 0.25,
  frequency = "monthly"
)

GeoJSON regions

# Download data for the regions in a GeoJSON file
data <- era5ify_geojson(
  request_id = "indian_states",
  variables = c("2m_temperature", "surface_pressure"),
  start_date = "2024-01-01",
  end_date = "2024-01-31",
  json_file = "path/to/states.geojson",
  frequency = "daily"
)

Use cases

Monsoon analysis

# Download 20 years of rainfall data for a monsoon study
rainfall <- imd_rainfall_bbox(
  request_id = "monsoon_study",
  start_year = 2000,
  end_year = 2020,
  north = 28, south = 8,
  east = 92, west = 68,
  resolution = 0.25,
  frequency = "monthly"
)

# Analyze the monsoon rainfall (June to September)
library(dplyr)
monsoon <- rainfall %>%
  filter(month(date) %in% 6:9) %>%
  group_by(year(date), latitude, longitude) %>%
  summarise(monsoon_total = sum(rainfall))

Atmospheric data at pressure levels

# Download ERA5 data at more than one atmospheric level
atmos_data <- era5ify_bbox(
  request_id = "atmosphere",
  variables = c("temperature", "geopotential", "u_component_of_wind"),
  start_date = "2024-01-01",
  end_date = "2024-01-05",
  north = 30, south = 20,
  east = 80, west = 70,
  dataset_type = "pressure",
  pressure_levels = c("1000", "850", "500", "200")
)

Documentation

Contributing

We accept contributions. To send a change, open a Pull Request.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("varunayan")

0.4.0 by Saket Choudhary, 8 hours ago


https://varunayan.saketlab.org/R/, https://github.com/saketlab/varunayan


Report a bug at https://github.com/saketlab/varunayan/issues


Browse source code at https://github.com/cran/varunayan


Authors: Saket Choudhary [aut, cre, cph] (ORCID: , Darakhshan Nehal [aut] , James C. Liljegren [ctb] (Author of the original WBGT C code) , UChicago Argonne , LLC [cph] (Copyright holder of the original WBGT C code)


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports data.table, digest, dplyr, ecmwfr, httr, jsonlite, lubridate, magrittr, ncdf4, rlang, sf, stars, stats, terra, tools, utils, parallel

Suggests ggplot2, ggpubr, gridExtra, knitr, maps, ncmeta, patchwork, R.utils, rmarkdown, scales, testthat, tidyr, units, withr


See at CRAN