Example: On-The-Fly (OTF) Mapping of the M33 Region#
This example demonstrates the process of calibrating and imaging On-The-Fly (OTF) mapping data of the M33 galactic region using HiFAST. The goal is to produce a final data cube suitable for scientific analysis.
Download Sample Data#
First, download the sample dataset from this link: https://pan.cstcloud.cn/s/u6u3iyfdRqo
The downloaded data contains the raw FITS files from the FAST telescope and a feed cabin position file (.xlsx). This .xlsx file records the trajectory of the feed’s phase center, which is used by hifast.radec to calculate the celestial coordinates for the observation. The directory structure looks like this:
$ ls RAW_data/*
RAW_data/KY:
M33_OTF_2021_07_31_05_14_00_000.xlsx
RAW_data/M33_OTF:
20210731
Processing Workflow#
The FAST telescope has a wide frequency coverage. Within the observed M33 region, the data contains signals from both the extended structure of the M33 galaxy itself and various point sources at other frequencies. The optimal data processing strategy differs for these two types of sources, so we present two separate cases.
Case 1: Extended Source (M33 Galaxy)#
This case is optimized for the extended, diffuse emission from the M33 galaxy. The processing is tailored for the frequencies corresponding to M33. The workflow consists of two main scripts. (See Section 3.2 of the arXiv:2401.17364 for details)
1. Calibration
The main calibration workflow is executed by the run_case1.sh script.
Script:
run_case1.shConfiguration:
S2-sw.iniandS2-rfi.ini
1#!/usr/bin/env bash
2
3# Enable recursive globbing to allow ** to match all files and directories recursively.
4shopt -s globstar
5
6# --- Step 1: Temperature Calibration ---
7# Calibrate the temperature for the raw spectrometer data.
8echo "Starting Step 1: Temperature Calibration..."
9
10# Select the first FITS file for each beam as input.
11# Note: Assumes naming convention M33_OTF_1_*W_0001.fits
12files="$(ls RAW_data/M33_OTF/20210731/M33_OTF_1_*W_0001.fits)"
13printf "Selected files for calibration:\n${files}\n"
14
15# Run hifast.sep to perform temperature calibration.
16# This converts the raw data into calibrated HDF5 files.
17# Note: "-p 3" enables parallel processing with 3 cores.
18python -m hifast sep -p 3 \
19 $files \
20 -d 4 -m 4 -n 596 --step 1 \
21 --frange 1400 1440 \
22 --smooth gaussian --s_sigma 2 \
23 --check_cal A --pcal_vary_lim_bin 0.02 \
24 --merge_pcals True --method_merge median --method_interp linear \
25 --save_pcals True \
26 --outdir output_1/%[project]s/%[date]s
27
28# The output files from this step will be named with the suffix "-specs_T.hdf5".
29
30# --- Step 2: Coordinate Calculation ---
31# Generate celestial coordinates (RA, Dec) for the calibrated data.
32echo "\nStarting Step 2: Coordinate Calculation..."
33
34# Run hifast.radec on the calibrated file for Beam 01.
35# Note: Only the M01 beam file is needed, as it contains the necessary trajectory
36# information to calculate coordinates for all other beams.
37python -m hifast radec output_1/**/*-M01*-specs_T.hdf5 --ky_dir RAW_data/KY/ --plot
38
39# --- Step 3: Data Processing Pipeline ---
40# Process the temperature-calibrated data to handle baseline, standing waves, and RFI.
41echo "\nStarting Step 3: Data Processing Pipeline..."
42
43# Select all temperature-calibrated HDF5 files for further processing.
44files="$(ls output_1/**/*-M*-specs_T.hdf5)"
45printf "Selected files for pipeline processing:\n${files}\n"
46
47# Define the processing pipeline using a series of hifast modules.
48# This multi-line string defines the sequence of commands that hifast.sh will execute.
49commands=$(cat <<'EOF'
50# Apply flux calibration.
51python -m hifast.flux |
52# Perform a first-pass baseline removal.
53python -m hifast.bld | --nproc 5 --frange 1400 1440 \
54 --method PLS-asym2 --lam 1e8 \
55 --njoin_t 20 \
56 --s_method_freq gaussian --s_sigma_freq 3 \
57 --exclude_type auto2 \
58 --post_method poly-asym2 --post_deg 3 \
59 --post_exclude_type auto2
60# Flag Radio Frequency Interference (RFI).
61python -m hifast.rfi | -c conf/S2-rfi.ini
62# Remove standing waves. Using ``--nobld True`` preserves the baseline from the
63# previous step, meaning this command only removes the standing wave component.
64python -m hifast.sw | --nobld True -c conf/S2-sw.ini
65# Perform a second, more refined baseline removal after the standing wave is gone.
66# This two-step baseline removal is effective for extended sources where a clean
67# off-source reference is not available. For point sources, ``hifast.ref`` is used instead (see run_case2.sh).
68python -m hifast.bld | --nproc 5 \
69 --method PLS-asym2 --lam 1e8 \
70 --s_method_t gaussian --s_sigma_t 20 \
71 --s_method_freq gaussian --s_sigma_freq 3 \
72 --exclude_type auto2 \
73 --post_method poly-asym2 --post_deg 2 \
74 --post_exclude_type auto2
75# Correct velocities, merge polarizations, and replace RFI flags.
76python -m hifast.multi | --vtype optical --frame LSRK --merge_polar True --replace_rfi True
77EOF
78)
79
80# Execute the pipeline on all selected files using hifast.sh.
81# ``-n 5`` runs 5 processes in parallel for efficiency.
82echo "\nExecuting pipeline with hifast.sh..."
83hifast.sh "$files" -c "$commands" -n 5
2. Cube Generation
After running the calibration pipeline, this final script takes all the processed HDF5 files and grids them into a FITS data cube named cube.fits.
Script:
gen_cube_case1.sh
1#!/usr/bin/env bash
2
3python -m hifast.cube \
4 --outname cube.fits \
5 -m gaussian --type3 vopt \
6 --range3 -1000 2000 \
7 --share-mem False --step 19 --nproc 4 \
8 output_1/M33_OTF_1_MultiBeamOTF/*/*fc.hdf5
Case 2: Point Sources in the M33 Field#
This case is optimized for identifying and analyzing point sources that appear at other frequencies within the observed M33 field.
Calibration Script:
run_case2.shConfiguration Files: Same as in Case 1.
Cube Generation: The gen_cube_case1.sh script from Case 1 is also used for this case.
The full calibration workflow is executed by the run_case2.sh script:
1#!/usr/bin/env bash
2
3# Enable recursive globbing to allow ** to match all files and directories recursively.
4shopt -s globstar
5
6# --- Step 1: Temperature Calibration ---
7# Calibrate the temperature for the raw spectrometer data.
8echo "Starting Step 1: Temperature Calibration..."
9
10# Select the first FITS file for each beam as input.
11# Note: Assumes naming convention M33_OTF_1_*W_0001.fits
12files="$(ls RAW_data/M33_OTF/20210731/M33_OTF_1_*W_0001.fits)"
13printf "Selected files for calibration:\n${files}\n"
14
15# Run hifast.sep to perform temperature calibration.
16# This converts the raw data into calibrated HDF5 files.
17# Note: "-p 3" enables parallel processing with 3 cores.
18python -m hifast sep -p 3 \
19 $files \
20 -d 4 -m 4 -n 596 --step 1 \
21 --frange 1360 1415 \
22 --smooth gaussian --s_sigma 2 \
23 --check_cal A --pcal_vary_lim_bin 0.02 \
24 --merge_pcals True --method_merge median --method_interp linear \
25 --save_pcals True \
26 --outdir output_2/%[project]s/%[date]s
27
28# The output files from this step will be named with the suffix "-specs_T.hdf5".
29
30# --- Step 2: Coordinate Calculation ---
31# Generate celestial coordinates (RA, Dec) for the calibrated data.
32echo "\nStarting Step 2: Coordinate Calculation..."
33
34# Run hifast.radec on the calibrated file for Beam 01.
35# Note: Only the M01 beam file is needed, as it contains the necessary trajectory
36# information to calculate coordinates for all other beams.
37python -m hifast radec output_2/**/*-M01*-specs_T.hdf5 --ky_dir RAW_data/KY/ --plot
38
39# --- Step 3: Data Processing Pipeline ---
40# Process the temperature-calibrated data to handle baseline, standing waves, and RFI.
41echo "\nStarting Step 3: Data Processing Pipeline..."
42
43# Select all temperature-calibrated HDF5 files for further processing.
44files="$(ls output_2/**/*-M*-specs_T.hdf5)"
45printf "Selected files for pipeline processing:\n${files}\n"
46
47# Define the processing pipeline using a series of hifast modules.
48# This multi-line string defines the sequence of commands that hifast.sh will execute.
49commands=$(cat <<'EOF'
50# Apply flux calibration.
51python -m hifast.flux |
52# Perform a first-pass baseline removal.
53python -m hifast.bld | --nproc 5 --frange 1360 1415 \
54 --method PLS-asym2 --lam 1e8 \
55 --njoin_t 20 \
56 --s_method_freq gaussian --s_sigma_freq 3 \
57 --exclude_type auto2 \
58 --post_method poly-asym2 --post_deg 3 \
59 --post_exclude_type auto2
60# Flag Radio Frequency Interference (RFI).
61python -m hifast.rfi | -c conf/S2-rfi.ini
62# Remove standing waves, preserving the baseline for the next step.
63python -m hifast.sw | --nobld True -c conf/S2-sw.ini
64# Subtract the reference (off-source) observation to remove background noise and baseline.
65# This approach is used for point sources where a clean off-source reference is available.
66# It replaces the second baseline removal step seen in the extended source case (run_case1.sh).
67python -m hifast.ref | --method MedMed --nsection 11 --npart 8 \
68 --post_method poly-asym2 --post_deg 3 \
69 --post_s_method_freq gaussian --post_s_sigma_freq 1 \
70 --post_exclude_type auto2
71# Correct velocities, merge polarizations, and replace RFI flags.
72python -m hifast.multi | --vtype optical --frame LSRK --merge_polar True --replace_rfi True
73EOF
74)
75
76# Execute the pipeline on all selected files using hifast.sh.
77# ``-n 5`` runs 5 processes in parallel for efficiency.
78echo "\nExecuting pipeline with hifast.sh..."
79hifast.sh "$files" -c "$commands" -n 5
Viewing the Results#
The following Jupyter notebook demonstrates how to inspect the calibrated data and the final data cube from these processing workflows.