
Versions, reproducibility and caching
Source:vignettes/versions-and-caching.Rmd
versions-and-caching.RmdThe G-TROPIC dataset is published as two Dataverse datasets:
- a historical dataset, spanning 1980 through the previous calendar year, which is updated once per year to include the most recent year’s data along with any corrections to the historical record (e.g., IBTRACS may update provisional data to final data); and
- a current-year dataset, updated once per week to include the latest storm data from the current calendar year.
gtropic_years()
#> $historical
#> [1] 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994
#> [16] 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009
#> [31] 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024
#> [46] 2025
#>
#> $current
#> [1] 2026
#>
#> $all
#> [1] 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994
#> [16] 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009
#> [31] 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024
#> [46] 2025 2026The G-TROPIC collection is organized this way in order to save storage space on Dataverse.
Both the historical and current-year datasets are version controlled, enabling you to retrieve any published version of the datasets you may need, e.g., to reproduce old analyses.
This vignette covers how to manage the dataset versions and downloads
made by the gtropic package.
The gtropic manifest
Every time you call gtropic_data(), a
manifest is attached to the result. It records the
published source files retrieved for the query, along with their
Dataverse paths, concrete dataset versions, sizes, and checksums.
The manifest can be accessed via the gtropic_manifest()
function:
usa_05 <- gtropic_data(
WHO_ENTITY = "United States",
date_range = c(2005, 2005)
)
#> Discovering datasets in collection "gtropic".
#> Retrieving 0 files (0.0 B) ; 10 already cached.
#> Warning in assemble_gtropic_data(args, call = call): No non-missing precipitation values were returned for 10 selected ADM2 units.
#> ! "52423323B10065184809144", "52423323B18524543454126",
#> "52423323B2854744470595", "52423323B36058634620210",
#> "52423323B37020317002794", "52423323B47905601981877",
#> "52423323B81395860012193", "52423323B84565222808084",
#> "52423323B93715825211285", and "52423323B95364314409049"
#> ℹ A known current source-data limitation can affect small or coastal ADM2 units
#> when no ERA5-Land grid cell is assigned.
#> ℹ A future G-TROPIC dataset release is planned to fill these gaps using
#> finer-resolution ERA5 precipitation data.
#> ℹ See `?gtropic_known_limitations`; complete identifiers are available from
#> `gtropic_warnings()`.
mf <- gtropic_manifest(usa_05)The file-level detail is found in the $files tibble. Its
downloaded_at column is the original time each source file
was acquired from Dataverse; a later cache hit preserves that time
rather than restamping it. mf$retrieved_at is the latest of
those original per-file timestamps.
mf$files
#> # A tibble: 10 × 10
#> source_role dataset_doi dataset_version directory_label label file_id
#> <chr> <chr> <chr> <chr> <chr> <int>
#> 1 Historical doi:10.7910/DVN/EA… 1.0 metadata adm2… 1.44e7
#> 2 Historical doi:10.7910/DVN/EA… 1.0 02_wind/storm_… 2005… 1.44e7
#> 3 Historical doi:10.7910/DVN/EA… 1.0 02_wind/exposu… 2005… 1.44e7
#> 4 Historical doi:10.7910/DVN/EA… 1.0 02_wind/zero_p… 2005… 1.44e7
#> 5 Historical doi:10.7910/DVN/EA… 1.0 04_precip 2005… 1.44e7
#> 6 Historical doi:10.7910/DVN/EA… 1.0 03_flood 2005… 1.44e7
#> 7 Historical doi:10.7910/DVN/EA… 1.0 01_pop 2005… 1.44e7
#> 8 Historical doi:10.7910/DVN/EA… 1.0 02_wind/storm_… 2005… 1.44e7
#> 9 Historical doi:10.7910/DVN/EA… 1.0 metadata code… 1.44e7
#> 10 Historical doi:10.7910/DVN/EA… 1.0 metadata adm2… 1.44e7
#> # ℹ 4 more variables: checksum <chr>, checksum_type <chr>, size_bytes <dbl>,
#> # downloaded_at <dttm>The manifest contains other metadata beyond the $files
table for you to inspect:
names(mf)
#> [1] "files" "server" "datasets" "resolved_query"
#> [5] "availability" "retrieved_at" "schema_version" "gtropic_version"Reproducible data retrievals using the manifest
With the manifest, you can ensure that future
gtropic_data() queries retrieve exactly the same data files
you had been using from an older query.
Save the manifest to a .rds file after a data query:
saveRDS(mf, "usa-2005-manifest.rds")Then replay it directly, even on another machine:
mf <- readRDS("usa-2005-manifest.rds")
usa_05 <- gtropic_data(manifest = mf)The manifest replays both the recorded files (with checksum
verification) and its canonical resolved query: resolved ADM2 and storm
identifiers, filters, tables, windows, and metadata years. You should
not repeat any data-shaping arguments, including version,
tables, geography, storm filters, or radii. Doing so would
potentially conflict with the manifest you are trying to recover and
yield an error. The only controls you may change during replay are the
operational arguments cache, as,
confirm, quiet, and offline –
these arguments will not affect what data is returned but rather how the
data is returned.
Asking for a specific version
You can also utilize the version argument to retrieve
specific versions of the G-TROPIC datasets:
gtropic_data(
WHO_ENTITY = "Cuba",
date_range = c(2019, 2026),
version = c(historical = "4.0", current = "16.0")
)A manifest is still the best tool for perfect reproducibility, as it records everything you need to reproduce a query exactly.
Caching
A cache is a folder of files you have already downloaded, kept so that repeating or extending a query does not fetch them again. It is enabled by default and is created only when a retrieval needs to store a file.
You can see whether or not the cache is enabled with:
getOption("gtropic.cache_enabled")
#> [1] TRUETo disable it for the current session, use:
You can re-enable it with:
The persist argument saves your cache preferences across
future R sessions:
# Turn off the cache for this and all future R sessions
gtropic_cache_disable(persist = TRUE)
# Turn the cache back on for this and all future R sessions
gtropic_cache_enable(persist = TRUE)The cache lives in the standard per-user location R reserves for package data on your operating system:
gtropic_cache_dir()
#> [1] "/Users/lgc2035/Library/Caches/org.R-project.R/R/gtropic"You can specify a different location for the cache (e.g. if you need
to put it on a disk with more storage) using the dir
argument:
gtropic_cache_enable(dir = "~/path/to/my/desired/cache/location/gtropic-cache")To bypass the cache for one retrieval without changing your global
cache settings, use gtropic_data()’s cache
argument:
gtropic_data(WHO_ENTITY = "United States", date_range = c(2025, 2025), cache = FALSE)What gets cached
The G-TROPIC dataset is broadly made up of yearly exposure files, and it is these files that the cache retrieves from the remote Dataverse repository and writes to disk. The cache stores these published year-files in their entirety, exactly as the remote Dataverse repository serves them – it does not use any of the filter arguments in your query before saving these files.
For storm metadata, wind, zero-pair, and track data, the annual file
year is the calendar year of STORM_GENESIS_DATE_UTC.
Temporal storm discovery and queries use the same organization, so
explicit year and date filters select genesis dates—not landfall or
exposure dates and not the published SEASON value. A
storm’s STORM_NAME has Name-YYYY form where
YYYY is SEASON, which can differ from its
genesis calendar year; the name is therefore not the annual partition
key.
- For instance, if you have caching enabled, an initial query that
asks for data from 2001-2003 followed by a later query requesting data
for 2002-2005 would result in
gtropiconly needing to download data for 2004 and 2005 in the second query, since the first query cached the results for 2002 and 2003. Note that assumes there was no published version update to the historical data between these two queries. If there was, then the newer versions of 2002 and 2003 would need to be downloaded. - Because G-TROPIC exposure data are partitioned by year rather than by geography in the backend, this means that if you ask for, e.g. data for the United States from 2025, and then later for Cuba from 2025, both queries will rely on the same 2025 files saved to the cache (with caching enabled).
Files are stored by checksum, which deduplicates across dataset versions automatically: a year-file that did not change between version 1.0 and version 2.0 has one checksum and is kept once, even though two versions reference it.
Current versions and offline retrieval
By default, gtropic_data() uses version = “:latest”. During a normal online retrieval, the package rediscovers the latest published Dataverse version on every call. With caching enabled, it records source files separately for each concrete dataset version. Changed files are retained as new checksum-addressed content; unchanged files share the existing cached content across versions.
For intentionally disconnected work, use offline = TRUE
with an enabled cache. A regular (non-manifest) retrieval uses only
cached source files and the persisted discovery snapshot created by a
prior online cached retrieval; no Dataverse update check is made, and
the snapshot’s saved time and age are reported. When
offline = TRUE and a manifest is passed in, it will
likewise use cached files only to fulfill the request. Offline
retrievals error if a required cache item is unavailable.
# You can use the offline argument provided that you have already called
# an online cached query that has cached the necessary files to fulfill your
# offline query:
usa_05_offline <- gtropic_data(
WHO_ENTITY = "United States",
date_range = c(2005, 2005),
offline = TRUE
)
# A canonical manifest replay may also use cached files only:
usa_05_replay_offline <- gtropic_data(manifest = mf, offline = TRUE)Managing the cache
gtropic_cache_list() # one row per cached file
gtropic_cache_size() # total bytes on disk
# Keep it under 10 GB, and drop anything older than six months
gtropic_cache_prune(max_size_gb = 10, older_than_days = 180)
# Start over
gtropic_cache_clear()Pruning removes least-recently-fetched files first.
The download guardrail
Calling gtropic_data() with no arguments requests all
available data for the full global record, 1980 - present. Before
downloading, the package estimates the total size of the data to be
downloaded, subtracting anything already cached, and compares it against
a threshold (one gigabyte by default). You can pass in a smaller
tables vector to reduce the size of the request, or narrow
your date_range.
If your request is under the threshold, the download proceeds. But if
your query is estimated to go over the threshold, in an interactive
session, gtropic will inform you of the estimated download
size and confirm whether you’d like to continue with the download. In a
non-interactive session, such as a scheduled job or a
rendered report, gtropic_data() will raise an error
instead.
To ignore the threshold and skip confirmations, use
confirm = FALSE for your queries:
gtropic_data(WHO_ENTITY = "India", date_range = c(1990, 2020), confirm = FALSE)Alternatively, you can raise the threshold for the current R session:
options(gtropic.confirm_threshold_gb = 3)Usually the better response is to narrow the query (by requesting
fewer years’ worth of data, or fewer tables).
Working with data larger than memory
By default results are ordinary data frames, held in memory. Setting
as = "arrow" returns them in a form that stays on disk or
in a compact in-memory representation until you ask for it.
Arrow is a format for holding tabular data
efficiently and reading only the columns and rows you need. In practice
you use the same dplyr verbs, and add
collect() when you want ordinary data frames back:
library(dplyr)
res <- gtropic_data(
WHO_ENTITY = "India",
date_range = c(2000, 2010),
as = "arrow"
)
heavy_days <- res$precip |>
filter(PRECIP_MM > 100) |>
group_by(ADM2_ID) |>
summarise(days = n()) |>
collect()Genuine out-of-memory processing needs caching switched on, because
that is what puts the files on disk where they can be streamed. Without
caching, as = "arrow" mainly saves conversion time rather
than memory.
What to record in a paper
We recommend recording the metadata contained in your manifest object
when documenting the G-TROPIC data you use in your research. Better yet,
publish your saved manifest.rds file along with your code
and coding environment for complete reproducibility.
Summary
- A manifest records the exact Dataverse files, versions, checksums, and resolved query needed to replay a retrieval.
- The cache stores source files by checksum, reducing repeated downloads while preserving distinct dataset versions.
- Use
offline = TRUEonly after the needed discovery metadata and source files have been cached. - For best reproducibility practices, publish the manifest needed for your analysis alongside your code & coding environment.
Where to go next
-
vignette("getting-started")introduces G-TROPIC data retrieval and query metadata. -
vignette("filtering")illustrates how thegtropic_data()arguments combine to filter the retrieved data files. -
vignette("linkage")covers connecting precipitation and flood observations to storms without double counting. -
vignette("plotting")shows how to visualize retrieved exposure and track data.