Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
c3310cb
fixing double-counting in angle_1 and _2, adding some context to read…
maria-milosh Jun 2, 2026
12bbcba
add a notebook summarizing changes; moran's i: now as counts instead …
maria-milosh Jun 2, 2026
10f88a3
use python not python3 consistently. fix a typo in moran
maria-milosh Jun 2, 2026
8fb0b83
Some comments about potetntial code changes
Jun 3, 2026
2e68442
changed some deprecated code and added a logbook summarizing changes
Jun 3, 2026
b7e7f5b
undeleting chicago.sh
Jun 3, 2026
e445954
updated logbook
Jun 5, 2026
f03f49d
changed python3 to python in reproduce.sh
Jun 5, 2026
3790384
Update dual graph generation: 0-pop nodes to be contracted to 0-pop n…
maria-milosh Jun 12, 2026
bb0ce3b
Adding Chicago Maup reproduction notebook
Jun 12, 2026
9117c27
Merge pull request #14 from maria-milosh/review-gen-duals-change
maria-milosh Jun 12, 2026
06facbb
added reproduction notebook for idealized patterns on grids
Jun 12, 2026
04caff8
idealized grid reproduction notebook added
Jun 12, 2026
0c823ef
reproduction notebook for analysis of 100 metro areas
Jun 12, 2026
0071202
calculate_metrics.py will write a log of json files that had a divisi…
maria-milosh Jun 12, 2026
be348ae
Use representative points instead of any intersection
maria-milosh Jun 12, 2026
e2ea5e3
implemented a workaround for the epsilon problem
Jun 12, 2026
dba9cc6
Fixed blau
Jun 15, 2026
01a043a
fixed the ranking differences code
Jun 15, 2026
e72acbe
fixed Grid divide by zero
Jun 15, 2026
85a61b0
Make dissimilarity, gini, moran use a y_column (majority) instead of …
maria-milosh Jun 16, 2026
a61b0c8
added a version ofpairwise Moran's I, skipping nodes where the pairwi…
maria-milosh Jun 17, 2026
dc11152
Iowa Analysis reproduction
Jun 18, 2026
c514593
added 2010 data + made blocks include the wisconsin and indiana parts…
Jun 21, 2026
0367571
added 2010 data
Jun 21, 2026
ff27245
nodes to be contracted if their White + Black population is 0, regard…
maria-milosh Jun 22, 2026
0764ed2
fixing cache typo
maria-milosh Jun 22, 2026
96ab1be
added multi-clusters
Jun 22, 2026
a59a852
no need to filter b+w=0 but pop > 0 nodes, now that they're contracte…
maria-milosh Jun 22, 2026
8ccab1e
quick fix to avoid conflict
maria-milosh Jun 22, 2026
8ba03a2
Merge pull request #16 from maria-milosh/review-metric-failures
stephenson-s Jun 22, 2026
087e964
Merge pull request #17 from maria-milosh/review-points-tract-assignment
stephenson-s Jun 22, 2026
6ab663d
add a print when graph still has zero nodes after contraction
maria-milosh Jun 22, 2026
2c8ef79
Merge pull request #26 from maria-milosh/black-white-pairwise-metrics
maria-milosh Jun 22, 2026
1eb255d
added boxplots to fig 14
Jun 22, 2026
b556765
mergeing
Jun 22, 2026
d1cabe5
ignore vs code settings file
maria-milosh Jun 23, 2026
4b5d2da
edge, exact, skew etc. reported
Jun 23, 2026
2cecb5c
generalized diss I think
Jun 23, 2026
92fa81e
added morans for non distance based weights matrices
Jun 24, 2026
903bd97
added new metrics
Jun 26, 2026
93b24c0
changed generate_figs + re[rpduction notebooks to accord with new cal…
Jun 26, 2026
30de42d
fixed Laplacian
Jun 26, 2026
c21098f
changed A from array to crs in make_adj_weights
Jun 26, 2026
b658b16
Merge pull request #30 from maria-milosh/metrics-branch
stephenson-s Jun 26, 2026
1a235b8
added distance weights
Jun 30, 2026
05b831d
updated old dependencies
maria-milosh Jul 1, 2026
d2e6633
implement census and ipums api to get inputs to the pipeline
maria-milosh Jul 1, 2026
13d7b33
graph centroids in ESRI: 102003
Jul 2, 2026
8f974fa
Chicago Reproduction now using Census/NHGIS APIS
Jul 2, 2026
665070e
fixed S0 normalization in moran
Jul 2, 2026
465a09d
Chicago Filemaker Added
Jul 2, 2026
301cd88
Merge pull request #31 from maria-milosh/metrics-chicago-branch
maria-milosh Jul 2, 2026
819c0ad
Move CBSA source lists into study_area_sources
maria-milosh Jul 3, 2026
8cf0421
Add Census and IPUMS input builders
maria-milosh Jul 3, 2026
f8a9bee
Move study-area workflow into pipeline modules
maria-milosh Jul 3, 2026
ce76e6d
scripts/pipeline_config.sh
maria-milosh Jul 3, 2026
4d9e815
Simplify pipeline configuration helpers
maria-milosh Jul 3, 2026
0c142f1
move py scripts from scripts and add small tweaks to pipeline py scri…
maria-milosh Jul 3, 2026
8456b01
Merge remote-tracking branch 'origin/main' into HEAD
maria-milosh Jul 6, 2026
414f8da
Merge pull request #32 from maria-milosh/implement-census-pulls
maria-milosh Jul 6, 2026
90338cd
tocrs fixed to to_crs
Jul 7, 2026
27ae3c1
gen figures does all metrics
Jul 7, 2026
89966ff
Deleted Logbook and photos directory
stephenson-s Jul 10, 2026
7766e25
skip downloading files if they exist; minor edits to config
maria-milosh Jul 11, 2026
b757d4c
generate more readable figures, lineplots on grid, top 10 graphs and …
maria-milosh Jul 11, 2026
c7be2cd
ignore DS_Store files across all subfolders
maria-milosh Jul 11, 2026
6b36d04
update figures
maria-milosh Jul 12, 2026
0e398af
add agents.md file
maria-milosh Jul 12, 2026
e5aefd8
upload figures; styling tweaks
maria-milosh Jul 12, 2026
f1e05a5
small corrections to readme
maria-milosh Jul 12, 2026
9ca37e0
update the main readme file
maria-milosh Jul 12, 2026
02ba650
config file to skip and warn about block groups 1980 file absence
maria-milosh Jul 12, 2026
395b76e
Add files via upload
stephenson-s Jul 12, 2026
4c798ab
fix inverse distance matrix title on moran figures
maria-milosh Jul 12, 2026
c3bdc62
Added all reproduction figures (including 13 and 14)
stephenson-s Jul 12, 2026
26a99f6
Merge branch 'main' of https://github.com/maria-milosh/capy-bara
maria-milosh Jul 12, 2026
2294456
Reproduction Reorganized, and Edge Topology Memo Notebooks Added
Jul 13, 2026
2f95b30
Delete Chicago File Make.ipynb
stephenson-s Jul 13, 2026
a742df7
Remove unnecessary duplicate notebooks and scripts
Jul 13, 2026
fb83cd6
fixed api
Jul 13, 2026
bb1884f
added TRUNC, city profiles now printing folders
Jul 14, 2026
c0d1e19
all figures now generated
Jul 14, 2026
044830b
moran calculates in terms of white + black not total pop
Jul 14, 2026
cb141ba
Merge branch 'main' into truncation_station
maria-milosh Jul 14, 2026
b72ef82
Merge pull request #36 from maria-milosh/truncation_station
maria-milosh Jul 14, 2026
24137d8
added maup notebook
Jul 14, 2026
2d7733c
cleaning the .gitignore accroding to the new structure
maria-milosh Jul 14, 2026
9a6eca3
breaking down pipeline into steps, a folder per step
maria-milosh Jul 14, 2026
5134947
moving things around
maria-milosh Jul 14, 2026
b18b075
add folders for experiments, stats, working paper figures reproduction
maria-milosh Jul 14, 2026
c48ecfd
cleaning the folders after moving
maria-milosh Jul 14, 2026
1a64858
move chicago to sh scripts
maria-milosh Jul 14, 2026
a301eac
updating the scripts to use new paths
maria-milosh Jul 14, 2026
7d7892b
adding the build folder, previously ignored
maria-milosh Jul 16, 2026
37a78b8
remove pre-restructuring artifacts
maria-milosh Jul 17, 2026
32b066a
restructure python pipeline
maria-milosh Jul 17, 2026
5186eb3
replace pipeline_config.sh with YAML config
maria-milosh Jul 17, 2026
a4d5398
rename data/processed/ dirs and shell script
maria-milosh Jul 17, 2026
1952cd9
updating tests to reflect changes and new structure
maria-milosh Jul 17, 2026
774094a
viz tweaks for readability
maria-milosh Jul 17, 2026
27f8b16
use gpkg files instead of shapefiles to avoid memory issues
maria-milosh Jul 17, 2026
916405b
update lineplot colors; small tweaks
maria-milosh Jul 18, 2026
71d5f8d
Highlight City Visualizations Added
stephenson-s Jul 18, 2026
852dbbd
updating paths to experiment_orchestraction.py
maria-milosh Jul 20, 2026
60f7d33
split years by a separator explicitly
maria-milosh Jul 20, 2026
9246a09
change expected input from shapefile to gpkg
maria-milosh Jul 20, 2026
7ba9d59
skip 1980 on blocks
maria-milosh Jul 20, 2026
c146c5f
small tweaks
maria-milosh Jul 20, 2026
861ce31
update test scripts accordingly
maria-milosh Jul 20, 2026
f7fd59a
Merge pull request #38 from maria-milosh/restructure
maria-milosh Jul 22, 2026
fa6adcf
temporarily move metro area stats to the stats folder; to be reviewed…
maria-milosh Jul 22, 2026
25f9320
remove Metro Area Network Statistics
maria-milosh Jul 22, 2026
5b124fa
memo statistics, notebooks, and pipeline updates
Jul 30, 2026
bb3c535
merger of memo branch (drop zero nodes + adding cities + adding more …
Jul 30, 2026
cf81ca0
fixed the pipeline to be configured to includeplaces , fixed bugs inv…
Jul 30, 2026
33484ef
Merge pull request #42 from maria-milosh/memo-branch
maria-milosh Jul 30, 2026
42b90fd
change shapefiles to gpkg
maria-milosh Jul 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 13 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ __pycache__/

# Distribution / packaging
.Python
build/
/build/
develop-eggs/
dist/
downloads/
Expand Down Expand Up @@ -130,6 +130,7 @@ venv/
ENV/
env.bak/
venv.bak/
.vscode/

# Spyder project settings
.spyderproject
Expand Down Expand Up @@ -162,3 +163,14 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# macOS
**/.DS_Store

# Project data and generated files
/cbsas/
/census_geographies/
/study_areas/
/census_raw/
/data/
/archive/
/outputs/
69 changes: 69 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
## Project Purpose

This project downloads population and geography data from the Census Bureau API and IPUMS/NHGIS, constructs adjacency graphs where census units (e.g. tracts) within study areas (e.g. CBSAs) are connected if they share a border, and applies a battery of residential segregation metrics. The goal is to assess segregation and disagreement among metrics across geographies and decades.

## Pipeline overview

The full pipeline is driven by `scripts/reproduce.sh`, which sources `scripts/pipeline_config.sh` for all configuration. Steps run in order:

1. **`scripts/setup.sh`** — scaffolds the directory tree (`census_raw/`, `census_geographies/`, `study_area_sources/`, `study_areas/`, `outputs/`, etc.)
2. **`pipeline/download_population_tables.py`** — downloads decennial census race/ethnicity counts (TOTPOP, WHITE, BLACK, POC, etc.) via Census API; uses IPUMS/NHGIS extracts for 1980 and 1990
3. **`pipeline/download_geographies.py`** — downloads TIGER/Line shapefiles (2000–2020 via Census API; 1980/1990 via IPUMS NHGIS)
4. **`pipeline/build_census_geographies.py`** — joins population tables to shapefiles, producing one attributed shapefile per year/level in `census_geographies/`
5. **`scripts/build_study_areas.sh`** → **`pipeline/build_study_areas.py`** — builds study area boundary polygons (e.g. CBSA outlines from county-component `.xls` files) into `study_areas/definitions/`
6. **`scripts/overlaps.sh`** → **`pipeline/overlaps.py`** — clips census geography shapefiles to each study area boundary (parallelized over years); outputs clipped shapefiles to `study_areas/<year>/` and coverage stats to `outputs/<run>/coverage_stats.csv`
7. **`pipeline/gen_duals.py`** — builds the dual adjacency graph from each clipped shapefile; contracts zero-population nodes and ensures full connectivity; outputs `*_orig.json` and `*_connected.json` alongside each shapefile
8. **`pipeline/calculate_metrics.py`** — computes ~80 segregation metrics per study area / year from each connected graph JSON; outputs one CSV row per area; errors logged to `outputs/<run>/metric_failures.csv`
9. **`pipeline/generate_figures.py`** — reads aggregated metric CSVs and produces publication figures

## Configuration

All pipeline behavior is controlled by environment variables (with defaults in `scripts/pipeline_config.sh`):

| Variable | Default | Options |
|---|---|---|
| `STUDY_AREA_TYPE` | `cbsa` | `cbsa`, `county` |
| `CENSUS_GEOGRAPHY_TYPE` | `tracts` | `tracts`, `block_groups`, `blocks`, `counties` |
| `CENSUS_GEOGRAPHY_YEARS` | `2020 2010 2000 1990 1980` | space-separated year list |
| `STUDY_AREA_VINTAGE` | `2020` | year |
| `RUN_NAME` | `<geo_type>_in_<study_area_type>` | string |
| `RUN_OUTPUT_DIR` | `outputs/<RUN_NAME>` | path |

For `STUDY_AREA_TYPE=cbsa`, a delineation file matching `list1_*_<vintage>.xls` must exist in `study_area_sources/`. A Census API key and IPUMS API key are required for downloads.

## Important directories

| Directory | Contents | Notes |
|---|---|---|
| `study_area_sources/` | CBSA delineation `.xls` files | Required input; not generated |
| `census_raw/geographies/` | Raw downloaded TIGER/NHGIS shapefiles | Do not modify |
| `census_raw/population/` | Raw downloaded population CSV tables | Do not modify |
| `census_geographies/` | Merged population+shapefile per year/level (`<year>_<level>.shp`) | Generated; heavy |
| `study_areas/definitions/` | Study area boundary shapefiles | Generated |
| `study_areas/<year>/` | Clipped census shapefiles + dual graph JSONs per study area | Generated; heavy |
| `outputs/<run_name>/` | Metric CSVs (`white_black.csv`, `white_poc.csv`), `coverage_stats.csv`, `metric_failures.csv`, figures, `run.log` | Generated outputs |

`_orig.json` = raw dual graph; `_connected.json` = fully connected, zero-pop nodes contracted (used for metrics).

## Important commands

- **Setup:** `bash scripts/setup.sh`
- **Full reproduction:** `bash scripts/reproduce.sh` (takes many hours on full dataset)
- **Generate dual graphs:** `python pipeline/gen_duals.py <shapefile.shp> <out_orig.json> <out_connected.json>`
- **Calculate metrics:** `python pipeline/calculate_metrics.py <connected.json> <x_col> <y_col> <tot_col>`
- **Generate figures:** `python pipeline/generate_figures.py --filename <metrics.csv> --prefix <prefix>`
- **Check overlaps:** `bash scripts/overlaps.sh`
- **Parse output:** `python pipeline/parse_output.py` (consumes CSV format)

## Testing / Verification

- Run `pytest` to execute `tests/test_gen_duals.py` and `tests/test_pipeline_config.py`
- Run `python pipeline/gen_duals.py ...` on a small fixture for a quick sanity check
- Run `bash scripts/reproduce.sh` only when full reproduction is needed

## Outputs

- Metric CSVs: `outputs/<run_name>/white_black.csv`, `outputs/<run_name>/white_poc.csv`
- Coverage stats: `outputs/<run_name>/coverage_stats.csv`
- Figures: under `outputs/<run_name>/`
- Output formats must not change.
38 changes: 13 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
.PHONY: all
.PHONY: install setup test run clean

CHICAGO_REF := 9618502_16980_march_2020
OUTPUT_DIR := chicago-maup
# Override with: make run EXPERIMENT=initial_paper_reproduction
EXPERIMENT ?= baseline

../data.mggg.org/census-2020/il/il_%.shp: pipeline/overlaps.py pipeline/gen_duals.py cbsas/defs/$(CHICAGO_REF).shp
python3 pipeline/overlaps.py $@ "cbsas/defs/$(CHICAGO_REF).shp" $(OUTPUT_DIR) --prefix "$*_"
python3 pipeline/gen_duals.py $(OUTPUT_DIR)/$*_$(CHICAGO_REF)_cbsa_tracts.shp $(OUTPUT_DIR)/$*_$(CHICAGO_REF)_orig.json $(OUTPUT_DIR)/$*_$(CHICAGO_REF)_connected.json --attr GEOID20 --pop-col TOTPOP20
install:
poetry install

chicago_duals: $(wildcard ../data.mggg.org/census-2020/il/il_*.shp)
setup:
bash scripts/setup.sh

chicago_black_header: pipeline/calculate_metrics.py ../data.mggg.org/census-2020/il/il_sldl.shp
python3 pipeline/calculate_metrics.py $(OUTPUT_DIR)/il_tract_cbsa_sldl_connected.json BLACK WHITE TOTPOP --headers-only > outputs/white_black_chicago.csv
chicago_poc_header: ../data.mggg.org/census-2020/il/il_sldl.shp
python3 pipeline/calculate_metrics.py $(OUTPUT_DIR)/il_tract_cbsa_sldl_connected.json POC WHITE TOTPOP --headers-only > outputs/white_poc_chicago.csv
test:
poetry run pytest pipeline/tests/ -v

chicago-maup/%_$(CHCIAGO_REF)_connected.json: pipeline/calculate_metrics.py chicago_black_header chicago_poc_header ../data.mggg.org/census-2020/il/il_%.shp
python3 pipeline/calculate_metrics.py $@ BLACK WHITE TOTPOP >> outputs/white_black_chicago.csv
python3 pipeline/calculate_metrics.py $@ POC WHITE TOTPOP >> outputs/white_poc_chicago.csv
run: setup
bash scripts/run_experiment.sh experiments/$(EXPERIMENT)/config.json

outputs/white_black_chicago.csv: chicago_black_header chicago_duals
$(MAKE) $(wildcard chicago-maup/*connected.json)
outputs/white_poc_chicago.csv: chicago_poc_header chicago_duals
$(MAKE) $(wildcard chicago-maup/*connected.json)

chicago: outputs/white_black_chicago.csv outputs/white_poc_chicago.csv

all: chicago

clean:
rm chicago-maup/*
clean:
rm -rf outputs/
104 changes: 89 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,106 @@
## CAPY
## Project Purpose

This project downloads population and geography data from the Census Bureau API and IPUMS/NHGIS, constructs adjacency graphs where census units (e.g. tracts) within study areas (e.g. CBSAs) are connected if they share a border, and applies a battery of residential segregation metrics. The goal is to assess segregation and disagreement among metrics across geographies and decades.

## Folder structure

## Testing
```
pytest
capy-bara/
├── data/
│ ├── raw/ # downloaded source files (gitignored)
│ │ ├── geographies/ # TIGER/Line and NHGIS shapefiles
│ │ ├── population/ # Census API / NHGIS population tables
│ │ └── ipums_extracts/ # IPUMS extracts (1980, 1990)
│ ├── interim/ # processed intermediates (gitignored)
│ │ ├── census_geographies/ # population-attributed shapefiles per year/level
│ │ ├── cbsas/ # CBSA definitions by decade
│ │ ├── study_areas/ # clipped shapefiles + dual graph JSONs per study area
│ │ └── study_area_sources/ # CBSA delineation .xls files
│ └── outputs/ # pipeline run outputs
│ ├── tracts_in_cbsa/
│ ├── block_groups_in_cbsa/
│ ├── blocks_in_cbsa/
│ └── cross_level_comparisons/ # figures comparing results across runs
├── pipeline/ # core pipeline modules
│ ├── download/ # download_geographies.py, download_population_tables.py
│ ├── build/ # build_census_geographies.py, build_study_areas.py,
│ │ # overlaps.py, gen_duals.py, filter_cbsas.py
│ ├── metrics/ # calculate_metrics.py, parse_output.py
│ ├── viz/ # generate_figures.py
│ ├── utils/ # definitions.py
│ └── tests/
├── experiments/ # hypothesis-testing experiments
│ ├── notebooks/ # scratch notebooks before a hypothesis becomes a script
│ ├── comparisons/ # cross-experiment analyses and figures
│ └── exp_<name>/ # one folder per experiment: run.py + figures/
├── working_paper_reproduction/ # materials for reproducing paper results
│ ├── notebooks/ # reproduction notebooks
│ ├── misc_analysis/
│ └── figures/
├── scripts/ # shell scripts for running the pipeline
└── archive/ # inactive code and old outputs
```

## Reproducing
First, install the [dependencies](#dependencies).
## Pipeline overview

Next, download the [nhgis](https://nhgis.org) race and shapefile data for Census tracts (from 1970-2020 inclusive) into the `nhgis` folder.
The full pipeline is driven by `scripts/reproduce.sh`, which sources `scripts/pipeline_config.sh` for all configuration. Steps run in order:

Finally, run the reproduce script to rerun the analysis pipeline:
```
bash reproduce.sh
```
1. **`scripts/setup.sh`** — scaffolds the directory tree
2. **`pipeline/download/download_population_tables.py`** — downloads decennial census race/ethnicity counts (TOTPOP, WHITE, BLACK, POC, etc.) via Census API; uses IPUMS/NHGIS extracts for 1980 and 1990
3. **`pipeline/download/download_geographies.py`** — downloads TIGER/Line shapefiles (2000–2020 via Census API; 1980/1990 via IPUMS NHGIS)
4. **`pipeline/build/build_census_geographies.py`** — joins population tables to shapefiles, producing one attributed shapefile per year/level in `data/interim/census_geographies/`
5. **`scripts/build_study_areas.sh`** → **`pipeline/build/build_study_areas.py`** — builds study area boundary polygons (e.g. CBSA outlines from county-component `.xls` files) into `data/interim/study_areas/definitions/`
6. **`scripts/overlaps.sh`** → **`pipeline/build/overlaps.py`** — clips census geography shapefiles to each study area boundary (parallelized over years); outputs clipped shapefiles to `data/interim/study_areas/<year>/` and coverage stats to `data/outputs/<run>/coverage_stats.csv`
7. **`pipeline/build/gen_duals.py`** — builds the dual adjacency graph from each clipped shapefile; contracts zero-population nodes and ensures full connectivity; outputs `*_orig.json` and `*_connected.json` alongside each shapefile
8. **`pipeline/metrics/calculate_metrics.py`** — computes ~80 segregation metrics per study area / year from each connected graph JSON; outputs one CSV row per area; errors logged to `data/outputs/<run>/metric_failures.csv`
9. **`pipeline/viz/generate_figures.py`** — reads aggregated metric CSVs and produces publication figures

`_orig.json` = raw dual graph; `_connected.json` = fully connected, zero-pop nodes contracted (used for metrics).

## Configuration

All pipeline behavior is controlled by environment variables (with defaults in `scripts/pipeline_config.sh`):

Your outputs will be in the `outputs/` folder.
| Variable | Default | Options |
|---|---|---|
| `STUDY_AREA_TYPE` | `cbsa` | `cbsa`, `county` |
| `CENSUS_GEOGRAPHY_TYPE` | `tracts` | `tracts`, `block_groups`, `blocks`, `counties` |
| `CENSUS_GEOGRAPHY_YEARS` | `2020 2010 2000 1990 1980` | space-separated year list |
| `STUDY_AREA_VINTAGE` | `2020` | year |
| `RUN_NAME` | `<geo_type>_in_<study_area_type>` | string |
| `RUN_OUTPUT_DIR` | `data/outputs/<RUN_NAME>` | path |

### Dependencies
Python deps are managed via Poetry. Install Python `3.9.10`, then install the Python deps by running:
For `STUDY_AREA_TYPE=cbsa`, a delineation file matching `list1_*_<vintage>.xls` must exist in `data/interim/study_area_sources/`. A Census API key and IPUMS API key are required for downloads.

## Important commands

- **Setup:** `bash scripts/setup.sh`
- **Full reproduction:** `bash scripts/reproduce.sh` (takes many hours on full dataset)
- **Generate dual graphs:** `python pipeline/build/gen_duals.py <shapefile.shp> <out_orig.json> <out_connected.json>`
- **Calculate metrics:** `python pipeline/metrics/calculate_metrics.py <connected.json> <x_col> <y_col> <tot_col>`
- **Generate figures:** `python pipeline/viz/generate_figures.py --filename <metrics.csv> --prefix <prefix>`
- **Check overlaps:** `bash scripts/overlaps.sh`
- **Parse output:** `python pipeline/metrics/parse_output.py`

## Dependencies

Python deps are managed via Poetry:
```
pip install poetry
poetry install
```

To launch a shell with the poetry enviroment activated, run:
To launch a shell with the poetry environment activated:
```
poetry shell
```

[`fd`](https://github.com/sharkdp/fd) is also required to run the reproduce script.
Set API keys in your shell before downloading data:
```
export CENSUS_API_KEY="..."
export IPUMS_API_KEY="..."
```
14 changes: 0 additions & 14 deletions chicago.sh

This file was deleted.

8 changes: 0 additions & 8 deletions configs/README.md

This file was deleted.

Binary file removed configs/list1_april_2018.xls
Binary file not shown.
Binary file removed configs/list1_august_2017.xls
Binary file not shown.
Binary file removed configs/list1_february_2013.xls
Binary file not shown.
Binary file removed configs/list1_july_2015.xls
Binary file not shown.
Binary file removed configs/list1_march_2020.xls
Binary file not shown.
Binary file removed configs/list1_september_2018.xls
Binary file not shown.
5 changes: 5 additions & 0 deletions experiments/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This folder stores hypothesis testing scripts (finalized python scripts, notebooks, and figures).

Folders are of the form `h*_t*_<short name>`, corresponding to the hypothesis and test number in the `hypotheses_notebook`.

`notebooks` are for figuring out what should be in python scripts.
3 changes: 3 additions & 0 deletions experiments/baseline/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "baseline"
}
6 changes: 6 additions & 0 deletions experiments/baseline/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from pathlib import Path

from experiments.experiment_orchestration import run_experiment

if __name__ == "__main__":
run_experiment(Path(__file__).parent / "config.json")
7 changes: 7 additions & 0 deletions experiments/defaults.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"study_area_type": "cbsa",
"census_geography_type": "tracts",
"census_geography_years": [2020, 2010, 2000, 1990, 1980],
"study_area_vintage": 2020,
"study_area_definition_geography_type": "counties"
}
Loading