frinZ
Rust version of frinZ.py - A high-performance fringe-fitting tool for VLBI data analysis.
Original Python version: https://github.com/M-AKIMOTOO/frinZ.py
Overview
frinZ is a Rust implementation of the frinZ fringe-fitting tool for processing Very Long Baseline Interferometry (VLBI) correlation data. It provides accurate delay and rate measurements with enhanced performance compared to the original Python version.
Features
- Fringe fitting analysis for VLBI correlation data (.cor files)
- Phase reference calibration with polynomial fitting
- Precise search mode with iterative refinement
- RFI mitigation with frequency range exclusion
- Bandpass calibration with binary file support
- Visualization with delay/rate plots and cumulative SNR plots
- Multiple output formats (text, binary, plots)
- Cross-power spectrum analysis
- Pulsar gating analysis with dedispersion, folding, and gating reports
Installation
From Source
# Clone the repository
# Install to ~/.cargo/bin
Development Build
# Check only the publishable frinZ crate
# Build the frinZ binary
# Build everything in this repository
Local Tools In This Workspace
This repository is split into:
frinZ: publishable crate and main binaryfrinZ-tools: local-only package forgfrinZ,pulsar_gating,cormerge,corshow, andbandscythe
# Check all local tools
# Build all local tools
# Build each tool separately
Run examples:
Note: crates.io publish target is frinZ only. On Windows, antivirus software may flag the compiled binary.
Usage
Basic Syntax
Input Options
Single File Analysis
# Basic fringe fitting
# With integration time and loop count
# Skip first 10 seconds
Phase Reference Analysis
# Basic phase referencing (calibrator, target)
# With fit_spec and custom integration times
# Arguments: calibrator target fit_spec cal_length target_length loop
# fit_spec: <deg>, sin, <deg>+sin, <deg>+sin:<period_sec>
# With polynomial degree and custom integration times
# Arguments: calibrator target fit_degree cal_length target_length loop
Analysis Options
Frequency Domain Analysis
# Cross-power spectrum instead of fringe
Precise Search Mode
# Enable iterative search with custom iterations
# With search windows
Manual Corrections
# Apply delay and rate corrections
RFI Mitigation
# Exclude frequency ranges (MHz)
Bandpass Calibration
# Generate bandpass table
# Apply existing bandpass calibration
Output Options
Text Output
# Save analysis results to text files
# Show header information
Plotting
# Generate fringe plots
# Time series plots
# Cumulative SNR plots
Advanced Examples
Complete Analysis with All Options
Phase Reference with Custom Parameters
Pulsar Gating Analysis
# Known pulsar mode (period is given)
# Unknown pulsar mode (period/DM estimated from data)
Build or run pulsar_gating from the local-only tools package:
# or
pulsar_gating creates outputs under frinZ/pulsar_gating/ next to the input .cor.
Modes
- Known mode (
--periodrequired,--dmoptional): Performs dedispersion (if DM is given), fold, on/off pulse bin selection, and gated spectrum/profile products. - Unknown mode (
--periodomitted): Estimates period from fringe-derived products, estimates DM from sub-band delay fit, writes handoff parameters, then automatically runs known mode with estimated values.
Core algorithm flow
- Read
.corsectors and build channel-wise time series. - Build fringe products (
rate spectrum,delay-rateplane). - Estimate period from spacing of periodic peaks in the rate spectrum (
rate-diff). - Refine period by fold-SNR scan.
- Estimate DM by fitting delay vs
1/f^2from phase-shifted sub-band folded profiles. - Run known-mode gating with selected/refined parameters.
Estimated/refined period and estimated DM are printed to stdout.
Noise evaluation before/after gating
pulsar_gating evaluates noise in two stages.
-
Before gating (folded profile)
- On-pulse bins are chosen by
--on-duty(largest folded amplitudes). - Off-pulse bins are the remaining bins.
off_meanandoff_sigmaare computed from off-pulse folded amplitudes.Estimated S/Nis:(peak_amp - off_mean) / off_sigma
- On-pulse bins are chosen by
-
After gating (on/off weighted aggregation)
- Time-domain means are computed from dedispersed sector amplitudes:
on_mean: weighted mean over on-pulse sectorsoff_mean: weighted mean over off-pulse sectorsoff_sigma: standard deviation of off-pulse sector amplitudes
Gated time S/Nis:(on_mean - off_mean) / off_sigma
Gated profile S/Nis computed from channel-subtracted time series (on-off) as:peak(on-off) / sigma(off on-off)
- Time-domain means are computed from dedispersed sector amplitudes:
In stdout and *_summary.txt, these appear as:
Estimated S/N(pre-gating folded profile)Gated on-mean,Gated off-mean,Gated off σGated time S/NGated profile S/N,Gated profile σ
ゲーティング前後のノイズ評価(日本語)
pulsar_gating では、ノイズ評価を次の2段階で行います。
-
ゲーティング前(folded profile)
--on-dutyで指定した割合だけ、振幅の大きい位相ビンを on-pulse として選択します。- 残りの位相ビンを off-pulse とします。
- off-pulse の振幅から
off_meanとoff_sigmaを計算します。 Estimated S/Nは次式です。(peak_amp - off_mean) / off_sigma
-
ゲーティング後(on/off 重み付き集約)
- dedispersed したセクター振幅から次を計算します。
on_mean: on-pulse セクターの重み付き平均off_mean: off-pulse セクターの重み付き平均off_sigma: off-pulse セクター振幅の標準偏差
Gated time S/Nは次式です。(on_mean - off_mean) / off_sigma
Gated profile S/Nは、チャネルごとの off 平均を引いた on-off 時系列から計算し、次式で定義します。peak(on-off) / sigma(off on-off)
- dedispersed したセクター振幅から次を計算します。
stdout と *_summary.txt では、主に以下の項目として表示されます。
Estimated S/N(ゲーティング前 folded profile)Gated on-mean,Gated off-mean,Gated off σGated time S/NGated profile S/N,Gated profile σ
Main outputs (current default)
*_rate_spectrum.png– rate profile with threshold/periodic markers.*_rate_spectrum_above_amp.csv– points above--amp-threshold.*_rate_spectrum_periodic_peaks.csv– periodic peak candidates used for period spacing.*_delay_rate_peakscan.png– delay-window peak scan map.*_rate_diff_folded_profile.png– folded profile from rate-diff period (when available).*_dm_fit_points.csv– DM fit points and residuals (when DM estimation succeeds).*_unknown_handoff.txt– estimatedperiod,dm, and reproducible command.*_profile.csv,*_folded_profile.png– fold result from known-mode stage.*_gated_spectrum_difference.csv,*_gated_spectrum.png*_gated_profile.csv,*_gated_profile.png*_onoff_pulse_bins.txt,*_summary.txt*_dedispersed_time_series.csv,*_dedispersed_time_series.png*_raw_phase_heatmap.png,*_phase_aligned_heatmap.png,*_phase_aligned_onminusoff_heatmap.png*_gated_spectrum_on.csv,*_gated_spectrum_off.csv*_gated_time_series.csv,*_gated_time_series.png*_gated_time_series_diff.csv,*_gated_time_series_diff.png
Notes
- Recent versions intentionally reduce redundant CSV/PNG generation to shorten runtime and reduce disk usage.
- Legacy files from older naming/output schemes are cleaned up automatically when running
pulsar_gating.
Output Files
frinZ creates organized output directories:
frinZ/
├── fringe_graph/ # Delay/rate plots
│ ├── time_domain/
│ └── freq_domain/
├── fringe_output/ # Text analysis results
├── add_plot/ # Time series plots
├── cumulate/ # Cumulative SNR plots
├── bandpass_table/ # Bandpass calibration files
├── phase_reference/ # Phase reference outputs
└── cor_header/ # Header information
Output File Formats
- Text files (
.txt): Analysis results with delay, rate, SNR, and statistics - Binary files (
.bin,.cor): Complex spectra and calibrated data - Plot files (
.png): Visualization of fringe patterns and time series
File Naming Convention
Output files follow the pattern:
{station1}_{station2}_{timestamp}_{source}_{band}_len{length}s[_rfi][_bp]
Example: YAMAGU32_YAMAGU34_2025001120000_3C84_x_len60s_rfi
Command Reference
Required Arguments (one of)
--input <FILE>: Single .cor file for analysis--phase-reference <CAL> <TARGET> [OPTIONS]: Phase referencing mode
Time Parameters
--length <SECONDS>: Integration time (default: entire file)--skip <SECONDS>: Skip time from start (default: 0)--loop <COUNT>: Number of processing loops (default: 1)--cumulate <SECONDS>: Cumulative integration length
Search Parameters
--search: Enable precise search mode--iter <COUNT>: Search iterations (default: 3)--delay-window <MIN MAX>: Delay search range (samples)--rate-window <MIN MAX>: Rate search range (Hz)--delay-correct <VALUE>: Manual delay correction (samples)--rate-correct <VALUE>: Manual rate correction (Hz)
Analysis Options
--frequency: Frequency domain analysis--rfi <"MIN,MAX">: RFI frequency ranges to exclude (MHz)--bandpass <FILE>: Apply bandpass calibration--bandpass-table: Generate bandpass table
Output Options
--output: Save text results--header: Show header information--plot: Generate fringe plots--add-plot: Generate time series plots--cross-output: Output complex visibility data--dynamic-spectrum: Generate dynamic spectrum plots
Performance Notes
frinZ provides significant performance improvements over the Python version:
- Faster FFT processing using rustfft
- Optimized memory usage for large datasets
- Parallel processing capabilities
- Accuracy comparable to original (within 0.1%)
The minor numerical differences (≤0.1%) compared to frinZ.py arise from:
- Different FFT library implementations (rustfft vs scipy.fft)
- Precision differences in binary decoding (Rust: 7-8 digits, Python: 6 digits)
- DC component handling in FFT processing
License
This program is licensed under the MIT License.
Author
(c) M.AKIMOTO with Gemini in 2025/08/04
Related Projects
- frinZ.py - Original Python implementation