Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Generation of synthetic noise and synthetic data for geoscience

To run it. From the repository root, start pixi run -e core jupyter lab. The core environment has every package imported here: numpy, scipy, matplotlib, pandas, obspy and the course package mlgeo_synth. The seismic records are course copies in snapshots/, beside this notebook; a missing file is downloaded once from the book repository, so after that the notebook runs offline.

1. Introduction

Noise in geoscientific data comes from the environment, from the instrument, and from human activity. If we can simulate noise, we can build controlled datasets with known ground truth. That lets us test filters, benchmark detectors, and augment training sets for machine learning.

This lesson covers synthetic noise in two settings:

  1. 1D time series: seismic records, atmospheric pressure, sea surface temperature.

  2. 2D geospatial fields: topography, soil moisture, temperature maps.

We end with a realistic seismological example, an in-class activity in which your team builds a synthetic version of its own data (section 5), and a discussion of when synthetic data is admissible in research.

Types of noise

  • White noise: constant power spectral density at all frequencies. Typical of instrumental noise.

  • Pink noise: power spectral density proportional to 1/f1/f. Common in natural systems such as climate records.

  • Gaussian noise: noise whose amplitude distribution is normal. White noise is often drawn from a Gaussian.

  • Spatially correlated noise: noise that varies smoothly over space, as in atmospheric or sensor artifacts in maps.

Throughout this notebook we use numpy’s modern random generator, seeded for reproducibility. Seeding matters: a synthetic dataset that cannot be regenerated is not reproducible.

🖥️ Lecture slides: Session 09 (Wed Oct 21)

2. Noise models in 1D and 2D

2.1 White and pink noise (1D)

White noise is a sequence of independent Gaussian draws. Pink noise is built in the frequency domain: we impose an amplitude spectrum proportional to 1/f1/\sqrt{f} (so the power goes as 1/f1/f), draw random phases, and transform back to the time domain. We use np.fft.irfft, which takes the spectrum at non-negative frequencies only and returns a real signal by construction.

<Figure size 1000x600 with 2 Axes>

The white noise fluctuates rapidly with no memory from sample to sample. The pink noise wanders: low frequencies carry most of the power, so the series drifts on long time scales.

Applications. White noise simulates instrumental self-noise in seismic or atmospheric records. Pink noise mimics natural variability, which is dominated by low frequencies in many geophysical processes.

2.2 Spatially correlated noise (2D)

Geospatial noise is rarely independent from pixel to pixel. Atmospheric interference and sensor drift vary smoothly over space. A simple way to simulate this: generate a 2D field of white noise, then smooth it with a Gaussian filter. The filter width sets the correlation length.

<Figure size 1200x600 with 4 Axes>

Applications. Spatially correlated noise simulates atmospheric distortion in satellite imagery, interpolation artifacts in gridded products, and smooth sensor errors in geophysical maps.

3. Synthetic transient events

We now build a time series that contains one transient event plus noise. This is the basic ingredient of a binary classification problem: does a window contain signal or only noise?

3.1 Event signal: the Ricker wavelet

The Ricker wavelet, also called the Mexican-hat wavelet, is a standard model for an impulsive seismic source. It is the negative second derivative of a Gaussian. scipy.signal.ricker was removed from recent scipy versions, so we define it ourselves.

<Figure size 640x480 with 1 Axes>

The Ricker wavelet is smooth and band-limited. Let’s plot its absolute Fourier amplitude spectrum.

<Figure size 1000x500 with 2 Axes>

What does the event data distribution look like?

<Figure size 640x480 with 1 Axes>

3.2 Gaussian noise and signal-to-noise ratio

We created a pure signal. Now we create a noise time series to add to it.

One caution: np.random.uniform(0, 1) draws values between 0 and 1, which have a mean of 0.5. Adding that to a signal injects a DC offset — a spurious spike at zero frequency in the spectrum. We use rng.standard_normal instead, which is zero-mean by construction.

One definition, used everywhere. We define the signal-to-noise ratio (SNR) as the peak absolute amplitude of the signal divided by the standard deviation of the noise. This is the definition built into mlgeo_synth and used by the detector experiments of Chapter 4.3. Keeping a single definition matters: a claim like “the detector fails below SNR 1” is meaningless if two chapters measure SNR differently. In code, we normalize the signal to unit peak amplitude and the noise to unit standard deviation, so that s + noise / SNR has exactly the stated SNR.

<Figure size 640x480 with 1 Axes>

Check the Fourier amplitude spectrum of the noise against the signal spectrum.

<Figure size 640x480 with 1 Axes>

They look very different in the spectral domain. The noise spreads its energy over all frequencies; the signal concentrates its energy in a narrow band.

Now we add noise to the signal, scaled by a signal-to-noise ratio (SNR). We define SNR here as the ratio of the maximum absolute amplitude of the signal to that of the noise. First normalize both, then divide the noise by the SNR.

<Figure size 640x480 with 1 Axes>

3.3 Noise with a chosen color: randomizing the phase

Noise may have different frequency content, or color. A general recipe builds a noise time series from a chosen Fourier amplitude spectrum:

  1. Choose the amplitude at each non-negative frequency (flat for white noise, 1/f1/f decay for colored noise, or the spectrum of real data).

  2. Draw a random phase at each frequency, uniform between 0 and 2π2\pi.

  3. Invert with np.fft.irfft.

A real-valued time series requires a Hermitian-symmetric spectrum: the value at −f-f must be the complex conjugate of the value at +f+f. Hand-coding that symmetry is error prone. irfft takes only the non-negative frequencies and enforces the symmetry by construction, so we use it. The zero-frequency and Nyquist bins must be real, so we set their phases to zero.

<Figure size 640x480 with 1 Axes>

Add the new noise to the signal (Ricker wavelet), this time with a much lower SNR, and plot in the time and frequency domains.

<Figure size 1000x500 with 2 Axes>

Compare the data distributions of the pure signal, the noise, and their sum.

<Figure size 1000x500 with 2 Axes>

3.4 Statistical moments

Calculate the statistical moments of the clean signal and the noise. Which moments discriminate between signal and noise, and how sensitive are they to the noise level?

The first moment of the signal is: 0.0
The second moment of the signal is: 0.013293333067181288
The third moment of the signal is: 0.006430940666682904
The fourth moment of the signal is: 0.007489819567378665
The first moment of the noise is: 0.0
The second moment of the noise is: 1.0
The third moment of the noise is: 0.005114776505715537
The fourth moment of the noise is: 3.134334832790316

The first central moment is zero by definition. The second moment (variance) depends on the normalization, so it is a weak discriminant. The fourth moment is the interesting one: a time series that is mostly zeros with one short transient has heavy tails relative to a Gaussian, so its kurtosis is large. Kurtosis is a workhorse feature for detecting impulsive events in noise, and we will use it again in the feature engineering lesson (2.11).

4. Physics-informed synthetic noise from real data

White and colored noise are idealizations. Real seismic noise has structure: microseism peaks, cultural noise during the day, the instrument response. To make synthetic noise realistic, we can borrow the amplitude spectrum of real noise and randomize only the phase.

We use two hours of noise recorded at broadband station UW.RATT (Rattlesnake Lake, Washington, Pacific Northwest Seismic Network) from 04:15 to 06:15 UTC on 29 July 2021, just before the Mww 8.2 Chignik, Alaska, earthquake (Mww: moment magnitude from the W phase). It is the vertical channel HHZ at 100 samples per second, in raw digitizer counts, the same station and day as sections 2.8 and 2.9. The course copy in snapshots/ was downloaded from the EarthScope FDSN web services (FDSN: International Federation of Digital Seismograph Networks). The next cell recomputes each file’s fingerprint (SHA-256, Secure Hash Algorithm) and compares it with the provenance file; a file that is missing is downloaded from the book repository first. Section 5 also uses the following two hours, which contain the earthquake.

matches 725e3b798e3a260c... ratt_chignik_2021-07-29_UW.RATT.HHZ_0415-0615.mseed
matches 3714a18f90478fbb... ratt_chignik_2021-07-29_UW.RATT.HHZ_0615-0815.mseed
1 Trace(s) in Stream:
UW.RATT..HHZ | 2021-07-29T04:15:00.000000Z - 2021-07-29T06:14:59.990000Z | 100.0 Hz, 720000 samples

4.1 Spectrum-matched noise

We now generate synthetic noise whose amplitude spectrum matches the real RATT noise. The course package mlgeo_synth provides spectrum_matched_noise, which keeps the amplitude spectrum of a reference record and draws random phases. It uses rfft/irfft, so the Hermitian symmetry needed for a real-valued output is guaranteed by construction. Run help(mlgeo_synth.spectrum_matched_noise) to see the signature.

(720000,) (720000,)

Compare the two in the time domain and in the frequency domain. The time series should look different — the phases are different, so the waveforms line up nowhere. The amplitude spectra should overlap exactly, because the synthetic spectrum is a copy of the real one.

<Figure size 1000x600 with 2 Axes>
<Figure size 1000x500 with 1 Axes>

The two spectra lie on top of each other: the amplitude information is identical. The phase information is not. We can check that directly.

<Figure size 1000x400 with 2 Axes>

4.2 Augmenting an event with realistic noise at varying SNR

Now we combine the two ideas: a synthetic event (the Ricker wavelet) plus spectrum-matched realistic noise, at a range of SNR levels. This is a standard data augmentation strategy: one clean event template yields many training samples with controlled noise levels.

spectrum_matched_noise accepts an output length n, so we can draw a noise realization of the same length as the signal window.

<Figure size 1000x2000 with 10 Axes>

At low SNR the event disappears into the noise. Somewhere along this ladder, any detector — human or algorithmic — starts to fail. Finding that failure point is exactly what we do next, with the oldest detector in the seismological toolbox.

4.3 The course synthetic-data generator

The mlgeo_synth package used above is the course’s synthetic-data generator. Besides spectrum_matched_noise, it can generate full synthetic seismograms with a P wave, an S wave, a coda, and colored noise, plus labeled datasets for classification exercises. We will rely on it in later chapters when we need data with known ground truth.

<Figure size 1000x400 with 1 Axes>
{'t_p': 10.0, 't_s': 13.571428571428571, 'peak_amplitude': np.float64(0.48413257576129515), 'snr': 5.0}

4.4 Worked example: the STA/LTA detection floor

Before any neural network touches traces like these (Chapter 4.3 trains one), we owe them a classical baseline. The STA/LTA detector (short-term average over long-term average; Allen, 1978) slides two windows over the trace: a short window (here 1 s) tracks the instantaneous signal level, a long window (10 s) tracks the background, and their ratio spikes when a transient arrives. It has run in observatory triggering pipelines for decades, it has nothing to train, and any learned detector must beat it to justify its complexity.

A detector needs a threshold, and the threshold must come from noise alone. We generate 200 noise-only windows, record the peak STA/LTA of each, and set the threshold at the 99th percentile of that distribution: a 1% false-alarm rate by construction, before we ever look at a signal. Then we run the detector on s + noise / SNR across the SNR ladder np.logspace(-1, 2, 20), with 60 fresh noise realizations per SNR, and count the fraction of trials in which the peak STA/LTA crosses the threshold. Each point is 60 Bernoulli trials, so we attach a binomial (Wilson) interval to it.

noise-only peak STA/LTA: median 4.34, 99th percentile 6.09
SNR   0.10: detection probability 0.02
SNR   0.14: detection probability 0.02
SNR   0.21: detection probability 0.02
SNR   0.30: detection probability 0.02
SNR   0.43: detection probability 0.05
SNR   0.62: detection probability 0.00
SNR   0.89: detection probability 0.02
SNR   1.27: detection probability 0.03
SNR   1.83: detection probability 0.00
SNR   2.64: detection probability 0.07
SNR   3.79: detection probability 0.22
SNR   5.46: detection probability 0.62
SNR   7.85: detection probability 0.85
SNR  11.29: detection probability 0.98
SNR  16.24: detection probability 1.00
SNR  23.36: detection probability 1.00
SNR  33.60: detection probability 1.00
SNR  48.33: detection probability 1.00
SNR  69.52: detection probability 1.00
SNR 100.00: detection probability 1.00
detection probability crosses 50% near SNR 4.97
<Figure size 1100x400 with 2 Axes>

