Skip to main content

Python interface for space weather indices

Project description

PySpaceWeather

Python interface for space weather indices

builds docs package wheel pyversions codecov coveralls scrutinizer

This python module interfaces the space weather indices available at https://celestrak.com/SpaceData/. 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 http://celestrak.com/SpaceData/SpaceWx-format.php (see file_format.txt for a local copy of the format description).

:warning: This package is in beta stage, that is, it works for the most part and the interface should not change (much) in future versions.

Documentation is available at https://pyspaceweather.readthedocs.io.

Install

Requirements

  • numpy - required
  • pandas - required
  • requests - required for updating the data files
  • pytest, pytest-mock - optional, for testing

spaceweather

A 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 https://pip.pypa.io/en/stable/reference/pip_install/#vcs-support and https://pip.pypa.io/en/stable/reference/pip_install/#git):

$ pip install [-e] git+https://github.com/st-bender/pyspaceweather.git

The other option is to use a local clone:

$ git clone https://github.com/st-bender/pyspaceweather.git
$ cd pyspaceweather

and then using pip (optionally using -e, see https://pip.pypa.io/en/stable/reference/pip_install/#install-editable):

$ pip install [-e] .

or using setup.py:

$ python setup.py 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'

Usage

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
30.0
>>> 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

License

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 https://celestrak.com/SpaceData/ and is included with kind permission from Dr. T.S. Kelso at celestrak, for details see the included COPYING.data file.

Project details


Download files

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

Source Distribution

spaceweather-0.1.0.tar.gz (872.7 kB view details)

Uploaded Source

Built Distribution

spaceweather-0.1.0-py2.py3-none-any.whl (892.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file spaceweather-0.1.0.tar.gz.

File metadata

  • Download URL: spaceweather-0.1.0.tar.gz
  • Upload date:
  • Size: 872.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.1

File hashes

Hashes for spaceweather-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ea29b537ada02b73297695e24b7bfe9f85b9c30b9920d3d02c7ea456c21a814c
MD5 36450f8018b843b4d28c99dac7315652
BLAKE2b-256 fadd09fe563c1dda80693352e47739525fbddeddbd14341db4a3e5056a55b384

See more details on using hashes here.

File details

Details for the file spaceweather-0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: spaceweather-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 892.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.1

File hashes

Hashes for spaceweather-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7dc5ac301014071aeca6a140d784a90af754afd0b4ad681b74409bdb145fda7b
MD5 4b4d01587c7cbef0b3bfa7459707dcd2
BLAKE2b-256 6928bbefe717731a14120c45f163a68255a09e6c35c58944a141a5e6f665f6d0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page