WARNING! THIS PACKAGE IS IN ACTIVE DEVELOPMENT AND IS NOT YET STABLE!

Analysis of Cluster data

Analysis of Cluster data#

In this example we will access Cluster data via a HAPI server (not from VirES)

For more information about HAPI, see http://hapi-server.org/

import datetime as dt

from swarmpal.io import create_paldata, PalDataItem
from swarmpal.toolboxes import tfa

Fetching data#

We can access HAPI data in an almost identical way as from VirES, instead using PalDataItem.from_hapi.

Here we will use the AMDA service to get the data. This might change in the future.

Available HAPI data can be browsed at http://hapi-server.org/servers, to quickly look at the data or to generate code snippets using the Python hapiclient package - the inputs to hapiclient can be used in PalDataItem.from_hapi (hapiclient is used underneath within SwarmPAL). For example:

data_params = dict(
    server="http://amda.irap.omp.eu/service/hapi",
    dataset="clust3-fgm-prp",
    parameters="c3_b_gse",
    start="2015-03-29T17:00:00",
    stop="2015-03-29T19:00:00",
    pad_times=(dt.timedelta(hours=3), dt.timedelta(hours=3)),
)
data = create_paldata(PalDataItem.from_hapi(**data_params))
print(data)
DataTree('paldata', parent=None)
└── DataTree('clust3-fgm-prp')
        Dimensions:   (Time: 6839, c3_b_gse_dim1: 3)
        Coordinates:
          * Time      (Time) datetime64[ns] 2015-03-29T14:00:02.868000 ... 2015-03-29...
        Dimensions without coordinates: c3_b_gse_dim1
        Data variables:
            c3_b_gse  (Time, c3_b_gse_dim1) float64 25.18 143.9 -123.6 ... 60.72 -36.98
        Attributes:
            PAL_meta:  {"analysis_window": ["2015-03-29T17:00:00", "2015-03-29T19:00:...
/home/docs/checkouts/readthedocs.org/user_builds/swarmpal/envs/latest/lib/python3.11/site-packages/hapiclient/hapitime.py:287: UserWarning: The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.
  Time = pandas.to_datetime(Time, infer_datetime_format=True).tz_convert(tzinfo).to_pydatetime()

Processing#

p1 = tfa.processes.Preprocess()
p1.set_config(
    dataset="clust3-fgm-prp",
    timevar="Time",
    active_variable="c3_b_gse",
    active_component=2,
    sampling_rate=1 / 4,
)
p2 = tfa.processes.Clean()
p2.set_config(
    window_size=300,
    method="iqr",
    multiplier=1,
)
p3 = tfa.processes.Filter()
p3.set_config(
    cutoff_frequency=0.1,
)
p4 = tfa.processes.Wavelet()
p4.set_config(
    min_frequency=1,
    max_frequency=25,
    dj=0.1,
)

p1(data)
p2(data)
p3(data)
p4(data);

Plotting#

tfa.plotting.quicklook(data, extra_x=None);
../../_images/e1e3edbf390524b32b10a052cf03db823094cd2c83be6a618631005d022bd56b.png