Skip to main content

Python interface for space weather indices

Project description


Python interface for space weather indices

builds docs package wheel pyversions codecov coveralls scrutinizer

This python module interfaces the space weather indices available at It includes the geomagnetic Ap and Kp indices, both the 3h values and the daily sum/averages. The data also include the solar f10.7 cm radio fluxes, the observed values as well as the 1 AU adjusted values, daily values and the 81-day running means. The data sources and file format are described at (see file_format.txt for a local copy of the format description).

:warning: This package is in alpha stage, that is, it may or may not work, and the interface might change in future versions.

Documentation is available at



  • numpy - required
  • pytest, pytest-mock - optional, for testing


An experimental pip package called spaceweather is available from the main package repository, and can be installed with:

$ pip install spaceweather

The latest development version can be installed with pip directly from github (see and

$ pip install [-e] git+

The other option is to use a local clone:

$ git clone
$ cd pyspaceweather

and then using pip (optionally using -e, see

$ pip install [-e] .

or using

$ python install

Optionally, test the correct function of the module with

$ py.test [-v]

or even including the doctests in this document:

$ py.test [-v] --doctest-glob='*.md'


The python module itself is named spaceweather and is imported as usual. This module provides mainly two functions sw_daily() for the daily data as available from the website, and ap_kp_3h() for the 3h Ap and Kp values. Both functions return pandas.DataFrames. The index data file can be updated on request by calling update_data(), when the data available in the packaged version are too old.

>>> import spaceweather as sw
>>> df_d = sw.sw_daily()
>>> df_d.loc["2000-01-01"].Apavg
>>> df_3h = sw.ap_kp_3h()
>>> df_3h.loc["2000-01-01 01:30:00"]
Ap    56.0
Kp     5.3
Name: 2000-01-01 01:30:00, dtype: float64
>>> # All 3h values for one day
>>> df_3h.loc["2000-01-01"]
                     Ap   Kp
2000-01-01 01:30:00  56  5.3
2000-01-01 04:30:00  39  4.7
2000-01-01 07:30:00  27  4.0
2000-01-01 10:30:00  18  3.3
2000-01-01 13:30:00  32  4.3
2000-01-01 16:30:00  15  3.0
2000-01-01 19:30:00  32  4.3
2000-01-01 22:30:00  22  3.7

Basic class and method documentation is accessible via pydoc:

$ pydoc spaceweather


This python interface is free software: you can redistribute it or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2 (GPLv2), see local copy or online version.

The original data can be found at and is included with kind permission from Dr. T.S. Kelso at celestrak, for details see the included file.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for spaceweather, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size spaceweather-0.0.2-py2.py3-none-any.whl (892.7 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size spaceweather-0.0.2.tar.gz (874.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page