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.

  • Windows on 64-bit x86, for Python 3.9 through 3.13. Nothing else has to be installed.

If pip is older than 20.3, 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 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
curl -O https://raw.githubusercontent.com/das-developers/das3py/main/examples/ex02_galileo_pws_spectra.py
python ex02_galileo_pws_spectra.py

On Windows type curl.exe in place of curl. In Windows PowerShell, curl alone is a different command.

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/cassini/rpws/survey_keyparam/das2' )
header, datasets = src.get( {'time' : ('2017-09-02', '2017-09-03')} )
  • get() returns the stream header and a list of datasets. This source sends one: a day of Cassini RPWS electric field spectra, one spectrum a minute at 73 frequencies.
  • print(src.info()) lists the query parameters a source takes.
  • 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_specdens']['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 das3.mpl   # das2 label formatting for matplotlib
import matplotlib.pyplot as pyplot
import matplotlib.colors as colors

fig, ax = pyplot.subplots()
im = ax.pcolormesh(vX.array, vY.array, vZ.array, norm=colors.LogNorm(), cmap='jet')
ax.set_yscale('log')
fig.colorbar(im, label=das3.mpl.label(dataset['electric_specdens'].props['label']))
fig.autofmt_xdate()

ax.set_title(das3.mpl.label(header['props']['title']))
ax.set_xlabel(das3.mpl.range_label(dataset['time']))
ax.set_ylabel(das3.mpl.label(dataset['frequency'].props['label']))
pyplot.show()
  • The title and axis labels come from the stream. das3.mpl.label() converts das2 formatting codes, such as !a for superscript, to matplotlib's, and das3.mpl.range_label() describes the time range.
  • Times arrive as NumPy datetime64 values, which matplotlib plots as dates.
  • Fill values arrive masked: vZ.array is a NumPy masked array.

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 Linux PyPI packages are built in a manylinux container with make pypi. The Makefile explains what that needs.

Windows and macOS

The Windows PyPI packages are built with buildfiles\win_wheels.bat. It uses Visual Studio, vcpkg and das2C's nmake makefile, and the comments at the top of the file list what it needs.

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

Licenses

das3py is under the MIT license. The PyPI packages also contain das2C and other libraries, compiled in. THIRD-PARTY.txt lists them and their licenses, and each package carries the license texts.

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.8

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.8
File Actions
das3py-3.0.8-cp315-cp315-macosx_11_0_arm64.whl CPython 3.15 CPython 3.15 macOS 11.0+ ARM64 Details for das3py-3.0.8-cp315-cp315-macosx_11_0_arm64.whl
das3py-3.0.8-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details for das3py-3.0.8-cp314-cp314-macosx_11_0_arm64.whl
das3py-3.0.8-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for das3py-3.0.8-cp313-cp313-macosx_11_0_arm64.whl
das3py-3.0.8-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for das3py-3.0.8-cp312-cp312-macosx_11_0_arm64.whl
das3py-3.0.8-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for das3py-3.0.8-cp311-cp311-macosx_11_0_arm64.whl
das3py-3.0.8-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details for das3py-3.0.8-cp310-cp310-macosx_11_0_arm64.whl
das3py-3.0.8-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details for das3py-3.0.8-cp39-cp39-macosx_11_0_arm64.whl

Total release size: 23.7 MB

Release files / das3py-3.0.8-cp315-cp315-macosx_11_0_arm64.whl

Download URL das3py-3.0.8-cp315-cp315-macosx_11_0_arm64.whl
Size 3.4 MB
Tags CPython 3.15 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2faaced1eff0ff8cdb3d392caa243f995d77c6dfc9e6fc284177deabfe2fa62f
BLAKE2b-256 checksum
How to use checksums
22fc38f802aff62ca541a98a5b4e799039b608fce8dd75af5532a407bf72bf70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / das3py-3.0.8-cp314-cp314-macosx_11_0_arm64.whl

Download URL das3py-3.0.8-cp314-cp314-macosx_11_0_arm64.whl
Size 3.4 MB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b4b6f8160712e001dcff3d7825df064e28b72aa82dc1978df51d4d2b6f462348
BLAKE2b-256 checksum
How to use checksums
502ce46cfcdc603c0b37f6d026d4af46ff00482a5fb71474cc5c8cc412738a6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / das3py-3.0.8-cp313-cp313-macosx_11_0_arm64.whl

Download URL das3py-3.0.8-cp313-cp313-macosx_11_0_arm64.whl
Size 3.4 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2e6f339b329612df4d3ccb0d26b7682cf47dde48b8c0c91f868a1a1e9367f9e0
BLAKE2b-256 checksum
How to use checksums
73e64c9c785ccedbd1675bb295c1f018aadacc9e6381b9fce9a6b467f5c0bebe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / das3py-3.0.8-cp312-cp312-macosx_11_0_arm64.whl

Download URL das3py-3.0.8-cp312-cp312-macosx_11_0_arm64.whl
Size 3.4 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
48dba3e2a8b62523c57aacf67957ab26e52b182239ac65207746b24603e0d1a2
BLAKE2b-256 checksum
How to use checksums
707e3d0cf9012e2e4c7cd8123fd4c1849ef203d983ed53951039a63b070950ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / das3py-3.0.8-cp311-cp311-macosx_11_0_arm64.whl

Download URL das3py-3.0.8-cp311-cp311-macosx_11_0_arm64.whl
Size 3.4 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6d52f54c5f1236f54d8334da3b38f5c6cafd3e0737a8a855ee65758d02d8ebba
BLAKE2b-256 checksum
How to use checksums
0d564e939227ae3b2a20328bd9503e1fb274836f9f1d68b40722efbb28ffbedb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / das3py-3.0.8-cp310-cp310-macosx_11_0_arm64.whl

Download URL das3py-3.0.8-cp310-cp310-macosx_11_0_arm64.whl
Size 3.4 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d3b5a45b860fb65830fb023f3810b8e2e0dd93f186642500ee4dbc62882b7c43
BLAKE2b-256 checksum
How to use checksums
6e3f7ef8f81410f30895928aafa8b5c6d27ce936cc9dc0129a72f14d740375f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / das3py-3.0.8-cp39-cp39-macosx_11_0_arm64.whl

Download URL das3py-3.0.8-cp39-cp39-macosx_11_0_arm64.whl
Size 3.4 MB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2c1fad6890633d41ad31326b9c9697ccda83f7e0df563a20b0b6cd5fc00bfe58
BLAKE2b-256 checksum
How to use checksums
876be77317795e1f7e503f2f7a971c5f6e57ffec465be468455b04a1daa7e733
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Security for das3py 3.0.8

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