|
| 1 | +# xarray: N-D labeled arrays and datasets |
| 2 | + |
| 3 | +[](https://github.com/pydata/xarray/actions?query=workflow%3ACI) |
| 4 | +[](https://codecov.io/gh/pydata/xarray) |
| 5 | +[](https://docs.xarray.dev/) |
| 6 | +[](https://pandas.pydata.org/speed/xarray/) |
| 7 | +[](https://pypi.python.org/pypi/xarray/) |
| 8 | +[](https://github.com/python/black) |
| 9 | +[](https://doi.org/10.5281/zenodo.598201) |
| 10 | +[](https://twitter.com/xarray_dev) |
| 11 | + |
| 12 | +**xarray** (formerly **xray**) is an open source project and Python |
| 13 | +package that makes working with labelled multi-dimensional arrays |
| 14 | +simple, efficient, and fun! |
| 15 | + |
| 16 | +Xarray introduces labels in the form of dimensions, coordinates and |
| 17 | +attributes on top of raw [NumPy](https://www.numpy.org)-like arrays, |
| 18 | +which allows for a more intuitive, more concise, and less error-prone |
| 19 | +developer experience. The package includes a large and growing library |
| 20 | +of domain-agnostic functions for advanced analytics and visualization |
| 21 | +with these data structures. |
| 22 | + |
| 23 | +Xarray was inspired by and borrows heavily from |
| 24 | +[pandas](https://pandas.pydata.org), the popular data analysis package |
| 25 | +focused on labelled tabular data. It is particularly tailored to working |
| 26 | +with [netCDF](https://www.unidata.ucar.edu/software/netcdf) files, which |
| 27 | +were the source of xarray\'s data model, and integrates tightly with |
| 28 | +[dask](https://dask.org) for parallel computing. |
| 29 | + |
| 30 | +## Why xarray? |
| 31 | + |
| 32 | +Multi-dimensional (a.k.a. N-dimensional, ND) arrays (sometimes called |
| 33 | +"tensors") are an essential part of computational science. They are |
| 34 | +encountered in a wide range of fields, including physics, astronomy, |
| 35 | +geoscience, bioinformatics, engineering, finance, and deep learning. In |
| 36 | +Python, [NumPy](https://www.numpy.org) provides the fundamental data |
| 37 | +structure and API for working with raw ND arrays. However, real-world |
| 38 | +datasets are usually more than just raw numbers; they have labels which |
| 39 | +encode information about how the array values map to locations in space, |
| 40 | +time, etc. |
| 41 | + |
| 42 | +Xarray doesn\'t just keep track of labels on arrays \-- it uses them to |
| 43 | +provide a powerful and concise interface. For example: |
| 44 | + |
| 45 | +- Apply operations over dimensions by name: `x.sum('time')`. |
| 46 | +- Select values by label instead of integer location: |
| 47 | + `x.loc['2014-01-01']` or `x.sel(time='2014-01-01')`. |
| 48 | +- Mathematical operations (e.g., `x - y`) vectorize across multiple |
| 49 | + dimensions (array broadcasting) based on dimension names, not shape. |
| 50 | +- Flexible split-apply-combine operations with groupby: |
| 51 | + `x.groupby('time.dayofyear').mean()`. |
| 52 | +- Database like alignment based on coordinate labels that smoothly |
| 53 | + handles missing values: `x, y = xr.align(x, y, join='outer')`. |
| 54 | +- Keep track of arbitrary metadata in the form of a Python dictionary: |
| 55 | + `x.attrs`. |
| 56 | + |
| 57 | +## Documentation |
| 58 | + |
| 59 | +Learn more about xarray in its official documentation at |
| 60 | +<https://docs.xarray.dev/>. |
| 61 | + |
| 62 | +Try out an [interactive Jupyter |
| 63 | +notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/weather-data.ipynb). |
| 64 | + |
| 65 | +## Contributing |
| 66 | + |
| 67 | +You can find information about contributing to xarray at our |
| 68 | +[Contributing |
| 69 | +page](https://docs.xarray.dev/en/latest/contributing.html#). |
| 70 | + |
| 71 | +## Get in touch |
| 72 | + |
| 73 | +- Ask usage questions ("How do I?") on |
| 74 | + [StackOverflow](https://stackoverflow.com/questions/tagged/python-xarray). |
| 75 | +- Report bugs, suggest features or view the source code [on |
| 76 | + GitHub](https://github.com/pydata/xarray). |
| 77 | +- For less well defined questions or ideas, or to announce other |
| 78 | + projects of interest to xarray users, use the [mailing |
| 79 | + list](https://groups.google.com/forum/#!forum/xarray). |
| 80 | + |
| 81 | +## NumFOCUS |
| 82 | + |
| 83 | +[](https://numfocus.org/) |
| 84 | + |
| 85 | +Xarray is a fiscally sponsored project of |
| 86 | +[NumFOCUS](https://numfocus.org), a nonprofit dedicated to supporting |
| 87 | +the open source scientific computing community. If you like Xarray and |
| 88 | +want to support our mission, please consider making a |
| 89 | +[donation](https://numfocus.salsalabs.org/donate-to-xarray/) to support |
| 90 | +our efforts. |
| 91 | + |
| 92 | +## History |
| 93 | + |
| 94 | +Xarray is an evolution of an internal tool developed at [The Climate |
| 95 | +Corporation](http://climate.com/). It was originally written by Climate |
| 96 | +Corp researchers Stephan Hoyer, Alex Kleeman and Eugene Brevdo and was |
| 97 | +released as open source in May 2014. The project was renamed from |
| 98 | +"xray" in January 2016. Xarray became a fiscally sponsored project of |
| 99 | +[NumFOCUS](https://numfocus.org) in August 2018. |
| 100 | + |
| 101 | +## License |
| 102 | + |
| 103 | +Copyright 2014-2019, xarray Developers |
| 104 | + |
| 105 | +Licensed under the Apache License, Version 2.0 (the "License"); you |
| 106 | +may not use this file except in compliance with the License. You may |
| 107 | +obtain a copy of the License at |
| 108 | + |
| 109 | + <https://www.apache.org/licenses/LICENSE-2.0> |
| 110 | + |
| 111 | +Unless required by applicable law or agreed to in writing, software |
| 112 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 113 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 114 | +See the License for the specific language governing permissions and |
| 115 | +limitations under the License. |
| 116 | + |
| 117 | +Xarray bundles portions of pandas, NumPy and Seaborn, all of which are |
| 118 | +available under a "3-clause BSD" license: |
| 119 | + |
| 120 | +- pandas: setup.py, xarray/util/print_versions.py |
| 121 | +- NumPy: xarray/core/npcompat.py |
| 122 | +- Seaborn: _determine_cmap_params in xarray/core/plot/utils.py |
| 123 | + |
| 124 | +Xarray also bundles portions of CPython, which is available under the |
| 125 | +"Python Software Foundation License" in xarray/core/pycompat.py. |
| 126 | + |
| 127 | +Xarray uses icons from the icomoon package (free version), which is |
| 128 | +available under the "CC BY 4.0" license. |
| 129 | + |
| 130 | +The full text of these licenses are included in the licenses directory. |
0 commit comments