Fig. 2 - pulse timing, trim window, and averaging
================================================

The raw record (measured_photocurrent_400pulses.csv) contains buffer dead-time
before the pulse sequence begins and a tail after it ends. Only the active window
is used for analysis.

    num_pulses       = 400
    pulse_width_s    = 5.007        <- the TRUE pulse period (not the nominal 5 s)
    trim_start_s     = 50.25        <- time of the first pulse edge
    trim_end_s       = 2053.05      =  trim_start_s + num_pulses * pulse_width_s
    active duration  = 2002.8 s     (~33 min)


Why 5.007 s and not 5.000 s
---------------------------
The true pulse period is 5.007 s. That 7 ms excess is negligible for a single
pulse but accumulates across the run: over 400 pulses it amounts to

    400 * 0.007 s = 2.8 s

which is more than half a pulse width. Using the nominal 5.000 s would therefore
progressively misalign the pulse boundaries, and by the end of the sequence each
measured segment would be assigned the wrong pulse label. Pulse boundaries are
laid down as

    pulse_edges[i] = trim_start_s + i * pulse_width_s ,   i = 0 ... 400

A sample at time t belongs to pulse i when pulse_edges[i] <= t < pulse_edges[i+1];
the final pulse also includes its right edge.


The light sequence is not in the measurement file
-------------------------------------------------
The measurement records only the resulting current (measured_current_A, in amperes),
acquired at a constant 20 V DC bias. It does NOT record the light input. The light
level applied during each pulse is given separately, in pulse_sequence_input.csv
(pulse_index, pulse_label), with levels drawn from {0.1, 0.5, 1.0} in arbitrary
intensity units.


Baseline correction
-------------------
fig2a_overlay_plotted.csv carries the baseline-corrected current (corrected_current_A)
only, because that is the trace drawn in Fig. 2(a). The correction removes a slow
monotonic drift by subtracting a fitted square-root baseline; the model and its fitted
coefficients are documented in the record README. The corrected current is also the
signal used for reservoir feature extraction.

For the as-measured counterpart, use figS_baseline/figS_baseline_correction.csv, which
is row-aligned with fig2a_overlay_plotted.csv and ships all three curves together
(measured_current_A, baseline_fit_A, corrected_current_A). The full untrimmed
measurement is in measured_photocurrent_400pulses.csv.


Fig. 2(c) / 2(d) - averaged responses
-------------------------------------
For a given PRESENT pulse level, every pulse at that level is grouped by the level of
the immediately PRECEDING pulse, and the within-pulse baseline-corrected current is
averaged over each group (mean and standard deviation).

    fig2c_avg_response_present1p0.csv    present level = 1.0
    fig2d_avg_response_present0p5.csv    present level = 0.5

Each past-group carries its own time column, because the time axis is built as
linspace(0, pulse_width, max_len) where max_len is that group's longest segment,
and segment lengths vary slightly between pulses (48-51 samples). The groups can
therefore sit on marginally different grids; giving each its own time column
reproduces the figure faithfully rather than forcing a shared axis.

Each group also carries an n_past* column: the number of pulses actually averaged
at each time point. Because segments differ in length and short ones are padded,
this count falls off at late times - the final point of a group can rest on only a
few pulses. Consult n_past* before drawing conclusions from the tail.

    columns per past level X in {0p1, 0p5, 1p0}:
        time_pastX_s    time within the pulse (s)
        mean_pastX_A    mean baseline-corrected current (A)
        std_pastX_A     standard deviation across the averaged pulses (A)
        n_pastX         number of pulses contributing at that time point
