🌞 Using HAPI

🌞 Using HAPI¢

Abstract: An overview of using HAPI to access Swarm data, and using hapiclient within the VRE. HAPI has been added to the VirES server as an alternative interface to the main VirES API. The Heliophysics Application Programming Interface (HAPI) is a community specification of a unified interface for accessing data time-series. VirES for Swarm acts as a HAPI server and allows access to selected datasets via the HAPI interface. This enables more interoperability with other analysis tools.

Learn more about HAPI

Only a few Swarm datasets are currently available through HAPI, but more will be available soon. HAPI is a more limited interface than the full VirES API so there is no access to special VirES features like magnetic model handling, resampling, and filtering.

Data is available at simple endpoints following /hapi/ and the interface is open so there is no authentication needed. For example:

!curl 'https://vires.services/hapi/data?dataset=SW_OPER_MAGA_LR_1B&parameters=Latitude,B_NEC&start=2013-11-25T11:02:52Z&stop=2013-11-25T11:03:02Z&format=csv'
2013-11-25T11:02:52.000Z,72.3503963,6308.8066,2347.5995000000003,45294.4964

2013-11-25T11:02:53.000Z,72.4134067,6283.5805,2344.415,45301.3983

2013-11-25T11:02:54.000Z,72.4764126,6259.3858,2341.6279,45309.266200000005

2013-11-25T11:02:55.000Z,72.5394141,6235.4103000000005,2338.6261,45317.1184

2013-11-25T11:02:56.000Z,72.6024111,6211.547500000001,2335.5979,45324.948000000004

2013-11-25T11:02:57.000Z,72.6654035,6188.0046,2332.0260000000003,45332.657

2013-11-25T11:02:58.000Z,72.7283913,6163.871300000001,2329.7936,45340.4164

2013-11-25T11:02:59.000Z,72.7913744,6139.6804,2327.0847,45348.1256

2013-11-25T11:03:00.000Z,72.8543528,6116.3845,2322.4503,45355.7724

2013-11-25T11:03:01.000Z,72.9173265,6092.4445000000005,2319.9843,45363.4006

Quickstart with hapiclientΒΆ

hapiclient is a Python client that interfaces with HAPI servers. It can be used like:

from hapiclient import hapi

server     = 'https://vires.services/hapi';
dataset    = 'SW_OPER_MAGA_LR_1B';
parameters = 'Latitude,B_NEC'; 
start      = '2013-11-25T11:02:52Z';
stop       = '2013-11-25T11:03:02Z';

data, meta = hapi(server, dataset, parameters, start, stop)

Data and metadata are returned separately as a NumPy Structured Array and dictionary.

data["Timestamp"]
array([b'2013-11-25T11:02:52.000Z', b'2013-11-25T11:02:53.000Z',
       b'2013-11-25T11:02:54.000Z', b'2013-11-25T11:02:55.000Z',
       b'2013-11-25T11:02:56.000Z', b'2013-11-25T11:02:57.000Z',
       b'2013-11-25T11:02:58.000Z', b'2013-11-25T11:02:59.000Z',
       b'2013-11-25T11:03:00.000Z', b'2013-11-25T11:03:01.000Z'],
      dtype='|S24')
data["B_NEC"]
array([[ 6308.8066,  2347.5995, 45294.4964],
       [ 6283.5805,  2344.415 , 45301.3983],
       [ 6259.3858,  2341.6279, 45309.2662],
       [ 6235.4103,  2338.6261, 45317.1184],
       [ 6211.5475,  2335.5979, 45324.948 ],
       [ 6188.0046,  2332.026 , 45332.657 ],
       [ 6163.8713,  2329.7936, 45340.4164],
       [ 6139.6804,  2327.0847, 45348.1256],
       [ 6116.3845,  2322.4503, 45355.7724],
       [ 6092.4445,  2319.9843, 45363.4006]])

For more help, see: