Skip to content
Heterodata An Arcanum Research project Myrdal
Myrdal

Code

Two bodies of code stand behind this site. One is downloadable today; the other is not yet, and this page says which is which rather than implying both.

Downloadable now — the package and site build

The site code bundle is the tooling that turns the Anu chopped output into what you are reading: tools/build_web_package.py (writes the Parquet and XLSX copies, regenerates the data dictionary and the manifest, and asserts the manifest against the disk in both directions), tools/build_bundles.py (the reproducible zips), the FastAPI application, and the templates. It carries no credentials and no absolute paths, and it is MIT-licensed.

Reproducing the published package from the chopped CSVs is one command:

Rebuild the package · verify the counts
# 1. regenerate parquet + xlsx + dictionary + manifest, and assert both ways
python tools/build_web_package.py --pkg /path/to/Myrdal_Web_v1.0.0

# 2. read the counts back out of the manifest the build just wrote
import json
m = json.load(open("/path/to/Myrdal_Web_v1.0.0/WEB_MANIFEST.json", encoding="utf-8"))
c = m["counts"]
assert c["series_registered"] == c["series_published"] == c["chopped_csv"]
assert c["chopped_parquet"] == c["chopped_xlsx"] == c["chopped_csv"]
# these three are DELIBERATELY smaller -- do not "fix" them to match
print(c["series_with_data"], c["series_chartable"], c["observations_total"])
# 1. regenerate parquet + xlsx + dictionary + manifest (the builder is Python)
system("python tools/build_web_package.py --pkg /path/to/Myrdal_Web_v1.0.0")

# 2. read the counts back out of the manifest the build just wrote
library(jsonlite)
m <- fromJSON("/path/to/Myrdal_Web_v1.0.0/WEB_MANIFEST.json")
c <- m$counts
stopifnot(c$series_registered == c$series_published,
          c$series_published  == c$chopped_csv,
          c$chopped_parquet   == c$chopped_xlsx)
# these three are DELIBERATELY smaller -- do not "fix" them to match
c(c$series_with_data, c$series_chartable, c$observations_total)

Reading a series

Every series is one file. Parquet is the fastest way in; the CSV is identical.

D001 — long-run world population
import pandas as pd

# Parquet (preferred) or CSV -- identical rows.
d = pd.read_parquet("https://population.heterodata.org/downloads/series/D001.parquet")

# D001 carries TWO measures: the sum over individual countries and the
# publisher's own world aggregate. They differ; both are kept.
print(d[["year", "pop_persons", "wld_official_total"]].tail())

# The pre-1960 rows come from a different publisher than the rest. The seam is
# recorded IN THE FILE, in the `source` column -- never assume one series.
print(d["source"].unique())
library(arrow)   # or readr::read_csv for the CSV
library(dplyr)

# Parquet (preferred) or CSV -- identical rows.
d <- read_parquet("https://population.heterodata.org/downloads/series/D001.parquet")

# D001 carries TWO measures: the sum over individual countries and the
# publisher's own world aggregate. They differ; both are kept.
d %>% select(year, pop_persons, wld_official_total) %>% tail()

# The pre-1960 rows come from a different publisher than the rest. The seam is
# recorded IN THE FILE, in the `source` column -- never assume one series.
unique(d$source)

Not downloadable yet — the Anu construction pipeline

The upstream pipeline that produced the chopped CSVs lives in the project rather than on this site: ten loaders (L01 Census baseline, L02 World Development Indicators, L03 Clio-Infra, L04 Maddison, L05 World Inequality Database, L07 United Nations World Population Prospects, L08 Internal Revenue Service Statistics of Income migration, L10 American Community Survey counties, L12 Population Estimates Program, L14 Census International Database), six processors (dependency ratios, demographic transition, migration matrix, age–sex pyramid, nativity and citizenship, long-run population), and two validators (schema; cross-source reconciliation).

Why it is not offered here. Those scripts still contain absolute workstation paths to the local source archive. Publishing them as they stand would leak filesystem layout, so they are withheld until they have been through the framework's publication scrub. That is a queued task, not a missing capability, and it is recorded on Methodology. Until then the loaders' inputs are fully named there, so the construction is reproducible from the published sources even though the scripts are not yet in your hands.

No public repository exists for this site yet, so the footer shows no “Website source” button rather than a link that would 404. Site and tooling: MIT. Data: see TERMS.md.