SEG‑D Monitor Download

Lessons › Lesson 3

How often we listen: the sample rate

A recorder does not hear the sea all the time. It measures the pressure at regular moments and keeps one number each time. How far apart those moments are decides what a record can hold, what it can get wrong, and how every time in it is counted. This lesson is about that one number.

  • about 30 minutes
  • three live demos
  • a 10-question quiz at the end

1What a sample is

A hydrophone turns pressure into a voltage that changes all the time. A recording system cannot store a curve - it stores numbers. At regular moments it measures the voltage and writes down one number: a sample. Whatever happens between two samples is not stored at all.

A continuous pressure wave, and the samples a recorder keeps of it: one number at every sample interval. Drawn the SEG way: a rise in pressure goes down. Δt - one sample interval pressure - drawn the SEG way: a rise goes down time → the wave in the sea (the thin line) the samples the recorder keeps (the dots)
The recorder keeps only the dots. The thin line is not in the file: a program that draws a trace joins the dots.

One thing has two names, and both are used:

  • The sample interval, written Δt: the time from one sample to the next, in milliseconds. In the field people say "we record at 2 ms" - that is the interval.
  • The sample rate: how many samples a second, in hertz. It is one divided by the interval: 1 ÷ 0.002 s = 500 samples a second.
Sample interval4 ms2 ms1 ms0.5 ms0.1 ms
Samples a second2505001,0002,00010,000

The idea to keepA record is a list of numbers, one every sample interval. The interval is what turns "sample number 500" into a time. Read it wrongly and every time - and every frequency - in the record is read wrongly with it.

2Two samples a cycle: Nyquist

How often is often enough? A wave goes up and down once in each cycle. To be told apart from a slower wave it has to be caught more than twice in every cycle - on the way up and on the way down. So the highest frequency a record can hold is half its sample rate. That frequency is the Nyquist frequency, fN:

fN = 1 ÷ (2 × Δt)   ·   at 2 ms: 1 ÷ 0.004 s = 250 Hz

The sampling theorem asks for strictly more than two samples a cycle. At exactly two, the samples can fall on the wave's zero crossings and see nothing at all.

Aliasing: a wave in disguise

A frequency above the Nyquist frequency does not simply go missing. Its samples are exactly the samples of a slower wave, and nothing in the record can tell the two apart. This is aliasing: the fast wave turns up in disguise, at a frequency it never had. Film does the same thing to wheels - a fast wheel can seem to turn slowly, stand still, or even turn backwards.

A fast wave of seven cycles sampled nine times; the same nine samples also fit a slow wave of one cycle, drawn dashed. the wave in the sea: 7 cycles (thin line) what the 9 samples say: 1 cycle (dashed)
The same nine samples fit the fast wave and a slow one. The record keeps only the samples - and the slow wave is all anyone reading it will ever see.

The sampling demo needs JavaScript; the drawing above shows what it shows.

For the curious: where an alias lands

Frequencies fold back around the Nyquist frequency like a paper fan. To find where one lands, subtract the nearest whole multiple of the sample rate fs and drop the sign:

falias = | f − k × fs |   (k: the whole number that makes it smallest)

At 2 ms, fs = 500 Hz and fN = 250 Hz. A 300 Hz wave lands at |300 − 500| = 200 Hz; 600 Hz at |600 − 500| = 100 Hz; 1,000 Hz at |1000 − 2 × 500| = 0 Hz - its samples are all the same number, and it looks like no wave at all.

The idea to keepAbove the Nyquist frequency nothing is lost quietly: it comes back as something false, and once recorded it cannot be taken out.

3The anti-alias filter

An alias cannot be removed after it is recorded, so recording systems remove its cause first. Before the signal is sampled, while it is still continuous, an anti-alias filter - a high-cut filter - takes out what lies above the Nyquist frequency.

