Interactive Receiver Function Selection Tool
A Python-based GUI tool for visually selecting and filtering teleseismic receiver functions. RFSelector allows users to interactively browse receiver functions, toggle selection with mouse clicks, and adjust display parameters in real-time.
- Interactive Selection: Click on individual receiver functions to toggle selection
- Real-time Mean Calculation: Automatically updates the stacked mean as you select/deselect traces
- Flexible Sorting: Sort receiver functions by back-azimuth or epicentral distance
- Adjustable Display: Change gain/amplification on-the-fly with keyboard shortcuts
- Batch Processing: Process multiple stations sequentially
- Keyboard Shortcuts: Efficient workflow with intuitive keyboard commands
- Multiple File Formats: Supports SAC, miniSEED, and other ObsPy-compatible formats
- Python 3.7+
- NumPy
- Matplotlib
- ObsPy
pip install numpy matplotlib obspyOr use the provided requirements file:
pip install -r requirements.txtgit clone https://github.com/yourusername/RFSelector.git
cd RFSelector-
Configure paths in
rf_selector.py:class Config: BASE_DIR = "path/to/your/receiver_functions" OUT_DIR = "path/to/output/selected_RFs" STATIONS = ["STATION1", "STATION2", "STATION3"] PATTERN = "*.sac" # or "*.eqr", "*.mseed", etc.
-
Run the program:
python rf_selector.py
-
Select receiver functions:
- Click on traces to toggle selection (red/blue = selected, gray = deselected)
- Use keyboard shortcuts (see below)
- Press
wto save selected traces - Press
qto move to next station
| Key | Action |
|---|---|
| Click | Toggle trace selection |
| w | Save selected traces and move to next station |
| q | Quit current station without saving |
| r | Restore all traces (select all) |
| c | Clear all traces (deselect all) |
| + or = | Increase gain (amplification) |
| - | Decrease gain |
| b | Sort by back-azimuth |
| d | Sort by distance |
Edit the Config class in rf_selector.py to customize:
BASE_DIR: Input directory containing station foldersOUT_DIR: Output directory for selected RFsSTATIONS: List of station names to processPATTERN: File pattern (e.g., ".sac", ".eqr")
P_ARRIVAL_ABS: Absolute time of P-wave arrival (seconds)T_BEFORE: Time window before P to display (seconds)T_AFTER: Time window after P to display (seconds)
GAIN: Initial amplitude gain factor (can be adjusted with +/- keys)FIGSIZE: Figure size in inches (width, height)SORT_BY: Initial sorting ('baz' or 'distance')
FILL_ALPHA_KEEP: Transparency for selected tracesFILL_ALPHA_DROP: Transparency for deselected tracesCOLOR_POSITIVE: Color for positive amplitudesCOLOR_NEGATIVE: Color for negative amplitudes
RFSelector/
├── rf_selector.py # Main program
├── README.md # This file
├── requirements.txt # Python dependencies
├── LICENSE # MIT License
├── docs/
│ └── USER_GUIDE.md # Detailed user guide
└── example_data/
└── README.md # Instructions for obtaining example data
RFSelector expects receiver functions organized as:
BASE_DIR/
├── STATION1/
│ ├── file1.sac
│ ├── file2.sac
│ └── ...
├── STATION2/
│ ├── file1.sac
│ └── ...
└── ...
Each receiver function file should contain:
- Time series data: Receiver function amplitude
- Timing: Either starting time or P-arrival marker
- Back-azimuth (optional): For sorting by BAZ
- Epicentral distance (optional): For sorting by distance
Supported header keys:
- Back-azimuth:
baz,back_azimuth,backazimuth(SAC or ObsPy stats) - Distance:
gcarc,dist,distance,epicentral_distance
See example_data/README.md for instructions on downloading publicly available receiver function data from IRIS DMC or other sources.
- Prepare Data: Organize receiver functions in station folders
- Configure: Set paths and parameters in
Configclass - Run: Execute
python rf_selector.py - Select: Use mouse and keyboard to select quality RFs
- Save: Press
wto save selected traces - Repeat: Program automatically moves to next station
- Look for coherent patterns across multiple RFs
- Remove outliers with unusual amplitudes or timing
- Check the mean trace (black line) for quality
- Use sorting to identify azimuthal variations
- Adjust gain if traces are too small/large to evaluate