The left panel is the threshold logic: pure noise produces a distribution of peak STA/LTA values (median about 4.3 for this microseism-rich noise), and placing the threshold at its 99th percentile, 6.1, fixes the false-alarm rate at 1% before any signal enters the experiment. The right panel is the detection floor: the curve sits at the designed 1-2% false-alarm level up to SNR of about 2.6, climbs through its 50% crossing near SNR 5, and saturates at 1 above SNR of about 16 — a transition under a decade wide. The takeaway: with its false-alarm rate pinned at 1%, this classical detector needs a peak amplitude of roughly five noise standard deviations before it triggers reliably on this event. That number is the baseline any learned detector has to beat; in Chapter 4.3 we overlay this curve on the detection floor of a trained CNN, measured the same way.

5. Build a synthetic version of your own data

In-class team activity, about 25 minutes. Run the whole notebook first (Run All, about 10 seconds): section 5 uses rng, ricker, real_noise, fs_real and SNAP from sections 1 to 4.

What counts as noise depends on the question. The ocean microseism that section 4 treats as noise is the signal of ambient-noise imaging, which correlates it between stations to map the crust. Traffic is noise for an earthquake detector and a measure of human activity during the 2020 lockdowns (Lecocq and others, 2020, Science). Ocean tide loading is noise for a GNSS (Global Navigation Satellite System) station tracking plate motion. Water vapour delay is noise for InSAR (interferometric synthetic aperture radar) ground deformation and signal for a weather model. Starspots are noise for a planet hunter and signal for a stellar physicist. A wrong label in a catalog is noise in the class column. In each case the noise is a real contribution, physical or human, that overlaps the signal in time, frequency, space or class, so a filter cannot simply remove it.

A synthetic version of your data makes the separation explicit: you decide what is signal, you write down its parameters, and you measure how each kind of noise changes what you would conclude.

Recipe. Write each ingredient down before you code it.

  1. A signal of interest with known parameters, kept in a separate variable (truth): event times and amplitudes, a drydown time scale, a trend in °C per decade, a transit depth, the true class of each sample.

  2. Realistic noise: white (independent draws), colored (an autoregressive process, in which each value keeps a fraction of the previous one, or a power-law spectrum 1/fβ1/f^\beta), or spectrum-matched to a real record as in section 4.1.

  3. One nuisance signal from another real source that overlaps yours: a distant earthquake under a volcano record, soil temperature acting on a soil moisture probe, El Niño in a temperature field, starspots in a light curve, cultural noise in a catalog.

  4. One instrument problem from lecture 8: a gap, a step offset, a clock or time-convention error.

  5. The distribution of the noise values: Gaussian, or heavy-tailed (large values more frequent than a Gaussian allows).

Timing. 3 min: pick the template (sections 5.2 to 5.6) closest to your team’s data and read it. 10 min: change the noise color, level or distribution and run the measurement in its Your-turn cell. 7 min: compare with the truth and write one number per setting in your team notes. 5 min: the reflection in section 5.7.

5.1 Color and distribution are two different properties

A noise record has two independent properties. Its spectrum, or color, says how values are correlated in time or space. White noise has equal power at all frequencies. An autoregressive process of order 1, AR(1), xt=ϕxt−1+etx_t = \phi x_{t-1} + e_t with 0<ϕ<10 < \phi < 1, is flat (white) at long periods and falls off as about 1/f21/f^2 above a corner frequency near −ln⁡ϕ/(2π)-\ln\phi/(2\pi) (0.017 cycles per sample for ϕ=0.9\phi = 0.9); climate papers call it red noise. A power law P(f)∝1/fβP(f) \propto 1/f^\beta has no corner: β=1\beta = 1 is pink or flicker noise, common in GNSS position series and climate records, and β=2\beta = 2 is Brownian noise, a random walk (called red in physics).

Its distribution says how large single values can be. A Gaussian is what you get when many small independent contributions add up; its tails fall as e−x2/2e^{-x^2/2}. Real records often hold more large values: transients, glitches, passing trucks, gusts. A Student t distribution with 3 degrees of freedom has power-law tails: the chance of exceeding aa falls as a−3a^{-3}. Some geoscience quantities follow a power law above a lower cutoff, such as earthquake energies (the Gutenberg-Richter law), landslide areas and fault lengths.

