Space Weather#

Plotting the \(K_p\), \(A_p\), and F10.7 space weather indices

import datetime
import os

import matplotlib.pyplot as plt
import pandas as pd

import mirage as mr
import mirage.vis as mrv

Loading the space weather file and extracting the dates and indices

urls_and_dirs = {
    'https://celestrak.org/SpaceData/SW-Last5Years.csv': os.environ['DATADIR']
}

for url, dir in urls_and_dirs.items():
    mr.save_file_from_url(url, dir)

sw_file_path = os.path.join(os.environ['DATADIR'], 'SW-Last5Years.csv')
sw_df = pd.read_csv(sw_file_path, header=0)
dates = [datetime.datetime.strptime(x, '%Y-%m-%d') for x in sw_df['DATE']]
f107_1au = sw_df['F10.7_ADJ']
f107_obs = sw_df['F10.7_OBS']
ap = sw_df['AP_AVG']
kp = sw_df['KP_SUM']
SW-Last5Years.csv |████████████████████████████████████████| 257772/257772 [100%] in 0.3s (946974.56/s)

Plotting F10.7 radio flux

plt.scatter(dates, f107_1au, s=1)
plt.scatter(dates, f107_obs, s=1)
mrv.texit('F10.7 Radio Flux', 'Date', 'F10.7', ['1 AU', 'Observed'])
plt.show()
F10.7 Radio Flux

Plotting the geomagnetic index \(K_p\)

plt.scatter(dates, ap, s=1)
mrv.texit('Equivalent Amplitude $A_p$', 'Date', '$A_p$')
plt.show()
Equivalent Amplitude $A_p$

Plotting the geomagnetic index \(K_p\)

plt.scatter(dates, kp, s=1)
mrv.texit('Range Index $K_p$', 'Date', '$K_p$')
plt.show()
Range Index $K_p$

Reference for the CSV format found at CelesTrak

Total running time of the script: (0 minutes 1.379 seconds)

Gallery generated by Sphinx-Gallery