Code
import sys
sys.path.append('.')
from rainDrought.config import get_config
config = get_config()10-Year Historical Records
Antigravity Coding Assistant
July 19, 2026
This document contains Python code to programmatically retrieve, process, and store 10-year historical climate records for: 1. Weekly Drought Monitor records for Oglala Lakota County (FIPS 46102), South Dakota. 1. Weekly Drought Monitor records for Todd County (FIPS 46121), South Dakota.
The collected datasets are saved to the data/ directory.
[!NOTE] Active Region Configuration: Default configured for South Dakota (precipitation) and counties: Oglala Lakota County (Pine Ridge), Todd County (Rosebud). To customize these locations, copy the layout from
config.csv.default(or the example fromconfig.csv.example) into a newconfig.csvfile and re-run.
https://usdmdataservices.unl.edu/api/.https://data.rcc-acis.org/GridData.The following Python block dynamically computes the date range for the past 10 years and calls the respective APIs to fetch and store the records.
Active State: South Dakota (sd)
Active Counties:
- Oglala Lakota County (FIPS: 46102, Label: Pine Ridge)
- Todd County (FIPS: 46121, Label: Rosebud)
Timeframe: 2016-08-27 to 2026-08-27
Querying USDM API for Oglala Lakota County...
-> Successfully saved weekly drought data to data/oglala_lakota_drought_weekly.csv
Querying USDM API for Todd County...
-> Successfully saved weekly drought data to data/todd_drought_weekly.csv
Querying ACIS GridData API...
-> Successfully saved daily precipitation data to data/south_dakota_precipitation_daily.csv
Let’s load the saved datasets to verify their content and print summary statistics.
Weekly USDM records: 523
| ValidStart | County | None | D0 | D1 | D2 | D3 | D4 | |
|---|---|---|---|---|---|---|---|---|
| 518 | 2026-07-28 | Oglala Lakota County | 0.0 | 100.0 | 100.0 | 100.0 | 33.84 | 0.0 |
| 519 | 2026-08-04 | Oglala Lakota County | 0.0 | 100.0 | 100.0 | 100.0 | 43.18 | 0.0 |
| 520 | 2026-08-11 | Oglala Lakota County | 0.0 | 100.0 | 100.0 | 100.0 | 43.18 | 0.0 |
| 521 | 2026-08-18 | Oglala Lakota County | 0.0 | 100.0 | 100.0 | 100.0 | 43.18 | 0.0 |
| 522 | 2026-08-25 | Oglala Lakota County | 0.0 | 100.0 | 100.0 | 100.0 | 43.18 | 0.0 |
| None | D0 | D1 | D2 | D3 | D4 | |
|---|---|---|---|---|---|---|
| count | 523.000000 | 523.000000 | 523.000000 | 523.000000 | 523.000000 | 523.0 |
| mean | 34.449675 | 65.550325 | 47.576922 | 18.856979 | 5.238126 | 0.0 |
| std | 46.167434 | 46.167434 | 46.299453 | 33.810416 | 17.039506 | 0.0 |
| min | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.0 |
| 25% | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.0 |
| 50% | 0.000000 | 100.000000 | 42.270000 | 0.000000 | 0.000000 | 0.0 |
| 75% | 100.000000 | 100.000000 | 100.000000 | 17.450000 | 0.000000 | 0.0 |
| max | 100.000000 | 100.000000 | 100.000000 | 100.000000 | 97.570000 | 0.0 |
Weekly USDM records: 523
| ValidStart | County | None | D0 | D1 | D2 | D3 | D4 | |
|---|---|---|---|---|---|---|---|---|
| 518 | 2026-07-28 | Todd County | 0.0 | 100.0 | 100.00 | 0.0 | 0.0 | 0.0 |
| 519 | 2026-08-04 | Todd County | 0.0 | 100.0 | 100.00 | 0.0 | 0.0 | 0.0 |
| 520 | 2026-08-11 | Todd County | 0.0 | 100.0 | 99.06 | 0.0 | 0.0 | 0.0 |
| 521 | 2026-08-18 | Todd County | 0.0 | 100.0 | 98.97 | 0.0 | 0.0 | 0.0 |
| 522 | 2026-08-25 | Todd County | 0.0 | 100.0 | 66.20 | 0.0 | 0.0 | 0.0 |
| None | D0 | D1 | D2 | D3 | D4 | |
|---|---|---|---|---|---|---|
| count | 523.000000 | 523.000000 | 523.000000 | 523.000000 | 523.000000 | 523.0 |
| mean | 43.186788 | 56.813212 | 29.544226 | 11.545315 | 2.528470 | 0.0 |
| std | 46.902388 | 46.902388 | 42.076676 | 29.324221 | 12.088991 | 0.0 |
| min | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.0 |
| 25% | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.0 |
| 50% | 0.000000 | 100.000000 | 0.000000 | 0.000000 | 0.000000 | 0.0 |
| 75% | 100.000000 | 100.000000 | 75.520000 | 0.000000 | 0.000000 | 0.0 |
| max | 100.000000 | 100.000000 | 100.000000 | 100.000000 | 79.050000 | 0.0 |
Number of daily precipitation records: 3653
| date | precipitation_inches | |
|---|---|---|
| 3648 | 2026-08-23 | 0.067627 |
| 3649 | 2026-08-24 | 0.075267 |
| 3650 | 2026-08-25 | 0.112057 |
| 3651 | 2026-08-26 | 0.000299 |
| 3652 | 2026-08-27 | NaN |
count 3652.000000
mean 0.059764
std 0.124284
min 0.000000
25% 0.000664
50% 0.008864
75% 0.056090
max 1.374540
Name: precipitation_inches, dtype: float64
Let’s visualize the trends over the 10-year period.
---
title: "Rain and Drought Records Collection"
subtitle: "10-Year Historical Records"
author: "Antigravity Coding Assistant"
date: "2026-07-19"
format:
html:
theme: cosmo
toc: true
code-fold: true
code-tools: true
embed-resources: true
---
```{python}
#| label: config-init
#| warning: false
#| message: false
import sys
sys.path.append('.')
from rainDrought.config import get_config
config = get_config()
```
```{python}
#| label: introduction
#| warning: false
#| message: false
#| output: asis
from rainDrought.visualizations import show_collect_data_intro
show_collect_data_intro(config)
```
***
# Data Sources & Citations
1. **U.S. Drought Monitor (USDM)**
- **Source**: National Drought Mitigation Center (NDMC), University of Nebraska-Lincoln, USDA, and NOAA.
- **Description**: Weekly reports of drought severity classifications (None, D0-D4) indicating the percentage of area affected.
- **Data Access**: Retrieved via the USDM REST Data Services API: `https://usdmdataservices.unl.edu/api/`.
- **Citation**:
> U.S. Drought Monitor. (2026). *U.S. Drought Monitor data archives*. National Drought Mitigation Center. Retrieved from https://droughtmonitor.unl.edu/
2. **Applied Climate Information System (ACIS)**
- **Source**: NOAA Regional Climate Centers (RCCs).
- **Description**: Daily precipitation observations aggregated and interpolated across the state of South Dakota, computed as a statewide mean.
- **Data Access**: Retrieved via the ACIS GridData API: `https://data.rcc-acis.org/GridData`.
- **Citation**:
> Applied Climate Information System (ACIS). (2026). *Gridded Daily Precipitation (NRCC Interpolated Grid)*. NOAA Regional Climate Centers. Retrieved from https://www.rcc-acis.org/
***
# Data Collection Pipeline
The following Python block dynamically computes the date range for the past 10 years and calls the respective APIs to fetch and store the records.
```{python}
#| label: data-collection
#| warning: false
#| message: false
from rainDrought.data_pipeline import run_pipeline
run_pipeline(config)
```
***
# Data Previews & Summaries
Let's load the saved datasets to verify their content and print summary statistics.
```{python}
#| label: usdm-summaries
#| warning: false
#| output: asis
from rainDrought.data_pipeline import show_summaries
show_summaries(config)
```
***
# Visualizations
Let's visualize the trends over the 10-year period.
```{python}
#| label: plots
#| warning: false
#| message: false
#| fig-width: 7.5
#| fig-height: 9.5
from rainDrought.visualizations import plot_matplotlib_trends
plot_matplotlib_trends(config)
```