This package analyzes geometric and temporal intersections between Coronal Mass Ejections (CMEs) and Interplanetary Scintillation (IPS) lines of sight. It identifies when CME structures intersect with IPS observation paths and validates these intersections using CME propagation models.
The analysis consists of two main components:
-
Intersection Detection (
cme_ips_intersection.py): Finds geometric intersections between CME cones and IPS lines of sight, then validates them using a drag-based CME propagation model. -
Data Extraction (
extract_intersection_data.py): Extracts detailed CME and IPS information for all detected intersections and generates comprehensive output files.
- 3D Geometric Intersection: Detects cone-line intersections in 3D space using robust computational geometry algorithms
- CME Propagation Modeling: Validates intersections using a drag-based model with configurable solar wind parameters
- Directional Filtering: Processes East and West solar elongations separately
- Temporal Validation: Ensures intersection timing is physically consistent with CME propagation
- Flexible Configuration: All parameters controlled through a centralized config file
- Python 3.7 or higher
- pip package manager
-
Clone or download this repository
-
Install required packages:
pip install -r requirements.txt
-
Ensure your data files are in the correct locations (see Configuration section)
All analysis parameters are defined in config.py. Edit this file to customize the analysis for your data:
# Input files
IPS_CATALOG_FILE = "source_catalog.fits" # IPS source catalog
CME_CATALOG_PATH = "../data/CME/seeds/cmecat_{month:02d}.txt" # CME catalog pattern
# Output
OUTPUT_DIR = "cme_ips_intersect_results_5hrs" # Results directory
# CME Propagation Model
DRAG_COEFFICIENT = 0.2e-7 # km^-1
SOLAR_WIND_SPEED = 400 # km/s
MAX_PROPAGATION_TIME = 100 # hours
# Intersection Parameters
CONE_HEIGHT_MIN = 0.0 # AU
CONE_HEIGHT_MAX = 2.0 # AU
TIME_WINDOW = 5 # hours (intersection validation tolerance)
# Timezone
TIMEZONE_OFFSET = 5.5 # hours (IST = UTC + 5.5)- IPS_CATALOG_FILE: Path to FITS file containing IPS source catalog with columns: source_name, mjd, elongation, ra, dec
- CME_CATALOG_PATH: Path template for monthly CME catalogs (use
{month:02d}as placeholder) - OUTPUT_DIR: Directory where intersection results will be saved
- DRAG_COEFFICIENT: Gamma parameter in CME drag equation (units: km^-1)
- SOLAR_WIND_SPEED: Background solar wind speed (units: km/s)
- TIME_WINDOW: Maximum time difference allowed between predicted and observed intersection times (hours)
- CONE_HEIGHT_MIN/MAX: CME cone extent along axis direction (units: AU)
Run the main intersection analysis:
python cme_ips_intersection.pyThis script will:
- Load CME and IPS catalogs for all available months
- Filter by East/West elongation directions
- Detect geometric intersections between CME cones and IPS lines of sight
- Validate intersections using CME propagation model
- Save results to text files in the output directory
Output: Files named cme_ips_intersections_month{MM}_{direction}.txt containing:
CME_Index IPS_Index Duration_Hours Time_Diff_Hours
After finding intersections, extract detailed information:
python extract_intersection_data.pyThis script will:
- Read intersection result files
- Extract CME properties (position angle, angular width, velocity, acceleration)
- Extract IPS properties (source name, position, elongation)
- Generate detailed combined tables
Output: Multiple files per month/direction:
month{MM}_{direction}_cme_data.txt: CME event detailsmonth{MM}_{direction}_ips_data.txt: IPS observation detailsmonth{MM}_{direction}_detailed_intersections.txt: Combined intersection datamonth{MM}_{direction}_detailed_intersections.csv: CSV format for analysis
Required columns:
source_name: Source identifier (string)mjd: Modified Julian Date of observation (float)elongation: Solar elongation in degrees (float, positive=East, negative=West)ra: Right ascension in degrees (float)dec: Declination in degrees (float)
Space-separated columns:
date: Date in YYYY/MM/DD or YYYY-MM-DD formattime: Time in HH:MM:SS formatnframe: Number of frames (integer)pa: Position angle in degrees (float, 0-360)da: Half angular width in degrees (float)vel: Velocity in km/s (float)acc: Acceleration in m/s^2 (float)
The code implements a robust cone-line intersection algorithm:
- CME represented as a finite cone with vertex at Sun's position
- IPS line of sight from Earth through the P-point (closest approach to Sun)
- 3D intersection computed using quadratic equation solving
- Handles all edge cases (point, segment, ray intersections)
Uses a drag-based differential equation:
dR/dt = s
ds/dt = -γ(s - ω)|s - ω|
Where:
- R: distance from Sun (km)
- s: CME velocity (km/s)
- γ: drag coefficient
- ω: solar wind speed
An intersection is valid if:
- Geometric intersection exists
- CME arrives at intersection distance within
TIME_WINDOWof IPS observation - Timing consistent with CME propagation model
# CME-IPS Intersection Results
# Month: MM, Elongation: EAST/WEST
# Columns: CME_Index IPS_Index Duration_Hours Time_Diff_Hours
0 5 12.3456 14.2345
1 7 15.6789 16.7890
...
Combined data with CME and IPS properties:
- CME: datetime, position angle, angular width, velocity, acceleration
- IPS: datetime, source name, elongation, RA, Dec
- Intersection: duration, time difference
- ICRS: International Celestial Reference System (barycentric)
- GCRS: Geocentric Celestial Reference System (geocentric)
- All coordinates transformed consistently through astropy
- Processing time depends on number of CME and IPS events
- Typical runtime: ~1-5 minutes per month (varies with data density)
- Progress bars display real-time status
- Results cached in output directory
- FileNotFoundError: Check paths in
config.pymatch your data structure - Import errors: Ensure all packages installed:
pip install -r requirements.txt - Empty results: Verify TIME_WINDOW and other parameters are appropriate for your data
- SIMBAD timeouts: Internet connection required for source coordinate queries
To enable verbose SIMBAD queries, set in config.py:
SIMBAD_VERBOSE = TrueIf you use this code in your research, please cite:
[Your citation information here]
[Your license information]
For questions or issues, please contact: [Your contact information]
This analysis uses: