### Install PySPEDAS Package Source: https://github.com/spedas/pyspedas/blob/master/README.md Install the PySPEDAS package from PyPI. This is the recommended way to get started. ```bash pip install pyspedas ``` -------------------------------- ### Install individual package with pip Source: https://github.com/spedas/pyspedas/blob/master/docs/source/dev_vscode.md If a package fails to install with 'pdm sync', use pip to install it directly. Repeat for any other problematic packages. ```bash pip install astropy ``` -------------------------------- ### Install Jupyter Support Source: https://github.com/spedas/pyspedas/blob/master/docs/source/getting_started.md Install the 'jupyter' and 'ipympl' packages to support running PySPEDAS examples in Jupyter notebooks. These packages are essential for interactive notebook environments. ```bash pip install jupyter ``` ```bash pip install ipympl ``` -------------------------------- ### Install Development Tools with pip Source: https://github.com/spedas/pyspedas/blob/master/docs/source/dev_pycharm.md Use pip to install the pdm package manager, the uv dependency installer, and pdm-bump for version management. Ensure your terminal is configured to use these installations. ```bash pip install pdm pip install uv pip install pdm-bump ``` -------------------------------- ### Install PySPEDAS with specific extras Source: https://github.com/spedas/pyspedas/blob/master/docs/source/pyspedas_2_migration.md Install PySPEDAS with selected optional dependencies. For example, install 'maps' (basemap) and 'mth5' extras, but not 'viresclient'. Use quotes if your shell interprets square brackets as special characters. ```bash pip install 'pyspedas[maps,mth5]' ``` -------------------------------- ### Install pdm-bump for versioning Source: https://github.com/spedas/pyspedas/blob/master/docs/source/dev_vscode.md Install the pdm-bump plugin, useful for managing version bumps during release workflows. ```bash pip install pdm-bump ``` -------------------------------- ### Install Basemap Toolkit Source: https://github.com/spedas/pyspedas/blob/master/pyspedas/projects/secs/README.md Use pip to install the basemap toolkit, a requirement for the SECS module. Refer to the official matplotlib documentation for detailed installation instructions. ```bash pip install basemap ``` -------------------------------- ### Install uv resolver Source: https://github.com/spedas/pyspedas/blob/master/docs/source/dev_vscode.md Install the uv package resolver, which is used by pdm, into the virtual environment. ```bash pip install uv ``` -------------------------------- ### Install Python 3.10 Executable Source: https://github.com/spedas/pyspedas/blob/master/docs/source/dev_vscode.md Run this command in Windows Command Prompt to install Python 3.10. Adjust the version number as needed. ```bash winget install python.python.3.10 ``` -------------------------------- ### Install PySPEDAS Dependencies with PDM Source: https://github.com/spedas/pyspedas/blob/master/docs/source/dev_pycharm.md Run this command in the terminal to install all runtime, optional, and development dependencies for PySPEDAS. Ensure PDM is installed and configured for the project. ```bash pdm sync ``` -------------------------------- ### Install PySPEDAS Source: https://context7.com/spedas/pyspedas/llms.txt Install PySPEDAS using pip. Optional extras can be included for additional functionalities. ```bash pip install pyspedas # With optional extras (e.g. HAPI, VirES, MTH5) pip install "pyspedas[hapi,vires,mth5]" ``` -------------------------------- ### Load and Plot THEMIS FGM Data with PySPEDAS Source: https://github.com/spedas/pyspedas/blob/master/docs/source/getting_started.md This example demonstrates loading THEMIS FGM data for a specified time range and plotting a specific variable. Ensure PySPEDAS is installed and configured. ```python from pyspedas import tplot from pyspedas.projects.themis import fgm trange=['2007-03-23' , '2007-03-24'] fgm_vars = fgm(probe='a',trange=trange) print(fgm_vars) tplot('tha_fgl_dsl') ``` -------------------------------- ### Example Plotting with Boundaries Source: https://github.com/spedas/pyspedas/blob/master/docs/source/plotting.md This example demonstrates how to plot THEMIS and ARTEMIS orbits and add the bow shock, magnetopause, and AEN neutral sheet locations to the plots. ```APIDOC ## Example Plotting with Boundaries ### Description This example displays THEMIS and ARTEMIS orbits using tplotxy3, then adds the bow shock, magnetopause, and AEN neutral sheet location to the plots. ### Code ```python import pyspedas from pyspedas import tplotxy3, tplotxy3_add_mpause, tplotxy3_add_neutral_sheet from pyspedas.analysis.neutral_sheet import neutral_sheet from pyspedas import bshock_2, mpause_2, get_data, store_data, set_coords, set_units, cotrans import numpy as np # Load THEMIS state data default_trange = ["2020-01-01", "2020-01-02"] pyspedas.projects.themis.state(trange=default_trange, probe=['a','b','c','d','e']) # Calculate bow shock and magnetopause boundaries bs = bshock_2() mp = mpause_2() # The neutral sheet is a little more complicated, since it's time-dependent. We'll pick the midpoint # of the time interval d=get_data('tha_pos_gse') mid_time = (d.times[-1] - d.times[0])/2.0 # Generate a set of points along the -X axis (night side of Earth), units of Re ns_x_re = -1.0*np.arange(0.0,375.0, 5.0) # We need replicate the timestamps to make a proper tplot variable times=np.zeros(len(ns_x_re)) times[:] = mid_time ns_gsm_pos=np.zeros((len(ns_x_re),3)) ns_gsm_pos[:,0] = ns_x_re # Generate the neutral sheet Z-axis values corresponding to the inputs ns = neutral_sheet(times, ns_gsm_pos, model="aen", sc2NS=False) # Add the Z component to the input positions, store it as a tplot variable ns_gsm_pos[:,2] = ns store_data('ns_gsm_pos', data={'x':times, 'y':ns_gsm_pos}) # We're making a GSE plot, but the neutral sheet is generated in GSM, so we do a cotrans set_coords('ns_gsm_pos','GSM') set_units('ns_gsm_pos', 're') cotrans('ns_gsm_pos', 'ns_gse_pos',coord_in='gsm', coord_out='gse') # Finally, we have the neutral sheet Z positions along the X axis on the night side. gse_dat = get_data('ns_gse_pos') # Plot the orbits and capture the resulting figure fig = tplotxy3('th?_pos_gse',title='THEMIS_ARTEMIS orbit plot 2020-01-01, all planes, extras, sun left, units re', legend_names=['THEMIS-A','THEMIS-B', 'THEMIS-C', 'THEMIS-D', 'THEMIS-E'], reverse_x=True, plot_units='re', display=False) # Add bow shock to figure tplotxy3_add_mpause(bs[0],bs[1],fig=fig,legend_name="Bow Shock",color='k',linestyle='dotted',linewidth=1,display=False) # Add magnetopause to figure tplotxy3_add_mpause(mp[0],mp[1],fig=fig,legend_name="Magnetopause",color='k',linestyle='dashed',linewidth=1,display=False) # Add neutral sheet to figure, then display the plot, and save it to a file tplotxy3_add_neutral_sheet(gse_dat.y[:,0],gse_dat.y[:,2],fig=fig, legend_name="Neutral sheet",color='k',linestyle='dashdot',linewidth=1,display=True,save_png='orbits_thm_art_re_legends_extras_3planes.png') ``` ``` -------------------------------- ### Install pdm package manager Source: https://github.com/spedas/pyspedas/blob/master/docs/source/dev_vscode.md Install the pdm package manager into the activated virtual environment using pip. ```bash pip install pdm ``` -------------------------------- ### Install PySPEDAS Source: https://github.com/spedas/pyspedas/blob/master/README.md Install the PySPEDAS package using pip. ```APIDOC ## Install PySPEDAS To get started, install the `pyspedas` package using PyPI: ```bash pip install pyspedas ``` ``` -------------------------------- ### Start Jupyter Notebook Server Source: https://github.com/spedas/pyspedas/blob/master/docs/source/getting_started.md Run this command in a terminal to launch the Jupyter notebook interface. This allows for the creation and management of Jupyter notebooks. ```bash jupyter notebook ``` -------------------------------- ### Install Package with Conda Source: https://github.com/spedas/pyspedas/blob/master/docs/source/devguide.md Use this command to install a package if 'pip install' fails due to missing binary wheels. This is particularly useful for Mac users. ```bash conda install -c conda-forge ``` -------------------------------- ### Install PySPEDAS in Google Colab Source: https://github.com/spedas/pyspedas/blob/master/docs/source/examples_and_tutorials.md Use this command in a Google Colab notebook to install PySPEDAS. Skip if PySPEDAS is already installed in your environment. ```bash !pip install pyspedas ``` -------------------------------- ### Install PySPEDAS with All Extras Source: https://github.com/spedas/pyspedas/blob/master/docs/source/getting_started.md Install PySPEDAS along with all optional dependencies. This command ensures all features, including mapping and data loading capabilities, are available. Ensure quotes are used if your shell interprets brackets specially. ```bash pip install 'pyspedas[all]' ``` -------------------------------- ### Install Jupyter Kernel for Virtual Environment Source: https://github.com/spedas/pyspedas/blob/master/README.md Install the ipykernel package and register your virtual environment with Jupyter for notebook integration. ```bash pip install ipykernel python -m ipykernel install --user --name pyspedas --display-name "Python (pySPEDAS)" ``` -------------------------------- ### FGM Example Source: https://github.com/spedas/pyspedas/blob/master/docs/source/mms.md An example demonstrating how to load and plot MMS FGM data for a specific time interval, including clipping data to the specified range. ```APIDOC ## FGM Example ### Description Load and plot MMS FGM data for a specific time interval. ### Method `pyspedas.projects.mms.fgm` ### Parameters * **trange** (list of str) - Time range of interest. Example: ['2015-10-16/12:45', '2015-10-16/13:00'] * **time_clip** (bool) - If True, data will be clipped to the exact trange specified. ### Request Example ```python import pyspedas from pyspedas import tplot pyspedas.projects.mms.fgm(trange=['2015-10-16/12:45', '2015-10-16/13:00'], time_clip=True) tplot(['mms1_fgm_b_gsm_srvy_l2_btot', 'mms1_fgm_b_gsm_srvy_l2_bvec']) ``` ### Response None explicitly documented, but implies data is loaded into tplot variables. ``` -------------------------------- ### Install MTH5 package Source: https://github.com/spedas/pyspedas/blob/master/docs/source/mth5.md Install the MTH5 package using pip. This is a prerequisite for using the pyspedas.mth5 module. ```bash pip install mth5 ``` -------------------------------- ### Install PySPEDAS with Specific Extras Source: https://github.com/spedas/pyspedas/blob/master/docs/source/getting_started.md Install PySPEDAS with selected optional dependencies. Use this if you only need specific features, such as mapping support or mth5 package for seismographic data. Quotes are recommended for shell compatibility. ```bash pip install 'pyspedas[maps]' ``` ```bash pip install 'pyspedas[maps,mth5]' ``` -------------------------------- ### Load BARREL Fast Spectra Data Example Source: https://github.com/spedas/pyspedas/blob/master/docs/source/barrel.md Loads BARREL Fast Spectra (fspc) data for a specific probe and time range. This example demonstrates loading data for probe '1D'. ```python import pyspedas from pyspedas import tplot pyspedas.projects.barrel.fspc(trange=['2013-01-17', '2013-01-19'], probe='1D') tplot('brl1D_FSPC1') ``` -------------------------------- ### Verify PySPEDAS Installation Source: https://github.com/spedas/pyspedas/blob/master/docs/source/devguide.md Perform a quick smoke check by importing pyspedas in a Python console. If this works, proceed to run tests in specific directories to ensure all dependencies are correctly installed. ```python import pyspedas ``` -------------------------------- ### L-shell Calculation Example Source: https://github.com/spedas/pyspedas/blob/master/docs/source/geopack.md Demonstrates the calculation of L-shell values from position data and plotting the results. Requires the 'state' function for data loading and 'tplot' for visualization. ```python from pyspedas.projects.themis import state from pyspedas import calculate_lshell, tplot state(trange=['2007-03-23', '2007-03-23'], probe='a') calculate_lshell('tha_pos_gsm','tha_pos_lshell') tplot('tha_pos_lshell') ``` -------------------------------- ### Get CDAWeb Instruments Source: https://github.com/spedas/pyspedas/blob/master/docs/source/cdaweb.md Fetches a list of available instruments from the CDAWeb archive. Use this to discover which instruments are available for a given mission. ```python from pyspedas import CDAWeb cdaweb_obj = CDAWeb() obs_names = cdaweb_obj.get_instruments() ``` -------------------------------- ### Load and Plot PSP SWEAP/SPAN-i Data Source: https://github.com/spedas/pyspedas/blob/master/README.md Example of loading and plotting PSP SWEAP/SPAN-i data for a specific time range, with time clipping enabled. ```python import pyspedas from pyspedas import tplot spi_vars = pyspedas.projects.psp.spi(trange=['2018-11-5', '2018-11-5/06:00'], time_clip=True) tplot(['DENS', 'VEL', 'T_TENSOR', 'TEMP']) ``` -------------------------------- ### Get Time Span of a Tplot Variable Source: https://github.com/spedas/pyspedas/blob/master/docs/source/utilities.md Retrieves the start and end times for a specified Tplot Variable. If no name is provided, it returns the global timespan. ```python >>> # Retrieve the time span from Variable 1 >>> import pyspedas >>> x_data = [1,2,3,4,5] >>> y_data = [1,2,3,4,5] >>> pyspedas.store_data("Variable1", data={'x':x_data, 'y':y_data}) >>> time1, time2 = pyspedas.get_timespan("Variable1") ``` -------------------------------- ### Load THEMIS ESA Data and Calculate Density Source: https://github.com/spedas/pyspedas/blob/master/docs/source/themis_analysis.md Example demonstrating how to load THEMIS ESA data for a specific time range and probe, retrieve relevant variables, and then use `scpot2dens` to calculate plasma density. ```python import pyspedas import pyspedas from pyspedas.projects.themis import scpot2dens # Define the time range for which to load the data trange = ['2007-7-20/17:00:00', '2007-7-20/17:20:00'] ``` ```python # Load THEMIS ESA data for probe 'c' within the specified time range pyspedas.projects.themis.esa(trange=trange, probe='c', varnames=['thc_peer_density', 'thc_peir_density', 'thc_peer_sc_pot', 'thc_peer_avgtemp'], level='l2') # Retrieve electron density dens_e_time, dens_e = get_data('thc_peer_density') # Retrieve ion density dens_i_time, dens_i = get_data('thc_peir_density') # Retrieve spacecraft potential sc_pot_time, sc_pot = get_data('thc_peer_sc_pot') # Retrieve electron temperature Te_time, Te = get_data('thc_peer_avgtemp') # Calculate the plasma density from spacecraft potential Npot = scpot2dens(sc_pot, sc_pot_time, Te, Te_time, dens_e, dens_e_time, dens_i, dens_i_time, 'c') ``` -------------------------------- ### Install basemap using Conda Source: https://github.com/spedas/pyspedas/blob/master/docs/source/pyspedas_2_migration.md Install the 'basemap' package using Conda for SECS/EICS maps, which may be an alternative if pip installation fails. ```bash conda install -c conda-forge basemap ``` -------------------------------- ### Install mth5 using Conda Source: https://github.com/spedas/pyspedas/blob/master/docs/source/pyspedas_2_migration.md Install the 'mth5' package using Conda for loading magnetotelluric/seismographical data, which may be an alternative if pip installation fails. ```bash conda install -c conda-forge mth5 ``` -------------------------------- ### Install viresclient using Conda Source: https://github.com/spedas/pyspedas/blob/master/docs/source/pyspedas_2_migration.md Install the 'viresclient' package using Conda for downloading SWARM or other ESA data from the VIRES service, which may be an alternative if pip installation fails. ```bash conda install -c conda-forge viresclient ``` -------------------------------- ### Install Dependencies with Conda Source: https://github.com/spedas/pyspedas/blob/master/docs/source/getting_started.md Use conda to install specific PySPEDAS dependencies if pip installation fails. This is a workaround for platform-specific issues or compilation problems. The '-c conda-forge' flag specifies the channel for package retrieval. ```bash conda install -c conda-forge basemap ``` ```bash conda install -c conda-forge mth5 ``` ```bash conda install -c conda-forge viresclient ``` -------------------------------- ### Load and Plot Magnetometer Data (KOMPSAT) Source: https://github.com/spedas/pyspedas/blob/master/docs/source/kompsat.md Imports necessary libraries and loads L2 magnetometer data for a specified time range, then plots it. Ensure ESA server authentication is configured. ```python import pyspedas from pyspedas import tplot, options # Load L2 magnetometer data and plot it var_names = pyspedas.projects.kompsat.load(trange=["2024-03-31 02:00:00", "2024-03-31 03:00:00"], datatype="1m") tplot(var_names) ``` -------------------------------- ### Install Specific Package with Conda Source: https://github.com/spedas/pyspedas/blob/master/docs/source/dev_pycharm.md If a package fails to install with 'pdm sync', use this command to install it with conda. This is particularly useful for packages with complex system dependencies on macOS. Replace 'netcdf4' with the actual failing package name. ```bash conda install -c conda-forge netcdf4 ``` -------------------------------- ### Load STEREO Low Energy Telescope (LET) Data Source: https://github.com/spedas/pyspedas/blob/master/pyspedas/projects/stereo/README.md Load Low Energy Telescope data for a specified time range. ```python sit_vars = pyspedas.stereo.let(trange=['2013-1-5', '2013-1-6']) ``` -------------------------------- ### Fetch dataset availability with default network and station Source: https://github.com/spedas/pyspedas/blob/master/docs/source/mth5.md This example demonstrates fetching dataset availability using only a time range. The function will query for all available datasets within the specified period, without filtering by network or station. Internet access is required. ```python from pyspedas.mth5.utilities import datasets valid_dataset = datasets(trange=["2015-06-22", "2015-06-23"]) print(valid_dataset) ``` ```text {'4P': {'ALW48': {('2015-06-18T15:00:36.0000', '2015-07-09T13:45:10.0000'): ['LFE', 'LFN', 'LFZ']}, ... ... More entries } ``` -------------------------------- ### Launch Interactive CDAWeb Browser Source: https://github.com/spedas/pyspedas/blob/master/docs/source/cdaweb.md Starts the interactive CDAWeb archive browser GUI. This tool allows users to visually select missions, instruments, datasets, and time ranges, then download the data. ```python from pyspedas import cdagui cdagui() ``` -------------------------------- ### Store and Retrieve Data with PySPEDAS Source: https://github.com/spedas/pyspedas/blob/master/docs/source/utilities.md Demonstrates how to store data with custom time and value arrays and then retrieve it using PySPEDAS. Also shows how to create gaps in the data. ```python >>> import pyspedas >>> time = [pyspedas.time_float("2020-01-01") + i for i in [1, 2, 3, 4, 5, 6, 9, 10, 11]] >>> y = [1, 2, 3, 4, 5, 6, 9, 10, 11] >>> pyspedas.store_data("a", data={"x": time, "y": y}) >>> a = pyspedas.get_data("a") >>> print(a) >>> b = pyspedas.makegap(a) >>> print(b) ``` -------------------------------- ### Get Help with PySPEDAS Instrument Functions Source: https://github.com/spedas/pyspedas/blob/master/README.md Use the `help` function to get detailed information about specific instrument functions within PySPEDAS. This is useful for understanding available parameters and options. ```python import pyspedas help(pyspedas.projects.themis.fgm) ``` -------------------------------- ### Use Wildcards in Library Search Source: https://github.com/spedas/pyspedas/blob/master/README.md Demonstrates how to use wildcard characters like '*' and '?' to search for libraries when the exact spelling is unknown. This is useful for flexible library discovery. ```python libs('wav*pol') ``` -------------------------------- ### Install basemap extra for maps Source: https://github.com/spedas/pyspedas/blob/master/docs/source/pyspedas_2_migration.md Install only the 'maps' extra, which includes the 'basemap' package, to support EICS and SECS map plotting. Use quotes if your shell interprets square brackets as special characters. ```bash pip install 'pyspedas[maps]' ``` -------------------------------- ### pyspedas.projects.stereo.let Source: https://github.com/spedas/pyspedas/blob/master/docs/source/stereo.md Loads data from the Low Energy Telescope (LET). ```APIDOC ## pyspedas.projects.stereo.let This function loads data from the Low Energy Telescope ### Parameters #### Path Parameters - **trange** (list of str) - Required - time range of interest [starttime, endtime] with the format ‘YYYY-MM-DD’,’YYYY-MM-DD’] or to specify more or less than a day [‘YYYY-MM-DD/hh:mm:ss’,’YYYY-MM-DD/hh:mm:ss’] Default: [‘2013-11-5’, ‘2013-11-6’] - **probe** (str) - Optional - Spacecraft probe (‘a’ for ahead, ‘b’ for behind) Default: ‘a’ - **level** (str) - Optional - Default: ‘l1’ - **suffix** (str) - Optional - The tplot variable names will be given this suffix. Default: ‘’, no suffix is added. - **prefix** (str) - Optional - The tplot variable names will be given this prefix. Default: ‘’, no prefix is added. - **get_support_data** (bool) - Optional - Data with an attribute “VAR_TYPE” with a value of “support_data” will be loaded into tplot. Default: False. Only loads in data with a “VAR_TYPE” attribute of “data”. - **varformat** (str) - Optional - The file variable formats to load into tplot. Wildcard character “*” is accepted. Default: None. All variables are loaded in. - **varnames** (list of str) - Optional - List of variable names to load. Default: [], if not specified, all data variables are loaded - **downloadonly** (bool) - Optional - Set this flag to download the CDF files, but not load them into tplot variables Default: False - **notplot** (bool) - Optional - Return the data in hash tables instead of creating tplot variables Default: False - **no_update** (bool) - Optional - If set, only load data from your local cache Default: False - **time_clip** (bool) - Optional - Time clip the variables to exactly the range specified in the trange keyword Default: False ### Return type List of tplot variables created. ### Example: ```pycon >>> import pyspedas >>> from pyspedas import tplot >>> sit_vars = pyspedas.projects.stereo.let(trange=["2013-1-5", "2013-1-6"]) >>> tplot(sit_vars) ``` ``` -------------------------------- ### Configure pdm to use uv Source: https://github.com/spedas/pyspedas/blob/master/docs/source/dev_pycharm.md Enable the use of the 'uv' tool for dependency management within pdm. This command should be run in your project's terminal after installing pdm and uv. ```bash pdm config use_uv true ``` -------------------------------- ### get_filenames Method Source: https://github.com/spedas/pyspedas/blob/master/docs/source/cdaweb.md Get a list of URLs for a specific dataset within a given time range. ```APIDOC ## get_filenames Return a list of urls for a dataset between dates t0 and t1. ### Method `get_filenames` ### Parameters * **dataset_list** (`list` of `str`) – A list of dataset names, as obtained from get_datasets() * **t0** (`str`) – Start time for data to be retrieved * **t1** (`str`) – End time for data to be retrieved ### Returns A list of URLs for the given dataset and time range ### Return type `list` of `str` ### Example ```pycon >>> from pyspedas import CDAWeb >>> cdaweb_obj = CDAWeb() >>> urllist = cdaweb_obj.get_filenames(['THB_L2_FIT (2007-02-26 to 2020-01-17)'], '2010-01-01 00:00:00', '2010-01-10 00:00:00') ``` ```