Created
July 30, 2016 14:07
-
-
Save crusaderky/07991681d49117bfbef7a8870e3cba67 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"import xarray\n", | |
"import dask.array" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"<xarray.DataArray 'wrapped-402b256c100221b96a9092bff27269f3' (dim_0: 10, dim_1: 6, dim_2: 6)>\n", | |
"dask.array<wrapped..., shape=(10, 6, 6), dtype=float64, chunksize=(5, 3, 3)>\n", | |
"Coordinates:\n", | |
" * dim_0 (dim_0) int64 0 1 2 3 4 5 6 7 8 9\n", | |
" * dim_1 (dim_1) int64 0 1 2 3 4 5\n", | |
" * dim_2 (dim_2) int64 0 1 2 3 4 5" | |
] | |
}, | |
"execution_count": 2, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"a = xarray.DataArray(dask.array.ones((10, 6, 6), chunks=(5, 3, 3)))\n", | |
"a" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"((5, 5), (3, 3), (3, 3))" | |
] | |
}, | |
"execution_count": 3, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"a.chunks" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"<xarray.DataArray 'wrapped-402b256c100221b96a9092bff27269f3' (dim_0: 10, stacked: 36)>\n", | |
"dask.array<stack-d..., shape=(10, 36), dtype=float64, chunksize=(1, 3)>\n", | |
"Coordinates:\n", | |
" * dim_0 (dim_0) int64 0 1 2 3 4 5 6 7 8 9\n", | |
" * stacked (stacked) object (0, 0) (0, 1) (0, 2) (0, 3) (0, 4) (0, 5) ..." | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"b = a.stack(stacked=['dim_1', 'dim_2'])\n", | |
"b" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"((1, 1, 1, 1, 1, 1, 1, 1, 1, 1), (3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3))" | |
] | |
}, | |
"execution_count": 5, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# Expected: ((5, 5), (9, 9))\n", | |
"b.chunks" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.5.2" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment