Package: pyspedas
PySPEDASThe Python-based Space Physics Environment Data Analysis Software (PySPEDAS) framework supports multi-mission, multi-instrument retrieval, analysis, and visualization of heliophysics time series data.Projects SupportedAdvanced Composition Explorer (ACE)AkebonoArase (ERG)ClusterColorado Student Space Weather Experiment (CSSWE)Communications/Navigation Outage Forecasting System (C/NOFS)Deep Space Climate Observatory (DSCOVR)Dynamics Explorer 2 (DE2)Equator-SFast Auroral Snapshot Explorer (FAST)GeotailGeostationary Operational Environmental Satellite (GOES)Imager for Magnetopause-to-Aurora Global Exploration (IMAGE)Kyoto Dst IndexLANLMars Atmosphere and Volatile Evolution (MAVEN)Magnetic Induction Coil Array (MICA)Magnetospheric Multiscale (MMS)OMNIPolar Orbiting Environmental Satellites (POES)PolarParker Solar Probe (PSP)Solar & Heliospheric Observatory (SOHO)Solar Orbiter (SOLO)Solar Terrestrial Relations Observatory (STEREO)Space Technology 5 (ST5)Spherical Elementary Currents (SECS)SwarmTime History of Events and Macroscale Interactions during Substorms (THEMIS)Two Wide-Angle Imaging Neutral-Atom Spectrometers (TWINS)UlyssesVan Allen Probes (RBSP)WindRequirementsPython 3.8+ is required.We recommendAnacondawhich comes with a suite of packages useful for scientific data analysis. Step-by-step instructions for installing Anaconda can be found at:Windows,macOS,LinuxInstallationVirtual EnvironmentTo avoid potential dependency issues with other Python packages, we suggest creating a virtual environment for PySPEDAS; you can create a virtual environment in your terminal with:python-mvenvpyspedasTo enter your virtual environment, run the 'activate' script:Windows.\pyspedas\Scripts\activatemacOS and Linuxsourcepyspedas/bin/activateUsing Jupyter notebooks with your virtual environmentTo get virtual environments working with Jupyter, in the virtual environment, type:pipinstallipykernel
python-mipykernelinstall--user--namepyspedas--display-name"Python (pySPEDAS)"(note: "pyspedas" is the name of your virtual environment)Then once you open the notebook, go to "Kernel" then "Change kernel" and select the one named "Python (PySPEDAS)"InstallPySPEDAS supports Windows, macOS and Linux. To get started, install thepyspedaspackage using PyPI:pipinstallpyspedasUpgradeTo upgrade to the latest version of PySPEDAS:pipinstallpyspedas--upgradeLocal Data DirectoriesThe recommended way of setting your local data directory is to set theSPEDAS_DATA_DIRenvironment variable.SPEDAS_DATA_DIRacts as a root data directory for all missions, and will also be used by IDL (if you’re running a recent copy of the bleeding edge).Mission specific data directories (e.g.,MMS_DATA_DIRfor MMS,THM_DATA_DIRfor THEMIS) can also be set, and these will overrideSPEDAS_DATA_DIRUsageTo get started, import pyspedas and pytplot:importpyspedasfrompytplotimporttplotYou can load data into tplot variables by callingpyspedas.mission.instrument(), e.g.,To load and plot 1 day of THEMIS FGM data for probe 'd':thm_fgm=pyspedas.themis.fgm(trange=['2015-10-16','2015-10-17'],probe='d')tplot(['thd_fgs_gse','thd_fgs_gsm'])To load and plot 2 minutes of MMS burst mode FGM data:mms_fgm=pyspedas.mms.fgm(trange=['2015-10-16/13:05:30','2015-10-16/13:07:30'],data_rate='brst')tplot(['mms1_fgm_b_gse_brst_l2','mms1_fgm_b_gsm_brst_l2'])Note: by default, PySPEDAS loads all data contained in CDFs found within the requested time range; this can potentially load data outside of your requested trange. To remove the data outside of your requested trange, set thetime_clipkeyword toTrueTo load and plot 6 hours of PSP SWEAP/SPAN-i data:spi_vars=pyspedas.psp.spi(trange=['2018-11-5','2018-11-5/06:00'],time_clip=True)tplot(['DENS','VEL','T_TENSOR','TEMP'])To download 5 days of STEREO magnetometer data (but not load them into tplot variables):stereo_files=pyspedas.stereo.mag(trange=['2013-11-1','2013-11-6'],downloadonly=True)Standard Optionstrange: two-element list specifying the time range of interest. This keyword accepts a wide range of formatstime_clip: if set, clip the variables to the exact time range specified by thetrangekeywordsuffix: string specifying a suffix to append to the loaded variablesvarformat: string specifying which CDF variables to load; accepts the wild cards * and ?varnames: string specifying which CDF variables to load (exact names)get_support_data: if set, load the support variables from the CDFsdownloadonly: if set, download the files but do not load them into tplotno_update: if set, only load the data from the local cachenotplot: if set, load the variables into dictionaries containing numpy arrays (instead of creating the tplot variables)ExamplesPlease see the following notebooks for examples of using PySPEDASPyTplot BasicsIntroduction to PyTplotLoading DataMMS examplesTHEMIS examplesLoad data from HAPI serversExploring the Heliosphere with PythonPlottingAnnotationsRange optionsSpectrogram optionsLegend optionsMarkers and symbolsError barsPseudo variablesHighlight intervals and vertical barsAdditional examples of loading and plotting data can be found in the documentation for the project you're interested in (PySPEDAS projects), as well as the project's README file.Dates and TimesWorking with dates and timesCoordinate TransformationsCoordinate transformationsBoundary normal (LMN) coordinatesQuaternion transformations with SpacePyAnalysisPlasma calculations with PlasmaPyPoynting flux with MMS dataPlasma beta with MMS data(note: the PlasmaPy notebook above shows a much easier method)Curlometer calculationsNeutral sheet modelsWave polarization calculationsDynamic power spectra calculations2D slices of MMS distribution functionsGenerating spectrograms and moments from MMS distribution functionsDocumentationFor more information, please see our HTML documentation at:https://pyspedas.readthedocs.io/Getting HelpTo find the options supported, callhelpon the instrument function you're interested in:help(pyspedas.themis.fgm)You can ask questions by creating an issue or by joining theSPEDAS mailing list.PyTplotPytplot is a separate project, that replicates the IDL "tplot" functionality. Pyspedas uses a modified version of pytplot with matplotlib as the plotting library.ContributingWe welcome contributions to PySPEDAS; to learn how you can contribute, please see ourContributing GuidePlug-in DevelopmentAn introduction to PySPEDAS plug-in development can be found here:Introduction to PySPEDAS plug-in developmentCode of ConductIn the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. To learn more, please see ourCode of Conduct.Additional InformationFor examples of pyspedas, see:https://github.com/spedas/pyspedas_examplesFor MMS examples, see:https://github.com/spedas/mms-examplesFor pytplot (matplotlib version), see:https://github.com/MAVENSDC/PyTplot/tree/matplotlib-backendFor cdflib, see:https://github.com/MAVENSDC/cdflibFor SPEDAS, seehttp://spedas.org/