Population projection pipeline with single-year ages ("unabridged") and joint parameter sweeps for fertility & mortality assumptions. Supports parallelized scenario runs and consolidated outputs (life tables, ASFR, Leslie matrices, projections).
Repo name:
PyCCM
Entry point:src/main_compute.py
Config:config.yaml(root)
Data dir:data/(CSV inputs)
Outputs:results_unabridged/(default)
Status: Production Ready (211/211 tests passing)
- Features
- Installation
- Quickstart
- Configuration
- Parameter sweeps & parallelism
- Inputs & expected files
- Outputs
- Troubleshooting
- Development
- Testing/Documentation Quick Links
- Citation
- License
- Unabridged single-year age structure & annual projections
- Joint sweeps (Cartesian product) over:
- Target TFR range
- Mortality improvement totals
- Life-table smoothing MA window
- Parallel execution across grid points/tasks
- Consolidated outputs per artifact type (CSV + Parquet)
- Reproducible seeds per scenario label
- Optional midpoints blending (EEVV vs. Census) for deaths
Using conda:
conda create -n pyccm python=3.11 -y
conda activate pyccmFrom the repo root:
pip install -e .If you don’t have a pyproject.toml yet, you can simply install runtime deps manually:
pip install numpy pandas tqdm pyarrow-
Put your inputs under
data/(see Inputs & expected files). -
Adjust
config.yaml(ranges, run mode, parallel processes, output paths). -
Run:
cd src
python main_compute.pyYou’ll see logs about detected ranges, tasks, and the global progress bar.
Final combined outputs land in results_unabridged/ (by default).
All behavior is controlled via config.yaml. Key sections:
paths: input/output locations (data_dir,results_dir, CSV paths)unabridging.enabled: single-year ages + annual steps whentrueprojections: years, death sources, flows yearfertility:default_tfr_targetconvergence_yearsdefault_tfr_target_range→ sweep bounds
mortality:improvement_total(default, if not in CSV)improvement_total_range→ sweep boundsma_windowandma_window_range→ sweep bounds
runs:mode:"no_draws"or"draws"no_draws_tasks: list of omission scenariosdraws:num_draws, distributions, label pattern
parallel.processes: worker threads per grid pointhousekeeping.clean_run: remove results directory before run
PyCCM builds a Cartesian grid over the configured ranges:
fertility.default_tfr_target_rangemortality.improvement_total_rangemortality.ma_window_range
For each grid point, the configured tasks (e.g., mid/low/high_omissions) are run, optionally in parallel.
- Total scenarios =
#grid_points × #tasks - Progress bar reflects
#grid_points × #tasks × #death_choices × #years
Set worker count in config.yaml:
parallel:
processes: 4Tip: On heavy runs, start with smaller ranges to validate I/O and shapes.
Place these (optional but recommended) under data/ or point via paths:
- Mortality improvements (per DPTO; optional):
mortality_improvements.csvwith columns like:DPTO_NOMBREimprovement_total(fraction or %)convergence_years,kind(exp/logistic),converge_frac,mid_frac,steepness
- Target TFRs (per DPTO; optional):
target_tfrs.csv(seefertility.default_tfr_targetfor global fallback) - Midpoint weights (optional):
midpoints.csvwithDPTO_NOMBRE→ EEVV weight in[0,1]
Raw population/migration/defunction data are loaded via data_loaders.load_all_data from paths.data_dir.
All consolidated results are written to results_dir:
all_lifetables.{csv,parquet}all_asfr.{csv,parquet}all_leslie_matrices.{csv,parquet}all_projections.{csv,parquet}
During the run, scenarios may write to _scenarios/<name>/ and are aggregated at the end.
- “Life tables not initialized before projection.”
Ensure deaths exist for the relevantdeath_choiceand year used to build life tables:EEVV: requires deaths up toprojections.last_observed_year_by_death.EEVVcenso_2018&midpoint: require deaths atprojections.start_year
- 0 scenarios detected
Check that ranges produce at least one value each (inclusive step logic) andruns.no_draws_tasksisn’t empty. - Slow runs
Reduce range sizes, restrictDEATH_CHOICES, or increaseparallel.processes. - Missing input CSVs
You’ll see warnings; the pipeline falls back to YAML defaults.
Documentations:
- docs/README.md - Complete documentation index
- TESTING_SUMMARY_QUICK.md - 1-page executive summary
- DOCUMENTATION_INDEX.md - Central navigation hub
For Developers/QA:
- COMPREHENSIVE_TESTING_REPORT.md - Full test analysis (25K words)
- docs/tests/README.md - Test suite navigation
- Run tests:
pytest tests/ -v
For Demographers:
- Module assessments in
docs/modules/[module]/DEMOGRAPHIC_ASSESSMENT_*.md
Quality Assurance:
- 211 tests (100% passing)
- Python 3.7-3.11 compatibility verified
If this work supports your research, please cite the repo:
@software{PyCCM,
title = {PyCCM: Population projection pipeline with joint parameter sweeps},
author = {Rahal, C., Jaramillo, J. and Yan, J.},
year = {2025},
url = {https://github.com/crahal/PyCCM}
}
This project is licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.
- Replace
your-orgwith your actual GitHub org/user. - Ensure
actions/workflows/ci.ymlexists for the CI badge. - Configure Codecov (or remove the coverage badge) if not in use.