Skip to main content

das3py

Das servers typically provide data relevant to space plasma and magnetospheric physics research. To retrieve data, an HTTP GET request is posted to a das server by a client program and a self-describing stream of data values covering the requested time range, at the requested time resolution, is provided in the response body. This package, das3py, provides an efficient space physics data client for python. It reads both das2 and das3 streams, and das2 streams will be supported indefinitely. Streams are parsed and stored as NumPy arrays using a C extension, avoiding data copies and conversions.

das3py was published as das2py through version 3.0.4. See Upgrading from das2py below.

Installing from PyPI

python -m pip install das3py

The PyPI packages are pre-built for Linux on x86_64, for Python 2.7 and 3.9 through 3.15. They need glibc 2.26 or newer (RHEL 8, Ubuntu 18.04 and later) and pip 20.3 or newer. The 2.7 package is for UCS-4 builds of Python, as Linux distributions ship; a 2.7 built from source needs --enable-unicode=ucs4. If pip is older, upgrade it first:

python -m pip install -U pip

On other Linux systems, build from source as described in Building and Installing from Source on Linux below. For Windows and macOS, see Windows and macOS.

To check the install, run one of the examples. It needs matplotlib and an internet connection:

python -m pip install matplotlib
wget https://raw.githubusercontent.com/das-developers/das3py/main/examples/ex02_galileo_pws_spectra.py
python ex02_galileo_pws_spectra.py

It writes ex02_galileo_pws_spectra.png, which should look like this:

First program

The following small program demonstrates how to query for data and generate a plot using das3py.

Query a URI for reduced resolution data

import das3
src = das3.get_source( 'tag:das2.org,2012:site:/uiowa/galileo/pws/survey_electric/das2' )
header, datasets = src.get( {'time' : ('1997-05-07T15:00', '1997-05-07T17:00', 4.0)} )
  • get() returns the stream header and a list of datasets. This instrument sends three, one for each of its frequency bands. Each has the same three physical dimensions: time, frequency and electric field.
  • site:/... is short for tag:das2.org,2012:site:/....
  • Servers come and go. The federated catalog provides stability for application code by mapping URIs to data sources.
  • Browse for URIs using a das2 catalog browser, or using das3py to get the root node (see example 11).

Access quantities by physical dimensions

dataset = datasets[0]
print(dataset)

vX = dataset['time']['center']
vY = dataset['frequency']['center']
vZ = dataset['electric']['center'] 
  • Datasets contain dimensions. Dimensions contain variables. Each variable in a dimension serves a purpose, the most common is to define the center point of a coordinate or measurement.
  • Array dimensions are not confused with physical dimensions. Dataset meaning is not tied to any particular array morphology.

Use Matplotlib to generate an image

import matplotlib.pyplot as pyplot
import matplotlib.colors as colors

fig, ax = pyplot.subplots()
scaleZ = colors.LogNorm(vmin=1e-17, vmax=1e-4)   # One color scale for all bands

for dataset in datasets:
   vX = dataset['time']['center']
   vY = dataset['frequency']['center']
   vZ = dataset['electric']['center']
   ax.pcolormesh(vX.array, vY.array, vZ.array, norm=scaleZ, cmap='jet')

ax.set_yscale('log')
pyplot.show() 

Vectors and other composites

das3 streams can carry vectors, rotation matrices and other multi-part values as a single variable. This query gets eight minutes of TRACERS-2 magnetometer data:

src = das3.get_source('site:/uiowa/tracers/tracers-2/l2/mag_16sps_delta')
header, datasets = src.get( {'time' : ('2026-05-04T01:29:59', '2026-05-04T01:38:07')} )

dB = datasets[0]['ts2_l2_mag_16sps_fac_deltab']['center']

print(dB.array.shape)   # (7808, 3)
print(dB.extShape())    # (7808,)  one value per record
print(dB.intrShape())   # (3,)     each value is a 3-vector
print(dB.labels)        # ['dBx', 'dBy', 'dBz']
print(dB.ops)           # {'kind': 'vector', 'frame': 'TS2_FAC', 'system': 'cartesian', ...}
  • The external shape counts records in the dataset. The internal shape is the shape of each value.
  • dB.ops says what the values are and which coordinate frame they are in.
  • The array is ordinary NumPy, so the field magnitude is numpy.linalg.norm(dB.array, axis=1).
  • Example 12 plots the three components.

Anaconda Package

A das3py conda package for Linux, Windows and macOS is planned. The dasdevelopers channel still has the older das2py 3.0.4.

What changed in 3.0

The short version, for people upgrading from 2.3:

  • The package is das3 now. It reads das3 streams as well as das2 streams. Code that says import das2 needs to say import das3. The pip name is now das3py. Python 2.7 and 3.x are both supported, das3 isn't a reference to the interpreter version.

  • Reads return the stream header too. Source.get() and the read_*() functions return a tuple, (stream_header, datasets), not just a list of datasets, so their call sites change.

  • Composite values. Vectors, rotation matrices, quaternions and complex pairs come through as one variable, with an internal shape. So a vector over N records is an (N, 3) array with the external shape (N,) in the dataset, and the internal shape (3,) within each value. These can be retrieved via var.extShape() and var.intrShape().

  • Mathematical Formalisms. Each variable is now tagged with metadata denoting which math operations it supports. For example a point variable supports subtraction (a point - point = length) but not addition. The dict var.ops provides information on operations.

  • Raw Storage. To get the compact raw storage for a variable, use var.storage(), which gives the values without the dataset's broadcast.

  • Sequences are materialized. A coordinate defined by a <sequence> in the stream header arrives as a real array.

  • Tidier names. dir(das3) shows the public API and nothing else. A few methods were renamed to match the rest: DasTime.fromString, DasTime.roundDoy, Dimension.hasProp and hasPropVal (replacing propEq) and Source.infoProto. The 2.3 names still work and warn. Quantity.to_value keeps its snake_case on purpose, since it's source compatible with AstroPy's Quantities.

  • das_verify checks more. Index counts against the dataset rank, one units= per composite, and <sequence> counts against the internal shape, none of which an XML schema can express.

  • Not yet: ragged arrays (variable length records) still don't convert to ndarrays. das2C reads them fully, but das3py stops at the conversion.

Upgrading from das2py

As of version 3.0 the package is das3, named for the das3 stream format it added, and as of 3.0.6 it is distributed as das3py. It still reads das2 streams, and runs on Python 2.7 and 3.x alike.

Most das2py code needs two changes:

  1. The module name. import das2 becomes import das3, and das2.DasTime becomes das3.DasTime, and so on. Don't change every "das2" in a file: catalog names such as 'tag:das2.org,2012:site:/...' and das2.org URLs stay as they are.

  2. Reading data returns the stream header too.

    ds_list = src.get()                 # das2py 2.3
    stream_hdr, ds_list = src.get()     # das3py
    

    The same goes for read_file(), read_http() and read_cmd(), which now raise an exception on failure instead of returning None.

Code written for the das2py 3.0.4 conda package needs only the first change.

A few 2.3 method names changed too. The old names still work, with a PendingDeprecationWarning that Python hides by default; see the CHANGELOG. To find them, run a script with the warning promoted to an error:

python -W error::PendingDeprecationWarning your_script.py

Data sources in the das catalog have also changed their query parameters since 2.3. print(src.info()) lists the ones a source takes now.

Note that das2py and das3py both include the das_verify command. If you uninstall das2py, reinstall das3py to replace it:

python -m pip install --force-reinstall --no-deps das3py

The old das2py releases stay on PyPI, so scripts that pin das2py<3 keep working.

Building and Installing from Source on Linux

Compilation and installation of das3py is regularly tested on Linux under both Python 2 (still) and Python 3. The following packages are required to build das3py and all dependencies:

  1. Get system software packages.

    Red Hat Enterprise Linux or compatible (Rocky, Alma)

    dnf install git gcc make curl expat-devel fftw-devel openssl-devel python3-devel
    

    Debian or compatible (Ubuntu)

    apt install gcc git make curl libexpat-dev libfftw3-dev libssl-dev python3-dev python3-venv
    
  2. Get the source, along with the pegged das2C version.

    git clone --recursive https://github.com/das-developers/das3py.git
    

    das2C is a git submodule in deps/das2C, pegged to the das2C release this das3py was written and tested against. If you cloned without --recursive that directory is empty, so fill it with git submodule update --init.

  3. Build and test sources against a specific version of python. The makefile will automatically find python if PY_BIN is not defined, but providing an explicit path avoids confusion down the road. For old Python2 builds, PY_BIN is required, as Python3 will be built by default.

    cd das3py
    make PY_BIN=/path/to/python           # See PY_BIN note above
    make PY_BIN=/path/to/python test      # optional, but recommended
    make PY_BIN=/path/to/python examples  # optional, needs network access
    

    The first make also builds the bundled das2C, which downloads the sources of NASA's CDF library. To use a CDF you already have, set CDF_INC and CDF_LIB as das2C's own build notes describe.

    To build against some other das2C, a development checkout for example, build that one yourself and reference it. das3py does not alter an external das2C build, it just uses it.

    make DAS2C=/path/to/das2C PY_BIN=/path/to/python
    
  4. Install into your desired python environment.

    /path/to/python -m pip install ./dist/das3py-*.whl
    
    # or
    
    make PY_BIN=/path/to/python install
    

The PyPI packages are built in a manylinux container with make pypi. The Makefile explains what that needs.

Windows and macOS

das3py has been built on Windows and macOS before, and setup.py has branches for both, but this release has not been tested on either. If you need it there, please ask on the issue tracker.

Reporting bugs

Please use the github.com issue tracker to report any problems with the library. If you've fixed a bug, thanks! Please send a pull request so that your fix can be merged into the main project.

Metadata

