Reading & writing data¶
dplPy reads the standard tree-ring file formats into a pandas DataFrame indexed
by year, with one column per measurement series — the shape every other function
expects. This guide covers loading ring widths, loading chronologies, combining
collections, and writing data back out.
Ring-width files with readers¶
readers loads Tucson (.rwl), CSV, and compact-format ring-width files:
Key arguments:
header— setTruewhen a Tucson file carries the three ITRDB header lines, so they are read as metadata rather than data.strict(defaultTrue) — mirror dplR's strict validation: dplPy warns and then raises on malformed rows, naming the offending series and year. Setstrict=Falseto fall back to a best-effort parse that returnsNoneon unrecoverable files instead of raising.join(defaultTrue) — when a series ID appears in more than one block, join the pieces into a single column. dplPy reports duplicated and non-overlapping same-name series so you can see what was merged.format— normally auto-detected; override with"csv","rwl", etc. if needed.
To load directly from a URL (for example an ITRDB file), use readers_url:
NOAA template files
dplPy recognizes the *-noaa.rwl NOAA-template files and refuses them with
an informative error — they are not decadal Tucson data. Use the plain
.rwl file (the same name without -noaa).
Chronology files with read_crn¶
read_crn reads Tucson chronology (.crn) files — the standardized site
chronologies produced by ARSTAN and friends:
It handles the standard single-chronology ITRDB file, the "combined" multi-block
files (an ARSTAN run's stacked std/res/ars chronologies for one site), and files
that concatenate many sites' chronologies. Bunched negative (BC/BCE) years parse
correctly, so long chronologies read as expected. Use split_by_site=True to
return separate frames per site block.
Combining collections with combine_rwl¶
combine_rwl merges ring-width datasets onto a common year index, following
dplR's combine.rwl (duplicate series IDs are kept as-is, not renamed):
Writing data with writers¶
writers writes a ring-width or chronology DataFrame back to disk. Specify the
output format — "rwl" (Tucson), "crn", or "csv":
For .rwl output, prec sets the measurement precision (0.001 writes values
×1000 with a -9999 end marker; 0.01 writes ×100 with a 999 marker), and
gaps controls how a true interior gap (a NaN inside a series' span) is encoded.
See the writers reference for the full option set.
Quick metadata¶
metadata extracts the ITRDB header fields (site, species, investigators,
location) from a headered Tucson file without loading the measurements, and
summary/report give per-series overviews. See the
Input & output reference.