Skip to content

nghn0/SolarCycle-analysis_and_prediction

Repository files navigation

SolarCycle Analysis & Prediction

AI LSTM Time Series Space Weather

Sunspot Cycle Insights + LSTM Time-Series Forecasting

This project performs an end-to-end analysis of solar sunspot cycles and builds an LSTM-based forecasting model to predict future Solar Sunspot Numbers (SSN).
It combines scientific visualization, time-series pattern discovery, and deep learning forecasting to better understand solar activity and its impact on space weather.


⭐ Why This Project Matters

Solar cycles are approximately 11-year cycles where the Sun’s magnetic activity fluctuates, influencing:

  • Satellite operations
  • Communication systems
  • Navigation signals
  • Power grid stability (space weather impact)

This repository demonstrates both interpretation (analysis) and prediction (modeling) using real historical SSN trends.


🎯 Objectives

  • Visualize long-term sunspot activity patterns
  • Compare SSN with correlated solar indicators
  • Study cyclic behavior, lag patterns, and seasonality
  • Forecast SSN values using an LSTM neural network
  • Evaluate forecasting quality using MAE and visualization

📥 Dataset

This project uses historical Sunspot Number data from the Kaggle dataset:

🔗 Sunspots Dataset:
https://www.kaggle.com/datasets/robervalt/sunspots

📊 About the Dataset

The dataset contains:

  • Monthly sunspot numbers from 1700s to present
  • Used for studying solar magnetic activity cycles
  • Ideal for time-series analysis and forecasting

📊 Sunspot Cycle Analysis (Exploratory Insights)

1) Historical Sunspot Cycle (1749–2021)

Sunspot Cycle Over Time

  • Cyclical pattern repeats roughly every 11 years
  • A full cycle can range from 9 to 14 years
  • Each cycle transitions through:
    • Solar MinimumSolar MaximumSolar Minimum

2) Comparing Radio Flux with Sunspot Number

Sunspot vs Radio Flux

  • Sunspot Number: direct indicator of solar magnetic activity
  • 10.7 cm Radio Flux: indirect measure via radio energy emission

Both rise and fall together, showing a strong correlation.


3) Comparing Polar Field with Sunspot Number

Polar Field vs Sunspot

This plot highlights an inverse relationship and supports the concept of magnetic polarity reversal approximately every 11 years.


4) Seasonality and Lag Analysis

Lag & Seasonality

Lag plots show the series is not random, meaning it contains strong predictive structure.
Key historical behavior includes:

  • Dip around 1790–1820Dalton Minimum
  • Major peak around 1960, followed by fluctuations

5) Comparing Total Solar Irradiance (TSI) with Sunspot Numbers

TSI vs Sunspot

A positive correlation is observed:

  • Higher sunspot activity → higher solar irradiance

6) Asymmetry and Long-Term Seasonality

Asymmetry Heatmap

The heatmap suggests:

  1. Short-term ~11-year solar cycle
  2. Long-term ~100-year brightness cycle

🔮 Solar Sunspot Number Forecasting with LSTM

This module uses a Long Short-Term Memory (LSTM) neural network to forecast SSN values from historical time-series data.

Key Steps

  • MinMax Scaling for stable neural training
  • Lag Feature Engineering using 16 time steps
  • 3-layer LSTM architecture with 32 units per layer
  • Callbacks
    • Learning rate reduction on plateau
    • Early stopping to reduce overfitting
  • Evaluation using Mean Absolute Error (MAE)

🧠 Model Summary

  • Model Type: LSTM (Time-Series Forecasting)
  • Lag Window: 16 steps
  • Loss Function: Mean Squared Error (MSE)
  • Optimizer: Adam
  • Output: Next-step SSN prediction

📈 Results

  • Baseline MAE: (update with your value)
  • LSTM MAE: 13.29 (inverse transformed)

Prediction vs Actual Plot


🗂️ Repository Contents

SolarCycle-analysis_and_prediction/
│
├── solorcycle_analysis.ipynb          # Full solar cycle analysis notebook
├── Lstm_sunspot_predict_model.ipynb   # LSTM forecasting notebook
├── image1.png                         # Historical SSN cycle plot
├── image2.png                         # SSN vs Radio Flux
├── image3.png                         # Polar Field vs SSN
├── image4.png                         # Lag & Seasonality plots
├── image5.png                         # TSI vs SSN
├── image6.png                         # Asymmetry heatmap
├── prediction_plot.png                # LSTM prediction vs actual
└── README.md

⚙️ Requirements

  • Python 3.x
  • Libraries:
    • NumPy
    • Pandas
    • Matplotlib
    • scikit-learn
    • statsmodels
    • TensorFlow / Keras

Install dependencies:

pip install numpy pandas matplotlib scikit-learn statsmodels tensorflow

▶️ How to Run

Option 1: Run in Jupyter / Colab

  1. Open solorcycle_analysis.ipynb and run all cells
  2. Open Lstm_sunspot_predict_model.ipynb and run all cells

Option 2: Local Execution

jupyter notebook

🔍 Conclusion

This project shows that sunspot data contains strong cyclic patterns, meaningful relationships with solar indicators, and clear forecasting potential.
By combining analysis + LSTM prediction, it provides a strong foundation for extending solar forecasting using more advanced deep learning and hybrid time-series methods.


🚀 Future Improvements

  • Experiment with different lag lengths
  • Try alternative architectures (GRU, ConvLSTM)
  • Add exogenous features (radio flux, polar field, TSI)
  • Perform hyperparameter tuning (Optuna / KerasTuner)
  • Multi-step forecasting (predict multiple months ahead)

👨‍💻 Author

Nithish Gowda H N - BTech(Hons.) CSE, AI & ML Major

Prajna - BTech(Hons.) CSE, Cloud & Full Stack Major

About

Sunspot cycle analysis and SSN forecasting using LSTM.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors