FISH detailed guide
For a short runnable sequence, open the quick start. This page covers parameters, calculations and detailed operating instructions.
A practical guide to the complete spectral workflow using a compact real Sun17_A_01 / M01 dataset: load inputs, calibrate, inspect RFI, fit and subtract baselines, align velocities, and save a resampled spectral table. Only spatial gridding is omitted.
The repository example contains the Python scripts, notebook, real SCI/CAL/Tcal extracts and reference results.
01 / Know the inputs
Sun17_A_01 input dataset
The example contains actual Sun17_A_01 observations from 10 October 2021: M01, 32 consecutive science integrations, and both auto-polarizations. Original zero-based SCI rows 1040–1071 are retained from N_0001. The native band keeps all 65,536 channels over 31.25 MHz.
The selection contains 6.442450944 seconds of exposure. Matching ON/OFF and diode-reference extracts retain context for the two default 10-timestamp filters and the 16-frequency-channel Tcal filter.
These are observed spectra, with no simulated signal or truth array. The original files are preserved. The complete example runs through baseline subtraction and Doppler-aligned resampling. Actual saved pointings and frequency factors are included; there is no need to download full telemetry. Spatial gridding is the only omitted production stage.
science.fits · 16,796,160 bytes32 times × 65,536 channels × AA/BB; original counts and scalar metadata.
on_off.fits · 279,360 bytes64 times × OFF/ON × AA/BB × 261 channels.
tcal_reference.fits · 106,560 bytesM01, 4,197 diode-reference channels including smoothing context.
provenance.jsonOriginal basenames and slices, midpoint ranges, exact sizes, SHA256 hashes, and extraction comparison.
Data volume. The three FITS files total 17,182,080 bytes (16.39 MiB). All 19 beams of Sun17_A_01 would require 82,037,318,400 bytes of narrow-band SCI and 10,288,290,240 bytes of extracted CAL; the whole scan is unnecessary for this calibration example.
02 / Run it locally
Installation and execution
Use a Python environment with Python ≥3.8 and a compatible scientific stack. The normal package installation includes the full pipeline dependencies; the tutorial itself uses NumPy, SciPy, Astropy, and Matplotlib. No server connection is required. The unattended workflow needs no desktop display; the Qt viewer does.
Install in a separate environment¶
Create and activate a Python environment, then install from the repository root.
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -e '.[notebook,qt]'Installation does not finish?
Read the first dependency error. The full package includes cygrid, whose installation depends on your platform and available compiled dependencies. Use a compatible scientific Python environment rather than replacing your working system Python. If using a notebook, select the kernel of the environment where FISH is installed.
Run the readable script¶
python examples/minimal_calibration/run_workflow.py \
--output "$HOME/fish-suna01-workflow"The runner verifies inputs and executes the normal FISH run/wait sequence for reference, calibration/RFI, baseline and resampling. Use a new empty workspace. It saves fit records, a spectral table and diagnostic figures; no gridding is started.
Prefer to inspect one cell at a time?
cd examples/minimal_calibration
jupyter notebook walkthrough.ipynbThe notebook explains each intermediate array and equation. Its final cell explicitly saves results to a temporary folder. Open the notebook in GitHub to read it online.
Start here / choose your route
Two ways to work through the same data
Download this operating guide as plain text.
Complete installation above first. All operating-system commands below are entered in a normal terminal, from the NJU_FAST_ISM repository folder with its Python environment activated. Commands labelled FISH prompt are entered after starting fish; do not paste them into Bash, Zsh, or the unrelated fish operating-system shell. Do not type the printed fish> prompt itself.
Route A · inspect, then process¶
Recommended for your first attempt. Prepare an empty session, inspect every stage in the Qt viewer, apply your settings, then save the four processing stages from FISH.
Follow the viewer walkthrough and the control reference, then save from the command line.
Route B · commands and a notebook¶
Prepare the same session and run each processing stage from the FISH prompt. A display is optional. Read its status, settings and saved table. Open Qt later if a display is available.
Follow the command-line walkthrough. Alternatively, execute walkthrough.ipynb cell by cell, or use the unattended runner above.
One session, one set of settings. Use one output directory throughout your chosen route. The examples below use ~/fish-suna01-session. The earlier one-command runner uses a different directory; do not prepare an already populated directory again. Original inputs remain in the cloned repository, so keep that package at the same location while using its session.
This example starts with extracted ON/OFF data. It does not demonstrate extraction from raw PSR files. Its real pointings and LSRK factors are already supplied; it does not recalculate telemetry. These choices keep the dataset small while exercising all four spectral processing stages.
03 / Desktop interface
Interactive workflow with the Qt viewer
Use the bundled Sun17 example to run the actual FISH desktop viewer on your own computer. For the detailed click-by-click instructions, see the viewer operating reference. The overview below creates a session with 32 real spectra and their measured sky positions; no connection to the original data server is required. The screenshots show the calibration and baseline pages.

