|
67 | 67 | "outputs": [],
|
68 | 68 | "source": [
|
69 | 69 | "import zarr\n",
|
| 70 | + "import pathlib\n", |
| 71 | + "import shutil\n", |
70 | 72 | "\n",
|
71 |
| - "z = zarr.create_array(shape=(40, 50), chunks=(10, 10), dtype='f8', store='test.zarr')\n", |
| 73 | + "# Ensure we start with a clean directory for the tutorial\n", |
| 74 | + "datadir = pathlib.Path('../data/zarr-tutorial')\n", |
| 75 | + "if datadir.exists():\n", |
| 76 | + " shutil.rmtree(datadir)\n", |
| 77 | + "\n", |
| 78 | + "output = datadir / 'test.zarr'\n", |
| 79 | + "z = zarr.create_array(shape=(40, 50), chunks=(10, 10), dtype='f8', store=output)\n", |
72 | 80 | "z"
|
73 | 81 | ]
|
74 | 82 | },
|
|
188 | 196 | "cell_type": "code",
|
189 | 197 | "execution_count": null,
|
190 | 198 | "id": "14",
|
191 |
| - "metadata": {}, |
| 199 | + "metadata": { |
| 200 | + "tags": [ |
| 201 | + "scroll-output" |
| 202 | + ] |
| 203 | + }, |
192 | 204 | "outputs": [],
|
193 | 205 | "source": [
|
194 |
| - "!tree -a test.zarr" |
| 206 | + "!tree -a ../data/test.zarr" |
195 | 207 | ]
|
196 | 208 | },
|
197 | 209 | {
|
198 | 210 | "cell_type": "code",
|
199 | 211 | "execution_count": null,
|
200 | 212 | "id": "15",
|
201 |
| - "metadata": {}, |
| 213 | + "metadata": { |
| 214 | + "tags": [ |
| 215 | + "scroll-output" |
| 216 | + ] |
| 217 | + }, |
202 | 218 | "outputs": [],
|
203 | 219 | "source": [
|
204 |
| - "!cat test.zarr/zarr.json" |
| 220 | + "!cat ../data/test.zarr/zarr.json" |
205 | 221 | ]
|
206 | 222 | },
|
207 | 223 | {
|
|
330 | 346 | "metadata": {},
|
331 | 347 | "outputs": [],
|
332 | 348 | "source": [
|
333 |
| - "c = zarr.create_array(shape=(200, 200, 200), chunks=(1, 200, 200), dtype='f8', store='c.zarr')\n", |
| 349 | + "output = datadir / 'c.zarr'\n", |
| 350 | + "c = zarr.create_array(shape=(200, 200, 200), chunks=(1, 200, 200), dtype='f8', store=output)\n", |
334 | 351 | "c[:] = np.random.randn(*c.shape)"
|
335 | 352 | ]
|
336 | 353 | },
|
|
351 | 368 | "metadata": {},
|
352 | 369 | "outputs": [],
|
353 | 370 | "source": [
|
354 |
| - "d = zarr.create_array(shape=(200, 200, 200), chunks=(200, 200, 1), dtype='f8', store='d.zarr')\n", |
| 371 | + "output = datadir / 'd.zarr'\n", |
| 372 | + "d = zarr.create_array(shape=(200, 200, 200), chunks=(200, 200, 1), dtype='f8', store=output)\n", |
355 | 373 | "d[:] = np.random.randn(*d.shape)"
|
356 | 374 | ]
|
357 | 375 | },
|
|
401 | 419 | "metadata": {},
|
402 | 420 | "outputs": [],
|
403 | 421 | "source": [
|
404 |
| - "import zarr\n", |
405 |
| - "\n", |
406 | 422 | "z6 = zarr.create_array(\n",
|
407 | 423 | " store={},\n",
|
408 | 424 | " shape=(10000, 10000, 1000),\n",
|
|
485 | 501 | "id": "41",
|
486 | 502 | "metadata": {},
|
487 | 503 | "source": [
|
488 |
| - "```{info}\n", |
| 504 | + "```{note}\n", |
489 | 505 | "`.info_complete()` provides a more detailed view of the Zarr array, including metadata about the chunks, compressors, and attributes, but will be slower for larger arrays. \n",
|
490 | 506 | "```"
|
491 | 507 | ]
|
|
528 | 544 | "cell_type": "code",
|
529 | 545 | "execution_count": null,
|
530 | 546 | "id": "45",
|
531 |
| - "metadata": {}, |
| 547 | + "metadata": { |
| 548 | + "tags": [ |
| 549 | + "hide-output" |
| 550 | + ] |
| 551 | + }, |
532 | 552 | "outputs": [],
|
533 | 553 | "source": [
|
534 | 554 | "from pprint import pprint\n",
|
|
646 | 666 | "- [Scalable and Computationally Reproducible Approaches to Arctic Research](https://learning.nceas.ucsb.edu/2025-04-arctic/sections/zarr.html)\n",
|
647 | 667 | "- [Zarr Cloud Native Geospatial Tutorial](https://github.com/zarr-developers/tutorials/blob/main/zarr_cloud_native_geospatial_2022.ipynb)"
|
648 | 668 | ]
|
649 |
| - }, |
650 |
| - { |
651 |
| - "cell_type": "code", |
652 |
| - "execution_count": null, |
653 |
| - "id": "54", |
654 |
| - "metadata": {}, |
655 |
| - "outputs": [], |
656 |
| - "source": [] |
657 | 669 | }
|
658 | 670 | ],
|
659 | 671 | "metadata": {
|
|
0 commit comments