Skip to content

RyanHaotianPang/RFSelector

Repository files navigation

RFSelector

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.

Features

  • 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

Installation

Requirements

  • Python 3.7+
  • NumPy
  • Matplotlib
  • ObsPy

Install Dependencies

pip install numpy matplotlib obspy

Or use the provided requirements file:

pip install -r requirements.txt

Clone Repository

git clone https://github.com/yourusername/RFSelector.git
cd RFSelector

Quick Start

  1. 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.
  2. Run the program:

    python rf_selector.py
  3. Select receiver functions:

    • Click on traces to toggle selection (red/blue = selected, gray = deselected)
    • Use keyboard shortcuts (see below)
    • Press w to save selected traces
    • Press q to move to next station

Keyboard Shortcuts

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

Configuration Parameters

Edit the Config class in rf_selector.py to customize:

Directory Settings

  • BASE_DIR: Input directory containing station folders
  • OUT_DIR: Output directory for selected RFs
  • STATIONS: List of station names to process
  • PATTERN: File pattern (e.g., ".sac", ".eqr")

Timing Parameters

  • 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)

Display Settings

  • GAIN: Initial amplitude gain factor (can be adjusted with +/- keys)
  • FIGSIZE: Figure size in inches (width, height)
  • SORT_BY: Initial sorting ('baz' or 'distance')

Visual Appearance

  • FILL_ALPHA_KEEP: Transparency for selected traces
  • FILL_ALPHA_DROP: Transparency for deselected traces
  • COLOR_POSITIVE: Color for positive amplitudes
  • COLOR_NEGATIVE: Color for negative amplitudes

File Structure

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

Input Data Format

RFSelector expects receiver functions organized as:

BASE_DIR/
├── STATION1/
│   ├── file1.sac
│   ├── file2.sac
│   └── ...
├── STATION2/
│   ├── file1.sac
│   └── ...
└── ...

Required Header Information

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

Example Data

See example_data/README.md for instructions on downloading publicly available receiver function data from IRIS DMC or other sources.

Workflow

  1. Prepare Data: Organize receiver functions in station folders
  2. Configure: Set paths and parameters in Config class
  3. Run: Execute python rf_selector.py
  4. Select: Use mouse and keyboard to select quality RFs
  5. Save: Press w to save selected traces
  6. Repeat: Program automatically moves to next station

Tips for Selection

  • 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

About

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.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages