Skip to content

Commit fd12b18

Browse files
committed
Merge branch 'master' into file-manager-del
2 parents 0a5b947 + 30288e8 commit fd12b18

18 files changed

+125
-80
lines changed

appveyor.yml

-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ branches:
77
environment:
88

99
matrix:
10-
- PYTHON: "C:\\Python27-conda32"
11-
PYTHON_VERSION: "2.7"
12-
PYTHON_ARCH: "32"
13-
CONDA_ENV: "py27-windows"
14-
1510
- PYTHON: "C:\\Python27-conda64"
1611
PYTHON_VERSION: "2.7"
1712
PYTHON_ARCH: "64"

doc/dask.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ Explicit conversion by wrapping a DataArray with ``np.asarray`` also works:
179179
Alternatively you can load the data into memory but keep the arrays as
180180
Dask arrays using the :py:meth:`~xarray.Dataset.persist` method:
181181

182-
.. ipython::
182+
.. ipython:: python
183183
184184
ds = ds.persist()
185185

doc/examples/multidimensional-coords.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ As an example, consider this dataset from the
2525

2626
.. ipython:: python
2727
28-
ds = xr.tutorial.load_dataset('rasm')
28+
ds = xr.tutorial.open_dataset('rasm').load()
2929
ds
3030
3131
In this example, the *logical coordinates* are ``x`` and ``y``, while
@@ -107,7 +107,8 @@ function to specify the output coordinates of the group.
107107
# define a label for each bin corresponding to the central latitude
108108
lat_center = np.arange(1, 90, 2)
109109
# group according to those bins and take the mean
110-
Tair_lat_mean = ds.Tair.groupby_bins('xc', lat_bins, labels=lat_center).mean()
110+
Tair_lat_mean = (ds.Tair.groupby_bins('xc', lat_bins, labels=lat_center)
111+
.mean(xr.ALL_DIMS))
111112
# plot the result
112113
@savefig xarray_multidimensional_coords_14_1.png width=5in
113114
Tair_lat_mean.plot();

doc/examples/weather-data.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Shared setup:
1717
.. ipython:: python
1818
:suppress:
1919
20-
fpath = "examples/_code/weather_data_setup.py"
20+
fpath = "doc/examples/_code/weather_data_setup.py"
2121
with open(fpath) as f:
2222
code = compile(f.read(), fpath, 'exec')
2323
exec(code)
@@ -123,6 +123,7 @@ The :py:func:`~xarray.Dataset.fillna` method on grouped objects lets you easily
123123
fill missing values by group:
124124

125125
.. ipython:: python
126+
:okwarning:
126127
127128
# throw away the first half of every month
128129
some_missing = ds.tmin.sel(time=ds['time.day'] > 15).reindex_like(ds)

doc/groupby.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ dimensions *other than* the provided one:
118118

119119
.. ipython:: python
120120
121-
ds.groupby('x').std()
121+
ds.groupby('x').std(xr.ALL_DIMS)
122122
123123
First and last
124124
~~~~~~~~~~~~~~
@@ -129,7 +129,7 @@ values for group along the grouped dimension:
129129

130130
.. ipython:: python
131131
132-
ds.groupby('letters').first()
132+
ds.groupby('letters').first(xr.ALL_DIMS)
133133
134134
By default, they skip missing values (control this with ``skipna``).
135135

@@ -144,7 +144,7 @@ coordinates. For example:
144144

145145
.. ipython:: python
146146
147-
alt = arr.groupby('letters').mean()
147+
alt = arr.groupby('letters').mean(xr.ALL_DIMS)
148148
alt
149149
ds.groupby('letters') - alt
150150
@@ -197,7 +197,7 @@ __ http://cfconventions.org/cf-conventions/v1.6.0/cf-conventions.html#_two_dimen
197197
'lat': (['ny','nx'], [[10,10],[20,20]] ),},
198198
dims=['ny','nx'])
199199
da
200-
da.groupby('lon').sum()
200+
da.groupby('lon').sum(xr.ALL_DIMS)
201201
da.groupby('lon').apply(lambda x: x - x.mean(), shortcut=False)
202202
203203
Because multidimensional groups have the ability to generate a very large

