Skip to main content

Introduction

https://github.com/perrette/dimarray/actions/workflows/tox.yml/badge.svg

Numpy array with dimensions

dimarray is a package to handle numpy arrays with labelled dimensions and axes. Inspired from pandas, it includes advanced alignment and reshaping features and as well as missing-value (NaN) handling.

The main difference with pandas is that it is generalized to N dimensions, and behaves more closely to a numpy array. The axes do not have fixed names (‘index’, ‘columns’, etc…) but are given a meaningful name by the user (e.g. ‘time’, ‘items’, ‘lon’ …). This is especially useful for high dimensional problems such as sensitivity analyses.

A natural I/O format for such an array is netCDF, common in geophysics, which relies on the netCDF4 package, and supports metadata.

License

dimarray is distributed under a 3-clause (“Simplified” or “New”) BSD license. Parts of basemap which have BSD compatible licenses are included. See the LICENSE file, which is distributed with the dimarray package, for details.

Getting started

A ``DimArray`` can be defined just like a numpy array, with additional information about its dimensions, which can be provided via its axes and dims parameters:

>>> from dimarray import DimArray
>>> a = DimArray([[1.,2,3], [4,5,6]], axes=[['a', 'b'], [1950, 1960, 1970]], dims=['variable', 'time'])
>>> a
dimarray: 6 non-null elements (0 null)
0 / variable (2): 'a' to 'b'
1 / time (3): 1950 to 1970
array([[1., 2., 3.],
       [4., 5., 6.]])

Indexing now works on axes

>>> a['b', 1970]
6.0

Or can just be done a la numpy, via integer index:

>>> a.ix[0, -1]
3.0

Basic numpy transformations are also in there:

>>> a.mean(axis='time')
dimarray: 2 non-null elements (0 null)
0 / variable (2): 'a' to 'b'
array([2., 5.])

Can export to pandas for pretty printing:

>>> a.to_pandas()
time      1950  1960  1970
variable
a          1.0   2.0   3.0
b          4.0   5.0   6.0

Install

Requirements:

  • python >= 3.7

  • numpy (latest test with version 1.21.5)

Optional:

  • netCDF4 (tested with 1.0.8, 1.2.1) (netCDF archiving) (see notes below)

  • matplotlib 1.1 (plotting)

  • pandas 0.11 (interface with pandas)

Download the latest version from github and extract from archive Then from the dimarray repository type (possibly preceded by sudo):

python setup.py install

Alternatively, you can use pip to download and install the version from pypi (could be slightly out-of-date):

pip install dimarray

Notes on installing netCDF4

sudo apt-get install libhdf5-serial-dev netcdf-bin libnetcdf-dev

Contributions

All suggestions for improvement or direct contributions are very welcome. You can open an issue on github for specific requests.

Metadata

Release files for dimarray 1.2.1

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

Source distribution (sdist)

Source distribution for dimarray 1.2.1
File Size Uploaded
dimarray-1.2.1.tar.gz 675.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dimarray 1.2.1
File Interpreter ABI Platform
dimarray-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 933.5 kB

Release files / dimarray-1.2.1.tar.gz

Download URL dimarray-1.2.1.tar.gz
Size 675.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6cd4fa74d7ac4fe8d5b84d86466c605fa95a921b0f87c20fd94c26d0d5d049c3
BLAKE2b-256 checksum
How to use checksums
02abc7e0b270fa5047fbbeef7f1014e07389df8244d5c88df0aed815eb84a72a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / dimarray-1.2.1-py3-none-any.whl

Download URL dimarray-1.2.1-py3-none-any.whl
Size 258.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2626f6f0e67dcc1c61d7ad77a1f553a4c7eac5e5534f41b251627ca9ac05a283
BLAKE2b-256 checksum
How to use checksums
865b8ec6eebccfff4bae3618ed9ddb9c0a26decdbbeb75105d67f26b5959ae96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.2

2 release files

1.0

3 release files

0.2.5

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

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