Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: flooded
Title: Portable Floodplain Delineation from DEM and Stream Network
Version: 0.2.0
Version: 0.2.1
Authors@R: c(
person("Allan", "Irvine", , "al@newgraphenvironment.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-3495-2128")),
Expand Down Expand Up @@ -30,6 +30,7 @@ RoxygenNote: 7.3.3
Depends:
R (>= 4.1)
Imports:
cli,
terra,
sf,
tibble
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# flooded 0.2.1

- Startup quote ritual: `library(flooded)` prints a random fact-checked quote on attach. Italic quote, grey attribution, clickable blue `source` hyperlink (OSC 8). Suppress via `options(flooded.quote_show_source = FALSE)`.
- 157 shipped entries across 45 voices — 25 hip-hop (Kanye West, Royce da 5'9", Black Thought, Ab-Soul, ASAP Rocky, Danny Brown, The Weeknd, Kenny Beats, Freddie Gibbs, Madlib, Travis Scott, Flatbush Zombies trio, J. Cole, Bad Bunny, Don Toliver, Aaron Frazer, Post Malone, Mac Miller, Lil Yachty, Fre$h, Mustard, IDK, Joey Bada$$) + 20 climate voices (Hayhoe, Mann, Hansen, Schmidt, Marvel, Cobb, Rockström, Hassol, Oreskes, Wilkinson, Oppenheimer, Otto, Kalmus, Francis, Santer, Alley, McKibben, Wallace-Wells, Kolbert, Johnson).
- Curated via the soul `/quotes-enable` skill. 8 parallel research agents returned 157 candidates; 2 independent fact-check agents flagged 2 drops and several URL upgrades to primary sources (GQ, W Magazine, Rolling Stone, Vulture).
- `cli` added to Imports for OSC 8 hyperlinks and styling.

# flooded 0.2.0

* Add `waterbodies` and `channel_buffer` params to `fl_valley_confine()` —
Expand Down
15 changes: 15 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.onAttach <- function(libname, pkgname) {
f <- system.file("extdata", "quotes.csv", package = pkgname)
if (!nzchar(f)) return(invisible())
q <- utils::read.csv(f, stringsAsFactors = FALSE, encoding = "UTF-8")
if (nrow(q) == 0) return(invisible())
row <- q[sample(nrow(q), 1), ]
quote_fmt <- cli::style_italic(sprintf("'%s'", row$quote))
msg <- sprintf("\n %s %s", quote_fmt, cli::col_grey(paste0("- ", row$author)))
if (isTRUE(getOption("flooded.quote_show_source", TRUE)) &&
!is.null(row$source) && nzchar(row$source)) {
link <- cli::style_hyperlink(cli::col_blue("source"), row$source)
msg <- paste0(msg, "\n ", link)
}
packageStartupMessage(msg)
}
30 changes: 30 additions & 0 deletions data-raw/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# data-raw/quotes

Source and provenance for the startup quotes shown on `library(flooded)`.

## Files

- `quotes_build.R` — **source of truth**. R tibble with provenance columns.
- `quotes_audit.csv` — generated, full audit trail. In-repo, Rbuildignored.
- `../inst/extdata/quotes.csv` — generated, slim shipped (quote, author, source). Read by `R/zzz.R` on attach.

## To add / edit / remove a quote

1. Edit the `quotes` tibble in `quotes_build.R`
2. Every row must have a primary-source URL confirmed via fetch on the `verification_date`
3. Run `Rscript data-raw/quotes_build.R`
4. Commit all three files together

## Runtime toggle

```r
options(flooded.quote_show_source = FALSE) # suppress source hyperlink
```

Default is `TRUE`. Clickable blue `source` hyperlink renders in RStudio console (OSC 8).

## Standards

- Primary source required; book quotes OK when canonical and cross-circulated
- No padding — drop rather than pad
- UTF-8 throughout
158 changes: 158 additions & 0 deletions data-raw/quotes_audit.csv

Large diffs are not rendered by default.

717 changes: 717 additions & 0 deletions data-raw/quotes_build.R

Large diffs are not rendered by default.

158 changes: 158 additions & 0 deletions inst/extdata/quotes.csv

Large diffs are not rendered by default.

277 changes: 277 additions & 0 deletions planning/active/candidates_raw.md

Large diffs are not rendered by default.

34 changes: 10 additions & 24 deletions planning/active/findings.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
# Findings: fl_scenarios() and fl_params()
# Findings

## Research (pre-existing)
## Repo state (2026-04-14)
- flooded v0.2.0, clean main, no existing .onAttach
- `planning/active/` tracked (unlike mc which gitignores)
- Prior PWF from issue #28 was stale in active/ — archived retroactively

All research already committed:
- `inst/research/vca_parameter_rationale.md` — verified quotes from Nagel 2014, Hall 2007
- `inst/extdata/flood_params.csv` — parameter legend with units, defaults, citations
## Template
- Proven infrastructure: drift v0.2.2, mc v0.2.6
- Option namespace: `flooded.quote_show_source` (matches pattern)

## Key facts for scenario design

### flood_factor zones (from vca_parameter_rationale.md)
- ff=2: Rosgen flood-prone width, ~50-yr flood (active channel margin)
- ff=3: Hall 2007 best fit for historical floodplain on 10m DEM (213 field sites)
- ff=4: Reasonable functional floodplain estimate on 25m DEM
- ff=5-7: Nagel 2014 valley bottom (includes terraces, depositional areas)
- ff=7: Nagel 2014 recommendation for 30m DEM

### Defaults from flood_params.csv
- slope_threshold: 9 (percent)
- max_width: 2000 (metres)
- cost_threshold: 2500 (dimensionless)
- size_threshold: 5000 (m²)
- hole_threshold: 2500 (m²)

### Two independent width models (from flooded#25)
- bcfishpass (Thorley et al. 2021): `exp(0.307) * (area * precip / 100000) ^ 0.458`
- VCA/Hall 2007 (flooded internal): `(area ^ 0.280) * 0.196 * (precip ^ 0.355)`
## Known-from-prior-rounds
- Ab-Soul, ASAP Rocky, Mac Miller, Killer Mike, Travis Scott, Bad Bunny already in fpr/rfp/drift/mc. New quotes for flooded to avoid duplication — research agents told to find fresh material, though ultimately curation is user's call.
19 changes: 10 additions & 9 deletions planning/active/progress.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Progress: fl_scenarios() and fl_params()
# Progress

## Session log
## Session 2026-04-14

### 2026-03-19
- Read flooded#28 comments — updated scope and implementation prompt
- Read inst/research/vca_parameter_rationale.md and inst/extdata/flood_params.csv
- Read R/fl_valley_confine.R for current param defaults
- Created branch `flood-scenarios` from main
- Set up planning/active/ structure
- Starting Phase 1: flood_scenarios.csv
- Branch `quotes-enable` off main (main up to date)
- Archived stale PWF from issue #28 → planning/archive/2026-04-issue-28-fl-scenarios/
- Wrote fresh PWF baseline
- 25 hip-hop + 20 climate
- 8 research agents launched in parallel — returned 157 candidates across 45 voices
- 2 fact-check agents: 2 drops (Ab-Soul Revolt unverified, Mac Miller paraphrase), several URL upgrades to primaries
- Final shipped: 157 quotes. Infrastructure matches drift v0.2.2 / mc v0.2.6
- R CMD check: pre-existing `whitebox` Suggests dep ERROR (unrelated to our changes)
62 changes: 21 additions & 41 deletions planning/active/task_plan.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,28 @@
# Task: fl_scenarios() and fl_params() — CSV loaders for VCA parameters
# Task Plan: Enable Startup Quotes in flooded

**Issue:** flooded#28
**Branch:** flood-scenarios
Third `/quotes-enable` round. 25 hip-hop + 20 climate voices = 45 people, 8 research agents.

## Goal
Add two exported functions (`fl_scenarios()`, `fl_params()`) and one new CSV
(`flood_scenarios.csv`) to give users access to VCA parameter metadata and
pre-defined flood factor scenarios. Close #28.
## Phase 1: Inputs
- [x] Hip-hop (25): Kanye West, Royce da 5'9", Black Thought, Ab-Soul, ASAP Rocky, Danny Brown, The Weeknd, Kenny Beats, Freddie Gibbs, Madlib, Travis Scott, Erick the Architect, Zombie Juice, Meechie Darko, Killer Mike, J Cole, Bad Bunny, Don Toliver, Aaron Frazer, Post Malone, Mac Miller, Lil Yachty, Fre$h, Mustard, IDK, Joey Bada$$
- [x] Climate (20): Katharine Hayhoe, Michael Mann, James Hansen, Gavin Schmidt, Kate Marvel, Kim Cobb, Johan Rockström, Susan Joy Hassol, Naomi Oreskes, Katharine Wilkinson, Michael Oppenheimer, Friederike Otto, Peter Kalmus, Jennifer Francis, Ben Santer, Richard Alley, Bill McKibben, David Wallace-Wells, Elizabeth Kolbert, Ayana Elizabeth Johnson

## Phases
## Phase 2: Research (parallel)
- [ ] 8 agents (4 hip-hop clusters + 2 climate-science + 2 climate-writer)
- [ ] ToolSearch WebSearch/WebFetch first
- [ ] Primary-source URLs + fetch-verify

### Phase 1: Create flood_scenarios.csv
- [x] Create `inst/extdata/flood_scenarios.csv`
- [x] Columns: scenario_id, flood_factor, slope_threshold, max_width, cost_threshold, size_threshold, hole_threshold, run, description, ecological_process, citation_keys
- [x] Three rows: ff02 (active channel), ff04 (functional floodplain), ff06 (valley bottom)
- [x] Non-flood_factor params use defaults from flood_params.csv
## Phase 3: Fact-check
- [ ] Tier-2 chained / book-source; spot-check direct-primary

### Phase 2: fl_params()
- [x] Create `R/fl_params.R`
- [x] Load flood_params.csv by default, accept custom path
- [x] Return tibble
- [x] roxygen with @export
## Phase 4: User review
- [ ] CSV veto round

### Phase 3: fl_scenarios()
- [x] Create `R/fl_scenarios.R`
- [x] Load flood_scenarios.csv by default, accept custom path
- [x] Return tibble
- [x] roxygen with @export
## Phase 5: Infrastructure
- [ ] R/zzz.R (drift/mc template, option namespace = flooded.quote_show_source)
- [ ] data-raw/quotes_build.R + audit CSV + README
- [ ] cli to Imports

### Phase 4: Tests
- [x] Create `tests/testthat/test-fl_params.R` (4 tests)
- [x] Create `tests/testthat/test-fl_scenarios.R` (7 tests)
- [x] Default load returns tibble with expected columns
- [x] Custom path override works
- [x] Invalid path errors cleanly
- [x] Scenarios match flood_params.csv defaults for non-flood_factor params

### Phase 5: Document and verify
- [x] devtools::document() — NAMESPACE, fl_params.Rd, fl_scenarios.Rd
- [x] devtools::test() — 154 pass (22 new)
- [x] lintr::lint_package() — no new warnings
- [x] Commit with Fixes #28 (16bf126)

## Constraints
- Do NOT modify fl_valley_confine()
- Do NOT add vignette (separate issue)
- Do NOT bump version
## Phase 6: Ship
- [ ] R CMD check (accept pre-existing)
- [ ] Version bump + NEWS
- [ ] Commit, PR, archive after merge
5 changes: 5 additions & 0 deletions planning/archive/2026-04-issue-28-fl-scenarios/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Outcome

Archived retrospectively. Work completed and merged via PR #32 (`Add fl_scenarios() and fl_params() with flood scenario CSV`, commit cb2a6d6). PWF files were left in `active/` after the merge; this archive cleanup happened on the subsequent branch.

Closed by: PR #32.
27 changes: 27 additions & 0 deletions planning/archive/2026-04-issue-28-fl-scenarios/findings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Findings: fl_scenarios() and fl_params()

## Research (pre-existing)

All research already committed:
- `inst/research/vca_parameter_rationale.md` — verified quotes from Nagel 2014, Hall 2007
- `inst/extdata/flood_params.csv` — parameter legend with units, defaults, citations

## Key facts for scenario design

### flood_factor zones (from vca_parameter_rationale.md)
- ff=2: Rosgen flood-prone width, ~50-yr flood (active channel margin)
- ff=3: Hall 2007 best fit for historical floodplain on 10m DEM (213 field sites)
- ff=4: Reasonable functional floodplain estimate on 25m DEM
- ff=5-7: Nagel 2014 valley bottom (includes terraces, depositional areas)
- ff=7: Nagel 2014 recommendation for 30m DEM

### Defaults from flood_params.csv
- slope_threshold: 9 (percent)
- max_width: 2000 (metres)
- cost_threshold: 2500 (dimensionless)
- size_threshold: 5000 (m²)
- hole_threshold: 2500 (m²)

### Two independent width models (from flooded#25)
- bcfishpass (Thorley et al. 2021): `exp(0.307) * (area * precip / 100000) ^ 0.458`
- VCA/Hall 2007 (flooded internal): `(area ^ 0.280) * 0.196 * (precip ^ 0.355)`
11 changes: 11 additions & 0 deletions planning/archive/2026-04-issue-28-fl-scenarios/progress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Progress: fl_scenarios() and fl_params()

## Session log

### 2026-03-19
- Read flooded#28 comments — updated scope and implementation prompt
- Read inst/research/vca_parameter_rationale.md and inst/extdata/flood_params.csv
- Read R/fl_valley_confine.R for current param defaults
- Created branch `flood-scenarios` from main
- Set up planning/active/ structure
- Starting Phase 1: flood_scenarios.csv
48 changes: 48 additions & 0 deletions planning/archive/2026-04-issue-28-fl-scenarios/task_plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Task: fl_scenarios() and fl_params() — CSV loaders for VCA parameters

**Issue:** flooded#28
**Branch:** flood-scenarios

## Goal
Add two exported functions (`fl_scenarios()`, `fl_params()`) and one new CSV
(`flood_scenarios.csv`) to give users access to VCA parameter metadata and
pre-defined flood factor scenarios. Close #28.

## Phases

### Phase 1: Create flood_scenarios.csv
- [x] Create `inst/extdata/flood_scenarios.csv`
- [x] Columns: scenario_id, flood_factor, slope_threshold, max_width, cost_threshold, size_threshold, hole_threshold, run, description, ecological_process, citation_keys
- [x] Three rows: ff02 (active channel), ff04 (functional floodplain), ff06 (valley bottom)
- [x] Non-flood_factor params use defaults from flood_params.csv

### Phase 2: fl_params()
- [x] Create `R/fl_params.R`
- [x] Load flood_params.csv by default, accept custom path
- [x] Return tibble
- [x] roxygen with @export

### Phase 3: fl_scenarios()
- [x] Create `R/fl_scenarios.R`
- [x] Load flood_scenarios.csv by default, accept custom path
- [x] Return tibble
- [x] roxygen with @export

### Phase 4: Tests
- [x] Create `tests/testthat/test-fl_params.R` (4 tests)
- [x] Create `tests/testthat/test-fl_scenarios.R` (7 tests)
- [x] Default load returns tibble with expected columns
- [x] Custom path override works
- [x] Invalid path errors cleanly
- [x] Scenarios match flood_params.csv defaults for non-flood_factor params

### Phase 5: Document and verify
- [x] devtools::document() — NAMESPACE, fl_params.Rd, fl_scenarios.Rd
- [x] devtools::test() — 154 pass (22 new)
- [x] lintr::lint_package() — no new warnings
- [x] Commit with Fixes #28 (16bf126)

## Constraints
- Do NOT modify fl_valley_confine()
- Do NOT add vignette (separate issue)
- Do NOT bump version
Loading