The next cell defines one generator, make_noise, used by every template, and a plotting helper show. In make_noise, dist sets the distribution of the independent draws before coloring. Coloring filters the draws, and a filter output is a weighted sum of many draws, so a colored series is closer to Gaussian than its draws (central limit theorem). To keep heavy tails in colored noise, add the spikes after coloring. The cell after it compares four colors and four distributions, among them the real RATT noise in the 1 to 20 Hz band and its random-phase twin from section 4.1. Look for one thing: random phases copy the spectrum of a record but not the distribution of its values, which comes out Gaussian whatever the reference.

Gaussian: excess kurtosis 0.0
Student t, 3 degrees of freedom: excess kurtosis 18335.5
RATT noise, 1 to 20 Hz: excess kurtosis 3.7
RATT, random-phase twin: excess kurtosis 0.0
(Student t with 3 degrees of freedom has infinite kurtosis in theory, so its sample value jumps between draws.)
Gaussian: |value| > 5 standard deviations once in 1,744,278 samples
RATT 1 to 20 Hz: 1,030 of 648,000 samples beyond 5 standard deviations
<Figure size 1300x380 with 3 Axes>

On a log-log plot a power-law tail is a straight line and a Gaussian tail drops off a cliff. The real RATT noise in the 1 to 20 Hz band, where cultural and wind noise live, has more large values than a Gaussian; its random-phase twin does not. A detector tuned on the twin will see fewer false alarms than it meets on the real record. Section 5.2 measures that.

5.2 Template A: a volcano or local seismic record (1D, 100 samples per second)

  • Signal: four impulsive events, Ricker pulses peaking near 4.5 Hz, like small volcano-tectonic earthquakes. The truth is their centre times and peak amplitudes.

  • Noise: noise="ratt" is a random minute of the real RATT noise in the 1 to 20 Hz band with randomized phases (section 4.1); noise="real" is the real minute itself; noise="white", "ar1" or a number β\beta calls make_noise, with dist for the distribution. noise_level is the noise standard deviation in units of the largest event’s peak, the inverse of the SNR of section 3.2.

  • Nuisance: the P-wave coda of the Chignik earthquake at RATT, 06:21 to 06:22 UTC, in the same band. For a volcano observatory in Washington, a great earthquake in Alaska is noise.

  • Instrument problem: a 2 s telemetry gap filled with zeros (lecture 8).

<Figure size 1000x300 with 1 Axes>

Your turn (team A): detection rate against the known event times. The cell runs an STA/LTA detector (short 0.2 s, long 3 s, threshold 4) on synthetic records. Fill in detected: the fraction of true events whose STA/LTA reaches the threshold within 1 s of the event centre. The settings start without the Chignik coda and without the gap, and each setting is averaged over 10 synthetic minutes (seeds 0 to 9). Then change the list: noise color, level, distribution, noise="real", add the nuisance (nuisance_level=0.5) or the gap (gap=(30.0, 32.0)), and compare detection rates and false triggers per minute.

Hint: near[:, j] selects the samples within 1 s of event j; an event is detected if (cft[near[:, j]] >= thr).any(). Average that over the events. What to look for: does the real minute give more false triggers than its random-phase twin, and what does the zero-filled gap do to the STA/LTA ratio just after it ends? A worked solution follows the code cell (hidden; click ⋯ to open).

{'nuisance_level': 0.0, 'gap': None} -> detected: not answered yet | false triggers per minute: 0.5
{'noise': 'real', 'nuisance_level': 0.0, 'gap': None} -> detected: not answered yet | false triggers per minute: 1.1
{'noise': 'white', 'dist': 'student-t', 'nuisance_level': 0.0, 'gap': None} -> detected: not answered yet | false triggers per minute: 4.4
self-check, almost no noise: not answered yet
Notebook Cell
20 synthetic minutes per cell
                              detection rate             false triggers per minute            
noise level                             0.05  0.10  0.20                      0.05  0.10  0.20
noise                                                                                         
1 RATT spectrum, random phase           1.00  0.82  0.50                      0.35  0.35  0.35
2 real RATT minute                      1.00  0.89  0.45                      0.75  0.80  0.80
3 white, Student t                      0.99  0.85  0.57                      4.25  4.60  4.65
4 + Chignik P coda                      0.74  0.60  0.39                      5.20  1.90  0.20
5 + 2 s zero-filled gap                 1.00  0.82  0.50                      1.75  1.75  1.75