doc/internals.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Back in an interactive IPython session, we can use these properties:
111111
.. ipython:: python
112112
:suppress:
113113
114-
exec(open("examples/_code/accessor_example.py").read())
114+
exec(open("doc/examples/_code/accessor_example.py").read())
115115
116116
.. ipython:: python
117117

doc/pandas.rst

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ So you can represent a Panel, in two ways:
173173
Let's take a look:
174174

175175
.. ipython:: python
176+
:okwarning:
176177
177178
panel = pd.Panel(np.random.rand(2, 3, 4), items=list('ab'), major_axis=list('mno'),
178179
minor_axis=pd.date_range(start='2000', periods=4, name='date'))

doc/plotting.rst

+14-7
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ axes created by ``plt.subplots``.
144144
plt.tight_layout()
145145
146146
@savefig plotting_example_existing_axes.png width=6in
147-
plt.show()
147+
plt.draw()
148148
149149
On the right is a histogram created by :py:func:`xarray.plot.hist`.
150150

@@ -343,7 +343,7 @@ matplotlib is available.
343343
plt.tight_layout()
344344
345345
@savefig plotting_2d_call_matplotlib.png width=4in
346-
plt.show()
346+
plt.draw()
347347
348348
.. note::
349349

@@ -359,7 +359,7 @@ matplotlib is available.
359359
air2d.plot()
360360
361361
@savefig plotting_2d_call_matplotlib2.png width=4in
362-
plt.show()
362+
plt.draw()
363363
364364
Colormaps
365365
~~~~~~~~~
@@ -444,9 +444,11 @@ if using ``imshow`` or ``pcolormesh`` (but not with ``contour`` or ``contourf``,
444444
since levels are chosen automatically).
445445

446446
.. ipython:: python
447+
:okwarning:
447448
448449
@savefig plotting_seaborn_palette.png width=4in
449450
air2d.plot(levels=10, cmap='husl')
451+
plt.draw()
450452
451453
.. _plotting.faceting:
452454

@@ -519,6 +521,11 @@ Other features
519521

520522
Faceted plotting supports other arguments common to xarray 2d plots.
521523

524+
.. ipython:: python
525+
:suppress:
526+
527+
plt.close('all')
528+
522529
.. ipython:: python
523530
524531
hasoutliers = t.isel(time=slice(0, 5)).copy()
@@ -528,7 +535,7 @@ Faceted plotting supports other arguments common to xarray 2d plots.
528535
@savefig plot_facet_robust.png
529536
g = hasoutliers.plot.pcolormesh('lon', 'lat', col='time', col_wrap=3,
530537
robust=True, cmap='viridis',
531-
cbar_kwargs={'label': 'this has outliers'})
538+
cbar_kwargs={'label': 'this has outliers'})
532539
533540
FacetGrid Objects
534541
~~~~~~~~~~~~~~~~~
@@ -568,7 +575,7 @@ they have been plotted.
568575
bottomright.annotate('bottom right', (240, 40))
569576
570577
@savefig plot_facet_iterator.png
571-
plt.show()
578+
plt.draw()
572579
573580
TODO: add an example of using the ``map`` method to plot dataset variables
574581
(e.g., with ``plt.quiver``).
@@ -603,7 +610,7 @@ by faceting are accessible in the object returned by ``plot``:
603610
ax.coastlines()
604611
ax.gridlines()
605612
@savefig plotting_maps_cartopy_facetting.png width=100%
606-
plt.show();
613+
plt.draw();
607614
608615
609616
Details
@@ -634,7 +641,7 @@ These are provided for user convenience; they all call the same code.
634641
xplt.line(da, ax=axes[1, 1])
635642
plt.tight_layout()
636643
@savefig plotting_ways_to_use.png width=6in
637-
plt.show()
644+
plt.draw()
638645
639646
Here the output is the same. Since the data is 1 dimensional the line plot
640647
was used.

