Radio Sky Journal
The 1665 MHz OH maser profile of W3(OH), averaged over 506 seconds of Allen Telescope Array data

W3(OH) at 1665 MHz, from entry 1

Hydroxyl (OH) maser W3(OH) from public Allen Telescope Array IQ data

This project processes a public raw-IQ recording of the 1665 MHz hydroxyl (OH) line toward the star-forming region W3(OH). One script, oh_spectrum.py, takes the raw samples all the way to physical results:

A second script, make_synthetic_test.py, generates a synthetic recording with known properties to validate the pipeline.

Dataset: Daniel Estévez, IQ recording of W3OH hydroxyl spectral line at 1665.4 MHz, Zenodo record 6711078, published 25 June 2022 (v1, open): https://zenodo.org/records/6711078

Official Github Repository: https://github.com/gracebrazil28/OH-Spectral-Line-Analysis


Contents

  1. The dataset
  2. Project layout
  3. Setup
  4. Commands at a glance
  5. Running the analysis
  6. What the outputs show
  7. Validation on synthetic data
  8. Results
  9. Caveats and limitations
  10. Possible next steps
  11. Change log

1. The dataset


2. Project layout

OH Spectral Line Analysis/
├── iq_data/
│   ├── W3OH_1665MHz_2022-06-21T19_36_55_pol_x.sigmf-data
│   ├── W3OH_1665MHz_2022-06-21T19_36_55_pol_x.sigmf-meta
│   ├── W3OH_1665MHz_2022-06-21T19_36_55_pol_y.sigmf-data
│   └── W3OH_1665MHz_2022-06-21T19_36_55_pol_y.sigmf-meta
├── validation/
│   ├── make_synthetic_test.py
│   └── synth/                  (created by make_synthetic_test.py: PX/PY SigMF pairs, ~230 MB each)
├── oh_spectrum.py
├── README.md
└── (outputs: *.png, *.csv)

3. Setup

Libraries

Library Used for Needed by
Python 3.8+   everything
numpy array math, FFTs everything
scipy running-median baseline (ndimage), Gaussian fitting (optimize), synthetic signal filters (signal) everything; scipy.signal only by make_synthetic_test.py
matplotlib plots spectrum, stokes, fit
astropy LSR velocity correction, Galactic coordinates optional: without it velocities stay topocentric and fit skips the kinematic plot

A dedicated environment avoids version conflicts with other packages:

conda create -n radio -c conda-forge python=3.12 numpy scipy matplotlib astropy inspectrum
conda activate radio

In VS Code, press Ctrl+Shift+P, choose Python: Select Interpreter, pick radio, then open a new terminal. Run conda activate radio before each session.

Troubleshooting

Optional viewers


4. Commands at a glance

Command Input What it does Outputs
info one .sigmf-meta prints sample rate, center frequency, start time, duration and the full metadata console only
spectrum one or more .sigmf-meta (one per polarization) averaged spectrum, baseline removal, LSR velocity, per-row normalized waterfall, row-gain plot <prefix>.png, <prefix>.csv
stokes X then Y .sigmf-meta cross-correlates X and Y; Stokes I, Q, U, V; per-feature polarization fractions and X–Y phase <prefix>.png, <prefix>.csv
fit a CSV written by spectrum Gaussian components (number chosen by BIC), noise vs radiometer equation, thermal widths, kinematic distance <prefix>.png, <prefix>_kinematic.png, <prefix>.csv
wav one .sigmf-meta converts to a WAV file SDR# can play SDRSharp_..._IQ.wav

Run any command with -h for every option, for example python oh_spectrum.py fit -h.


5. Running the analysis

Run these from the OH Spectral Line Analysis folder. Each command is a single line.

Step 1: check the metadata

python oh_spectrum.py info iq_data\W3OH_1665MHz_2022-06-21T19_36_55_pol_x.sigmf-meta

Step 2: averaged spectrum and waterfall, both polarizations (xy_rows)

python oh_spectrum.py spectrum iq_data\W3OH_1665MHz_2022-06-21T19_36_55_pol_x.sigmf-meta iq_data\W3OH_1665MHz_2022-06-21T19_36_55_pol_y.sigmf-meta --vmin -50 --vmax -40 --out xy_rows

About 4 minutes for both files (each file is read separately). Add --seconds 60 for a quick test on the first minute.

Step 3: polarization (w3oh_stokes)

python oh_spectrum.py stokes iq_data\W3OH_1665MHz_2022-06-21T19_36_55_pol_x.sigmf-meta iq_data\W3OH_1665MHz_2022-06-21T19_36_55_pol_y.sigmf-meta --out w3oh_stokes

X must come first, then Y. About 4–5 minutes, because both files are read in lockstep.

Step 4: components, noise check and kinematic distance (xy_rows_fit)

python oh_spectrum.py fit xy_rows.csv --integration 506.2