5.3 Template B: daily soil moisture (1D, one value per day)

  • Signal: a bucket. Each rainy day adds water in proportion to the rain; between rains the water above a residual content drains exponentially with a drydown time scale. The truth is that time scale (12 days), the residual and the gain. Rain falls more often in winter than in summer, as east of the Cascades, so the bucket makes its own seasonal cycle.

  • Noise: probe noise, white or AR(1), Gaussian or heavy-tailed.

  • Nuisance: dielectric probes read differently in warm and cold soil; temp_coef adds a soil-temperature term (m³/m³ per °C) that follows the seasons, as the water content does.

  • Instrument problem: days with frozen soil are left blank, as monitoring networks flag them, because the probe cannot measure liquid water in frozen soil.

<Figure size 1000x300 with 2 Axes>

Your turn (team B): the drydown time scale and its error. On a day without rain, the excess water above the residual shrinks by the factor e−1/τe^{-1/\tau}. Fill in tau_hat from the median of that ratio over all such pairs of days, then change settings: noise level, color="ar1", dist="student-t", temp_coef, and compare tau_hat with the truth, 12 days.

Hint: ratio = excess[1:][pairs] / excess[:-1][pairs], then tau_hat = -1 / np.log(np.median(ratio)). What to look for: which ingredient biases the estimate, and which only spreads it? A worked solution follows the code cell (hidden).

{'noise_sd': 0.0, 'temp_coef': 0.0} -> tau_hat: None days; truth: 12.0
{'noise_sd': 0.005} -> tau_hat: None days; truth: 12.0
{'noise_sd': 0.005, 'color': 'ar1'} -> tau_hat: None days; truth: 12.0
self-check, no noise and no temperature effect: not answered yet
Notebook Cell
mean tau_hat (days) over 20 synthetic records; truth 12 days
noise_sd                    0.000  0.002  0.005  0.010
noise            temp_coef                            
AR(1), phi = 0.9 0.000       12.0   12.0   12.0   11.9
                 0.001       12.6   12.6   12.7   12.6
white, Gaussian  0.000       12.0   11.8   10.9    8.9
                 0.001       12.6   12.3   11.4    9.1
white, Student t 0.000       12.0   11.9   11.5   10.3
                 0.001       12.6   12.5   12.1   10.8

5.4 Template C: a monthly gridded temperature field (2D in space, plus time)

  • Signal: 30 years of monthly surface temperature on a 5° by 7.5° grid from 60° S to 75° N: a warming trend that grows toward the poles (the truth is its map, in °C per decade) and a seasonal cycle that grows with latitude and has opposite sign in the two hemispheres.

  • Noise: weather anomalies, spatially correlated (white noise smoothed over corr_cells grid cells, as in section 2.2) and persistent from month to month (AR(1) with coefficient phi).

  • Nuisance: an El Niño-like pattern, warm in the eastern equatorial Pacific, driven by an irregular index with periods of 44 and 63 months (3.7 and 5.3 years).

  • Instrument problem: a step offset of step °C from January 2006 in one region (35° N to 70° N, 0° E to 40° E), as after a change of instruments or of station network; lecture 8 showed an antenna offset on Mount St. Helens.

<Figure size 1400x360 with 5 Axes>

Your turn (team C): the fitted trend and its error. fit_trends fits, at every grid cell at once, a constant, a trend and an annual sine and cosine by least squares, and returns the naive standard error of the trend, the one that assumes white noise. Fill in the least-squares solve, then change settings: phi (0 is white in time), corr_cells, enso, step, and compare the actual trend error, known because you know the truth, with the naive error bar.

Hint: m = np.linalg.lstsq(G, y, rcond=None)[0] solves for every column of y at once. What to look for: when phi grows, does the naive error bar keep up with the actual error? Where on the map does the step or the El Niño pattern bias the trend? A worked solution follows the code cell (hidden).

self-check, no noise: not answered yet
Notebook Cell
 phi  actual RMS error  mean naive error bar
0.00             0.043                 0.048
0.50             0.073                 0.048
0.80             0.123                 0.047
0.95             0.235                 0.043
<Figure size 600x340 with 2 Axes>