1. Install and open the bundled example¶
From the NJU_FAST_ISM repository directory, in the same Python environment used above:
python -m pip install -e '.[qt]'
python examples/minimal_calibration/prepare_viewer.py \
--output "$HOME/fish-suna01-session"
fish-viewer --session-state "$HOME/fish-suna01-session/fish_session.json"
Run the viewer on a machine with a desktop display; a headless Linux server needs a configured desktop/display session. The preparation command requires a new empty output directory and keeps the bundled inputs intact. To reopen a session and retain your edits, run only the last command. In the viewer, raw rows 0–31 refer to this compact extract and correspond to original Sun17 SCI rows 1040–1071.
2. Inspect the temperature reference¶
- Select Tsys calibration in the Stage menu. Click one of the 32 points in the footprint; Previous / Next also changes the selected spectrum.
- Keep Tpsr smoothing = 10, change ON−OFF smoothing from 10 to 5, then click Update preview. Compare the reference curves. This first filter changes the ON−OFF used to derive Tpsr.
- Restore ON−OFF smoothing to 10, change Tpsr smoothing to 5 and update again. This second filter acts on Tpsr before matching SCI timestamps. The two changes need not have identical effects.
- Use Reset edits to discard pending, unapplied edits. Once an edit has been applied, restore a value explicitly and click Update preview. Use values 1–10; larger filters require a longer CAL extract and are rejected in this teaching session.
3. Inspect calibrated spectra¶
- Choose Apply calibration. The upper plot is raw SCI counts; the lower plot is temperature in K for the same observation. No baseline has yet been subtracted.
- Switch between AA and BB. Compare their gain-calibrated spectra; do not expect the backend counts or bandpass to be identical.
- Use Z for horizontal zoom, Shift+Z for both axes, B for the previous view, F for full extent, and Escape to cancel selection. For exact limits, use View → Plot ranges….
- Open View → Display tools to switch between centered steps and lines, or adjust display averaging. These settings affect drawing, not the calibration arrays.
4. Try baseline and spectral-output previews¶
- Choose Baseline. Inspect the observed spectrum, fitted components and residual. The initial list contains sin/cos plus a local degree-1 polynomial. Each component fits and applies only within its listed range; protected H I and detected RFI do not anchor the fit.
- Use + Add component, choose a function and range, then Update preview. Change one parameter at a time. If a period reaches its search limit, open Details… and inspect the residual rather than assuming the fit is correct.
- Choose Table. Set rebinning n_b or the Gaussian target n_g, and the output velocity limits. Update the preview. Select a region on the footprint with R (rectangle) or P (polygon), then use Region mean to inspect its mean spectrum.
What the bundled example supports. All 32 positions, midpoint times and LSRK frequency factors are real values saved from the verified Sun17 reduction. No sky coordinates are invented. The desktop viewer and complete workflow use these LSRK factors. The separate calibration-only sub-example uses topocentric frequencies. This short, one-beam extract supports saving all four spectral stages, but is unsuitable for a meaningful spatial cube. Only gridding is disabled. The full raw telemetry and full scan are not needed to run it.
5. Save the processing stages with your chosen settings¶
After inspecting and applying settings in the viewer, open FISH in the same environment and restore that session:
fish --viewer qt
restore ~/fish-suna01-session/fish_session.json
tsyscal run
wait
applycal run
wait
baseline run
wait
table run
wait
status
Run the commands one stage at a time and inspect any failure before proceeding. These commands process the compact dataset itself. Run commands… copies this same sequence, ending at Table. If editing settings in the terminal while the viewer is open, refresh the viewer before making further edits. Different settings receive different stage fingerprints; previous results are retained.
Use the same workflow with your own full observation project
Prepare a project with org_spec/, org_cal/, and matching feed_info/ telemetry, plus its appropriate Tcal reference. In FISH, select the files before calculating their footprint:
fish --viewer qt
project /path/to/your/project
file in org_spec/your_scan/your_date/*.fits
list
go where /workers 4
tsyscal
Inspect Tsys, Apply calibration, Baseline and Table previews, applying the settings you intend to use. Only then run the batch stages in the FISH prompt, waiting and checking each stage before continuing:
tsyscal run
wait
applycal run
wait
baseline run
wait
table run
wait
status
Run commands… copies stage commands for a full project; it does not execute them. This guide ends at the spectral table. Finite output does not establish true baseline quality or absolute calibration accuracy. Do not use a project path or Tcal reference from another observation without checking compatibility.
Interactive tool / detailed operating reference
How to operate the viewer at each step
The window is a working preview of the selected spectrum, not a browser simulation. Use the Stage menu to switch pages or Next step → to advance. In a spectrum page, the footprint is on the left and spectra are on the right. The selection line identifies scan, beam and zero-based row. Wait for Ready before requesting another calculation.
1. Open a fresh session and check the footprint¶
Normal terminal:
python examples/minimal_calibration/prepare_viewer.py \
--output "$HOME/fish-suna01-session"
fish-viewer --session-state "$HOME/fish-suna01-session/fish_session.json"
- Check that Stage = Footprint. This example contains only 32 positions from M01, so the map is a short track, not a two-dimensional survey.
- Choose Tsys calibration. Click a point on the map, or use Previous / Next. Confirm the selection line changes. Row 0 corresponds to original SCI row 1040; row 31 corresponds to original row 1071.
- To select another spectrum later, click a pointing again. Selecting it updates the requested preview; it does not discard other loaded spectra or change the batch selection.
- Keep the same session open for the remaining steps. To reopen tomorrow, use only the
fish-viewer --session-state …command; do not prepare the directory again.
2. Understand the main controls before changing science settings¶
| Control | What to do | What it changes |
|---|---|---|
| Stage / Next step → | Select the inspection page. | The displayed diagnostic, not a batch reduction. |
| AA / BB / average | Inspect AA and BB individually before their mean. | The displayed polarization. Baseline processing fits AA/BB separately. |
| Settings | Show or hide the parameter area. Its arrow menu offers Detach parameter console; select Attach parameter console to put it back. | Window layout only. |
| Update preview | After editing parameters, click once and wait for the result. | Saves the accepted settings to this session and recalculates the requested preview. It does not run all spectra or replace completed stage files. |
| Reset edits | Discard unapplied edits. | Restores the controls to the session’s saved settings. It is not an undo for already applied edits. |
| Refresh | Reload the session after changes made elsewhere, especially in the FISH prompt. | Synchronizes the window with current saved state. |
| Run commands… | Read the run folder, then use Copy commands only and paste into FISH. | Copies commands; clicking it does not start processing. This example’s list ends at Table. |
How to confirm an edit: after changing a field, the window reports Unapplied edits · Update preview. After a successful update it reports Settings applied. If an error appears, read it and correct the value; do not treat the old plotted curve as the result of the rejected edit. Before copying run commands, apply all intended edits and wait for the preview to finish.
3. Tsys calibration: choose the two time filters¶
- Use the Tsys calibration page. The upper plot compares raw and filtered Tpsr; the lower plot displays filtered Tpsr separately. These frequency summaries are diagnostics, not a replacement for the channel-dependent reference.
- Start with ON−OFF smoothing = 10 and Tpsr smoothing = 10. The first smooths the increment used to calculate Tpsr; the second smooths Tpsr before matching science times. Neither averages SCI timestamps together.
- Change only ON−OFF smoothing to 5, update and inspect AA/BB. Then restore it to 10. Change only Tpsr smoothing to 5 and compare. Restore both to 10 before reproducing the supplied default result.
- Values 1–10 are supported by this extract; 1 disables that time filter. Larger values need additional CAL context. Do not bypass the context check.
- Look for discontinuities, extreme values or invalid reference anchors. A visually smooth reference alone does not guarantee valid calibration. Continue to the calibrated spectra before deciding whether a setting is acceptable.
4. Apply calibration: inspect temperatures and RFI¶
- Choose Apply calibration. The upper plot is raw SCI backend counts, the lower plot is calibrated K for the same timestamp/polarization. Their vertical scales differ because their units differ. Baseline subtraction has not yet happened.
- Inspect AA, then BB. Zoom across the full band as well as around H I. The central bright line is not automatically interference.
- Read the mask legend: Detected RFI is shown with red bands and a count; Protected H I is gray. A count of zero means no detections by the current search, not proof of an interference-free spectrum.
- To load a catalogue, open Workflow → RFI catalogue… (also available from the display tools). Enter
packagedfor the distributed reference, or a compatible catalogue JSON path. Use Browse for a local file. For a remote viewer, enter the path on the data server. Choose a profile only if it matches the observation; leave it blank for catalogue statistics only, then click Open. - Catalogue entries guide the observed-spectrum search. They are not unconditional channel masks. Loading saves the choice for later runs and refreshes the preview; it does not rewrite completed products. A manually chosen baseline exclusion is also not an automatic RFI identification.
5. Baseline: build, inspect and revise the component list¶
- Choose Baseline, select AA and inspect the upper observed/model curves and lower residual. Repeat for BB. First keep the supplied sin/cos followed by a degree-1 polynomial.
- Each row is one component. Choose sin/cos or polynomial. For a polynomial set its degree n. For sin/cos enter a period in MHz as
auto, a fixed value, ormin:max. The degree control does not select the sinusoidal period. - Use Fit & apply range =
fullfor the full native band or-1500:1500for that LSRK interval. A component fits the residual left by preceding rows and is subtracted only inside its own range. A local function is not extrapolated outside its range. - Use + Add component to add a function, ↑ / ↓ to change order and × to remove it. Order matters because fitting is sequential. Change one item at a time, then update and inspect the result.
- Keep Protect ±km/s = 250 for reproducing the example. This excludes the central H I range from fitting anchors; it does not leave the baseline unsubtracted beneath H I. Detected RFI and extra exclusions are also omitted from anchors.
- For an additional baseline-only exclusion, enter paired intervals such as
[[800,850],[-900,-850]]in Exclude km/s. Use[]for none. These are syntax examples, not identified contamination in this dataset. Do not exclude real emission without examining it. - Use Baseline zoom or set exact plot limits to inspect small offsets. The H I peak may extend beyond a tight intensity range; that is display clipping, not lost channels.
- If Period at search limit appears, open Details…. It means the selected period lies at an allowed search boundary. Compare the residual and alternative justified functions/ranges. It does not by itself prove either a good fit or a failed fit.
- Check clean channels outside protected H I for offsets and coherent structure. Also compare H I profiles between reasonable choices. Because the protected interval is not fitted, a low outside residual cannot establish the true baseline underneath it.
6. Table: choose the spectral response and output interval¶
- Choose Table. Its upper plot is the selected native spectrum; the lower plot is the resampled product. The two plots can differ in channel spacing and response.
- For the default result choose rebin, n_b = 2, and output velocities −250 to +250 km/s. Update the preview. The output uses the real LSRK factors for each timestamp.
- For a comparison, select gaussian and set n_g, the target final Gaussian FWHM in native-channel units. It must not be smaller than the assumed native FWHM. Output spacing follows n_b in rebin mode or the final Gaussian FWHM in Gaussian mode. These settings change the science response; they are not merely display averaging.
- To preview a spatial-selection mean, place the mouse over the footprint, press R or P, adjust the rectangle/polygon using its handles, and click Region mean. This is a preview limited to at most 128 spectra, with no gridding. It does not redefine which spectra a later stage run processes.
- Return to the default settings if reproducing the default example. Check Settings applied and continue to the command-line saving steps below.
7. Zoom, vertical ranges and plotting style¶
Click the plotting canvas to give it keyboard focus, then place the pointer over the panel you want to control. Typing in a numeric field does not invoke plot shortcuts. Free dragging and wheel navigation are disabled intentionally.
| Action | How | Expected result |
|---|---|---|
| Zoom horizontally | Press Z, then drag a rectangle on a spectrum. | Changes the spectral X range and retains its Y range. |
| Zoom both axes | Press Shift+Z, then drag a rectangle. | Changes both velocity and intensity limits. |
| Cancel an armed zoom | Escape | Cancels the selection; it does not undo a completed zoom. |
| Previous / full view | B / F over the panel | Restores the previous view / full extent. |
| Exact X and Y limits | View → Plot ranges… | Enter shared X limits and independent upper/lower Y limits, then Apply. Minimum must be below maximum. On Tsys, X is MJD; on spectra, it is km/s. |
| Steps / lines / averaging | View → Display tools (style, colors, images) | Choose centered steps or lines and Display mean points. A value of 32 averages channels only for drawing; 1 displays native sampling. Stored data and fit settings are unaffected. |
| Read cursor / help | V / H | Reports cursor coordinates in the status bar / opens keyboard help. |
| Close the viewer | E / Q with canvas focus, or close the window. | Closes the viewer; terminal/background reduction jobs continue. |
Command line / complete step-by-step route
Run each spectral stage from the FISH prompt
This route uses the same real data, production functions and settings as the viewer. The compact example needs no original data-server access. Start from the package root in the activated environment. For a first run, keep the defaults below; parameter experiments can use a second, fresh workspace.
Step 1 · prepare the inputs, without processing¶
Normal terminal: if you already prepared ~/fish-suna01-session in the viewer walkthrough, skip this command.
python examples/minimal_calibration/prepare_viewer.py \
--output "$HOME/fish-suna01-session"
Expected: “Created session” followed by a fish_session.json path. The workspace contains configuration, selection and real saved coordinates, plus a CAL copy. Native SCI and Tcal are referenced from the package. Preparation is not yet calibration.
Step 2 · enter FISH and restore the prepared session¶
Normal terminal, with a desktop:
fish --viewer qt
On a headless computer, or for command-only processing, use fish --viewer none. The FISH prompt appears. From here, type only FISH commands:
restore ~/fish-suna01-session/fish_session.json
guide
settings
status
Expected: restore reports the loaded session; guide lists inspection/processing stages; settings prints the session, parameters and run directory; status lists completed or pending stages. A fresh session has no completed spectral products and reports that gridding is omitted. Check the paths before running anything. Restoring this compact session replaces the usual project/file/pointing setup; do not import science.fits separately here.
Step 3 · set and inspect the reference filters¶
FISH prompt:
set n_t_cal 10
set n_t_apply 10
get 0
tsyscal
Expected: each set prints its accepted value. With Qt enabled, tsyscal opens the temperature-reference page for spectrum 0. With --viewer none, no inspection window is opened. Use get next, get previous or get 15 to choose another zero-based spectrum; issue the desired inspection command again to view it. Indices in this example are 0–31.
tsyscal without run requests inspection. tsyscal run below computes/saves references for the whole loaded selection. The same distinction applies to applycal, baseline and table.
Step 4 · calculate and save the temperature references¶
tsyscal run
wait
status
Expected: Started reference, a job PID and log path; then Complete: reference with its stage directory. The example processes 32 selected science timestamps from one scan/beam. Do not start the next stage until wait reports completion. wait 10 waits up to ten seconds and may report Still running; that is not failure. Run wait again or inspect status.
Step 5 · inspect calibration and the RFI catalogue, then save calibration¶
catalog
applycal
Expected: catalog reports the active search-prior catalogue. With Qt, applycal shows counts above and K below. Inspect AA/BB and the legend as described above. To deliberately load a different compatible catalogue, use catalog /absolute/path/to/catalog.json; catalog packaged restores the distributed catalogue without selecting an observation profile. Use help catalog for the optional profile argument. Do not guess a profile for another observation.
After deciding on the settings:
applycal run
wait
status
Expected: Complete: calibration. The saved products include frequency-dependent gain coefficients and detected RFI intervals; the fitted gain is applied independently to AA/BB. No baseline has been subtracted yet. Existing stage paths are fingerprinted by their settings and provenance.
Step 6 · configure the baseline, inspect it and save its coefficients¶
The following reproduces the initial two-component model. Enter the entire component list on one line:
set protect_kms 250
set baseline_exclusions_kms []
set baseline_components [{"function":"sincos","range_kms":null,"period_MHz":null},{"function":"polynomial","degree":1,"range_kms":[-1500,1500]}]
baseline
Meaning: null range means full band; null period requests automatic search. The second component is linear and confined to ±1500 km/s. AA and BB are fitted separately; H I and detected RFI are omitted from fitting anchors. These are initial teaching settings, not a claim that they are optimal for every spectrum.
Inspect the components and residual in Qt, including Details for any period-boundary warning. A terminal-only run saves the fit reports for later inspection but cannot substitute for looking at the data. Once satisfied:
baseline run
wait
status
Expected: Complete: baseline. The stage stores component coefficients and reports. It does not create a spatial map. Reproducing the default example reports a period at its allowed boundary in one of its two chunks; investigate the warning rather than reading it as automatic success.
Step 7 · choose the spectral response and save the table¶
set spectral_mode rebin
set n_b 2
set velocity_range_kms [-250,250]
table
With Qt, inspect the resampled preview. For a separate Gaussian experiment, use set spectral_mode gaussian and set n_g 2, then inspect again; restore rebin to reproduce the default. n_g is a target final Gaussian FWHM in native-channel units. Native sampling, final resolution, output spacing and display averaging are distinct quantities.
table run
wait
status
Expected: Complete: resample, with a root-level table_manifest.json. The default disk-backed table has 32 rows × 2,485 channels. Each row is one selected timestamp; its spectrum has been baseline-subtracted, Doppler-aligned and resampled. No spatial gridding occurs. Do not run xy_map in this compact session.
Step 8 · save your session and leave safely¶
save ~/fish-suna01-session/my-settings.json
exit
The session JSON stores paths and parameters, not a self-contained data archive. A saved copy still points to the same workspace and input files; it is not a new isolated reduction. To continue, start FISH again and restore ~/fish-suna01-session/my-settings.json. Reopen Qt with fish-viewer --session-state "$HOME/fish-suna01-session/fish_session.json" for the original session, or use the saved settings path to open that snapshot. Keep one active settings file while alternating terminal and viewer edits.
Step 9 · read the saved spectral table¶
Python or a notebook: read product paths through the manifest instead of guessing fingerprinted folder names.
from pathlib import Path
import json
import numpy as np
root = Path.home() / "fish-suna01-session"
manifest = json.loads((root / "table_manifest.json").read_text())
records = json.loads(Path(manifest["processed"]).read_text())
product = records[0]["products"][0]
spectra = np.load(product["data"], mmap_mode="r")
frequency_ghz = np.asarray(manifest["frequency_ghz"])
print(spectra.shape) # default: (32, 2485)
print(np.isfinite(spectra).all()) # default: True
The unattended runner additionally creates workflow_summary.json and three figures. The manual stage sequence saves the normal production products and manifest; it does not automatically make those extra tutorial figures. Run the notebook or unattended example in its own fresh workspace to obtain them.
Optional · run a reproducible command file¶
Create a plain-text file called sun17-example.fish, containing FISH commands, not operating-system commands. This file assumes the prepared session already exists:
# Run against the existing prepared session.
restore ~/fish-suna01-session/fish_session.json
set n_t_cal 10
set n_t_apply 10
set protect_kms 250
set baseline_exclusions_kms []
set baseline_components [{"function":"sincos","range_kms":null,"period_MHz":null},{"function":"polynomial","degree":1,"range_kms":[-1500,1500]}]
set spectral_mode rebin
set n_b 2
set velocity_range_kms [-250,250]
tsyscal run
wait
applycal run
wait
baseline run
wait
table run
wait
status
exit
Normal terminal:
fish --viewer none --execute sun17-example.fish
The command-file reader stops on a reported command error. Read the printed output and stage log; do not remove wait commands or launch another run into the same workspace. For unattended use with compact summary figures, the supplied run_workflow.py remains the shorter option.
What must be rerun after a setting change?¶
| Changed setting | Stages to complete with the new settings |
|---|---|
| ON−OFF / Tpsr filters, or calibration/RFI catalogue | Start with tsyscal run, then calibration, baseline and table, checking each stage. Compatible checkpoints may be reused. |
| Baseline functions, protected range or extra exclusions | Ensure the required upstream checkpoints exist for the current settings; run baseline and table. If FISH requests a missing dependency, complete the requested upstream stage first. |
| Rebin/Gaussian choice or output velocity range | Regenerate Table using compatible upstream products; follow any dependency message. |
| Plot style, display averaging, colors or zoom | No processing rerun. These are drawing controls. |
Fingerprints determine product compatibility. The current settings can point to a different stage directory even though older products remain on disk. Use status after an edit; do not rename old products to make a dependency appear satisfied.
Troubleshooting / check before continuing
Common problems and recovery
| Symptom | Check and next action |
|---|---|
| fish or fish-viewer is not found / wrong fish program starts | Activate the Python environment where this source was installed. FISH is this package’s executable; an unrelated operating-system fish shell may also exist. From the package root, python -m fastfish.commands.shell --viewer qt explicitly starts the package prompt. |
| Qt cannot connect to a display | Use a desktop session for Qt. On a headless host run fish --viewer none for processing, or use the remote-viewer route below. Installing Qt alone does not create a display. |
| Output directory is not empty | Reopen its existing fish_session.json; do not prepare again. For an independent experiment, choose a new output directory. |
| A file is missing after moving the package | Sessions contain paths to package inputs. Restore the original location or prepare a new session from the new package location. Copying only fish_session.json does not copy SCI/CAL/Tcal. |
| Unapplied edits / run commands disabled | Click Update preview and wait. Fix a reported validation error, or Reset edits to discard the draft. The previous plot is not confirmation that a rejected change worked. |
| Keyboard shortcuts or vertical zoom seem inactive | Click the canvas and hover the target panel. Use Shift+Z for both axes, or View → Plot ranges. Z alone intentionally preserves spectral Y limits. Escape cancels an armed zoom; B undoes a completed view change. |
| Period at search limit | Read Details and inspect residuals in both polarizations. Compare justified ranges/functions; widening a bound without evidence is not a quality check. |
| No red RFI bands | Read the detection count and catalogue/profile. Entries are search priors, not guaranteed contamination. Inspect the observed band; zero detections does not prove every spike is astrophysical. |
| Need smoothing above 10 timestamps | The compact CAL extract lacks the required context. Use a larger real CAL selection; do not disable the support guard. |
| Complete upstream stage first | Current settings do not have a compatible dependency checkpoint. Run the named upstream stage, wait and check status, then continue downstream. |
| Stage stopped or failed | Read the exact job log path in the message. Inspect the last traceback and scheduler status. A stopped process is not completion. Preserve the log and resolve the actual error before starting the next stage. |
| Want progress without stopping the job | Use status or a bounded wait. Ctrl+C during wait returns to the prompt and leaves processing running. Closing the viewer or leaving FISH does not mean the science job was stopped. Use stop only when you intend to terminate the owned active job. |
Using the same viewer with server data¶
The bundled example runs locally. For your own remote session, prepare it on the data host and use its absolute session path. With the package and Qt installed on your desktop and working SSH access, the general form is:
fish-viewer --remote USER@HOST \
--remote-source /absolute/server/package/src \
--session-state /absolute/server/workspace/fish_session.json
The worker reads spectra on the server and the desktop draws the plots. The session and catalogue paths refer to the server; local Browse is unavailable for a remote catalogue. Use compatible package versions on both hosts. This does not copy an observation onto the desktop and does not create SSH access. Run processing commands in FISH on the data host, not against server paths in a local FISH prompt.
04 / Follow the calculation
Calibration procedure
The example calls the production calibration functions. It does not maintain a second estimator just for the tutorial. Open each step to see its meaning and code location.
01 Measure the noise-diode increment
D = PON − POFF20480 × 20480 + 286722
Smooth this increment along time using n_t_cal (default 10 timestamps). The original code uses ON=20480 and OFF=28672. The official FAST backend manual, Section 4 (p. 4) defines their unit as 4 ns. These settings give unequal diode durations: 81.92 μs ON and 114.688 μs OFF.
| Quantity | Calculation | Duration |
|---|---|---|
| Diode ON | 20480 × 4 ns | 81.92 μs |
| Diode OFF | 28672 × 4 ns | 114.688 μs |
| Cycle | (20480 + 28672) × 4 ns | 196.608 μs |
| PSR sample | Sun17 CAL header TBIN | 98.304 μs |
The extractor averages alternating equal-length PSR sample bins separately. With the assumed phase alignment, the ON-labelled bin receives injection for only 81.92/98.304 = 5/6 of its duration. The required multiplier is therefore tsample/tON = (20480 + 28672)/(2 × 20480) = 1.2. It is not the inverse of the ON fraction of the entire cycle.
The CRAFTS pipeline paper, Section II.1 also documents the unequal diode durations. The numerical settings here come from the original calibration code; the FAST manual establishes the units, not these observation-specific values. This explanation assumes the pulse is confined to the ON-labelled bin. Different settings or phase alignment require a corresponding timing calculation.
Production: src/fastfish/calibration/extracted.py → rebuild_reference
02 Build and align the temperature reference
Tpsr = Tcal × POFF / smooth(D)
The reader smooths the diode-temperature reference over 16 frequency channels and interpolates it to the CAL grid. It retains the production float32 reference rounding. Then n_t_apply independently smooths Tpsr in time before interpolation to SCI midpoints.
The reader converts original SCI UTOBS start times to midpoints using EXPOSURE/2. CAL timestamps already denote midpoints. Time extrapolation is disabled. Smoothing Tpsr does not time-average the science spectra.
Production: rebuild_reference; time matching: scipy.interpolate.interp1d(..., bounds_error=True)
03 Estimate the frequency-dependent gain
Gain anchors = overlap-averaged SCI counts / Tpsr
SCI is averaged into fully covered CAL frequency bins for comparison. A cubic log-gain is fitted independently at every time and for AA/BB, then evaluated on the native SCI grid. Anchors within ±700 km/s of H I are excluded here; this is a gain-fit exclusion, not a baseline-protection setting.
The example calls the production calibration wrapper, including its chunk-level catalogue-guided RFI search. Only observed detections become exclusions. No intervals were detected for this selected chunk at the current thresholds; this does not establish that every channel is clean.
Production: processing/preview.py → calibrate and processing/spectral.py → frequency_gain
04 Apply gain to native science channels
TSCI = PSCI / Gain
The final spectrum retains native channels. Frequencies outside the CAL support remain NaN; they are not extrapolated. The measured background remains because no continuum or baseline has been removed.
Tutorial: calibrate.py → apply_reference
(time, channel, polarization); Tpsr is (time, polarization, channel). Frequencies supplied to the gain estimator are GHz, diode-file frequencies are MHz, temperature is K, and gain is counts/K.05 / RFI exclusions and baseline removal
Fit and inspect the baseline separately in AA and BB
Calibration converts backend counts to temperature; it does not remove the spectral baseline. The baseline stage fits each polarization independently, subtracts its model on native channels, and only then averages the residual polarizations.
- Inspect RFI and H I first. In Apply calibration, zoom through the native band and compare AA/BB. Red bands mark detected RFI; gray marks protected H I. Catalogue priors are not automatic masks. The selected sample currently has no catalogue-guided detections, which does not prove that all channels are clean.
- Choose Baseline. The component table initially has a full-band sin/cos component and a degree-1 polynomial over −1500:1500 km/s. Components fit sequential residuals in list order. Use the arrows to change order or × to remove a component.
- Protect H I. The default protection is ±250 km/s. Protected channels and detected RFI are excluded from fitting anchors, but the model is subtracted beneath the protected line. Choose a different interval only after inspecting the actual profile.
- Adjust one component. Choose polynomial and its degree, or sin/cos with automatic, fixed or bounded period in MHz. Set the velocity fit/apply range, then click Update preview. Each component is applied only within that range; a local model is not extrapolated outside it.
- Inspect the residual. Check both polarizations, especially offsets and coherent structure outside H I and excluded RFI. Compare plausible models. A flat-looking average or low residual outside H I does not establish the true baseline under the protected interval.
- Save the result. After applying settings, run
baseline runandwaitin the restored FISH session. If calibration settings changed too, complete the upstream reference/calibration stages first.

Extra exclusions and period-search warnings
Additional baseline-only intervals can be entered in Exclude km/s. For example, the FISH syntax set baseline_exclusions_kms [[800,850]] excludes that interval from fitting; it does not identify an RFI there. Use exclusions only when justified by the observed data.
The default demonstration reports a period at its allowed search boundary in one of two processing chunks. Open Details to identify the component/polarization and compare its residual with alternatives. This is a diagnostic, not an automatic pass/fail verdict. The initial model is illustrative and is not asserted to be scientifically optimal.
Inside protected ±250 km/s, the baseline is inferred from outside anchors and the chosen function. The fit alone cannot measure its true error there. Native-channel scatter also contains radiometer noise; the plotted channel means have lower scatter and should not be confused with native noise.
06 / Doppler alignment and resampling
Generate the final spectral table
The Table stage uses the actual per-spectrum LSRK frequency factors bundled with the example. It aligns baseline-subtracted spectra onto a common output grid and retains one row for each selected timestamp. This is a spectral table, not a spatially gridded cube.
- Choose Table in Stage. Keep rebin mode with n_b=2 and output velocity limits −250 to +250 km/s for the default example.
- To compare responses, change the rebin factor or select Gaussian with a target n_g in native-channel FWHM units. Update preview and inspect the result; display averaging is a separate plotting control.
- Optionally select points with R (rectangle) or P (polygon) on the footprint and use Region mean. This previews a mean without spatial gridding.
- Run table run, then wait and status in FISH. The default saved table has 32 rows × 2,485 channels. There is no need to run xy_map for this example.

Read the saved table in Python
Replace the workspace path if you chose another output folder:
from pathlib import Path
import json
import numpy as np
root = Path.home() / "fish-suna01-workflow"
manifest = json.loads((root / "table_manifest.json").read_text())
processed = json.loads(Path(manifest["processed"]).read_text())
product = processed[0]["products"][0]
spectra = np.load(product["data"], mmap_mode="r")
frequency_ghz = np.asarray(manifest["frequency_ghz"])
print(spectra.shape) # (32, 2485) for the defaults07 / Check your answer
Saved outputs and verification

The compact inputs were compared with three surrounding original CAL files and the full original Tcal file. At the default smoothing settings, the effective Tpsr and all calibrated SCI values were exactly equal on the server (maximum difference 0 K). The separate calibration-only script and notebook additionally compare selected native temperatures and all gain coefficients with frozen original-input results. Small floating-point differences across platforms are allowed.
workflow_summary.jsonFour completed stages, table dimensions, residual statistics and warnings.
table_manifest.jsonSettings, output frequencies and paths to the saved spectral table.
stages/Reference arrays, gain coefficients, RFI intervals, baseline fits/reports and disk-backed resampled spectra.
The unattended runner also saves calibration.png, baseline.png and table-spectrum.png. All four stages process 32 spectra. The default table is fully finite; RFI-fraction fields remain within [0,1]. The workflow does not run spatial gridding.
Reference quality. A few nonpositive Tpsr values occur at 1420.28808594 MHz (about 0.084% of AA and 0.048% of BB reference samples). That channel is inside the excluded H I gain interval and is not used as a gain anchor. These values are reported, not changed or automatically labelled RFI.
Real-data repeatability does not establish the true astronomical spectrum or absolute calibration accuracy. The calibration diagnostic plots native frequency as topocentric velocity. The baseline plots, viewer and final spectral table use the bundled real LSRK factors. Baseline and RFI quality still require scientific assessment.
08 / Parameter changes
Parameter tests and code modification
Time-smoothing parameters¶
python examples/minimal_calibration/calibrate.py \
--output "$HOME/fish-calibration-no-smoothing" \
--n-t-cal 1 --n-t-apply 1Compare the reference curves, gain coefficients and spectra with the default result. Real references fluctuate, so changing the two filters can change the answer. The default regression comparison is skipped for non-default windows; the change is reported instead. With both filters disabled, a few nonfinite references appear at 1425.415 and 1426.514 MHz; the production fit rejects invalid anchors and the summary reports them. This does not make reference-quality checks optional.
Relevant source functions¶
Read rebuild_reference for the two time filters. Read frequency_gain for overlap averaging, exclusions, log fitting, clipping, and support checks. The package’s src/README.md maps the remaining modules and explains how to extend them.
The compact extract supports time-filter windows from 1 to 10. Larger windows need more surrounding CAL timestamps and must not be forced by disabling support checks. Preserve the bundled data and numerical reference when experimenting.
Scope of the full reduction workflow
Real reductions add input convention and reference-quality checks, observed RFI detection, consistent pointing/time/Doppler calculations, configurable baseline components, spectral resampling, and spatial gridding. This compact tutorial demonstrates the spectral stages; spatial gridding and full-observation quality assessment require a larger dataset. Native channel spacing is not a measurement of the instrumental line-spread function.