|
3 | 3 | { |
4 | 4 | "cell_type": "code", |
5 | 5 | "execution_count": 1, |
| 6 | + "id": "42ac0087-fe1b-4088-919e-ce007e6dea8c", |
| 7 | + "metadata": {}, |
| 8 | + "outputs": [], |
| 9 | + "source": [ |
| 10 | + "%load_ext autoreload\n", |
| 11 | + "%autoreload 2" |
| 12 | + ] |
| 13 | + }, |
| 14 | + { |
| 15 | + "cell_type": "code", |
| 16 | + "execution_count": 2, |
6 | 17 | "id": "706cee66-6557-402d-ae97-679ed202a9fe", |
7 | 18 | "metadata": { |
8 | 19 | "tags": [] |
|
16 | 27 | }, |
17 | 28 | { |
18 | 29 | "cell_type": "code", |
19 | | - "execution_count": 4, |
| 30 | + "execution_count": 3, |
20 | 31 | "id": "29a54dac-abdc-4a95-967f-2289fc1c9ecb", |
21 | 32 | "metadata": { |
22 | 33 | "tags": [] |
|
28 | 39 | "from pathlib import Path\n", |
29 | 40 | "from shutil import make_archive\n", |
30 | 41 | "from tempfile import TemporaryDirectory\n", |
31 | | - "from pathlib import Path\n", |
32 | 42 | "\n", |
33 | 43 | "import dask.config\n", |
34 | 44 | "import requests\n", |
35 | 45 | "import shared\n", |
| 46 | + "import xarray as xr\n", |
36 | 47 | "from sliiders import settings as sset\n", |
| 48 | + "from sliiders.io import open_zarr\n", |
37 | 49 | "from zarr import ZipStore" |
38 | 50 | ] |
39 | 51 | }, |
40 | 52 | { |
41 | 53 | "cell_type": "code", |
42 | | - "execution_count": 3, |
| 54 | + "execution_count": 4, |
| 55 | + "id": "f804bd08-6edb-43f6-8bbd-7a2b98281c29", |
| 56 | + "metadata": {}, |
| 57 | + "outputs": [], |
| 58 | + "source": [ |
| 59 | + "PATH_SLIIDERS_NC = sset.PATH_SLIIDERS.parent / (sset.PATH_SLIIDERS.stem + \".nc\")\n", |
| 60 | + "PATH_OUTPUTS_NC = shared.PATH_OUTPUTS.parent / (shared.PATH_OUTPUTS.stem + \".nc\")\n", |
| 61 | + "\n", |
| 62 | + "shared.save_dataset(shared.open_zarr(sset.PATH_SLIIDERS).load(), PATH_SLIIDERS_NC)\n", |
| 63 | + "shared.save_dataset(shared.open_zarr(sset.PATH_OUTPUTS).load(), PATH_OUTPUTS_NC)" |
| 64 | + ] |
| 65 | + }, |
| 66 | + { |
| 67 | + "cell_type": "code", |
| 68 | + "execution_count": 4, |
43 | 69 | "id": "d37ca26f-091d-4cb6-be02-385464e0b687", |
44 | 70 | "metadata": { |
45 | 71 | "tags": [] |
|
48 | 74 | { |
49 | 75 | "data": { |
50 | 76 | "text/plain": [ |
51 | | - "<dask.config.set at 0x112a25b70>" |
| 77 | + "<dask.config.set at 0x7cfe44438890>" |
52 | 78 | ] |
53 | 79 | }, |
54 | | - "execution_count": 3, |
| 80 | + "execution_count": 4, |
55 | 81 | "metadata": {}, |
56 | 82 | "output_type": "execute_result" |
57 | 83 | } |
|
70 | 96 | }, |
71 | 97 | { |
72 | 98 | "cell_type": "code", |
73 | | - "execution_count": 6, |
| 99 | + "execution_count": 21, |
74 | 100 | "id": "55a3e849-a554-49fa-882c-846acf76f3b8", |
75 | 101 | "metadata": { |
76 | 102 | "tags": [ |
|
79 | 105 | }, |
80 | 106 | "outputs": [], |
81 | 107 | "source": [ |
82 | | - "ACCESS_TOKEN = environ[\"ACCESS_TOKEN\"]\n", |
83 | | - "VERSION = \"1.1.0\"\n", |
| 108 | + "ACCESS_TOKEN = \"Q5z5IQ1m5Z9l1QS7ZYeV78IS5bqPmhzcFVo0KSNLoh2p39HRMPgFoJsCyQt5\"\n", |
| 109 | + "VERSION = \"1.2.0\"\n", |
84 | 110 | "TITLES = {\n", |
85 | 111 | " \"SLIIDERS\": \"SLIIDERS: Sea Level Impacts Input Dataset by Elevation, Region, and Scenario\",\n", |
86 | | - " \"pyCIAM\": \"Estimates of Global Coastal Losses Under Multiple Sea Level Rise Scenarios\",\n", |
| 112 | + " # \"pyCIAM\": \"Estimates of Global Coastal Losses Under Multiple Sea Level Rise Scenarios\",\n", |
87 | 113 | "}\n", |
88 | | - "PYCIAM_CODE_PATH=Path(\"pyCIAM-1.1.2.zip\")\n", |
89 | | - "SLIIDERS_CODE_PATH=Path(\"sliiders-1.1.1.zip\")" |
| 114 | + "PYCIAM_CODE_PATH = Path(\"pyCIAM-1.1.2.zip\")\n", |
| 115 | + "SLIIDERS_CODE_PATH = Path(\"/tmp/sliiders-1.2.zip\")" |
90 | 116 | ] |
91 | 117 | }, |
92 | 118 | { |
93 | 119 | "cell_type": "code", |
94 | | - "execution_count": 7, |
| 120 | + "execution_count": 22, |
95 | 121 | "id": "8725b84c-8a7f-4d88-96ec-849e963ef8ce", |
96 | 122 | "metadata": {}, |
97 | 123 | "outputs": [], |
|
101 | 127 | }, |
102 | 128 | { |
103 | 129 | "cell_type": "code", |
104 | | - "execution_count": 8, |
| 130 | + "execution_count": 23, |
105 | 131 | "id": "956c40ee-e3e8-4257-bd0d-2c938546604d", |
106 | 132 | "metadata": {}, |
107 | 133 | "outputs": [], |
|
136 | 162 | }, |
137 | 163 | { |
138 | 164 | "cell_type": "code", |
139 | | - "execution_count": 9, |
| 165 | + "execution_count": 24, |
140 | 166 | "id": "b5fcb2b8-3fb4-4789-bae0-18f7a66b7c51", |
141 | 167 | "metadata": {}, |
142 | 168 | "outputs": [], |
|
206 | 232 | }, |
207 | 233 | { |
208 | 234 | "cell_type": "code", |
209 | | - "execution_count": 10, |
| 235 | + "execution_count": 25, |
210 | 236 | "id": "55188020-c02f-4fa6-bf4c-cf1cd87e1754", |
211 | 237 | "metadata": {}, |
212 | 238 | "outputs": [], |
213 | 239 | "source": [ |
214 | 240 | "# Files and paths\n", |
215 | 241 | "ORIGINAL_PATHS = {\n", |
216 | 242 | " \"SLIIDERS\": {\n", |
217 | | - " \"products\": [shared.PATH_SLIIDERS],\n", |
| 243 | + " \"products\": [sset.PATH_SLIIDERS, PATH_SLIIDERS_NC],\n", |
218 | 244 | " \"inputs\": [\n", |
219 | 245 | " sset.PATH_GEOG_GTSM_SNAPPED,\n", |
220 | 246 | " sset.PATH_GEOG_GTSM_STATIONS_TOTHIN,\n", |
|
224 | 250 | " \"pyCIAM\": {\n", |
225 | 251 | " \"products\": [\n", |
226 | 252 | " shared.PATH_OUTPUTS,\n", |
| 253 | + " PATH_OUTPUTS_NC,\n", |
227 | 254 | " shared.PATH_DIAZ_RES,\n", |
228 | 255 | " shared.PATH_MOVEFACTOR_DATA,\n", |
229 | 256 | " ],\n", |
|
240 | 267 | "if PYCIAM_CODE_PATH is not None:\n", |
241 | 268 | " ORIGINAL_PATHS[\"pyCIAM\"][\"source\"] = [PYCIAM_CODE_PATH]\n", |
242 | 269 | "if SLIIDERS_CODE_PATH is not None:\n", |
243 | | - " ORIGINAL_PATHS[\"SLIIDERS\"][\"source\"] = [SLIIDERS_CODE_PATH" |
| 270 | + " ORIGINAL_PATHS[\"SLIIDERS\"][\"source\"] = [SLIIDERS_CODE_PATH]" |
244 | 271 | ] |
245 | 272 | }, |
246 | 273 | { |
|
255 | 282 | }, |
256 | 283 | { |
257 | 284 | "cell_type": "code", |
258 | | - "execution_count": 11, |
| 285 | + "execution_count": 40, |
259 | 286 | "id": "50c10e4c-b3eb-4714-8d32-486ac878d041", |
260 | 287 | "metadata": {}, |
261 | 288 | "outputs": [], |
|
264 | 291 | " dep = EXISTING_DEPOSITS[name]\n", |
265 | 292 | " # create new deposit\n", |
266 | 293 | " deposition_id = dep[\"id\"]\n", |
267 | | - " if deposition_id == int(dep[\"links\"][\"latest\"].split(\"/\")[-1]):\n", |
| 294 | + " if \"latest_draft\" not in dep[\"links\"]:\n", |
268 | 295 | " url = f\"{Z_URL}/{deposition_id}/actions/newversion\"\n", |
269 | 296 | " r = requests.post(url, params=PARAMS)\n", |
270 | 297 | " if r.status_code not in [200, 201]:\n", |
|
390 | 417 | }, |
391 | 418 | { |
392 | 419 | "cell_type": "code", |
393 | | - "execution_count": 12, |
| 420 | + "execution_count": 41, |
394 | 421 | "id": "868b1d78-5eb4-4fa6-bcfc-0dbd8c88d39b", |
395 | 422 | "metadata": {}, |
396 | 423 | "outputs": [], |
|
408 | 435 | }, |
409 | 436 | { |
410 | 437 | "cell_type": "code", |
411 | | - "execution_count": 14, |
| 438 | + "execution_count": 44, |
412 | 439 | "id": "ff8703bb-c630-418e-9f2f-c62b116ee7e8", |
413 | 440 | "metadata": {}, |
414 | 441 | "outputs": [ |
415 | 442 | { |
416 | 443 | "name": "stdout", |
417 | 444 | "output_type": "stream", |
418 | 445 | "text": [ |
419 | | - "pyCIAM\n", |
420 | | - "Uploading: gs://rhg-data/impactlab-rhg/coastal/sliiders/raw/CIAM_2016/diaz2016_inputs_raw.zarr\n", |
421 | | - "Uploading: gs://rhg-data/impactlab-rhg/coastal/ciam_paper/data/int/slr/ar5/ar5-msl-rel-2005-quantiles.zarr\n", |
422 | | - "Uploading: gs://rhg-data/impactlab-rhg/coastal/sliiders/int/exposure/ypk/finalized/ypk_2000_2100_20221122.zarr\n", |
423 | | - "Uploading: gs://rhg-data/impactlab-rhg/coastal/ciam_paper/data/int/surge-lookup-v1.1-seg.zarr\n", |
424 | | - "Uploading: gs://rhg-data/impactlab-rhg/coastal/ciam_paper/data/int/surge-lookup-v1.1-seg_adm.zarr\n", |
425 | | - "Uploading: gs://rhg-data/impactlab-rhg/coastal/ciam_paper/results-v1.1/pyCIAM_outputs.zarr\n", |
426 | | - "Uploading: gs://rhg-data/impactlab-rhg/coastal/ciam_paper/results-v1.1/diaz2016_outputs.zarr\n", |
427 | | - "Uploading: gs://rhg-data/impactlab-rhg/coastal/ciam_paper/results-v1.1/suboptimal_capital_by_movefactor.zarr\n" |
| 446 | + "SLIIDERS\n" |
| 447 | + ] |
| 448 | + }, |
| 449 | + { |
| 450 | + "ename": "TypeError", |
| 451 | + "evalue": "string indices must be integers, not 'str'", |
| 452 | + "output_type": "error", |
| 453 | + "traceback": [ |
| 454 | + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
| 455 | + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", |
| 456 | + "Cell \u001b[0;32mIn[44], line 6\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28mprint\u001b[39m(name)\n\u001b[1;32m 4\u001b[0m this_dep \u001b[38;5;241m=\u001b[39m draft_deps[name]\n\u001b[0;32m----> 6\u001b[0m uploads[name] \u001b[38;5;241m=\u001b[39m \u001b[43mupload_file_list\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 7\u001b[0m \u001b[43m \u001b[49m\u001b[43mthis_dep\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkind\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43minputs\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43minputs/\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43moverwrite\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\n\u001b[1;32m 8\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 9\u001b[0m uploads[name] \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m upload_file_list(\n\u001b[1;32m 10\u001b[0m this_dep, kind[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mproducts\u001b[39m\u001b[38;5;124m\"\u001b[39m], \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mproducts/\u001b[39m\u001b[38;5;124m\"\u001b[39m, overwrite\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m\n\u001b[1;32m 11\u001b[0m )\n\u001b[1;32m 12\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msource\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m kind\u001b[38;5;241m.\u001b[39mkeys():\n", |
| 457 | + "Cell \u001b[0;32mIn[40], line 83\u001b[0m, in \u001b[0;36mupload_file_list\u001b[0;34m(deposit, flist, root, overwrite)\u001b[0m\n\u001b[1;32m 81\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mupload_file_list\u001b[39m(deposit, flist, root, overwrite\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m):\n\u001b[1;32m 82\u001b[0m out \u001b[38;5;241m=\u001b[39m []\n\u001b[0;32m---> 83\u001b[0m existing_files \u001b[38;5;241m=\u001b[39m \u001b[43m{\u001b[49m\n\u001b[1;32m 84\u001b[0m \u001b[43m \u001b[49m\u001b[43mf\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mfilename\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mf\u001b[49m\n\u001b[1;32m 85\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mf\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mrequests\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdeposit\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mlinks\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mfiles\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mPARAMS\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mjson\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 86\u001b[0m \u001b[43m \u001b[49m\u001b[43m}\u001b[49m\n\u001b[1;32m 87\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m f \u001b[38;5;129;01min\u001b[39;00m flist:\n\u001b[1;32m 88\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mUploading: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mstr\u001b[39m(f)\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n", |
| 458 | + "Cell \u001b[0;32mIn[40], line 84\u001b[0m, in \u001b[0;36m<dictcomp>\u001b[0;34m(.0)\u001b[0m\n\u001b[1;32m 81\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mupload_file_list\u001b[39m(deposit, flist, root, overwrite\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m):\n\u001b[1;32m 82\u001b[0m out \u001b[38;5;241m=\u001b[39m []\n\u001b[1;32m 83\u001b[0m existing_files \u001b[38;5;241m=\u001b[39m {\n\u001b[0;32m---> 84\u001b[0m \u001b[43mf\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mfilename\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m: f\n\u001b[1;32m 85\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m f \u001b[38;5;129;01min\u001b[39;00m requests\u001b[38;5;241m.\u001b[39mget(deposit[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mlinks\u001b[39m\u001b[38;5;124m\"\u001b[39m][\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mfiles\u001b[39m\u001b[38;5;124m\"\u001b[39m], params\u001b[38;5;241m=\u001b[39mPARAMS)\u001b[38;5;241m.\u001b[39mjson()\n\u001b[1;32m 86\u001b[0m }\n\u001b[1;32m 87\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m f \u001b[38;5;129;01min\u001b[39;00m flist:\n\u001b[1;32m 88\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mUploading: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mstr\u001b[39m(f)\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n", |
| 459 | + "\u001b[0;31mTypeError\u001b[0m: string indices must be integers, not 'str'" |
428 | 460 | ] |
429 | 461 | } |
430 | 462 | ], |
|
440 | 472 | " uploads[name] += upload_file_list(\n", |
441 | 473 | " this_dep, kind[\"products\"], \"products/\", overwrite=False\n", |
442 | 474 | " )\n", |
443 | | - " if \"source\" in kind.keys(): \n", |
| 475 | + " if \"source\" in kind.keys():\n", |
444 | 476 | " uploads[name] += upload_file_list(\n", |
445 | 477 | " this_dep, kind[\"source\"], \"source/\", overwrite=False\n", |
446 | 478 | " )" |
|
449 | 481 | ], |
450 | 482 | "metadata": { |
451 | 483 | "kernelspec": { |
452 | | - "display_name": "Python [conda env:sliiders]", |
| 484 | + "display_name": "Python 3 (ipykernel)", |
453 | 485 | "language": "python", |
454 | | - "name": "conda-env-sliiders-py" |
| 486 | + "name": "python3" |
455 | 487 | }, |
456 | 488 | "language_info": { |
457 | 489 | "codemirror_mode": { |
|
463 | 495 | "name": "python", |
464 | 496 | "nbconvert_exporter": "python", |
465 | 497 | "pygments_lexer": "ipython3", |
466 | | - "version": "3.10.9" |
| 498 | + "version": "3.11.8" |
467 | 499 | }, |
468 | 500 | "widgets": { |
469 | 501 | "application/vnd.jupyter.widget-state+json": { |
|
0 commit comments