|
36 | 36 | "* [Array examples](https://examples.dask.org/array.html)" |
37 | 37 | ] |
38 | 38 | }, |
| 39 | + { |
| 40 | + "cell_type": "markdown", |
| 41 | + "metadata": {}, |
| 42 | + "source": [ |
| 43 | + "## Create data" |
| 44 | + ] |
| 45 | + }, |
| 46 | + { |
| 47 | + "cell_type": "code", |
| 48 | + "execution_count": null, |
| 49 | + "metadata": {}, |
| 50 | + "outputs": [], |
| 51 | + "source": [ |
| 52 | + "%run prep.py -d random" |
| 53 | + ] |
| 54 | + }, |
| 55 | + { |
| 56 | + "cell_type": "markdown", |
| 57 | + "metadata": {}, |
| 58 | + "source": [ |
| 59 | + "## Setup" |
| 60 | + ] |
| 61 | + }, |
39 | 62 | { |
40 | 63 | "cell_type": "code", |
41 | 64 | "execution_count": null, |
|
67 | 90 | "We do exactly this with Python and NumPy in the following example:" |
68 | 91 | ] |
69 | 92 | }, |
70 | | - { |
71 | | - "cell_type": "markdown", |
72 | | - "metadata": {}, |
73 | | - "source": [ |
74 | | - "**Create random dataset**" |
75 | | - ] |
76 | | - }, |
77 | 93 | { |
78 | 94 | "cell_type": "code", |
79 | 95 | "execution_count": null, |
80 | 96 | "metadata": {}, |
81 | 97 | "outputs": [], |
82 | 98 | "source": [ |
83 | | - "# create data if it doesn't already exist\n", |
84 | | - "from prep import random_array\n", |
85 | | - "random_array() \n", |
86 | | - "\n", |
87 | 99 | "# Load data with h5py\n", |
88 | 100 | "# this creates a pointer to the data, but does not actually load\n", |
89 | 101 | "import h5py\n", |
|
155 | 167 | "metadata": {}, |
156 | 168 | "outputs": [], |
157 | 169 | "source": [ |
158 | | - "# Compute the mean of the array" |
159 | | - ] |
160 | | - }, |
161 | | - { |
162 | | - "cell_type": "code", |
163 | | - "execution_count": null, |
164 | | - "metadata": {}, |
165 | | - "outputs": [], |
166 | | - "source": [ |
| 170 | + "# Compute the mean of the array\n", |
167 | 171 | "sums = []\n", |
168 | 172 | "lengths = []\n", |
169 | 173 | "for i in range(0, 1000000000, 1000000):\n", |
|
173 | 177 | "\n", |
174 | 178 | "total = sum(sums)\n", |
175 | 179 | "length = sum(lengths)\n", |
176 | | - "print(total / length)\n" |
| 180 | + "print(total / length)" |
177 | 181 | ] |
178 | 182 | }, |
179 | 183 | { |
|
510 | 514 | "metadata": {}, |
511 | 515 | "outputs": [], |
512 | 516 | "source": [ |
513 | | - "from prep import create_weather # Prep data if it doesn't exist\n", |
514 | | - "create_weather()" |
| 517 | + "%run prep.py -d weather" |
515 | 518 | ] |
516 | 519 | }, |
517 | 520 | { |
|
637 | 640 | }, |
638 | 641 | "outputs": [], |
639 | 642 | "source": [ |
640 | | - "# complete the following\n", |
| 643 | + "# complete the following:\n", |
641 | 644 | "fig = plt.figure(figsize=(16, 8))\n", |
642 | 645 | "plt.imshow(..., cmap='RdBu_r')" |
643 | 646 | ] |
|
755 | 758 | "\n", |
756 | 759 | "result = x[:, ::2, ::2]\n", |
757 | 760 | "\n", |
758 | | - "da.to_zarr(result, os.path.join('data', 'myfile.zarr'), overwrite=True)\n" |
| 761 | + "da.to_zarr(result, os.path.join('data', 'myfile.zarr'), overwrite=True)" |
759 | 762 | ] |
760 | 763 | }, |
761 | 764 | { |
|
830 | 833 | "cell_type": "markdown", |
831 | 834 | "metadata": {}, |
832 | 835 | "source": [ |
833 | | - "Notice that the most time consuming function is `distances`." |
| 836 | + "Notice that the most time consuming function is `distances`:" |
834 | 837 | ] |
835 | 838 | }, |
836 | 839 | { |
|
973 | 976 | "name": "python", |
974 | 977 | "nbconvert_exporter": "python", |
975 | 978 | "pygments_lexer": "ipython3", |
976 | | - "version": "3.7.3" |
| 979 | + "version": "3.7.6" |
977 | 980 | } |
978 | 981 | }, |
979 | 982 | "nbformat": 4, |
|
0 commit comments