Session 05 · Agentic scientific reproduction

A paper figure, rebuilt from conversation.

This lesson reconstructs a missed live recording as a log-playback screencast: user prompts pause, agent/tool output scrolls quickly, and the video slows down at failures, equations, digitization, and validation checkpoints.

Source paperPetters, M. D. & Kreidenweis, S. M. (2007). A single parameter representation of hygroscopic growth and cloud condensation nucleus activity. Atmos. Chem. Phys. 7, 1961–1971. doi.org/10.5194/acp-7-1961-2007 ↗

UV + gitred-green-refactorHypothesisPDF extractionimage thresholdinginteractive transcript
Jump to interactive demo ↓
▶ Start 5-minute reconstruction
Reconstructed Pi log playback: prompts pause, agent responses fast-forward, key bugs pause00:00

Why this workflow worked

This was not just “make me a plot.” The prompt asked for a reproducible environment, local version control, test-driven development, physics properties, and visible artifacts. Those constraints made the agent leave a trail that can be audited.

Process matters: a good scientific-agent prompt specifies how trust should be earned, not just what final output should appear.

Prompt choices that improved the result

  • “Use UV.” This forced an explicit, recreatable Python environment rather than a mystery global install.
  • “Use git, do not push.” This created an audit trail without publishing unfinished work.
  • “Use TDD and commit after every cycle.” This made failures visible and prevented a giant unreviewable rewrite.
  • “Use property-based tests.” For scientific code, exact answers are often unavailable. Physical monotonicity and limiting cases are excellent oracles.
  • “Extract and digitize the figure.” This moved the comparison from subjective visual similarity to data-backed regression checks.

Key moments in the session

1. Equations became executable tests

The paper’s κ-Köhler expression was translated into a public API. Tests checked the Kelvin coefficient, the κ=0 limiting case, and the large-droplet approximation for critical supersaturation.

S(D) = [(D³ - Dd³) / (D³ - Dd³(1 - κ))] exp(A/D)
A = 4 σ M_w / (R T ρ_w)
sc = max_D S(D) - 1

2. TDD exposed missing interfaces early

The first tests failed because the module did not exist yet. That is a feature, not a bug: the failing test defined the intended public interface before the implementation was written.

ImportError: cannot import name 'kohler' from 'kappa_kohler_figure'

3. Property tests found a subtle numerical edge case

Hypothesis generated a tiny positive value of κ. Mathematically it behaves like κ=0, but the numerical solver tried to bracket an interior maximum and failed. The fix was to define a tolerance for the Kelvin branch.

Falsifying example:
  dry_diameter=4.904843734817048e-07
  kappa=4.417464254787923e-65

ValueError: f(a) and f(b) must have different signs

Fix: if kappa <= 1e-12, use the Kelvin limit.

4. The plot was digitized, not just eyeballed

The PDF page was rendered at 300 dpi. A crop of Figure 1 was calibrated using log-axis tick marks. Thresholding found dark curve crossings; the axis transform converted pixels into dry diameter values.

pdftoppm -f 3 -l 3 -png -r 300 acp-7-1961-2007.pdf extracted/page3
threshold: grayscale < 80
x calibration: 0.01, 0.10, 1.00 μm ticks
y calibration: 1.0%, 0.1% ticks

5. Visual agreement became a regression test

The digitized points were saved as CSV and loaded by a test. The test is intentionally tolerant because the points are image-derived, but it still protects against gross physical or plotting regressions.

Data and logs for deeper inspection

The digitized Figure 1 test points are available as a linked CSV artifact rather than embedded in the page. The full exported HTML session log is also linked for anyone who wants to inspect the raw interaction in more detail.

Download the digitized test points CSV · Open the full session log HTML

Conversation summary

The user-facing exchange is summarized below. Tool calls and long pytest output are linked as artifacts so the main narrative stays readable.

Turn 1: initial research-code request
User: I'm learning about cloud condensation nuclie and I want to study this paper @acp-7-1961-2007.pdf . The goal is to recreate figure 1 from this paper. I would like you to use a UV managed environment here and git to track your progress (do not push anything to any remote). I would like you to use /skill:tdd to write this package and commit after every test cycle. Additionally use property based tests to check for consistency in the physics (you may use hypothesis for python).
Assistant: Implemented a UV-managed Python package to recreate Figure 1 from acp-7-1961-2007.pdf using TDD and git commits. Validation: uv run pytest → 8 passed. Working tree clean. Commits made after each completed TDD cycle.
Turn 2: extract and digitize
User: Can you extract the figure from the paper, digitize it and use it to make some test points that you can tabulate for me?
Assistant: Done. I extracted/rendered Figure 1 from the PDF, digitized selected curve crossings, and added them as regression test points. Validation: uv run pytest → 10 passed.
Turn 3: overlay
User: Can you overlay these points as markers on a new figure over the one you just generated?
Assistant: Done — I generated outputs/figure1_with_digitized_points.png. The digitized paper points are shown as red open-circle markers over the recreated κ-Köhler curves. Validation: uv run pytest → 11 passed.
Turn 4: polish the plot
User: Now that you extracted plots for comparison can you use the /matplotlib skill to make the graph prettier. Copy some of the style elements from the actual paper, but you can improve it further include the overlayed points from the digitization
Assistant: Added a prettier overlay figure while preserving the digitized-points comparison and test validation.
Turn 5: make this lesson
User: This is great. Now I want you to do something very cool. Take our entire discussion so far and create a video + article that shows our discussion verbatim along with the artifacts ... Create the files but do not push anything to git.

Open the redacted exported Pi session log (tool calls/results included; hidden reasoning and image payloads omitted) · Open the full HTML session log.