5.5 Template D: a planetary transit light curve (1D, 2-minute cadence)

  • Signal: box-shaped transits of a planet in front of its star. The truth is the period, the first mid-transit time, the duration and the depth (the fraction of starlight blocked, 1%).

  • Noise: photon noise, white by default; color and dist change it.

  • Nuisance: the star itself. Spots rotating with the star make a quasi-periodic modulation (6.3-day period here), and granulation, a red process with a time scale of about an hour (an AR(1) process here), adds short-term flicker; star_amp sets their size.

  • Instrument problem: the data downlink gap in the middle of one 27-day TESS (Transiting Exoplanet Survey Satellite) sector, when the spacecraft sends its data to Earth near the closest point of its 13.7-day orbit.

<Figure size 1000x300 with 1 Axes>

Your turn (team D): the transit depth. The cell removes the stellar variability with a running median over window_d days and folds the record at the known period. Fill in depth_hat: the median detrended flux just outside the transits minus the mean inside. Then change settings: star_amp, photon_sd, color of the photon noise, window_d, and compare depth_hat with the truth, 0.010.

Hint: np.nanmedian(detr[outside]) - np.nanmean(detr[inside]). What to look for: a window too short follows the transit and eats part of it; a window too long leaves the starspots in. A worked solution follows the code cell (hidden).

{'star_amp': 0.0} -> depth_hat: None ; truth: 0.01
{} -> depth_hat: None ; truth: 0.01
{'star_amp': 0.01} -> depth_hat: None ; truth: 0.01
{'color': 1.0} -> depth_hat: None ; truth: 0.01
self-check, no noise and a quiet star: not answered yet
Notebook Cell
mean depth_hat over 10 synthetic sectors; truth 0.010; columns: running-median window (days)
window_d    0.20    0.75    3.00
star_amp                        
0.000     0.0009  0.0100  0.0100
0.004     0.0013  0.0101  0.0101
0.010     0.0024  0.0102  0.0103
0.020     0.0036  0.0102  0.0106

5.6 Template E: categorical source labels in a local catalog

  • Signal: the true class of each of 900 events: earthquake, quarry blast or noise trigger. Two features describe each event: the log ratio of S-wave to P-wave amplitude (explosions make weaker S waves than earthquakes) and the local hour of the day, entered as cos⁡(2π(h−13)/24)\cos(2\pi(h - 13)/24) so that 23 h and 1 h are neighbours, a transform of the data.

  • Noise in the labels: a fraction flip of the labels is wrong. flip is the fraction of the whole catalog; structured flips are taken from the blasts only, so flip=0.15 relabels 135 of the 900 events, most of the blasts. Random flips (structured=False) pick any event and any other class; structured flips call quarry blasts earthquakes, a known contamination of seismicity catalogs (Wiemer and Baer, 2000, Bulletin of the Seismological Society of America).

  • Nuisance: noise triggers from traffic and other cultural sources cluster in the daytime, during the blasting hours.

  • Instrument problem: with mixed_clock=True, the second half of the catalog stores hours in UTC while the first half used Pacific Standard Time, an 8-hour shift: a time-convention error, like lecture 8’s clock errors.

<Figure size 700x400 with 1 Axes>

Your turn (team E): label agreement and two consequences. Fill in agreement in label_agreement: the fraction of observed labels equal to the true ones. The cell then measures two consequences. First, the day-to-night ratio of the events labelled earthquakes, per hour, between 8 and 18 h against the rest; true earthquakes come at any hour, so the truth is close to 1. Second, the accuracy of a nearest-class-mean rule (each event goes to the class whose mean features are closest), trained on the first half of the catalog with the observed labels and scored on the second half against the truth. Change settings: flip, structured, mixed_clock, and compare. A nearest-mean rule only uses class averages, so a clean subset of blasts still finds them; the logistic regression in the Session 9 slides learns where the classes overlap and is hurt by the same structured flips. Which behaves like your model?

Hint: np.mean(y_obs == y_true). What to look for: at the same fraction of wrong labels, which kind of error makes daytime “earthquakes” appear, and which kind hurts the trained rule? What does the 8-hour shift do? A worked solution follows the code cell (hidden).