Needs the CSV from step 2: a two-file spectrum run with the LSR correction applied. Takes seconds.

Step 5 (optional): WAV for SDR#

python oh_spectrum.py wav iq_data\W3OH_1665MHz_2022-06-21T19_36_55_pol_x.sigmf-meta

In SDR#, choose Source → IQ File (*.wav). If the spectrum looks mirrored, add --swap-iq.

Main options

Shared by spectrum and stokes

Option Default Meaning
--nfft 16384 FFT size. Resolution = 1.92 MHz / nfft (16384 → 117 Hz, 4096 → 469 Hz)
--seconds, --skip all, 0 process only part of the recording
--vmin, --vmax −100, +10 (spectrum); −50, −40 (stokes) velocity window in km/s. Must match the velocity frame: LSR if astropy is installed, topocentric if not
--baseline-khz 300 running-median width for the bandpass. Must be much wider than the line
--edge, --dc-mask 0.06, 1500 Hz band-edge fraction and DC-spike half-width to exclude
--rest 1665.4018e6 rest frequency (Hz). Use 1420.405751768e6 for hydrogen
--ra, --dec, --site W3(OH), ATA target and observatory
--start, --center, --rate from metadata overrides
--no-lsr off keep velocities topocentric
--out, --no-show   output prefix; save without opening a window

spectrum only

Option Default Meaning
--dump 10 seconds per waterfall row
--row-norm scale scale: each row rescaled to its own gain (removes gain jumps). median: each row divided by its own running median (also follows bandpass-shape changes; slower). none: single time-averaged baseline (original behaviour)

stokes only

Option Default Meaning
--features automatic feature velocities to measure; otherwise peaks above --min-snr
--min-snr 6 automatic peak threshold (σ, after 5-channel smoothing)
--halfwidth 0.15 half-width of each feature’s window (km/s)
--xy-phase none instrumental phase the receiver adds to XY*, in degrees; it is subtracted so U and V can be separated. Unknown for this dataset

fit

Option Default Meaning
--column mean_line profile to fit; e.g. a single polarization’s ..._line column
--vmin, --vmax −48, −42.5 fit window (km/s)
--guess −46.2 −45.2 −44.9 −44.1 starting component velocities
--max-extra 1 extra components tried at the largest residual, kept only if the BIC improves
--center-range 0.4 how far a component may move from its guess (km/s)
--min-fwhm, --max-fwhm 0.07, 2.5 allowed widths (km/s); components at a limit are flagged
--noise −60 −50 −40 −30 line-free velocity ranges, as pairs
--integration none integration time (s), for the radiometer comparison
--mass-amu, --tkin 17; 50 100 150 molecule mass and temperatures for the thermal-width comparison
--r0, --theta0 8.15, 236 rotation curve (Reid et al. 2019)
--parallax 1.95 distance to compare (Xu et al. 2006); 0 to omit
--kin-velocity strongest component velocity used for the kinematic distance
--no-kinematic off skip the kinematic plot

6. What the outputs show

spectrum (e.g. xy_rows.png)

  1. Raw averaged spectrum (dB vs frequency offset): the receiver bandpass, the DC spike at the center and the maser bump at about +335 kHz. Dashed lines are the estimated baselines.
  2. Baseline-removed line profile vs LSR velocity, for each polarization and their mean, as (S − baseline) / baseline, the line power as a fraction of the system noise.
  3. Dynamic spectrum: mean of the polarizations, with each row normalized by its own gain.
  4. Row gain vs time for each polarization: the broadband gain changes that step 3 removes.

The CSV holds frequency, velocity, raw power and line profile per file, plus the mean. The console reports the LSR correction, the strongest feature and the range of row gains.

Why panel 1 is transformed into panel 2

The power measured in each frequency bin is approximately:

measured(f) = gain(f) × [system noise + line(f)]

The receiver gain varies across the band and is not known, and the line is a few percent of the system noise. A running median (300 kHz wide) ignores narrow features and estimates baseline(f) ≈ gain(f) × system noise. Dividing out the baseline cancels the gain:

measured / baseline − 1 = line(f) / system noise

The frequency axis is then converted to velocity using the radio Doppler convention, v = c (f₀ − f) / f₀, and corrected to the local standard of rest (LSRK). The correction adds Earth’s rotation and orbit (the barycentric correction, from astropy) and the Sun’s standard 20 km/s motion. It was cross-checked against astropy’s independent SpectralCoord method and agreed to within 0.003 km/s.

Per-row normalization (panels 3 and 4)

Each 10 s row is divided by the time-averaged bandpass, then rescaled by that row’s own gain: the median ratio of row to bandpass over all usable channels. The median ignores the few channels with maser emission, so a broadband gain jump is removed while the line is kept. A short final row (fewer than half the usual FFTs) is dropped, because the median of only a few averaged spectra is biased low.

stokes (e.g. w3oh_stokes.png)

