cdasws Example Jupyter Notebook

This Jupyter notebook demonstrates using the cdasws Python package to access data from cdaweb with the data returned in the SpasePy data model. Alternatively, it is possible to have the data returned in an xarray.Dataset. For xarray.Dataset results, see this notebook (ipynb file). This notebook contains the following sections:

  1. Prerequisites
  2. Setup
  3. Get Datasets
  4. Get Dataset Variables
  5. Get Data
  6. Display Metadata
  7. Plot Values
  8. Binning Example
  9. DOI Example
  10. Additional Documentation

Prerequisites

Install the prerequisite software from CDF and the Python Package Index.

  1. Install CDF.
  2. pip install spacepy
  3. pip install cdasws

Setup

Execute some preliminary code that is necessary before the code that follows.

Get Datasets

The following code demontrates how to get a list of datasets.

Get Dataset Variables

The following code demonstrates how to get a dataset's variables.

Get Data

The following code demonstrates how to access magnetic field measurements from the ACE AC_H1_MFI dataset.

Display Metadata

The following code displays metadata for the Magnitude variable.

Plot Values

The following code plots the Magnitude variable's values using the label values from the metadata.

Binning Example

For analysis, it is often useful to place two datasets that have different timestamps on the same time grid (with optional spike removal). The following demonstrates doing this with cdasws and the datasets AC_H0_SWE and AC_H2_SWE. For more information on binning, see binning in cdaweb.

Display Original Data

The following code gets and displays the original, unbinned data.

Bin Data

The following code gets data after it has been binned with 60 second time intervals and any missing values created by interpolation.

Compare Data

The following code compares the binned data from the two datasets by plotting the values.

DOI Example

The following code gets data from a dataset using the dataset's digital object identifier and displays the dataset's values.

Additional Documentation

View the cdasws API for additional functions. Additional notebook examples are also available.