dapper.met.exporter

Meteorological data export pipelines.

Classes

Exporter(adapter, src_path, *, domain[, ...])

Source-agnostic meteorological exporter.

class dapper.met.exporter.Exporter(adapter, src_path, *, domain, out_dir=None, calendar='noleap', dtime_resolution_hrs=1, dtime_units='days', dformat='BYPASS', append_attrs=None, chunks=None, include_vars=None, exclude_vars=None, clip_to_full_years=None)[source]

Bases: object

Source-agnostic meteorological exporter.

Ingests time-sharded CSVs for all sites/cells, preprocesses each shard with a pluggable adapter, stages per-gid parquet files, and writes packed (int16) ELM MET NetCDFs. The layout follows domain.mode:

  • "cellset": <out_dir>/MET/<file>.nc per variable with dims ('DTIME', 'lat', 'lon'), one global packing, and a single DTIME axis shared by every point (sparse lat/lon axes are allowed).

  • "sites": <out_dir>/<gid>/MET/<file>.nc per variable with dims ('n', 'DTIME') (n=1), per-site packing, and a per-site DTIME axis.

Each MET directory also gets a zone_mappings.txt.

All dataset-specific logic (file discovery, unit conversions, renaming to ELM short names) lives in the adapter (see dapper.met.adapters.base.BaseAdapter).

Parameters:
  • adapter (BaseAdapter) – Source adapter (e.g. ERA5Adapter).

  • src_path (str or pathlib.Path) – Input location passed to adapter.discover_files.

  • domain (Domain) – Sites/cells to export; gid links CSV rows to cells.

  • out_dir (str or pathlib.Path, optional) – Output root. Defaults to domain.run_dir (requires domain.path_out).

  • calendar (str, default "noleap") – DTIME calendar; Feb 29 is dropped for no-leap aliases.

  • dtime_resolution_hrs (float, default 1) – Target DTIME step in hours (fractions allowed).

  • dtime_units ({"days", "hours"}, default "days") – Units of the numeric DTIME coordinate.

  • dformat ({"BYPASS", "DATM_MODE"}, default "BYPASS") – ELM forcing format passed to the adapter.

  • append_attrs (dict, optional) – Extra global attributes for every file. Exporter provenance (domain_mode, pack_scope, export_start_year, …) is added without overriding user keys, except domain_mode, pack_scope, clip_to_full_years and the export years, which always win.

  • chunks (tuple[int, ...], optional) – Explicit NetCDF chunk sizes; auto-chunked when omitted.

  • include_vars (Iterable[str], optional) – Allow/block lists of ELM short names applied after preprocessing. Meta columns gid, time, LATIXY, LONGXY and zone are kept.

  • exclude_vars (Iterable[str], optional) – Allow/block lists of ELM short names applied after preprocessing. Meta columns gid, time, LATIXY, LONGXY and zone are kept.

  • clip_to_full_years (bool or None, optional) – Clip the discovered year range to complete calendar years (raises if none). None keeps the adapter default (True for ERA5).

Notes

Temporary parquet shards are written under <out_dir>/.dapper_tmp and removed at the end of run().

run(*, pack_scope=None, filename=None, overwrite=False)[source]

Run the MET export for this exporter’s Domain.

The output layout is derived from Domain.mode:
  • sites: writes <run_dir>/<gid>/MET/{prefix_}{var}.nc and a per-site zone_mappings.txt (always zone=01, id=1).

  • cellset: writes <run_dir>/MET/{prefix_}{var}.nc and a single zone_mappings.txt covering all locations (zones taken from df_loc, default 1).

Parameters:
  • pack_scope (str | None) – Optional packing strategy override. Defaults to per-site for sites and global for cellset outputs.

  • filename (str | None) – Optional filename template for output NetCDF files. Supports two formats: - Template with {var} placeholder: ‘ERA5_{var}_1950-2025_z01’ generates ‘ERA5_TBOT_1950-2025_z01.nc’ - Simple prefix (legacy): ‘prefix’ generates ‘prefix_TBOT.nc’ If omitted, the default is ‘<driver>_<var>_<start>-<end>_z01.nc’. The ‘.nc’ extension is added automatically.

  • overwrite (bool) – If True, clears existing MET outputs before writing.

Return type:

None