For linear feeds X and Y:

I = XX + YY        Q = XX − YY        U = 2 Re(XY*)        V = 2 Im(XY*)

Each auto-power is divided by its own bandpass, and the cross-power has its own baseline (correlated receiver noise) subtracted and is divided by √(Bx·By). Every Stokes parameter is therefore a fraction of one channel’s system noise.

  1. I and Q. Q shows linear polarization along X (+) or Y (−).
  2. The cross-correlation. U' and V' are its real and imaginary parts. Without an X–Y phase calibration they are mixtures of U and V. Their magnitude, √(U² + V²) = 2|XY*|, does not depend on the phase.
  3. The X–Y phase of each channel with significant cross-power, plus each feature’s summed value (black).

The console table gives, per feature:

Column Meaning
q = Q/I X vs Y difference. Non-zero at > 3σ means linear polarization along a feed (assumes equal system temperatures in X and Y)
sqrt(U2+V2)/I fraction of power correlated between the feeds: linear at ±45° and/or circular. Independent of the unknown X–Y phase. Noise-bias corrected
X-Y phase includes an unknown instrumental offset, so only differences between features mean anything. Features about 180° apart have opposite-sign polarization; for purely circular lines that means opposite hands, the signature of a Zeeman pair

Uncertainties are measured empirically from line-free channels, so they include the correlation between neighbouring channels, and they include the noise in I.

fit (e.g. xy_rows_fit.png, xy_rows_fit_kinematic.png)


7. Validation on synthetic data

make_synthetic_test.py builds a 30 s two-polarization SigMF recording in the same format as the ATA data, with known properties. The random seed is fixed, so every run produces byte-identical files (about 230 MB each). The properties are listed at the top of the script and in the .sigmf-meta annotations, which inspectrum displays.

Property Injected Recovered
Y/X power ratio 2.92 dB removed by normalization
X gain jump (10–15 s) +3% amplitude (+6.09% power) +6.06%
Y gain variation none −0.10% to +0.14%
Instrumental X–Y phase −40° on XY* phases offset by −36° to −42°
Line A (−42.88 km/s) linear along X q = +0.972 ± 0.050
Line E (−43.78 km/s) linear at 45° √(U²+V²)/I = 0.974 ± 0.053, phase −36° (expected −40°)
Line B (−44.68 km/s) circular √(U²+V²)/I = 1.129 ± 0.062, phase −132° (expected −130°)
Line C (−45.58 km/s) circular, opposite hand √(U²+V²)/I = 0.976 ± 0.051, phase +49° (expected +50°); 181° from B
Line D (−46.48 km/s) unpolarized q = +0.004 ± 0.016, √(U²+V²)/I = 0.021 ± 0.020
Correlated X–Y noise none 0.0001 of system power

Every measured value agrees with its injected value to within about 2σ.

To reproduce, from the validation folder:

python make_synthetic_test.py --out-dir synth
python ..\oh_spectrum.py spectrum synth/PX.sigmf-meta synth/PY.sigmf-meta --no-lsr --vmin -48 --vmax -41 --dump 2
python ..\oh_spectrum.py stokes synth/PX.sigmf-meta synth/PY.sigmf-meta --no-lsr --vmin -48 --vmax -41

Adding --xy-phase -40 to the stokes command removes the injected phase offset. U and V are then separated: line E appears in U, and lines B and C appear in V with opposite signs.


8. Results

LSR correction at mid-recording (2022-06-21 19:41 UTC): +14.94 km/s. Topocentric velocity + 14.94 = LSR velocity.

Detection and noise

Instrumental gain variations

Line components (fit, X+Y average)

Five components fit to within the noise: reduced χ² 0.98. The BIC prefers five components over four (325.3 against 331.2).

v (km/s) Peak FWHM (km/s) Area (km/s) Note
−46.220 ± 0.008 0.0209 ± 0.0011 0.313 ± 0.022 0.00696 narrow
−45.300 ± 0.082 0.0080 ± 0.0013 1.672 ± 0.220 0.01428 broad wing, 32% of the total area
−45.197 ± 0.006 0.0376 ± 0.0014 0.481 ± 0.020 0.01925 main component
−44.130 ± 0.021 0.0079 ± 0.0011 0.345 ± 0.060 0.00289 weak
−42.681 ± 0.018 0.0056 ± 0.0015 0.145 ± 0.043 0.00087 tentative (~3.7σ)

Polarization (stokes)

Two features detected above 6σ:

v (km/s) I S/N q = Q/I √(U²+V²)/I X–Y phase
−46.18 19 +0.062 ± 0.049 1.150 ± 0.082 −172° ± 3°
−45.19 39 −0.184 ± 0.024 0.196 ± 0.027 −75° ± 8°

Kinematic distance (fit)


9. Caveats and limitations


10. Possible next steps


11. Change log

November 16–17, 2026

November 13, 2026


References