HAPI - CSA Guide
HAPI: Heliophysics Application Programmer's Interface
Introduction
The Heliophysics Application Programmer's Interface (HAPI) facilitates simplified access to distributed time series data for research in Heliophysics. A few simple lines can retrieve standardised output from hundreds of datasets covering tens of missions. HAPI servers supply thousands of datasets, retrievable quickly and easily in very few lines of code, allowing the analysis and science to start!
See this real use case below
Why so HAPI?
Simple:
The easiest way to demonstrate the power of HAPI is the number of lines of Python code (10!) it takes to retrieve CSA data in a standardised format and plot it →
This example (which uses hapiplot to plot very quickly), OMNI, Swarm and plotting CSA data with Matplotlib are given in this Jupyter Notebook
Data can also be plotted directly from the server page, e.g., https://hapi-server.org/servers/#server=CSA&dataset=C4_CP_WHI_PASSIVE_ACTIVE¶meters=time_tags&start=2022-12-31T18:00Z&stop=2022-12-31T19:00Z&return=image&format=hapiplot&style=svg
ADAPTABLE
Clients are available in IDL, Javascript, Java, MATLAB, and Python clients from the github page https://github.com/hapi-server
Huge amounts of data:
There are 9 servers (see https://hapi-server.org/servers/), providing thousands of datasets, all retrievable in the same simple way:
Servers and number of datasets:
-
SSCWeb: 272
-
CDAWeb: 3042
-
INTERMAGNET: 2887
-
CCMC_ISWA: 271
-
LISIRD: 29
-
AMDA: 905
-
VirES for Swarm: 101
-
Helioviewer: 79
-
Cluster Science Archive: 1989
Python Demo page & documentation
Using the Python client, these lines are all that is needed to retrieve and plot CSA data:
from hapiclient import hapi
from hapiplot import hapiplot
server = 'https://csatools.esac.esa.int/HapiServer/hapi'
dataset = 'C4_CP_FGM_SPIN'
start = '2014-04-22T03:00:00'
stop = '2014-04-22T06:30:00'
parameters = 'B_vec_xyz_gse'
opts = {}
# Get data
csadata, csameta = hapi(server, dataset, parameters, start, stop, **opts)
# Plot all parameters
hapiplot(csadata, csameta)
Autoplot
Autoplot can access the HAPI servers directly. Just go to File > Add Plot From > hapi...
Use Case - quick Access
During a presentation, the speaker said that the data in the plot covered 8 minutes, while the plot itself appeared to show 8 hours. Rather than download and plot the data to be sure for the minutes, simply went to https://hapi-server.org/servers, entered one of the datasets plotted and the times shown on the plot, and they agree: