Skip to content

Commit

Permalink
Merge branch 'master' into yohai-ds_scatter
Browse files Browse the repository at this point in the history
* master:
  Remove broken Travis-CI builds (pydata#2661)
  Type checking with mypy (pydata#2655)
  Added Coarsen (pydata#2612)
  Improve test for GH 2649 (pydata#2654)
  revise top-level package description (pydata#2430)
  Convert ref_date to UTC in encode_cf_datetime (pydata#2651)
  Change an `==` to an `is`. Fix tests so that this won't happen again. (pydata#2648)
  ENH: switch Dataset and DataArray to use explicit indexes (pydata#2639)
  Use pycodestyle for lint checks. (pydata#2642)
  Switch whats-new for 0.11.2 -> 0.11.3
  DOC: document v0.11.2 release
  Use built-in interp for interpolation with resample (pydata#2640)
  BUG: pytest-runner no required for setup.py (pydata#2643)
  • Loading branch information
dcherian committed Jan 8, 2019
2 parents faf4302 + 6795fd0 commit b5653a0
Show file tree
Hide file tree
Showing 60 changed files with 1,022 additions and 496 deletions.
14 changes: 9 additions & 5 deletions .pep8speaks.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# File : .pep8speaks.yml

# This should be kept in sync with the duplicate config in the [pycodestyle]
# block of setup.cfg.

scanner:
diff_only: True # If True, errors caused by only the patch are shown
diff_only: False # If True, errors caused by only the patch are shown

pycodestyle:
max-line-length: 79
ignore: # Errors and warnings to ignore
- E402, # module level import not at top of file
- E731, # do not assign a lambda expression, use a def
- W503 # line break before binary operator
- W504 # line break after binary operator
- E402 # module level import not at top of file
- E731 # do not assign a lambda expression, use a def
- E741 # ambiguous variable name
- W503 # line break before binary operator
- W504 # line break after binary operator
27 changes: 5 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,52 +17,35 @@ matrix:
- env:
- CONDA_ENV=py36
- EXTRA_FLAGS="--run-flaky --run-network-tests"
- env: CONDA_ENV=py36-netcdf4-dev
addons:
apt_packages:
- libhdf5-serial-dev
- netcdf-bin
- libnetcdf-dev
- env: CONDA_ENV=py36-dask-dev
- env: CONDA_ENV=py36-pandas-dev
- env: CONDA_ENV=py36-bottleneck-dev
- env: CONDA_ENV=py36-condaforge-rc
- env: CONDA_ENV=py36-pynio-dev
- env: CONDA_ENV=py36-rasterio
- env: CONDA_ENV=py36-zarr-dev
- env: CONDA_ENV=docs
- env: CONDA_ENV=flake8
- env: CONDA_ENV=lint
- env: CONDA_ENV=py36-hypothesis

allow_failures:
- env:
- CONDA_ENV=py36
- EXTRA_FLAGS="--run-flaky --run-network-tests"
- env: CONDA_ENV=py36-netcdf4-dev
addons:
apt_packages:
- libhdf5-serial-dev
- netcdf-bin
- libnetcdf-dev
- env: CONDA_ENV=py36-pandas-dev
- env: CONDA_ENV=py36-bottleneck-dev
- env: CONDA_ENV=py36-condaforge-rc
- env: CONDA_ENV=py36-pynio-dev
- env: CONDA_ENV=py36-zarr-dev

before_install:
- wget http://repo.continuum.io/miniconda/Miniconda3-3.16.0-Linux-x86_64.sh -O miniconda.sh;
- wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- hash -r
- conda config --set always_yes yes --set changeps1 no --set show_channel_urls true
- conda update -q conda
- conda info -a

install:
- if [[ "$CONDA_ENV" == "docs" ]]; then
conda env create -n test_env --file doc/environment.yml;
elif [[ "$CONDA_ENV" == "flake8" ]]; then
elif [[ "$CONDA_ENV" == "lint" ]]; then
conda env create -n test_env --file ci/requirements-py37.yml;
else
conda env create -n test_env --file ci/requirements-$CONDA_ENV.yml;
Expand All @@ -79,8 +62,8 @@ script:
- if [[ "$CONDA_ENV" == "docs" ]]; then
conda install -c conda-forge sphinx sphinx_rtd_theme sphinx-gallery numpydoc;
sphinx-build -n -j auto -b html -d _build/doctrees doc _build/html;
elif [[ "$CONDA_ENV" == "flake8" ]]; then
flake8 xarray ;
elif [[ "$CONDA_ENV" == "lint" ]]; then
pycodestyle xarray ;
elif [[ "$CONDA_ENV" == "py36-hypothesis" ]]; then
pytest properties ;
else
Expand Down
38 changes: 26 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,34 @@ xarray: N-D labeled arrays and datasets
.. image:: https://img.shields.io/badge/powered%20by-NumFOCUS-orange.svg?style=flat&colorA=E1523D&colorB=007D8A
:target: http://numfocus.org

**xarray** (formerly **xray**) is an open source project and Python package that aims to bring the
labeled data power of pandas_ to the physical sciences, by providing
N-dimensional variants of the core pandas data structures.

Our goal is to provide a pandas-like and pandas-compatible toolkit for
analytics on multi-dimensional arrays, rather than the tabular data for which
pandas excels. Our approach adopts the `Common Data Model`_ for self-
describing scientific data in widespread use in the Earth sciences:
``xarray.Dataset`` is an in-memory representation of a netCDF file.

**xarray** (formerly **xray**) is an open source project and Python package
that makes working with labelled multi-dimensional arrays simple,
efficient, and fun!

Multi-dimensional (a.k.a. N-dimensional, ND) arrays (sometimes called
"tensors") are an essential part of computational science.
They are encountered in a wide range of fields, including physics, astronomy,
geoscience, bioinformatics, engineering, finance, and deep learning.
In Python, NumPy_ provides the fundamental data structure and API for
working with raw ND arrays.
However, real-world datasets are usually more than just raw numbers;
they have labels which encode information about how the array values map
to locations in space, time, etc.

By introducing *dimensions*, *coordinates*, and *attributes* on top of raw
NumPy-like arrays, xarray is able to understand these labels and use them to
provide a more intuitive, more concise, and less error-prone experience.
Xarray also provides a large and growing library of functions for advanced
analytics and visualization with these data structures.
Xarray was inspired by and borrows heavily from pandas_, the popular data
analysis package focused on labelled tabular data.
Xarray can read and write data from most common labeled ND-array storage
formats and is particularly tailored to working with netCDF_ files, which were
the source of xarray's data model.

.. _NumPy: http://www.numpy.org/
.. _pandas: http://pandas.pydata.org
.. _Common Data Model: http://www.unidata.ucar.edu/software/thredds/current/netcdf-java/CDM
.. _netCDF: http://www.unidata.ucar.edu/software/netcdf
.. _OPeNDAP: http://www.opendap.org/

Why xarray?
-----------
Expand Down
8 changes: 4 additions & 4 deletions ci/install_python.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
# Authors: Olivier Grisel, Jonathan Helmus and Kyle Kastner
# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/

$MINICONDA_URL = "http://repo.continuum.io/miniconda/"
$MINICONDA_URL = "https://repo.anaconda.com/miniconda/"
$BASE_URL = "https://www.python.org/ftp/python/"


function DownloadMiniconda ($python_version, $platform_suffix) {
$webclient = New-Object System.Net.WebClient
if ($python_version -match "3.6") {
$filename = "Miniconda3-latest-Windows-" + $platform_suffix + ".exe"
} else {
if ($python_version -match "2.7") {
$filename = "Miniconda2-latest-Windows-" + $platform_suffix + ".exe"
} else {
$filename = "Miniconda3-latest-Windows-" + $platform_suffix + ".exe"
}
$url = $MINICONDA_URL + $filename

Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py35.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ dependencies:
- matplotlib=1.5
- netcdf4
- pytest
- pytest-env
- pytest-cov
- pytest-env
- coveralls
- flake8
- numpy
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py36-bottleneck-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ dependencies:
- matplotlib
- netcdf4
- pytest
- pytest-env
- pytest-cov
- pytest-env
- coveralls
- flake8
- numpy
Expand Down
23 changes: 0 additions & 23 deletions ci/requirements-py36-condaforge-rc.yml

This file was deleted.

2 changes: 1 addition & 1 deletion ci/requirements-py36-dask-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ dependencies:
- matplotlib
- netcdf4
- pytest
- pytest-env
- pytest-cov
- pytest-env
- coveralls
- flake8
- numpy
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py36-hypothesis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ dependencies:
- matplotlib
- netcdf4
- pytest
- pytest-env
- pytest-cov
- pytest-env
- coveralls
- hypothesis
- flake8
Expand Down
23 changes: 0 additions & 23 deletions ci/requirements-py36-netcdf4-dev.yml

This file was deleted.

2 changes: 1 addition & 1 deletion ci/requirements-py36-pandas-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ dependencies:
- matplotlib
- netcdf4
- pytest
- pytest-env
- pytest-cov
- pytest-env
- coveralls
- flake8
- numpy
Expand Down
26 changes: 0 additions & 26 deletions ci/requirements-py36-pynio-dev.yml

This file was deleted.

2 changes: 1 addition & 1 deletion ci/requirements-py36-rasterio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ dependencies:
- matplotlib
- netcdf4
- pytest
- pytest-env
- pytest-cov
- pytest-env
- coveralls
- numpy
- pandas
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py36-zarr-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ dependencies:
- distributed
- matplotlib
- pytest
- pytest-env
- pytest-cov
- pytest-env
- coveralls
- flake8
- numpy
Expand Down
3 changes: 2 additions & 1 deletion ci/requirements-py36.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
- pytest-cov
- pytest-env
- coveralls
- flake8
- pycodestyle
- numpy
- pandas
- scipy
Expand All @@ -32,3 +32,4 @@ dependencies:
- lxml
- pip:
- cfgrib>=0.9.2
- mypy==0.650
5 changes: 3 additions & 2 deletions ci/requirements-py37.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
- pytest-cov
- pytest-env
- coveralls
- flake8
- pycodestyle
- numpy
- pandas
- scipy
Expand All @@ -28,4 +28,5 @@ dependencies:
- eccodes
- pydap
- pip:
- cfgrib>=0.9.2
- cfgrib>=0.9.2
- mypy==0.650
2 changes: 2 additions & 0 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ Computation
Dataset.groupby
Dataset.groupby_bins
Dataset.rolling
Dataset.coarsen
Dataset.resample
Dataset.diff
Dataset.quantile
Expand Down Expand Up @@ -312,6 +313,7 @@ Computation
DataArray.groupby
DataArray.groupby_bins
DataArray.rolling
DataArray.coarsen
DataArray.dt
DataArray.resample
DataArray.get_axis_num
Expand Down
41 changes: 41 additions & 0 deletions doc/computation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,47 @@ You can also use ``construct`` to compute a weighted rolling sum:
To avoid this, use ``skipna=False`` as the above example.


.. _comput.coarsen:

Coarsen large arrays
====================

``DataArray`` and ``Dataset`` objects include a
:py:meth:`~xarray.DataArray.coarsen` and :py:meth:`~xarray.Dataset.coarsen`
methods. This supports the block aggregation along multiple dimensions,

.. ipython:: python
x = np.linspace(0, 10, 300)
t = pd.date_range('15/12/1999', periods=364)
da = xr.DataArray(np.sin(x) * np.cos(np.linspace(0, 1, 364)[:, np.newaxis]),
dims=['time', 'x'], coords={'time': t, 'x': x})
da
In order to take a block mean for every 7 days along ``time`` dimension and
every 2 points along ``x`` dimension,

.. ipython:: python
da.coarsen(time=7, x=2).mean()
:py:meth:`~xarray.DataArray.coarsen` raises an ``ValueError`` if the data
length is not a multiple of the corresponding window size.
You can choose ``boundary='trim'`` or ``boundary='pad'`` options for trimming
the excess entries or padding ``nan`` to insufficient entries,

.. ipython:: python
da.coarsen(time=30, x=2, boundary='trim').mean()
If you want to apply a specific function to coordinate, you can pass the
function or method name to ``coord_func`` option,

.. ipython:: python
da.coarsen(time=7, x=2, coord_func={'time': 'min'}).mean()
Computation using Coordinates
=============================

Expand Down
Loading

0 comments on commit b5653a0

Please sign in to comment.