Skip to contents

metscale 0.1.0

First release. metscale prepares model-ready meteorological forcing from gridded reanalysis and climate projections: extract, bias-correct against local observations, apply a climate-scenario delta change, and temporally disaggregate to sub-daily. It works standalone and integrates with AEME when that is installed. It carries the canonical implementation of the meteorology helpers that previously lived in AEME, with three long-standing defects fixed (time-zone handling in the solar geometry, MET_prsttn / MET_prmslp returned in Pa not hPa, and the u/v swap in expand_met()).

Acquire ERA5

  • download_era5_isimip_point() – daily ERA5 point series from ISIMIP3a, global, no account or key.
  • download_era5_cds() / read_era5_grib_point() – hourly ERA5 GRIB from the Copernicus Data Store and point extraction from it.
  • convert_era5_netcdf() – daily aggregation: a thin wrapper that runs extract_era5_hourly_met() (so it now reads netCDF or GRIB, with the same pattern discovery and spatial sampling) and aggregates to daily with met_to_daily(), adding daily min/max air and dewpoint temperature. Takes path first and forwards ... to extract_era5_hourly_met(); the old year / variable (singular) / positional file arguments are gone.
  • extract_era5_hourly_met() / extract_era5_lake_met() – hourly ERA5-Land at a point or area-weighted over a lake polygon, de-accumulated, in standard units and a chosen time zone.
    • Reads netCDF or GRIB; the backend is chosen per file from its extension (.grib / .grb / .grib2 via terra, else ncdf4).
    • Files are found with pattern, a {variable} / {year} / {month} template matched against the names in path (replaces the old positional file_template; default "{variable}" covers download_era5_cds() output and most ad-hoc layouts).
    • max_dist_km (default 50) reports the distance to a "nearest" sample and errors if the closest valid cell is further away.
    • extract_era5_lake_met() now takes a lake polygon (an sf/sfc or a path to one) plus optional id / name labels; the old lakes / layer id-and-name lookup has been removed.
  • plot_era5() – a quick-look viewer for a downloaded ERA5 / ERA5-Land GRIB or netCDF file: for every variable it finds (GRIB bands grouped by GRIB_ELEMENT, netCDF by sub-dataset), a map of the field aggregated over time next to a time series – the grid mean, or a bilinear sample at point. time maps a single step instead; a vector of files is stacked in time. Returns a per-variable summary data frame with the aggregated maps and series attached, or a ggplot for engine = "ggplot2". Reads with terra, matching the extractors’ backend rule.
  • plot_extract_grid() – a pre-extraction sanity-check map: the ERA5-Land grid around a point or lake polygon, the cell(s) each method would sample shaded by weight, the land/sea mask, and the geometry on top. Run it to catch a mis-projected shapefile or a sign-flipped longitude before extracting. Returns a ggplot (drawn cells attached as an sf on attr(., "grid") for handing to mapview / tmap), or draws with sf::plot() for engine = "base". Uses the same file-matching and sampling code as the extractors, so the preview cannot drift from the extraction.

Climate projections

  • extract_climate_point() – daily CMIP6 / CCAM projections at a point, decoding the model calendar (365_day, 360_day, 366_day, standard) and returning AEME MET_* names and units. Feeds the delta-change step.

Observations

  • prepare_obs_met() – standardise a measured meteorology table (names, units, time zone, resampling) for bias correction, with a wind_height argument to bring a low anemometer onto the 10 m convention.
  • standardise_met(), guess_met_vars(), met_vars() – name/unit matching against a self-contained synonym table.

Bias correction and delta change

  • fit_met_bias_correction() – per-variable transfer function ERA5 -> observations: per-month scaling (additive or ratio, optionally day-of-year loess-smoothed), variance scaling, linear regression, and empirical or trend-preserving quantile mapping, with leave-one-year-out cross-validation and a skill table.
  • apply_met_bias_correction(), met_to_daily(), bias_correct_daily_baseline() – apply to the full record, aggregate to daily, and build the corrected baseline for a delta-change workflow.
  • ?scenario_workflow – why the local correction goes on the baseline, not the delta.

Temporal disaggregation

  • disaggregate_met_to_hourly() – daily meteorology (including climate-scenario series) to hourly or 3-hourly by an analogue-day method of fragments or a mean diurnal cycle; daily means and rainfall totals are conserved, shortwave is rebuilt from solar geometry.
  • build_diurnal_climatology() – the month-by-hour mean diurnal cycle.

Conversions

Time zones

  • Every function that takes a tz argument now defaults to UTC, the zone ERA5, ERA5-Land and CMIP6 are published in, instead of the New-Zealand-specific "Etc/GMT-12". extract_era5_hourly_met() / extract_era5_lake_met() therefore return the reanalysis on its native clock with no hidden shift; convert downstream by passing tz (e.g. "Etc/GMT-12" for fixed NZST) or with lubridate::with_tz().
  • tz is resolved consistently across the package: an explicit argument wins, otherwise the tz attribute carried on the input data frame (or a POSIXct’s tzone), otherwise UTC. expand_met(), calc_cc() and estimate_hourly_swr() previously ignored that attribute and hard-coded "Etc/GMT-12", which could re-introduce the solar phase-shift on non-NZ input; they now follow the attribute like the rest.

Vignettes