dapper.Exporter¶
- class dapper.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:
objectSource-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>.ncper 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>.ncper 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;
gidlinks CSV rows to cells.out_dir (str or pathlib.Path, optional) – Output root. Defaults to
domain.run_dir(requiresdomain.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, exceptdomain_mode,pack_scope,clip_to_full_yearsand 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,LONGXYandzoneare kept.exclude_vars (Iterable[str], optional) – Allow/block lists of ELM short names applied after preprocessing. Meta columns
gid,time,LATIXY,LONGXYandzoneare kept.clip_to_full_years (bool or None, optional) – Clip the discovered year range to complete calendar years (raises if none).
Nonekeeps the adapter default (True for ERA5).
Notes
Temporary parquet shards are written under
<out_dir>/.dapper_tmpand removed at the end ofrun().- __init__(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]¶
Create a MET exporter for
domain; see the class docstring.- Parameters:
adapter (BaseAdapter)
src_path (str | Path)
domain (Domain)
out_dir (str | Path | None)
calendar (str)
dtime_resolution_hrs (float)
dtime_units (str)
dformat (str)
append_attrs (dict | None)
chunks (tuple[int, ...] | None)
include_vars (Iterable[str] | None)
exclude_vars (Iterable[str] | None)
clip_to_full_years (bool | None)
- Return type:
None
Methods
__init__(adapter, src_path, *, domain[, ...])Create a MET exporter for
domain; see the class docstring.run(*[, pack_scope, filename, overwrite])Run the MET export for this exporter’s Domain.
- 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}.ncand a per-sitezone_mappings.txt(always zone=01, id=1).cellset: writes<run_dir>/MET/{prefix_}{var}.ncand a singlezone_mappings.txtcovering all locations (zones taken from df_loc, default 1).
- Parameters:
pack_scope (
str|None) – Optional packing strategy override. Defaults toper-sitefor sites andglobalfor 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
- The output layout is derived from