Skip to main content

Calculate Field Aligned Currents based on swarm data, mainly through the ViRES python interface viresclient. Some utilities for these kinds of scientific calculations are also provided.

Project description


Documentation Status PyPI Package latest release

The SwarmPyFAC package is used for calculating Geomagnetic Field-Aligned Currents based on cdf-files possibly downloaded via viresclient.

Geomagnetic Field-Aligned Currents are current systems that connect the magnetosphere to the ionosphere, and one of the fundamental interactions between these two regions. These currents, as their name suggests, flow in a direction aligned with the local magnetic field. Swarm is able to estimate these currents using the horizontal component of the magnetic field information alongside a baseline magnetic field estimation. These can then be used with Ampere’s law to determine the currents that flowing in the field-aligned direction. More detailed information on this formulation can be found in Ritter et. al. (2013).

The SwarmPyFAC package contains 2 modules:

  • swarmpyfac.fac, the main module. It contains functions to calculate field aligned currents, and related scientific steps. It is rolled into the main package, so you can call its functionality directly from there.
  • swarmpyfac.utils, the utility module. It contains functions for the underlaying mathematics, and should also be usefull for computing other products.


Using pip:

pip install swarmpyfac


  • numpy
  • cdflib
  • viresclient
  • matplotlib
  • scipy

Extra dependencies for handling the source version:

  • sphinx
  • numpydoc
  • hypothesis

Quick Start

The package handle imports of its own modules, so it is sufficient to import the base package. The different packages can be access from there:

>>> import swarmpyfac as fc
>>> fc  # count as swarmpyfac.fac
>>> fc.utils  # count as swarmpyfac.utils

Calculating the field aligned currents based on swarm data for some periode:

>>> import swarmpyfac as fc
>>> import datetime as date
>>> start = date.datetime(2016, 1, 1)
>>> end = date.datetime(2016, 1, 2)
>>> output, input_data = fc.fac_from_file(start=start, end=end, user_file=None)
>>> time, position, __, fac, *___ = output

The steps in fc.fac_from_file is broken down into other functions, which one can use and replace for their own needs.




Ritter, P., H. Lühr, and J. Rauberg (2013), Determining field-aligned currents with the Swarm constellation mission, Earth Planets Space, 65(11), 1285-1294. doi: 10.5047/eps.2013.09.006

See also: Swarm Level 2 product description: Swarm_L2_FAC_single_product_description.


The code is produced with support from ESA through the Swarm Data Innovation and Science Cluster (Swarm DISC). For more information on Swarm DISC, please visit

The project is based on the matlab program for caclulating the fac product level 2 product for the swarm mission, which is written by GFZ.


docs Documentation Status
PyPI Package latest release


Version 0.0.1: Initial version

To be decided

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

swarmpyfac-0.2.2.tar.gz (26.7 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page