Release files for das3py 3.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for das3py 3.0.6
File Actions
das3py-3.0.6-cp315-cp315-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl CPython 3.15 CPython 3.15 Linux glibc 2.26+ x86-64, Linux glibc 2.28+ x86-64 Details for das3py-3.0.6-cp315-cp315-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
das3py-3.0.6-cp314-cp314-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.26+ x86-64, Linux glibc 2.28+ x86-64 Details for das3py-3.0.6-cp314-cp314-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
das3py-3.0.6-cp313-cp313-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.26+ x86-64, Linux glibc 2.28+ x86-64 Details for das3py-3.0.6-cp313-cp313-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
das3py-3.0.6-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.26+ x86-64, Linux glibc 2.28+ x86-64 Details for das3py-3.0.6-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
das3py-3.0.6-cp311-cp311-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.26+ x86-64, Linux glibc 2.28+ x86-64 Details for das3py-3.0.6-cp311-cp311-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
das3py-3.0.6-cp310-cp310-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.26+ x86-64, Linux glibc 2.28+ x86-64 Details for das3py-3.0.6-cp310-cp310-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
das3py-3.0.6-cp39-cp39-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.26+ x86-64, Linux glibc 2.28+ x86-64 Details for das3py-3.0.6-cp39-cp39-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
das3py-3.0.6-cp27-cp27mu-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.28+ x86-64, Linux glibc 2.26+ x86-64 Details for das3py-3.0.6-cp27-cp27mu-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl

Total release size: 37.6 MB

Release files / das3py-3.0.6-cp315-cp315-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl

Download URL das3py-3.0.6-cp315-cp315-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Size 4.7 MB
Tags CPython 3.15 Linux glibc 2.26+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
18299ff3e7d391a9a7bd9e87a2e9237bc2f36575021bb5b5250de2577edf1966
BLAKE2b-256 checksum
How to use checksums
40210254de744218ca933c7b9af8a54649ea331aa949f71642fe8821870e7045
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / das3py-3.0.6-cp314-cp314-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl

Download URL das3py-3.0.6-cp314-cp314-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Size 4.7 MB
Tags CPython 3.14 Linux glibc 2.26+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
5555f115079589f5e05cb0b6fdfb536ae63e3461df7301f50f120a7709e245a2
BLAKE2b-256 checksum
How to use checksums
f27be1a12bc265ce669e29f1d60db0aeab9e96ed41fa824eff6abd8c5d198abe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / das3py-3.0.6-cp313-cp313-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl

Download URL das3py-3.0.6-cp313-cp313-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Size 4.7 MB
Tags CPython 3.13 Linux glibc 2.26+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
e1a400f5235162494156a98cfaf3f7c97dc70e511570342ffd056ed4b2993e50
BLAKE2b-256 checksum
How to use checksums
8116d13841812b7391f52364e1ab3f51ccd3fef1126620c57ae77848eedfe841
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / das3py-3.0.6-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl

Download URL das3py-3.0.6-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Size 4.7 MB
Tags CPython 3.12 Linux glibc 2.26+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
e76ca6e0622d4a1c11b74cf92b173e896924e6d43d11291c160349b181167ae6
BLAKE2b-256 checksum
How to use checksums
4291df8c3867e039facb578b23940fe813c8ca2099ebb3a29855075434145738
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / das3py-3.0.6-cp311-cp311-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl

Download URL das3py-3.0.6-cp311-cp311-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Size 4.7 MB
Tags CPython 3.11 Linux glibc 2.26+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
52a48ca1968bb0a32bcff4fa6e0415e590b29d086e67ec8ad7443fc623f7faee
BLAKE2b-256 checksum
How to use checksums
2353fcb05ad40250dceaccc9d49356ead430055ef92eb1d9f0213fd047b6f2c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / das3py-3.0.6-cp310-cp310-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl

Download URL das3py-3.0.6-cp310-cp310-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Size 4.7 MB
Tags CPython 3.10 Linux glibc 2.26+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
a4942f8850f46437ae516685850757ac9066720aad356aa76d6e324e1109a690
BLAKE2b-256 checksum
How to use checksums
4b60b93fc46d220469fe7b65f0573e4a973aa31f8192737cc59a86b2bda01ff4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / das3py-3.0.6-cp39-cp39-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl

Download URL das3py-3.0.6-cp39-cp39-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Size 4.7 MB
Tags CPython 3.9 Linux glibc 2.26+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
f80a6e6de1ea583489afbc336f58679147784bbf6984a436ca14c30bb1725668
BLAKE2b-256 checksum
How to use checksums
45cc24d63b4999420ec4f6003227cd0dcffff1143db6088ccfe3337709231aff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / das3py-3.0.6-cp27-cp27mu-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl

Download URL das3py-3.0.6-cp27-cp27mu-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Size 4.7 MB
Tags CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.26+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
70c336613f06c458674311c92bbbeb4ebf2da06659ae2366d5e71ae6175c1eef
BLAKE2b-256 checksum
How to use checksums
d8029abdd1acf402d402748f59cba8eca6f3861dfea85144b9a15f15a386edfc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for das3py 3.0.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page