ahay/src/using-sf-programs
Claude Code and agent skill by ahay/src
- community
Checking that the SKILL.md file is still in the repository.
Use when composing a Madagascar data-processing pipeline from existing sf* programs — includes discovery, parameter conventions, and piping patterns.
Install
npx vskill@latest install ahay/src/using-sf-programsSKILL.md
When to use
Use this skill any time you are assembling a Madagascar data-processing workflow from existing sf* programs: creating synthetic data, filtering, reshaping, transforming, inspecting, or plotting. If you are writing a new sf* program from scratch (in C or Python), consult the program-authoring skill instead. If you need to embed pipelines inside a reproducible SCons build, consult the writing-rsf-flows skill.
The patterns here apply equally at the shell prompt, inside SConstruct Flow calls, and inside short Python driver scripts — the programs themselves are identical in all three contexts.
For a worked end-to-end pipeline that chains these programs to solve a named geophysical problem, see the finding-workflow-examples skill.
The pipeline model
Every sf* program is a Unix filter. It reads an RSF dataset from stdin and writes an RSF dataset to stdout. Because all programs speak the same binary format, they compose without adapters:
The equivalent using explicit intermediates:
Both forms are semantically identical. The pipe form is more concise for throwaway work; the intermediate-file form is better when you want to inspect or reuse mid-stream results.
Key properties of the model:
- Composability is the design goal. Each program does one thing and passes
the header plus binary data downstream unchanged (except for the dimensions it modifies).
- The header travels with the data. RSF files consist of a small ASCII
header (.rsf) that records n#, d#, o#, label#, unit#, and a pointer to the binary data file. Programs update the header automatically; you rarely touch it by hand.
- Axis numbering is 1-based.
n1is the fast (innermost) axis — usually
time samples. n2 is the slow axis — usually trace index. Higher axes follow naturally.
- stdin/stdout are the default I/O names. Programs that take secondary
inputs (e.g. a mask file) use named parameters: mask=head.rsf.
Discovery
Looking up a specific program
This prints the program description, synopsis with all parameters and defaults, the known functions, and a list of reproducible examples that use the program. Every parameter claim in this skill was verified with sfdoc.
Keyword search
sfdoc -k <word> searches program descriptions for the keyword and prints matching program names and one-line summaries. Use it when you know what you want to do but not which program does it.
Listing all sf* programs
This lists every installed program. Pipe through grep to narrow by name fragment (e.g. grep fft). The catalog is large (hundreds of programs); rely on sfdoc -k for semantic search rather than scanning the full list.
Do not use sfdoc -l <dir> to list programs — that flag writes LaTeX documentation to files and is not a listing tool.
Reading source
Source lives under user/<author>/M<name>.c (user-contributed) or system/main/<name>.c / system/generic/M<name>.c (core programs). The SOURCE field in sfdoc output names the file. Reading source is the authoritative way to understand edge cases and defaults not covered by the synopsis.
Parameter conventions
Parameter conventions are uniform across all sf* programs. The following are grounded in actual sfdoc output.
Axis parameters (n#, d#, o#, label#, unit#)
From sfdoc sfspike:
n1=1000— 1000 samples along the first (fast) axis.d1=0.004— 4 ms sample interval (the default for axis 1).o1=0— axis starts at time 0.label1="Time"— string labels appear in plots and insfinoutput.
The # is a literal digit: n1, n2, n3, … Programs that accept axis parameters accept as many as the data has.
Boolean flags
From sfdoc sfbandpass:
Booleans are always y or n. Never use true/false or 1/0.
Comma-separated lists (multi-valued parameters)
From sfdoc sfspike:
When nsp=2, you supply two values separated by commas:
This places two spikes on axis 1 at samples 300 and 700 with magnitudes 1.0 and 0.5 respectively. The [nsp] annotation in the sfdoc synopsis means the parameter repeats once per spike.
Note: sfspike reads nsp BEFORE k#/mag, so you MUST set nsp=N explicitly when passing N-element lists; it is not inferred from list length. With the default nsp=1, only the first element of each list is used and only one spike is placed.
File-valued parameters
Some programs accept secondary files by name. From sfdoc sfheaderwindow:
Usage:
The named file is opened separately; stdin/stdout handle the primary data flow.
The output= expression parameter
From sfdoc sfmath:
This is a string containing a mathematical expression. Named input files become variable names:
When stdin is supplied, it is available as input. When producing data from scratch (no stdin), set nostdin=y and specify n1=, d1=, o1= etc.
Window parameters (f#, n#, j#, min#, max#)
From sfdoc sfwindow:
You can mix coordinate-based (min1=, max1=) and sample-based (f1=, n1=) windowing. Unspecified parameters default to keeping the full extent.
Core catalog
The table below covers the programs used most often, grouped by purpose. Run sfdoc <name> for full parameter lists.
Synthesize
| Program | What it does | |
|---|---|---|
sfspike | Generate spikes, boxes, planes, or constant arrays. The primary tool for making synthetic data. Key params: n1, n2, k1, mag, nsp. | |
sfmath | Evaluate a mathematical expression to create or transform data. Accepts named file inputs as variables. Supports trig, log, exp, abs, erf, complex functions. | |
sfnoise | Add (or replace with) random noise. Key params: var, range, mean, type (y=normal, n=uniform), rep (replace instead of add), seed. |
Reshape
| Program | What it does | |
|---|---|---|
sfwindow | Extract a sub-volume along any axis. Supports sample-based (f#, n#, j#) and coordinate-based (min#, max#) selection. | |
sfpad | Pad with zeros. Key params: beg# (prepend), end# (append), n# (set output length directly). | |
sftransp | Transpose two axes. Default: plane=12 swaps axes 1 and 2. Use plane=13 for axes 1 and 3, etc. | |
sfput | Set or override header parameters in place. Useful for correcting d1, o1, label1, etc. without touching data. | |
sfcat | Concatenate datasets along an axis. Key param: axis= (default 3). |
Filter
| Program | What it does | |
|---|---|---|
sfbandpass | Butterworth bandpass along axis 1. Key params: flo, fhi, nplo=6, nphi=6 (filter poles), phase (y=minimum-phase, n=zero-phase). | |
sfsmooth | Triangle smoothing along any axis. Key params: rect1, rect2, … (smoothing radius in samples on each axis). repeat= applies the filter multiple times. |
Transform
| Program | What it does | |
|---|---|---|
sffft1 | FFT along axis 1 (time → frequency). Key params: inv=n (forward), sym=n, opt=y (auto-pad to efficient length). | |
sffft3 | FFT along any extra axis (default axis=2). Input and output are complex. Key params: axis, pad=2 (padding factor), sym=n. | |
sfcabs | Convert complex RSF to float RSF by computing the complex magnitude. Use after sffft1/sffft3 before float-consuming programs such as sfgrey. Use sfreal for the real part only. |
Inspect
| Program | What it does | |
|---|---|---|
sfin | Print RSF header fields: n1, d1, o1, label1, … plus data-file path, element size, and a quick zero-check. | |
sfattr | Print amplitude statistics: rms, mean, 2-norm, variance, std dev, max, min, nonzero sample count. | |
sfheaderwindow | Select traces whose header key satisfies a mask. Key params: mask= (integer RSF file, nonzero = keep), inv=n. | |
sfheadermath | Apply math to trace headers. Key params: key= (header key to replace), output= (expression), segy=y. |
Plot (brief — see plotting-with-vplot skill for full coverage)
| Program | What it does | |
|---|---|---|
sfgrey | Raster (density / image) plot. Writes a vplot byte stream. | |
sfgraph | Line/graph plot. Writes a vplot byte stream. | |
sfwiggle | Wiggle-trace plot with filled lobes. Writes a vplot byte stream. |
These write vplot streams, not RSF. Use sfpen, xtpen, or pdfpen to render them, or chain into pspen for PDF output. Full parameter coverage is in the plotting-with-vplot skill.
Piping patterns
Pattern 1: Synthesize → filter → plot
The simplest end-to-end workflow: generate a synthetic impulse, apply a filter, and plot the result.
Stage-by-stage:
sfspike n1=500 d1=0.004 … k1=250— creates a single 500-sample trace
(axis 2 defaults to 1 trace) with a spike at sample 250. Spike positioning is 1-based. Omitting k1 (or setting k1=0) fills the entire trace with a constant of magnitude mag — not what you usually want for an impulse test. The axis metadata (d1, label1, unit1) flows downstream.
sfbandpass fhi=60 phase=n— zero-phase low-pass at 60 Hz.sfbandpass
reads d1 from the header to convert Hz to normalized frequency; you do not need to repeat it.
sfwiggle— renders as a wiggle plot. Axis labels and title come from
header metadata. Pipe to a viewer (xtpen, pspen > out.ps, etc.).
Pattern 2: FK spectrum
Compute the 2D Fourier transform (time → frequency, space → wavenumber) and display power.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/using-sf-programs/SKILL.md
Popularity
- Repository stars
- 349
- Repository forks
- 191
- 7-day trend score
- 29
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/ahay/src/using-sf-programs)