{'flip': 0.0} -> label agreement: None | earthquakes day/night 1.01 (true labels, same clock 1.01) | nearest-mean accuracy 0.733
{'flip': 0.15} -> label agreement: None | earthquakes day/night 1.14 (true labels, same clock 1.01) | nearest-mean accuracy 0.640
{'flip': 0.15, 'structured': True} -> label agreement: None | earthquakes day/night 1.65 (true labels, same clock 1.01) | nearest-mean accuracy 0.738
{'flip': 0.0, 'mixed_clock': True} -> label agreement: None | earthquakes day/night 1.02 (true labels, same clock 1.02) | nearest-mean accuracy 0.431
self-check, flip = 0.1: not answered yet
Notebook Cell
means of 20 catalogs; columns: fraction of wrong labels
                       earthquakes day/night                   accuracy                  
flip                                    0.00  0.05  0.10  0.15     0.00  0.05  0.10  0.15
flips      mixed clock                                                                   
random     False                        1.03  1.08  1.13  1.18     0.75  0.73  0.70  0.68
           True                         1.05  1.05  1.07  1.06     0.42  0.42  0.43  0.43
structured False                        1.03  1.27  1.50  1.74     0.75  0.75  0.76  0.76
           True                         1.05  1.09  1.12  1.17     0.42  0.43  0.43  0.44

5.7 Reflection (5 minutes, in your team notes)

  1. Which parts of your real data are signal for someone else? Name the field or the person who would want what you remove.

  2. Which ingredient moved your measured number the most: the noise level, its color, its distribution, the nuisance, or the instrument problem? Give the numbers.

  3. What does your synthetic leave out? Name two properties of your real record it does not reproduce: noise that changes with season or time of day, transients that are not Gaussian, a nuisance correlated with the signal, labels that are wrong for a reason, a gap that falls when the signal is strongest.

  4. Would a model trained on your synthetic learn the real problem, or an easier one? Friday’s class turns these answers into a rubric for AI-ready data.

6. Exercises

Exercise 1: spectrum-matched noise from two different hours

The course copy holds two hours of noise. Split it into the first hour (04:15 to 05:15 UTC) and the second (05:15 to 06:15 UTC), generate spectrum-matched noise from each, and compare:

  1. Compare the variance and kurtosis of the two real hours and of their two synthetic versions.

  2. Overlay the four amplitude spectra. Do the microseism peaks move between the two hours?

  3. Comment: is one synthetic noise window enough to represent the noise at this station? What would a window from another day or season add? (Optional, needs internet: download 04:15 to 06:15 UTC on 28 July 2021 from the EarthScope FDSN web services, as in the commented lines of the scaffold, and repeat.)

Exercise 2: move the STA/LTA detection floor

The detection floor in Section 4.4 was measured with one specific window pair: 1 s short, 10 s long. Those lengths are the detector’s only tuning knobs, and observatories choose them to match the signals they hunt.

  1. Repeat the Section 4.4 sweep for three window pairs: (0.5 s, 5 s), (1 s, 10 s), and (2 s, 20 s). For each pair, recompute the threshold from noise-only windows first — the noise distribution changes with the windows — then measure the detection curve and its 50% crossing.

  2. Plot the three detection curves on one axis. Which window pair detects the Ricker event at the lowest SNR, and how does that relate to the event’s roughly 1 s duration?

  3. What goes wrong if you keep the 1 s / 10 s threshold while changing the windows?

7. When is synthetic data admissible?

Synthetic data is a tool, not a substitute for observation. Use this checklist before putting synthetic data into a project.

Admissible:

  • Method development. Prototyping a detector, a filter, or a model on data with known ground truth before touching real data.

  • Benchmarking. Measuring accuracy, recall, or failure points (as in Exercise 2) requires knowing the true answer. Synthetic data provides it.

  • Augmentation with disclosed provenance. Adding noise realizations or synthetic events to a training set is standard practice, as long as the paper or report states which samples are synthetic and how they were generated.

  • Hidden test sets. Instructors and benchmark maintainers use synthetic data to build test sets that models cannot have memorized.

Not admissible:

  • Substituting for real validation in scientific claims. A model validated only on synthetic data has not been validated. A scientific conclusion about the Earth must rest on real observations.

Always disclose. Whenever synthetic data enters an analysis, say so: which samples, which generator, which seed. The generator code and seeds belong in the repository with the rest of the project. In this course, use the mlgeo_synth package as the generator so that provenance is one import away, and follow the project guidance in the MLGeo project instructions.