Skip to content

Instantly share code, notes, and snippets.

@crusaderky
Created July 30, 2016 13:45
Show Gist options
  • Save crusaderky/5087365dedd506beb464a53761d58d82 to your computer and use it in GitHub Desktop.
Save crusaderky/5087365dedd506beb464a53761d58d82 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import xarray\n",
"import dask.array"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<xarray.DataArray 'wrapped-0bd22a36c2fc0082109cd7e2896d38e9' (dim_0: 15)>\n",
"dask.array<wrapped..., shape=(15,), dtype=float64, chunksize=(5,)>\n",
"Coordinates:\n",
" * dim_0 (dim_0) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a = xarray.DataArray(dask.array.ones(15, chunks=5))\n",
"a"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"((5, 5, 5),)"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a.chunks"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<xarray.DataArray 'wrapped-0bd22a36c2fc0082109cd7e2896d38e9' (dim_0: 10)>\n",
"dask.array<getitem..., shape=(10,), dtype=float64, chunksize=(10,)>\n",
"Coordinates:\n",
" * dim_0 (dim_0) int64 0 1 7 14 1 1 1 1 1 1"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"b = a.isel(dim_0=[0, 1, 7, 14, 1, 1, 1, 1, 1, 1])\n",
"b"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"((10,),)"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Expected: ((3, 1, 5, 1),)\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