No filter cuts like a knife: it needs room to go from passing everything to passing nothing. So it starts below the Nyquist frequency. Sercel's specification for its Seal 428 marine system, for example, gives the high-cut filter as 0.8 FN - 0.8 of the Nyquist frequency - with more than 120 dB of attenuation above Nyquist. On a 2 ms record that is full strength up to 200 Hz, and next to nothing past 250 Hz.

SEG‑D writes the filter down with the data: every channel set descriptor carries an alias filter frequency (0 to 9999 Hz) and its slope in dB per octave.

Making the interval longer: resampling

Data is often resampled to a longer interval - a 0.1 ms signature compared with a model drawn at 2 ms, for one. Keeping every 20th sample is not enough. Everything between the new Nyquist frequency (250 Hz) and the old one (5,000 Hz) would fold down into the band and sit there as false signal. Filter first, below the new Nyquist frequency; then keep every 20th sample.

The idea to keepFilter before you sample, and filter again before you resample.

4What the interval decides

Sample interval4 ms2 ms1 ms0.5 ms0.1 ms
Nyquist frequency125 Hz250 Hz500 Hz1,000 Hz5,000 Hz
A time read to the nearest sample± 2 ms± 1 ms± 0.5 ms± 0.25 ms± 0.05 ms
One channel, one minute, 4-byte samples60 kB120 kB240 kB480 kB2.4 MB
  • The highest frequency in the record - the Nyquist frequency, less the room the anti-alias filter needs.
  • How precisely a time is known. Read straight off the samples, a time is known to the nearest sample - half an interval either way. That is why gun controllers sample finely: Seamap's GunLink 4000 samples its near-field hydrophones every 0.1 ms.
  • Whether the ghost notch can be seen. Lesson 1 put the ghost notch of a gun at 6 m at c ÷ (2 × z) = 1500 ÷ 12 = 125 Hz. A 4 ms record's Nyquist frequency is exactly 125 Hz - the notch is at the very edge of what it can hold, and its anti-alias filter has already taken the band away.
  • Not how finely a spectrum is resolved. That is the record's length: a spectrum's lines are 1 ÷ T apart, so a 0.5 s record gives a line every 2 Hz whether it was sampled at 2 ms or at 0.1 ms. A shorter interval reaches higher frequencies; a longer record separates close ones.
  • The size of the data. Halve the interval and the data doubles.

The idea to keepChoose the interval for the highest frequency you need, with room for the filter - and pay for it in data.

5How SEG‑D writes the interval

In SEG‑D revision 1 - the revision of Lesson 2 - the interval is written in two steps:

  1. General Header Block #1, byte 23: the base scan interval. In the standard's words, it is "coded as a binary number with the LSB equal to 1/16 msec", and "the allowable base scan intervals are 1/16, 1/8, 1/4, 1/2, 1, 2, 4, and 8 msec".
  2. Each channel set descriptor, byte 12: the subscans. A number S/C, an exponent of 2: the set is sampled 2S/C times in each base scan - 1, 2, 4 … up to 512 times. The set's interval is the base scan interval divided by that.
Interval1/16 ms1/8 ms1/4 ms1/2 ms1 ms2 ms4 ms8 ms0.1 ms
Byte 23, counting sixteenths of a ms12481632641281.6 ?
In binary0000 00010000 00100000 01000000 10000001 00000010 00000100 00001000 0000no code

Every interval revision 1 can write is a power of two: halves, quarters, eighths, sixteenths of a millisecond - and dividing by subscans only halves it further. 0.1 ms is 1.6 sixteenths. It has no code at all.

The channel set descriptor also gives the set's start and end time, in 2 ms steps. From those and the interval a reader works out how many samples each trace has: (end − start) ÷ interval. Revision 1 can also write the count itself, in a trace header extension ("Number of Samples per Trace", bytes 8-10) - but a record whose traces carry no extension leaves the reader to work it out.

SEG‑Y does it differently. Its binary file header (bytes 3217-3218) and every trace header (bytes 117-118) hold the sample interval in microseconds. In SEG‑Y, 0.1 ms is simply 100.

