das2py


Namedas2py JSON
Version 2.3.1 PyPI version JSON
download
home_pagehttps://das2.org/das2py
SummaryAn efficient space physics data client for python
upload_time2023-11-21 04:47:51
maintainer
docs_urlNone
authorC Piker
requires_python>=2.7
licenseMIT License Copyright (c) 2023 Chris Piker Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords space-physics magneosphere das2
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # das2py
Das2 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, *das2py* provides 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 Package
[![Anaconda Package](https://anaconda.org/dasdevelopers/das2py/badges/version.svg)](https://anaconda.org/DasDevelopers/das2py)

Pre-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:
```bash
(base) $ conda install -c dasdevelopers das2py
```
The anaconda package automatically pulls in [das2C](https://anaconda.org/dasdevelopers/das2c), 
[pycdf](https://anaconda.org/dasdevelopers/pycdf), and [pthreads4w](https://anaconda.org/dasdevelopers/pthreads4w) as needed.

If this works then test using:
```bash
(base) $ wget https://raw.githubusercontent.com/das-developers/das2py/master/examples/ex05_mex_marsis_query_by_angle.py
(base) $ python ex02_galileo_pws_spectra.py
```
If this command produces a plot similar to the following\.\.\.

<img src="https://raw.githubusercontent.com/das-developers/das2py/master/examples/ex05_mex_marsis_query_by_angle.png" width="660" height="379">

\.\.\.then das2py is installed, and you can skip building the software and
head straight the example program below.

## Prerequisite
Compilation 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](https://github.com/das-developers/das2C) - Version 2.3 or above.  Need not be installed, but must be built
  * **NumPy** - Version 1.10.1 or above
  * **MatplotLib++** - For plotting data (optional, recommended)
  * **[CDF](https://spdf.gsfc.nasa.gov/pub/software/cdf/dist/cdf38_1/cdf38_1-dist-cdf.tar.gz)** - For writing CDF files (optional)

Pre-requisite package install commands are give below.
```bash
$ sudo apt install python3-setuptools python3-dev python3-numpy # debian
```

## New 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.
```bash
# (Works on Linux, more steps needed on Windows & MacOS. 
#  See buildfiles/pypi/ReadMe.md for details)

# First build and test das2C, installation is not necessary
git clone git@github.com:das-developers/das2C.git
cd das2C
env N_ARCH=/ make 
env N_ARCH=/ make test
cd ../

# Now build das2py using the PIP of your choice in an adjacent directory
git clone git@github.com:das-developers/das2py.git
cd das2py
env DAS2C_LIBDIR=$PWD/../das2C/build. DAS2C_INCDIR=$PWD/../das2C python3.9 -m build
```
That'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:
```bash
pip3.9 install ./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...
```bash
das_verify das2py/test/ex96_yscan_multispec.d2t
```
and to generate a plot of Cassini electron cyclotron frequencies.
```bash
python3.9 das2py/examples/ex09_cassini_fce_ephem_ticks.py 2017-09-14
okular cas_mag_fce_2017-09-14.png # Or whatever PNG viewer you like
```

## Old Build and Install

*The 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-packages` but any location is fine so long as
it is on the `PYTHONPATH` or you are willing to add it to your PYTHONPATH.

```bash
# Where to find the das2C static library
$ export DAS2C_INCDIR=$HOME/git/das2C
$ export DAS2C_LIBDIR=$HOME/git/das2C/build.  #last dot is not a typo

# Which python version to use
$ export PYVER=3.9

# Where you want to install the files
$ export INST_HOST_LIB=/usr/local/lib/python3.9
$ export INST_EXT_LIB=/usr/local/lib/python3.9

# Build and test
$ make           # <-- If only using system packages
$ make local     # <-- If using numpy or others from $HOME/.local
                 #     Do not use for RPM/DEB builds
$ make test

# Check install location, then install
$ make -n install
$ make install
```

## First program

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

### Query a URI for reduced resolution data
```python
import das2
src = 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 a [das2 catalog](https://das2.org/browse) browser,
    or using das2py to get the root node (see [example 11](https://raw.githubusercontent.com/das-developers/das2py/master/examples/ex11_catalog_listings.py)).

### Access quantities by physical dimensions
```python
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.
```python
import matplotlib.pyplot as pyplot
import matplotlib.colors as colors

fig, 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 bugs
Please use the github.com [issue tracker](https://github.com/das-developers/das2py/issues) 
report 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.





            

Raw data

            {
    "_id": null,
    "home_page": "https://das2.org/das2py",
    "name": "das2py",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=2.7",
    "maintainer_email": "K Steele <KaiwenS7@users.noreply.github.com>",
    "keywords": "space-physics,magneosphere,das2",
    "author": "C Piker",
    "author_email": "C Piker <cpiker@users.noreply.github.com>",
    "download_url": "",
    "platform": null,
    "description": "# das2py\r\nDas2 servers typically provide data relevant to space plasma and magnetospheric\r\nphysics research. To retrieve data, an HTTP GET request is posted to a das2\r\nserver by a client program and a self-describing stream of data values covering\r\nthe requested time range, at the requested time resolution, is provided in the\r\nresponse body. This package, *das2py* provides an efficient space physics data\r\nclient for python.  Streams are parsed and stored as NumPy arrays using a C\r\nextension, avoiding data copies and conversions.\r\n\r\n## Anaconda Package\r\n[![Anaconda Package](https://anaconda.org/dasdevelopers/das2py/badges/version.svg)](https://anaconda.org/DasDevelopers/das2py)\r\n\r\nPre-build versions of das2py are available from Anaconda.  If you're working in an \r\nAnoconda or Miniconda python 3 environment these are easier to install as no C \r\ncompiler is required.   To install the conda package run the command:\r\n```bash\r\n(base) $ conda install -c dasdevelopers das2py\r\n```\r\nThe anaconda package automatically pulls in [das2C](https://anaconda.org/dasdevelopers/das2c), \r\n[pycdf](https://anaconda.org/dasdevelopers/pycdf), and [pthreads4w](https://anaconda.org/dasdevelopers/pthreads4w) as needed.\r\n\r\nIf this works then test using:\r\n```bash\r\n(base) $ wget https://raw.githubusercontent.com/das-developers/das2py/master/examples/ex05_mex_marsis_query_by_angle.py\r\n(base) $ python ex02_galileo_pws_spectra.py\r\n```\r\nIf this command produces a plot similar to the following\\.\\.\\.\r\n\r\n<img src=\"https://raw.githubusercontent.com/das-developers/das2py/master/examples/ex05_mex_marsis_query_by_angle.png\" width=\"660\" height=\"379\">\r\n\r\n\\.\\.\\.then das2py is installed, and you can skip building the software and\r\nhead straight the example program below.\r\n\r\n## Prerequisite\r\nCompilation and installation of das2py has been tested on Linux, Windows, MacOS using\r\nboth Python 2 and Python 3.  The following packages are required to build das2py:\r\n\r\n  * [Das2C](https://github.com/das-developers/das2C) - Version 2.3 or above.  Need not be installed, but must be built\r\n  * **NumPy** - Version 1.10.1 or above\r\n  * **MatplotLib++** - For plotting data (optional, recommended)\r\n  * **[CDF](https://spdf.gsfc.nasa.gov/pub/software/cdf/dist/cdf38_1/cdf38_1-dist-cdf.tar.gz)** - For writing CDF files (optional)\r\n\r\nPre-requisite package install commands are give below.\r\n```bash\r\n$ sudo apt install python3-setuptools python3-dev python3-numpy # debian\r\n```\r\n\r\n## New build instructions (wheel)\r\n\r\nIn this version, almost no environment variables are needed  Below, das2C\r\nis built adjacent to das2py so that it can be included in das2py.\r\n```bash\r\n# (Works on Linux, more steps needed on Windows & MacOS. \r\n#  See buildfiles/pypi/ReadMe.md for details)\r\n\r\n# First build and test das2C, installation is not necessary\r\ngit clone git@github.com:das-developers/das2C.git\r\ncd das2C\r\nenv N_ARCH=/ make \r\nenv N_ARCH=/ make test\r\ncd ../\r\n\r\n# Now build das2py using the PIP of your choice in an adjacent directory\r\ngit clone git@github.com:das-developers/das2py.git\r\ncd das2py\r\nenv DAS2C_LIBDIR=$PWD/../das2C/build. DAS2C_INCDIR=$PWD/../das2C python3.9 -m build\r\n```\r\nThat's it!  Now you have a wheel file that can be installed where ever you\r\nlike.  The included setup.py instructs the python setuptools module to staticlly\r\nlink das2C. So the wheel is self contained.\r\n\r\nTo install your new wheel into the user-local area:\r\n```bash\r\npip3.9 install ./dist/das2py-2.3.0-cp310-cp310-linux_x86_64.whl\r\nls .local/bin/das_verify\r\nls .local/lib/python3.9/site-packages/das2\r\nls .local/lib/python3.9/site-packages/_das2*\r\n```\r\n\r\nTo test it by validating one of the example files...\r\n```bash\r\ndas_verify das2py/test/ex96_yscan_multispec.d2t\r\n```\r\nand to generate a plot of Cassini electron cyclotron frequencies.\r\n```bash\r\npython3.9 das2py/examples/ex09_cassini_fce_ephem_ticks.py 2017-09-14\r\nokular cas_mag_fce_2017-09-14.png # Or whatever PNG viewer you like\r\n```\r\n\r\n## Old Build and Install\r\n\r\n*The old makefile based build and install wrapper is still supported.  It's \r\nbased on distutils, and it works for Python 2.7 and up.  For newer versions \r\nof python the pip-wheel build is recommended, for Python2 support read on...*\r\n\r\nDecide where you want to install das2py.  In the example below I've selected \r\n`/usr/local/lib/python3.9/site-packages` but any location is fine so long as\r\nit is on the `PYTHONPATH` or you are willing to add it to your PYTHONPATH.\r\n\r\n```bash\r\n# Where to find the das2C static library\r\n$ export DAS2C_INCDIR=$HOME/git/das2C\r\n$ export DAS2C_LIBDIR=$HOME/git/das2C/build.  #last dot is not a typo\r\n\r\n# Which python version to use\r\n$ export PYVER=3.9\r\n\r\n# Where you want to install the files\r\n$ export INST_HOST_LIB=/usr/local/lib/python3.9\r\n$ export INST_EXT_LIB=/usr/local/lib/python3.9\r\n\r\n# Build and test\r\n$ make           # <-- If only using system packages\r\n$ make local     # <-- If using numpy or others from $HOME/.local\r\n                 #     Do not use for RPM/DEB builds\r\n$ make test\r\n\r\n# Check install location, then install\r\n$ make -n install\r\n$ make install\r\n```\r\n\r\n## First program\r\n\r\nThe following small program demonstrates how to query for data and generate a plot \r\nusing das2py.\r\n\r\n### Query a URI for reduced resolution data\r\n```python\r\nimport das2\r\nsrc = das2.get_source( 'tag:das2.org,2012:site:/uiowa/galileo/pws/survey_electric/das2' )\r\ndataset = src.get( {'time' : ('1997-05-07T15:00', '1997-05-07T17:00', 4.0)} )[0] \r\n```\r\n  * Servers come and go.  The federated catalog provides stability for \r\n    application code by maping URIs to data sources.\r\n  * Browse for URIs using a [das2 catalog](https://das2.org/browse) browser,\r\n    or using das2py to get the root node (see [example 11](https://raw.githubusercontent.com/das-developers/das2py/master/examples/ex11_catalog_listings.py)).\r\n\r\n### Access quantities by physical dimensions\r\n```python\r\nprint(dataset)\r\n\r\nvX = dataset['time']['center']\r\nvY = dataset['frequency']['center']\r\nvZ = dataset['electric']['center'] \r\n```\r\n  * Datasets contain dimensions. Dimensions contain variables. Each variable in a \r\n    dimension serves a purpose, the most common is to define the center point of a\r\n    coordinate or measurement. \r\n  * Array dimensions are not confused with physical dimensions. Dataset meaning is\r\n    not tied to any particular array morphology.\r\n\r\n### Use Matplotlib to generate an image.\r\n```python\r\nimport matplotlib.pyplot as pyplot\r\nimport matplotlib.colors as colors\r\n\r\nfig, ax = pyplot.subplots()\r\nscaleZ = colors.LogNorm(vmin=vZ.array.min(), vmax=vZ.array.max())\r\nax.pcolormesh(vX.array, vY.array, vZ.array, norm=scaleZ, cmap='jet')\r\npyplot.show() \r\n```\r\n## Reporting bugs\r\nPlease use the github.com [issue tracker](https://github.com/das-developers/das2py/issues) \r\nreport any problems with the library.  If you've fixed a bug, 1) thanks!, 2) please send\r\na pull request so that your updates can be merged into the main project.\r\n\r\n\r\n\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 Chris Piker  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "An efficient space physics data client for python",
    "version": "2.3.1",
    "project_urls": {
        "Homepage": "https://das2.org/das2py",
        "Repository": "https://github.com/das-developers/das2py"
    },
    "split_keywords": [
        "space-physics",
        "magneosphere",
        "das2"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1fa1bea721c19528c2bc5015d31ecd95ef333a2cc86e537a4e6fe20b0787fe36",
                "md5": "1532d180a5554e9afe8ca243036bb15f",
                "sha256": "107fa0b5423e328fbf56373a8526186ad31bcc513fa17f66a2e5b2cba63d0688"
            },
            "downloads": -1,
            "filename": "das2py-2.3.1-cp310-cp310-macosx_12_0_x86_64.whl",
            "has_sig": false,
            "md5_digest": "1532d180a5554e9afe8ca243036bb15f",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=2.7",
            "size": 3150841,
            "upload_time": "2023-11-21T04:47:51",
            "upload_time_iso_8601": "2023-11-21T04:47:51.618879Z",
            "url": "https://files.pythonhosted.org/packages/1f/a1/bea721c19528c2bc5015d31ecd95ef333a2cc86e537a4e6fe20b0787fe36/das2py-2.3.1-cp310-cp310-macosx_12_0_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b995015b7e4d25e714be7e58b138f1908b676371384f69a6c36de8409a67a54e",
                "md5": "b0a13dbaf80b53789e8836dd3de98faf",
                "sha256": "5054ad211e8873b3c686f6b6422ae7568b85e183f5282a30629523a360b1f7d0"
            },
            "downloads": -1,
            "filename": "das2py-2.3.1-cp310-cp310-macosx_14_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "b0a13dbaf80b53789e8836dd3de98faf",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=2.7",
            "size": 2202111,
            "upload_time": "2023-11-21T03:41:06",
            "upload_time_iso_8601": "2023-11-21T03:41:06.888631Z",
            "url": "https://files.pythonhosted.org/packages/b9/95/015b7e4d25e714be7e58b138f1908b676371384f69a6c36de8409a67a54e/das2py-2.3.1-cp310-cp310-macosx_14_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a71795d1776734d93a94a33c5b6a29a8e07d76d4c7a9b5ac13fd76071d7d3039",
                "md5": "9f54f92674db83f97b80755f06f12a06",
                "sha256": "e1c406b5ad8ebde82fd85ef6b9633af51d32293b123cfd056dc812ac4d3d6420"
            },
            "downloads": -1,
            "filename": "das2py-2.3.1-cp310-cp310-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "9f54f92674db83f97b80755f06f12a06",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=2.7",
            "size": 2346815,
            "upload_time": "2023-11-21T02:58:38",
            "upload_time_iso_8601": "2023-11-21T02:58:38.593190Z",
            "url": "https://files.pythonhosted.org/packages/a7/17/95d1776734d93a94a33c5b6a29a8e07d76d4c7a9b5ac13fd76071d7d3039/das2py-2.3.1-cp310-cp310-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-21 04:47:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "das-developers",
    "github_project": "das2py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "das2py"
}
        
Elapsed time: 0.94025s