GHRtools
  • data4health
    • Overview
    • Reference
    • Changelog

    • Vignettes
    • Getting started
    • Access health data
  • clim4health
    • Overview
    • Reference
    • Changelog

    • Vignettes
    • Getting started
    • Glossary
    • s2dv_cube objects
    • Get function
    • Downscaling function
    • Verification function
  • GHRexplore
    • Overview
    • Reference
    • Changelog

    • Vignettes
    • Getting started
  • GHRmodel
    • Overview
    • Reference
    • Changelog

    • Vignettes
    • Getting started
    • Covariate structures
    • DLNMs in GHRmodel
  • GHRpredict
    • Overview
  • About GHR

On this page

  • c4h_load
    • Description
    • Arguments
    • Returns
    • Examples

c4h_load

Description

Load forecast, hindcast, or observational climate data (reanalysis or stations) as an s2dv_cube object.

c4h_load(
  path,
  variable = NULL,
  year = "all",
  month = "all",
  day = "all",
  time = "all",
  leadtime_month = "all",
  ext = NULL,
  bbox = NULL
)

Arguments

  • path: String to the folder containing the files to be loaded, or a vector of specific file paths.
  • variable: The variable that you want to load.
  • year: A vector of years, starting in 1950.
  • month: A vector of months. e.g. c(1,2) for January and February. Default is all months.
  • day: A vector of days in the month. Default is all days.
  • time: A vector of hours (0-23). Only needed when datasets are hourly. Default is all hours.
  • leadtime_month: A vector of months for the forecast leadtime. e.g. c(1,2) for January and February for data initialized in January. Default is “all”. If “all” for hindcast and forecast data, all leadtime months will be loaded. If “all” for reanalysis or station data, data will be loaded as a time series in the time dimension, and the sdate dimension will be set to 1.
  • ext: File extension. Options include “nc”, “.nc”, “csv”, and “.csv”.
  • bbox: A vector of coordinates in order: c(lat_max, lon_min, lat_min, lon_max).

Returns

An s2dv_cube object.

Examples

# Forecast data included in the package
fcst_path <- system.file("extdata/forecast/", package = "clim4health")
fcst_path <- paste0(fcst_path, "/")

# Load the forecast data
fcst <- c4h_load(fcst_path,
                 variable = "t2m",
                 year = 2025,
                 month = 1,
                 ext = "nc")
class(fcst)
dim(fcst$data)
summary(fcst$data)

# Hindcast data included in the package
hcst_path <- system.file("extdata/hindcast/", package = "clim4health")
hcst_path <- paste0(hcst_path, "/")

# Load the hindcast data
hcst <- c4h_load(hcst_path,
                 variable = "t2m",
                 year = 2010:2012,
                 month = 1,
                 leadtime_month = 1:3,
                 ext = "nc")
class(hcst)
dim(hcst$data)
summary(hcst$data)

# Reanalysis data included in the package
rean_path <- system.file("extdata/reanalysis/", package = "clim4health")
rean_path <- paste0(rean_path, "/")

# Load the reanalysis data with dates to match the hindcast
rean <- c4h_load(rean_path,
                 variable = "t2m",
                 year = 2010:2012,
                 month = 1,
                 leadtime_month = 1:3,
                 ext = "nc")
class(rean)
dim(rean$data)
summary(rean$data)

# Load the reanalysis data as a time series
rean <- c4h_load(rean_path,
                 variable = "t2m",
                 year = 2010,
                 month = 1:3,
                 leadtime_month = "all",
                 ext = "nc")
class(rean)
dim(rean$data)
summary(rean$data)

# Load station data as a time series matching the reanalysis above
stat_path <- system.file("extdata/stations/", package = "clim4health")
stat_path <- paste0(stat_path, "/")

station <- c4h_load(stat_path,
                    variable = "temp_mean",
                    year = 2010,
                    month = 1:3,
                    leadtime_month = "all",
                    ext = "csv")
class(station)
dim(station$data)
summary(station$data)

Copyright 2026, GHR

 

BSC IDExtremes HARMONIZE Wellcome