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_time
    • Description
    • Arguments
    • Returns
    • Examples

c4h_time

Description

Performs a temporal aggregation of climate data from a finer to a coarser time scale.

c4h_time(
  data,
  time_aggregation,
  dim_aggregation,
  fun = "mean",
  week_start = NULL,
  min_valid = 1
)

Arguments

  • data: s2dv_cube object with the climate data to be aggregated, usually read using c4h_load.
  • time_aggregation: string indicating the type of temporal aggregations to be performed. Options are “monthly”, “yearly”, “weekly”, and “daily”.
  • dim_aggregation: string indicating the dimension along which the aggregation should be performed. Options are “sdate” and “time”.
  • fun: string specifying the aggregation function. Options are “mean”, “sum”, “max”, “min”. Defaults to “mean”.
  • week_start: for weekly aggregation, specify the starting weekday from “Monday” to “Sunday”.
  • min_valid: integer specifying the minimum number of valid (non-NA) values desired in a group to return a non-NA aggregated value. Defaults to 1, so that any group with at least one valid value will be aggregated.

Returns

An s2dv_cube object with the temporally aggregated climate data.

Examples

# Load station data
station_path <- system.file("extdata", "stations", package = "clim4health")
station_timeseries <- c4h_load(station_path, variable = "temp_mean",
                               ext = "csv")
stat_week <- c4h_time(station_timeseries, time_aggregation = "weekly",
                      dim_aggregation = "time", week_start = "Monday",
                      min_valid = 5)
dim(stat_week$data)

# Load station data with sdate dimension
station_data <- c4h_load(station_path, variable = "temp_mean", ext = "csv",
                         month = 1, leadtime_month = 1:12)
# Aggregate to monthly max across sdate dimension
stat_month <- c4h_time(station_data, time_aggregation = "monthly",
                       dim_aggregation = "sdate", fun = "max",
                       min_valid = 20)
dim(stat_month$data)

Copyright 2026, GHR

 

BSC IDExtremes HARMONIZE Wellcome