Package: das2py
das2pyDas2 servers typically provide data relevant to space plasma and magnetospheric
physics research. To retrieve data, an HTTP GET request is posted to a das2
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,das2pyprovides an efficient space physics data
client for python.  Streams are parsed and stored as NumPy arrays using a C
extension, avoiding data copies and conversions.Anaconda PackagePre-build versions of das2py are available from Anaconda.  If you're working in an
Anoconda or Miniconda python 3 environment these are easier to install as no C
compiler is required.   To install the conda package run the command:(base)$condainstall-cdasdevelopersdas2pyThe anaconda package automatically pulls indas2C,pycdf, andpthreads4was needed.If this works then test using:(base)$wgethttps://raw.githubusercontent.com/das-developers/das2py/master/examples/ex05_mex_marsis_query_by_angle.py(base)$pythonex02_galileo_pws_spectra.pyIf this command produces a plot similar to the following......then das2py is installed, and you can skip building the software and
head straight the example program below.PrerequisiteCompilation and installation of das2py has been tested on Linux, Windows, MacOS using
both Python 2 and Python 3.  The following packages are required to build das2py:Das2C- Version 2.3 or above.  Need not be installed, but must be builtNumPy- Version 1.10.1 or aboveMatplotLib++- For plotting data (optional, recommended)CDF- For writing CDF files (optional)Pre-requisite package install commands are give below.$sudoaptinstallpython3-setuptoolspython3-devpython3-numpy# debianNew build instructions (wheel)In this version, almost no environment variables are needed  Below, das2C
is built adjacent to das2py so that it can be included in das2py.# (Works on Linux, more steps needed on Windows & MacOS.#  See buildfiles/pypi/ReadMe.md for details)# First build and test das2C, installation is not necessarygitclonegit@github.com:das-developers/das2C.gitcddas2C
envN_ARCH=/makeenvN_ARCH=/maketestcd../# Now build das2py using the PIP of your choice in an adjacent directorygitclonegit@github.com:das-developers/das2py.gitcddas2py
envDAS2C_LIBDIR=$PWD/../das2C/build.DAS2C_INCDIR=$PWD/../das2Cpython3.9-mbuildThat's it!  Now you have a wheel file that can be installed where ever you
like.  The included setup.py instructs the python setuptools module to staticlly
link das2C. So the wheel is self contained.To install your new wheel into the user-local area:pip3.9install./dist/das2py-2.3.0-cp310-cp310-linux_x86_64.whl
ls.local/bin/das_verify
ls.local/lib/python3.9/site-packages/das2
ls.local/lib/python3.9/site-packages/_das2*To test it by validating one of the example files...das_verifydas2py/test/ex96_yscan_multispec.d2tand to generate a plot of Cassini electron cyclotron frequencies.python3.9das2py/examples/ex09_cassini_fce_ephem_ticks.py2017-09-14
okularcas_mag_fce_2017-09-14.png# Or whatever PNG viewer you likeOld Build and InstallThe old makefile based build and install wrapper is still supported.  It's
based on distutils, and it works for Python 2.7 and up.  For newer versions
of python the pip-wheel build is recommended, for Python2 support read on...Decide where you want to install das2py.  In the example below I've selected/usr/local/lib/python3.9/site-packagesbut any location is fine so long as
it is on thePYTHONPATHor you are willing to add it to your PYTHONPATH.# Where to find the das2C static library$exportDAS2C_INCDIR=$HOME/git/das2C
$exportDAS2C_LIBDIR=$HOME/git/das2C/build.#last dot is not a typo# Which python version to use$exportPYVER=3.9# Where you want to install the files$exportINST_HOST_LIB=/usr/local/lib/python3.9
$exportINST_EXT_LIB=/usr/local/lib/python3.9# Build and test$make# <-- If only using system packages$makelocal# <-- If using numpy or others from $HOME/.local#     Do not use for RPM/DEB builds$maketest# Check install location, then install$make-ninstall
$makeinstallFirst programThe following small program demonstrates how to query for data and generate a plot
using das2py.Query a URI for reduced resolution dataimportdas2src=das2.get_source('tag:das2.org,2012:site:/uiowa/galileo/pws/survey_electric/das2')dataset=src.get({'time':('1997-05-07T15:00','1997-05-07T17:00',4.0)})[0]Servers come and go.  The federated catalog provides stability for
application code by maping URIs to data sources.Browse for URIs using adas2 catalogbrowser,
or using das2py to get the root node (seeexample 11).Access quantities by physical dimensionsprint(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.importmatplotlib.pyplotaspyplotimportmatplotlib.colorsascolorsfig,ax=pyplot.subplots()scaleZ=colors.LogNorm(vmin=vZ.array.min(),vmax=vZ.array.max())ax.pcolormesh(vX.array,vY.array,vZ.array,norm=scaleZ,cmap='jet')pyplot.show()Reporting bugsPlease use the github.comissue trackerreport any problems with the library.  If you've fixed a bug, 1) thanks!, 2) please send
a pull request so that your updates can be merged into the main project.