doc/reshaping.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ labels for one or several dimensions:
186186
array
187187
array['c'] = ('x', ['a', 'b', 'c'])
188188
array.set_index(x='c')
189-
array.set_index(x='c', inplace=True)
190-
array.reset_index('x', drop=True)
189+
array = array.set_index(x='c')
190+
array = array.reset_index('x', drop=True)
191191
192192
.. _reshape.shift_and_roll:
193193

@@ -201,7 +201,7 @@ To adjust coordinate labels, you can use the :py:meth:`~xarray.Dataset.shift` an
201201
202202
array = xr.DataArray([1, 2, 3, 4], dims='x')
203203
array.shift(x=2)
204-
array.roll(x=2)
204+
array.roll(x=2, roll_coords=True)
205205
206206
.. _reshape.sort:
207207

doc/time-series.rst

+4
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ Datetime components couple particularly well with grouped operations (see
163163
calculate the mean by time of day:
164164

165165
.. ipython:: python
166+
:okwarning:
166167
167168
ds.groupby('time.hour').mean()
168169
@@ -176,6 +177,7 @@ same api as ``resample`` `in pandas`_.
176177
For example, we can downsample our dataset from hourly to 6-hourly:
177178

178179
.. ipython:: python
180+
:okwarning:
179181
180182
ds.resample(time='6H')
181183
@@ -184,6 +186,7 @@ necessary for resampling. All of the reduction methods which work with
184186
``Resample`` objects can also be used for resampling:
185187

186188
.. ipython:: python
189+
:okwarning:
187190
188191
ds.resample(time='6H').mean()
189192
@@ -326,6 +329,7 @@ For data indexed by a :py:class:`~xarray.CFTimeIndex` xarray currently supports:
326329
:py:meth:`~xarray.CFTimeIndex.to_datetimeindex` method:
327330

328331
.. ipython:: python
332+
:okwarning:
329333
330334
modern_times = xr.cftime_range('2000', periods=24, freq='MS', calendar='noleap')
331335
da = xr.DataArray(range(24), [('time', modern_times)])

doc/whats-new.rst

+10-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ Bug fixes
6262
By `Stephan Hoyer <https://github.com/shoyer>`_
6363
- Fix h5netcdf saving scalars with filters or chunks (:issue:`2563`).
6464
By `Martin Raspaud <https://github.com/mraspaud>`_.
65+
- Fix parsing of ``_Unsigned`` attribute set by OPENDAP servers. (:issue:`2583`).
66+
By `Deepak Cherian <https://github.com/dcherian>`_
67+
6568

6669
.. _whats-new.0.11.0:
6770

@@ -184,7 +187,7 @@ Bug fixes
184187
By `Spencer Clark <https://github.com/spencerkclark>`_.
185188
- We now properly handle arrays of ``datetime.datetime`` and ``datetime.timedelta``
186189
provided as coordinates. (:issue:`2512`)
187-
By `Deepak Cherian <https://github.com/dcherian`_.
190+
By `Deepak Cherian <https://github.com/dcherian>`_.
188191
- ``xarray.DataArray.roll`` correctly handles multidimensional arrays.
189192
(:issue:`2445`)
190193
By `Keisuke Fujii <https://github.com/fujiisoup>`_.
@@ -2226,6 +2229,7 @@ Enhancements
22262229
for shifting/rotating datasets or arrays along a dimension:
22272230

22282231
.. ipython:: python
2232+
:okwarning:
22292233
22302234
array = xray.DataArray([5, 6, 7, 8], dims='x')
22312235
array.shift(x=2)
@@ -2733,6 +2737,7 @@ Enhancements
27332737
need to supply the time dimension explicitly:
27342738

27352739
.. ipython:: python
2740+
:verbatim:
27362741
27372742
time = pd.date_range('2000-01-01', freq='6H', periods=10)
27382743
array = xray.DataArray(np.arange(10), [('time', time)])
@@ -2742,26 +2747,30 @@ Enhancements
27422747
options such as ``closed`` and ``label`` let you control labeling:
27432748

27442749
.. ipython:: python
2750+
:verbatim:
27452751
27462752
array.resample('1D', dim='time', how='sum', label='right')
27472753
27482754
If the desired temporal resolution is higher than the original data
27492755
(upsampling), xray will insert missing values:
27502756

27512757
.. ipython:: python
2758+
:verbatim:
27522759
27532760
array.resample('3H', 'time')
27542761
27552762
- ``first`` and ``last`` methods on groupby objects let you take the first or
27562763
last examples from each group along the grouped axis:
27572764

27582765
.. ipython:: python
2766+
:verbatim:
27592767
27602768
array.groupby('time.day').first()
27612769
27622770
These methods combine well with ``resample``:
27632771

27642772
.. ipython:: python
2773+
:verbatim:
27652774
27662775
array.resample('1D', dim='time', how='first')
27672776

xarray/backends/api.py

+1
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ def open_mfdataset(paths, chunks=None, concat_dim=_CONCAT_DIM_DEFAULT,
487487
"""Open multiple files as a single dataset.
488488
Requires dask to be installed. See documentation for details on dask [1].
489489
Attributes from the first dataset file are used for the combined dataset.
490+
490491
Parameters
491492
----------
492493
paths : str or sequence

xarray/coding/cftime_offsets.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ def _count_not_none(*args):
553553

554554

555555
def cftime_range(start=None, end=None, periods=None, freq='D',
556-
tz=None, normalize=False, name=None, closed=None,
556+
normalize=False, name=None, closed=None,
557557
calendar='standard'):
558558
"""Return a fixed frequency CFTimeIndex.
559559

xarray/coding/variables.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,11 @@ class UnsignedIntegerCoder(VariableCoder):
249249
def encode(self, variable, name=None):
250250
dims, data, attrs, encoding = unpack_for_encoding(variable)
251251

252-
if encoding.get('_Unsigned', False):
252+
# from netCDF best practices
253+
# https://www.unidata.ucar.edu/software/netcdf/docs/BestPractices.html
254+
# "_Unsigned = "true" to indicate that
255+
# integer data should be treated as unsigned"
256+
if encoding.get('_Unsigned', 'false') == 'true':
253257
pop_to(encoding, attrs, '_Unsigned')
254258
signed_dtype = np.dtype('i%s' % data.dtype.itemsize)
255259
if '_FillValue' in attrs:
@@ -266,7 +270,7 @@ def decode(self, variable, name=None):
266270
unsigned = pop_to(attrs, encoding, '_Unsigned')
267271

268272
if data.dtype.kind == 'i':
269-
if unsigned:
273+
if unsigned == 'true':
270274
unsigned_dtype = np.dtype('u%s' % data.dtype.itemsize)
271275
transform = partial(np.asarray, dtype=unsigned_dtype)
272276
data = lazy_elemwise_func(data, transform, unsigned_dtype)

xarray/core/combine.py

+2
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ def auto_combine(datasets, concat_dim=_CONCAT_DIM_DEFAULT,
560560
``auto_combine`` works well if you have N years of data and M data
561561
variables, and each combination of a distinct time period and set of data
562562
variables is saved its own dataset.
563+
563564
Parameters
564565
----------
565566
datasets : sequence of xarray.Dataset
@@ -589,6 +590,7 @@ def auto_combine(datasets, concat_dim=_CONCAT_DIM_DEFAULT,
589590
Details are in the documentation of concat
590591
coords : {'minimal', 'different', 'all' or list of str}, optional
591592
Details are in the documentation of conca
593+
592594
Returns
593595
-------
594596
combined : xarray.Dataset

0 commit comments

Comments
 (0)