The idea to keepKnow what a format can write before you trust what it says. SEG‑D revision 1 writes powers of two of a millisecond, and nothing in between.

7Sample 0 or sample 1?

Time zero is the moment of the shot. In SEG‑D a channel set's start time "identifies the timing word of the first scan of data in this channel set" - and in a single record it is "typically recorded as a zero". So the first sample is at 0 ms, the next one interval later, and so on.

But what number does the first sample have? Two habits exist:

  • Counting from 0. The first sample is sample 0, and sample k is at k × Δt. A sample's number is then the number of intervals since time zero - which is why seismic work usually counts this way. C and Python count from 0 too: in Python's own words, "the first character having index 0".
  • Counting from 1. The first sample is sample 1, and sample n is at (n − 1) × Δt. Fortran counts this way, and so does MATLAB ("MATLAB uses 1-based indexing") - and so do many programs' sample counters, because people count from one.

Neither habit is wrong. Mixing them is: the same number then means two times, one interval apart.

counted from 0: t = k × Δt   ·   counted from 1: t = (n − 1) × Δt

At 0.5 ms, a gun aimed at 50 ms fires on sample 100 counted from 0 - and on sample 101 counted from 1. Read a program's "sample 100" the wrong way, and a gun that fired on time looks 0.5 ms early. SEG‑D Monitor, for one, flags a gun that fires more than half a sample interval from its aim point: an error of one whole sample, made by counting, fails a good gun.

SEG‑Y adds one more thing to check: the delay recording time (trace header bytes 109-110), the "time in ms between initiation time of energy source and time when recording of data samples begins". When it is not zero, the first sample is not at time zero.

The counting demo needs JavaScript; the two formulas above are all it does.

For the curious: why programmers count from zero

In 1982 the computer scientist Edsger Dijkstra wrote a short note, "Why numbering should start at zero". Counting from 0, he argued, a subscript equals the number of elements before it. For samples that is exactly the time: sample k has k samples before it, so it is k intervals after the first.

The idea to keepBefore you read a time off a sample number, ask two questions: does it count from 0 or from 1 - and when is the first sample?

8Interesting facts

Kotelnikov's theorem

In Russian literature the sampling theorem bears another name: Vladimir Kotelnikov found it independently in 1933.

Wikipedia: Nyquist-Shannon sampling theorem

Many fathers

Whittaker wrote about it in 1915 and Nyquist in 1928. Shannon's papers of 1948 and 1949 made it widely known - though he never claimed to have originated it.

Wikipedia: Nyquist-Shannon sampling theorem

The wheel that turns backwards

In films a spoked wheel can seem to turn slowly, stand still or go backwards. In recorded media that is aliasing in time - the camera samples the wheel.

Wikipedia: Wagon-wheel effect

Why a CD runs at 44.1 kHz

To reproduce the audible range of 20 to 20,000 Hz. Half of 44,100 is 22,050 Hz, which leaves a 2.05 kHz band for the anti-alias filter to do its work.

Wikipedia: 44,100 Hz

Eight intervals

SEG‑D revision 1's base scan interval can be only 1/16, 1/8, 1/4, 1/2, 1, 2, 4 or 8 ms - powers of two, nothing in between.

SEG‑D revision 1

Zero, the most natural number

Dijkstra's 1982 note ends by arguing that zero deserves to be treated as the most natural number to start counting from.

E. W. Dijkstra, EWD831

9Quiz: what stayed?

Ten questions. Pick an answer and it is marked at once, with a line on why. Nothing you answer leaves this page.

  1. 1. A recorder samples every 2 ms. How many samples does it keep each second?
    Answer

    500. 1 ÷ 0.002 s = 500. The interval (2 ms) and the rate (500 a second) are two ways of saying one thing.

  2. 2. What is the Nyquist frequency of a record sampled every 0.5 ms?
    Answer

    1,000 Hz. 1 ÷ (2 × 0.0005 s) = 1,000 Hz - half of the 2,000 samples a second.

  3. 3. A 300 Hz wave is sampled every 2 ms, with no filter. What do the samples show?
    Answer

    A 200 Hz wave. The sample rate is 500 Hz and the Nyquist frequency 250 Hz; 300 Hz folds back to |300 − 500| = 200 Hz - a false frequency that nothing in the record can tell from a real one.

  4. 4. Why does a recorder filter the signal before it samples it?
    Answer

    To stop aliasing. An alias cannot be taken out once it is recorded, so the anti-alias filter removes what is above the Nyquist frequency while the signal is still continuous.

  5. 5. You resample a 0.1 ms signature to 2 ms. What must come first?
    Answer

    A filter below the new Nyquist frequency. Without it, everything between 250 Hz and 5,000 Hz would fold down into the band. Filter first, then keep every 20th sample.

  6. 6. What decides how far apart the lines of a spectrum are?
    Answer

    The record's length. A 0.5 s record gives a line every 2 Hz, whatever its interval. The interval decides how high the spectrum reaches, not how finely it is resolved.

  7. 7. Which sample interval can SEG‑D revision 1's base scan interval NOT express?
    Answer

    0.1 ms. Byte 23 counts sixteenths of a millisecond in binary steps - 1/16, 1/8, 1/4 … 8 ms. 0.1 ms would be 1.6 sixteenths, and there is no such code.

  8. 8. A record sampled every 0.1 ms is read as if its interval were 1/8 ms. Its bubble pulse really comes 100 ms after the primary. Where does the reader show it?
    Answer

    At 125 ms. Each sample is placed 1/8 ms after the last instead of 0.1 ms: every time comes out 1.25 times too late, and every frequency at 0.8 of the truth.

  9. 9. Where should the true sample interval of a GunLink channel set come from?
    Answer

    The recording system's setup. The header can only write the nearest interval revision 1 allows; the file size fixes how many samples there are, not how far apart they are.

  10. 10. Sampled every 0.5 ms and counted from 0, sample 100 is at 50 ms. Counted from 1, at what time is sample 100?
    Answer

    49.5 ms. (100 − 1) × 0.5 = 49.5 ms - one interval earlier. The same number, two times.

10Sources and further reading

Every fact in this lesson comes from one of these - except what GunLink's records carry in their headers, which is what SEG‑D Monitor finds when it reads them; the arithmetic is the standard's. The drawings and the demos' data are the site's own.

  1. SEG Field Tape Standards Subcommittee (1994). Digital field tape standards - SEG‑D, revision 1 (special report). Geophysics 59, 668-684 - the base scan interval (General Header Block #1, byte 23), the subscans (channel set descriptor, byte 12), the channel set start and end times, the alias filter fields and the number of samples per trace.
  2. Pavlukhin, S. (2019). SegDSee manual - a free viewer for SEG‑D revisions 0 to 3.1 and SEG‑B.
  3. MIND Technology: Seamap GunLink 4000 data sheet - near-field hydrophones sampled every 0.1 ms.
  4. Sercel: Seal 428 specifications - sample rates, the high-cut filter at 0.8 FN and the stop-band attenuation above Nyquist.
  5. U.S. Geological Survey, Data Series 95: SEG‑Y format - the sample interval in microseconds, the number of samples and the delay recording time.
  6. Wikipedia: Nyquist-Shannon sampling theorem - the theorem, the strict inequality and its history.
  7. Wikipedia: Wagon-wheel effect.
  8. Wikipedia: 44,100 Hz.
  9. Dijkstra, E. W. (1982). Why numbering should start at zero (EWD831).
  10. Wikipedia: Zero-based numbering - C counting from 0, Fortran from 1.
  11. Python Software Foundation: An informal introduction to Python - indexing from 0.
  12. MathWorks: Matrix indexing in MATLAB - indexing from 1.