Module Overview

This page is a compililation of the overviews of each of the 3 modules. First a short overview of each of the module, the long one is on other sections below:

  • 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.

swarmpyfac.fac module

The fac module is used for calculated field alligned currents.

This module contains functions used to calculated field alligned currents, and some of the components used in the calculations. This module is dependent on the swarm_util module, which contains functions for utilities and some of the more general components needed.

This module currently only allows caluculation of the single satelite version of the FAC product, and it uses data available from viresclient’s python client or another data source with similar format. The major difference between this and the official ESA product, is that the input from models are their effects at each measurement point, since this is the format delivered by viresclient.

This means that there is a small algorithmic difference compared to what is used in the official ESA products, though experimental comparison have found the difference to be less than 1.2*10^(-4) micro A/m^2, and the average difference to be less than 1% of this.

Running this module as a script will (outside of running some tests) perform the default experiment.

Overview

This section lists each of the functions in this module, and give a short description of them. You can use this as an easier way to look up what you might need.

split_models

Takes measurements and up to several models, and returns the combined model and the residual on the measurements.

radial_current

Calculate the radial currents for time-like series.

single_sat_fac

Calculate the field alligned currents for a single satelinte on time-like series.

single_sat_fac_full

Like single_sat_fac, but it handles input from a dictionary, and can figure out which models are pressent itself.

fetch_data

Fetch the data needed, and can figure out itself whether it needs to download it first.

fac_from_file

Do the entire single satelite field alligned currents calculations, but takes a possible file as input the same way as fetch_data.

Examples

>>> from pyfac.fac import fac_from_file  
>>> import datetime as date
>>> results, input_data = fac_from_file(
...     start=date.datetime(2017, 4, 11),
...     end=date.datetime(2017, 4, 12),
...     force_download=True)  
>>> lat, fac = results[1][:, 0], results[3]  

swarmpyfac.utils module

The swarm_util module provides a host of utilities function.

This module stores a vararity of different functions and constants, which is deemed general usefull when working on swarm data, specifically when such data is loaded from the viresclient python client.

There is a mix of general constants, such as the permuability of vacum, and different types of functions. The functions can generally be categorised into twi types: Functions for working on arrays of scalars or vectors, and functions to work with viresclient. These categories have their own sections, with a short descriptions on each.

Array Utilities

These functions are used to work on numpy arrays of scalars or vectors. They are mostly geared toward dealign with time-like series.

pack_3d

Take 3 equaly long arrays of scalars and make an array of 3d vectors.

as_3d

Like pack_3d, but uses dublicates of the same array of scalars. Usefull for aggregating scalar-vector operations over an array.

map_3d

A map function over arrays of 3d vectors, where the function maped takes a 3d vector to a 3d vector.

NEC_to_VSC

Build a transformation from the NEC frame to the VSC frame. The return is a function, which will transfrom its input from the NEC frame to the VSC frame.

delta

Calculate the changes of a time-like series.

means

Calculate the intermediate value (by linear interpolation) for a time-like series.

spherical_delta

Calculate the changes in spherical coordinates as NEC frame vectors.

curl

Calculate a single component of curl for an array of vectors.

inclination

Calculate the inclination for an awway of vectors.

Viresclient

These are the functions related to fetching and loading data from the viresclient python client.

request_data

Builds and send a request for a CDF file to vires. Most usefull for defaulting all the relevant parameters.

read_cdf

A function to read a cdf file based on a dictionary pairing of attributes you want to read from the cdf file, and what you want to refere to them as afterwards.