Space Physics made EASY: one function for in-situ space physics data.
import speasy as spz ace_mag = spz.get_data("amda/imf", "2016-6-2", "2016-6-5") ace_mag.plot();
That's it. Three lines, and you have three days of ACE magnetic field data, with time, units and labels. The same call works for tens of thousands of products from many data centers.
- One call for many archives. AMDA, CDAWeb, ESA's Cluster Science Archive, SSCWeb, CDPP 3DView, the U. Iowa ephemeris tool, every server of the HAPI server list, and your own archives described in a YAML file. See the data providers page.
- Find data by tab-completion. Browse
spz.inventories.tree.<provider>in IPython or Jupyter, down to each product. - Fast on the second request. Data is cached on your disk, and a community cache server speeds up the first one.
- Reproducible studies. A
DataIndexkeeps exactly the data a study used. It never expires, works offline, and exports as a single file to share with a colleague. - Fits the tools you already use. Numpy functions work directly on Speasy variables, and they convert to pandas, xarray and astropy.
- Your own products. Register a Python function as a virtual product, and use it like any other product.
- Also from the shell, and from Julia. A
speasycommand downloads, converts and pre-fetches data. Speasy.jl brings the same API to Julia.
Prefer clicking to coding? SciQLop is a graphical interface built on Speasy.
Speasy needs Python 3.10 or newer:
$ python -m pip install speasyOr try the command line without installing anything, with uv:
$ uvx speasy get amda/imf 2018-06-01 2018-06-02The first request for some data needs internet access; after that, it comes from the local cache. Behind a proxy or a firewall? See the configuration page.
Every provider is a tree you can explore with tab-completion. This is the same product as above:
import speasy as spz amda_tree = spz.inventories.data_tree.amda ace_mag = spz.get_data(amda_tree.Parameters.ACE.MFI.ace_imf_all.imf, "2016-6-2", "2016-6-5")
The Dst index during the May 2024 geomagnetic storm, from the World Data Center in Kyoto:
import speasy as spz dst = spz.get_data("hapi/wdc_kyoto_hapi/hour_dst/dstValue", "2024-05-09", "2024-05-14") dst.plot();
Magnetic field, electron and ion data from MMS1, on a shared time axis:
import speasy as spz import matplotlib.pyplot as plt mms1 = spz.inventories.tree.cda.MMS.MMS1 fig = plt.figure(figsize=(8, 16), layout="constrained") axes = fig.add_gridspec(6, hspace=0).subplots(sharex=True) plots = [ (mms1.FGM.MMS1_FGM_SRVY_L2.mms1_fgm_b_gse_srvy_l2_clean, axes[0]), (mms1.SCM.MMS1_SCM_SRVY_L2_SCSRVY.mms1_scm_acb_gse_scsrvy_srvy_l2, axes[1]), (mms1.DES.MMS1_FPI_FAST_L2_DES_MOMS.mms1_des_bulkv_gse_fast, axes[2]), (mms1.DES.MMS1_FPI_FAST_L2_DES_MOMS.mms1_des_temppara_fast, axes[3]), (mms1.DES.MMS1_FPI_FAST_L2_DES_MOMS.mms1_des_tempperp_fast, axes[3]), (mms1.DES.MMS1_FPI_FAST_L2_DES_MOMS.mms1_des_energyspectr_omni_fast, axes[4]), (mms1.DIS.MMS1_FPI_FAST_L2_DIS_MOMS.mms1_dis_energyspectr_omni_fast, axes[5]), ] for product, ax in plots: spz.get_data(product, "2019-01-02T15", "2019-01-02T22").replace_fillval_by_nan().plot(ax=ax)
The result holds one list per product, with one variable per interval:
import speasy as spz products = [ spz.inventories.tree.amda.Parameters.Wind.SWE.wnd_swe_kp.wnd_swe_vth, spz.inventories.tree.amda.Parameters.Wind.SWE.wnd_swe_kp.wnd_swe_pdyn, spz.inventories.tree.amda.Parameters.Wind.SWE.wnd_swe_kp.wnd_swe_n, spz.inventories.tree.cda.Wind.WIND.MFI.WI_H2_MFI.BGSE, spz.inventories.tree.ssc.Trajectories.wind, ] intervals = [["2010-01-02", "2010-01-02T10"], ["2009-08-02", "2009-08-02T10"]] data = spz.get_data(products, intervals)
Compute the field magnitude yourself, and check it against the one MMS provides:
import speasy as spz import numpy as np mms1 = spz.inventories.tree.cda.MMS.MMS1 b = spz.get_data(mms1.FGM.MMS1_FGM_SRVY_L2.mms1_fgm_b_gsm_srvy_l2, "2017-01-01T02:00:00", "2017-01-01T02:00:15") b.replace_fillval_by_nan(inplace=True) bt = b["Bt"] b = b["Bx GSM", "By GSM", "Bz GSM"] computed_norm = np.sqrt(np.sum(b ** 2, axis=1)) print(f"Type of computed_norm: {type(computed_norm)}") print("Same as the provided magnitude?", bool(np.allclose(computed_norm, bt)))
Type of computed_norm: <class 'speasy.products.variable.SpeasyVariable'> Same as the provided magnitude? True
import speasy as spz ace_mag = spz.get_data("amda/imf", "2016-6-2", "2016-6-5") print(type(ace_mag.to_dataframe()).__name__) print(type(ace_mag.to_dataarray()).__name__) print(type(ace_mag.to_astropy_table()).__name__)
DataFrame DataArray Table
Interpolate ion temperatures onto the magnetic field timestamps:
import speasy as spz from speasy.signal.resampling import interpolate import matplotlib.pyplot as plt mms1 = spz.inventories.tree.cda.MMS.MMS1 b, Tperp, Tpara = spz.get_data( [ mms1.FGM.MMS1_FGM_SRVY_L2.mms1_fgm_b_gsm_srvy_l2, mms1.DIS.MMS1_FPI_FAST_L2_DIS_MOMS.mms1_dis_tempperp_fast, mms1.DIS.MMS1_FPI_FAST_L2_DIS_MOMS.mms1_dis_temppara_fast, ], "2017-01-01T02:00:00", "2017-01-01T02:00:15", ) Tperp_interp, Tpara_interp = interpolate(b, [Tperp, Tpara]) plt.figure() ax = b.plot() plt.plot(Tperp_interp.time, Tperp_interp.values, marker="+") plt.plot(Tpara_interp.time, Tpara_interp.values, marker="+") plt.tight_layout()
A virtual product is a Python function that Speasy serves like any other product:
import numpy as np import speasy as spz from speasy.virtual_products import register_virtual_product @register_virtual_product("virtual/ace/b_magnitude", meta={"units": "nT"}, labels=["|B|"]) def ace_b_magnitude(start, stop): b = spz.get_data("amda/imf", start, stop) return np.sqrt(np.sum(b ** 2, axis=1)) spz.get_data("virtual/ace/b_magnitude", "2016-6-2", "2016-6-5").plot();
Inside a DataIndex block, get_data stores what it downloads in a folder.
Next time, the same calls are served from that folder, even offline.
Export it as one file, and a colleague gets exactly the same data:
import speasy as spz with spz.DataIndex("my_study") as study: ace_mag = spz.get_data("amda/imf", "2016-6-2", "2016-6-5") # downloaded, kept in my_study/ study.export_data("my_study.tar") # one file to send # On your colleague's machine: with spz.DataIndex("their_copy") as copy: copy.import_data("my_study.tar") ace_mag = spz.get_data("amda/imf", "2016-6-2", "2016-6-5") # read from their_copy/, no download
The documentation covers each data provider, configuration, the command line, and has a gallery of examples. Speasy's plots are meant for quick looks; for publication figures, use Matplotlib directly, or SciQLop for interactive exploration.
- Tell us how you use Speasy in our user survey.
- Report bugs or request features in the issues.
- Ask questions in the discussions or on Matrix.
- Want to add a data provider? See the contributing guide.
If Speasy helped your research, please cite it. GitHub's "Cite this repository" button, on the right of this page, gives a ready-made reference from CITATION.cff. Every release also has a Zenodo DOI.
Speasy only exists thanks to the data centers and teams who produce, archive and serve the data, and to the HAPI community for a shared standard. The development of Speasy is supported by the CDPP.




