diff --git a/STAC/data/notebooks/10_Land_subsidence_prediction_maps_updated.ipynb b/STAC/data/notebooks/10_Land_subsidence_prediction_maps_updated.ipynb index 831c7623..38a1e637 100644 --- a/STAC/data/notebooks/10_Land_subsidence_prediction_maps_updated.ipynb +++ b/STAC/data/notebooks/10_Land_subsidence_prediction_maps_updated.ipynb @@ -13,13 +13,21 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 34, "id": "f1aef40e", "metadata": {}, "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The nb_black extension is already loaded. To reload it, use:\n", + " %reload_ext nb_black\n" + ] + }, { "data": { - "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 1;\n var nbb_unformatted_code = \"# Optional; code formatter, installed as jupyter lab extension\\n# %load_ext lab_black\\n\\n# Optional; code formatter, installed as jupyter notebook extension\\n%load_ext nb_black\";\n var nbb_formatted_code = \"# Optional; code formatter, installed as jupyter lab extension\\n# %load_ext lab_black\\n\\n# Optional; code formatter, installed as jupyter notebook extension\\n%load_ext nb_black\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", + "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 34;\n var nbb_unformatted_code = \"# Optional; code formatter, installed as jupyter lab extension\\n# %load_ext lab_black\\n\\n# Optional; code formatter, installed as jupyter notebook extension\\n%load_ext nb_black\";\n var nbb_formatted_code = \"# Optional; code formatter, installed as jupyter lab extension\\n# %load_ext lab_black\\n\\n# Optional; code formatter, installed as jupyter notebook extension\\n%load_ext nb_black\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", "text/plain": [ "" ] @@ -38,13 +46,13 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 35, "id": "80287b05", "metadata": {}, "outputs": [ { "data": { - "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 2;\n var nbb_unformatted_code = \"# Import standard packages\\nimport os\\nimport pathlib\\nfrom pathlib import Path\\n\\nimport numpy as np\\n#import geopandas as gpd\\nimport pandas as pd\\nimport matplotlib.pyplot as plt\\nimport xarray as xr\\nimport glob\\nimport itertools\\nimport json\\nimport copy\\nfrom itertools import chain\\nfrom shapely import wkb\\nimport json\\n\\n# Import custom functionality\\nfrom coclicodata.drive_config import p_drive\\nfrom coclicodata.etl.cf_compliancy_checker import check_compliancy, save_compliancy\";\n var nbb_formatted_code = \"# Import standard packages\\nimport os\\nimport pathlib\\nfrom pathlib import Path\\n\\nimport numpy as np\\n\\n# import geopandas as gpd\\nimport pandas as pd\\nimport matplotlib.pyplot as plt\\nimport xarray as xr\\nimport glob\\nimport itertools\\nimport json\\nimport copy\\nfrom itertools import chain\\nfrom shapely import wkb\\nimport json\\n\\n# Import custom functionality\\nfrom coclicodata.drive_config import p_drive\\nfrom coclicodata.etl.cf_compliancy_checker import check_compliancy, save_compliancy\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", + "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 35;\n var nbb_unformatted_code = \"# Import standard packages\\nimport os\\nimport pathlib\\nfrom pathlib import Path\\n\\nimport numpy as np\\n#import geopandas as gpd\\nimport pandas as pd\\nimport matplotlib.pyplot as plt\\nimport xarray as xr\\nimport glob\\nimport itertools\\nimport json\\nimport copy\\nfrom itertools import chain\\nfrom shapely import wkb\\nimport json\\n\\n# Import custom functionality\\nfrom coclicodata.drive_config import p_drive\\nfrom coclicodata.etl.cf_compliancy_checker import check_compliancy, save_compliancy\";\n var nbb_formatted_code = \"# Import standard packages\\nimport os\\nimport pathlib\\nfrom pathlib import Path\\n\\nimport numpy as np\\n\\n# import geopandas as gpd\\nimport pandas as pd\\nimport matplotlib.pyplot as plt\\nimport xarray as xr\\nimport glob\\nimport itertools\\nimport json\\nimport copy\\nfrom itertools import chain\\nfrom shapely import wkb\\nimport json\\n\\n# Import custom functionality\\nfrom coclicodata.drive_config import p_drive\\nfrom coclicodata.etl.cf_compliancy_checker import check_compliancy, save_compliancy\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", "text/plain": [ "" ] @@ -88,13 +96,13 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 36, "id": "2d5692d8", "metadata": {}, "outputs": [ { "data": { - "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 3;\n var nbb_unformatted_code = \"# Workaround to the Windows OS (10) udunits error after installation of cfchecker: https://github.com/SciTools/iris/issues/404\\nos.environ[\\\"UDUNITS2_XML_PATH\\\"] = str(\\n pathlib.Path().home().joinpath( # change to the udunits2.xml file dir in your Python installation\\n r\\\"Anaconda3\\\\pkgs\\\\udunits2-2.2.28-hfda9870_3\\\\Library\\\\share\\\\udunits\\\\udunits2.xml\\\"\\n )\\n)\";\n var nbb_formatted_code = \"# Workaround to the Windows OS (10) udunits error after installation of cfchecker: https://github.com/SciTools/iris/issues/404\\nos.environ[\\\"UDUNITS2_XML_PATH\\\"] = str(\\n pathlib.Path()\\n .home()\\n .joinpath( # change to the udunits2.xml file dir in your Python installation\\n r\\\"Anaconda3\\\\pkgs\\\\udunits2-2.2.28-hfda9870_3\\\\Library\\\\share\\\\udunits\\\\udunits2.xml\\\"\\n )\\n)\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", + "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 36;\n var nbb_unformatted_code = \"# Workaround to the Windows OS (10) udunits error after installation of cfchecker: https://github.com/SciTools/iris/issues/404\\nos.environ[\\\"UDUNITS2_XML_PATH\\\"] = str(\\n pathlib.Path().home().joinpath( # change to the udunits2.xml file dir in your Python installation\\n r\\\"Anaconda3\\\\pkgs\\\\udunits2-2.2.28-hfda9870_3\\\\Library\\\\share\\\\udunits\\\\udunits2.xml\\\"\\n )\\n)\";\n var nbb_formatted_code = \"# Workaround to the Windows OS (10) udunits error after installation of cfchecker: https://github.com/SciTools/iris/issues/404\\nos.environ[\\\"UDUNITS2_XML_PATH\\\"] = str(\\n pathlib.Path()\\n .home()\\n .joinpath( # change to the udunits2.xml file dir in your Python installation\\n r\\\"Anaconda3\\\\pkgs\\\\udunits2-2.2.28-hfda9870_3\\\\Library\\\\share\\\\udunits\\\\udunits2.xml\\\"\\n )\\n)\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", "text/plain": [ "" ] @@ -122,13 +130,13 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 37, "id": "ef7e94bc", "metadata": {}, "outputs": [ { "data": { - "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 4;\n var nbb_unformatted_code = \"# Define (local and) remote drives\\n# raw_data_dir = p_drive.joinpath(\\\"archivedprojects\\\", \\\"11208003-latedeo2022\\\", \\\"020_InternationalDeltaPortfolio\\\", \\\"datasets\\\", \\\"00_bodemdalingsvoorspellingskaarten\\\")\\nraw_data_dir = p_drive.joinpath(r\\\"archivedprojects\\\\11208003-latedeo2022\\\\020_InternationalDeltaPortfolio\\\\datasets\\\") \\nprocessed_data_dir = p_drive.joinpath(r\\\"11210264-003-delta-portal\\\\data\\\") \";\n var nbb_formatted_code = \"# Define (local and) remote drives\\n# raw_data_dir = p_drive.joinpath(\\\"archivedprojects\\\", \\\"11208003-latedeo2022\\\", \\\"020_InternationalDeltaPortfolio\\\", \\\"datasets\\\", \\\"00_bodemdalingsvoorspellingskaarten\\\")\\nraw_data_dir = p_drive.joinpath(\\n r\\\"archivedprojects\\\\11208003-latedeo2022\\\\020_InternationalDeltaPortfolio\\\\datasets\\\"\\n)\\nprocessed_data_dir = p_drive.joinpath(r\\\"11210264-003-delta-portal\\\\data\\\")\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", + "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 37;\n var nbb_unformatted_code = \"# Define (local and) remote drives\\n# raw_data_dir = p_drive.joinpath(\\\"archivedprojects\\\", \\\"11208003-latedeo2022\\\", \\\"020_InternationalDeltaPortfolio\\\", \\\"datasets\\\", \\\"00_bodemdalingsvoorspellingskaarten\\\")\\nraw_data_dir = p_drive.joinpath(r\\\"archivedprojects\\\\11208003-latedeo2022\\\\020_InternationalDeltaPortfolio\\\\datasets\\\") \\nprocessed_data_dir = p_drive.joinpath(r\\\"11210264-003-delta-portal\\\\data\\\") \";\n var nbb_formatted_code = \"# Define (local and) remote drives\\n# raw_data_dir = p_drive.joinpath(\\\"archivedprojects\\\", \\\"11208003-latedeo2022\\\", \\\"020_InternationalDeltaPortfolio\\\", \\\"datasets\\\", \\\"00_bodemdalingsvoorspellingskaarten\\\")\\nraw_data_dir = p_drive.joinpath(\\n r\\\"archivedprojects\\\\11208003-latedeo2022\\\\020_InternationalDeltaPortfolio\\\\datasets\\\"\\n)\\nprocessed_data_dir = p_drive.joinpath(r\\\"11210264-003-delta-portal\\\\data\\\")\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", "text/plain": [ "" ] @@ -154,13 +162,13 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 38, "id": "6c5f5cc6", "metadata": {}, "outputs": [ { "data": { - "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 5;\n var nbb_unformatted_code = \"# Project paths & files (manual input)\\nraw_ms_data_dir = raw_data_dir.joinpath(r\\\"00_bodemdalingsvoorspellingskaarten\\\\Mild scenario\\\")\\nraw_ss_data_dir = raw_data_dir.joinpath(r\\\"00_bodemdalingsvoorspellingskaarten\\\\Sterk scenario\\\")\\n\\n \\nds_ms_2020_2050_path = raw_ms_data_dir.joinpath(\\\"scenario_mild_bodemdaling_incl_ogzw_2020_2050.tif\\\")\\nds_ms_2020_2100_path = raw_ms_data_dir.joinpath(\\\"scenario_mild_bodemdaling_incl_ogzw_2020_2100.tif\\\")\\nds_ss_2020_2050_path = raw_ss_data_dir.joinpath(\\\"scenario_sterk_bodemdaling_incl_ogzw_2020_2050.tif\\\")\\nds_ss_2020_2100_path = raw_ss_data_dir.joinpath(\\\"scenario_sterk_bodemdaling_incl_ogzw_2020_2100.tif\\\")\";\n var nbb_formatted_code = \"# Project paths & files (manual input)\\nraw_ms_data_dir = raw_data_dir.joinpath(\\n r\\\"00_bodemdalingsvoorspellingskaarten\\\\Mild scenario\\\"\\n)\\nraw_ss_data_dir = raw_data_dir.joinpath(\\n r\\\"00_bodemdalingsvoorspellingskaarten\\\\Sterk scenario\\\"\\n)\\n\\n\\nds_ms_2020_2050_path = raw_ms_data_dir.joinpath(\\n \\\"scenario_mild_bodemdaling_incl_ogzw_2020_2050.tif\\\"\\n)\\nds_ms_2020_2100_path = raw_ms_data_dir.joinpath(\\n \\\"scenario_mild_bodemdaling_incl_ogzw_2020_2100.tif\\\"\\n)\\nds_ss_2020_2050_path = raw_ss_data_dir.joinpath(\\n \\\"scenario_sterk_bodemdaling_incl_ogzw_2020_2050.tif\\\"\\n)\\nds_ss_2020_2100_path = raw_ss_data_dir.joinpath(\\n \\\"scenario_sterk_bodemdaling_incl_ogzw_2020_2100.tif\\\"\\n)\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", + "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 38;\n var nbb_unformatted_code = \"# Project paths & files (manual input)\\nraw_ms_data_dir = raw_data_dir.joinpath(r\\\"00_bodemdalingsvoorspellingskaarten\\\\Mild scenario\\\")\\nraw_ss_data_dir = raw_data_dir.joinpath(r\\\"00_bodemdalingsvoorspellingskaarten\\\\Sterk scenario\\\")\\n\\n \\nds_ms_2020_2050_path = raw_ms_data_dir.joinpath(\\\"scenario_mild_bodemdaling_incl_ogzw_2020_2050.tif\\\")\\nds_ms_2020_2100_path = raw_ms_data_dir.joinpath(\\\"scenario_mild_bodemdaling_incl_ogzw_2020_2100.tif\\\")\\nds_ss_2020_2050_path = raw_ss_data_dir.joinpath(\\\"scenario_sterk_bodemdaling_incl_ogzw_2020_2050.tif\\\")\\nds_ss_2020_2100_path = raw_ss_data_dir.joinpath(\\\"scenario_sterk_bodemdaling_incl_ogzw_2020_2100.tif\\\")\";\n var nbb_formatted_code = \"# Project paths & files (manual input)\\nraw_ms_data_dir = raw_data_dir.joinpath(\\n r\\\"00_bodemdalingsvoorspellingskaarten\\\\Mild scenario\\\"\\n)\\nraw_ss_data_dir = raw_data_dir.joinpath(\\n r\\\"00_bodemdalingsvoorspellingskaarten\\\\Sterk scenario\\\"\\n)\\n\\n\\nds_ms_2020_2050_path = raw_ms_data_dir.joinpath(\\n \\\"scenario_mild_bodemdaling_incl_ogzw_2020_2050.tif\\\"\\n)\\nds_ms_2020_2100_path = raw_ms_data_dir.joinpath(\\n \\\"scenario_mild_bodemdaling_incl_ogzw_2020_2100.tif\\\"\\n)\\nds_ss_2020_2050_path = raw_ss_data_dir.joinpath(\\n \\\"scenario_sterk_bodemdaling_incl_ogzw_2020_2050.tif\\\"\\n)\\nds_ss_2020_2100_path = raw_ss_data_dir.joinpath(\\n \\\"scenario_sterk_bodemdaling_incl_ogzw_2020_2100.tif\\\"\\n)\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", "text/plain": [ "" ] @@ -183,13 +191,13 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 39, "id": "eb987dab", "metadata": {}, "outputs": [ { "data": { - "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 6;\n var nbb_unformatted_code = \"ds_ms_2020_2050 = xr.open_dataset(\\n ds_ms_2020_2050_path, engine=\\\"rasterio\\\", mask_and_scale=False\\n) \\nds_ms_2020_2100 = xr.open_dataset(\\n ds_ms_2020_2100_path, engine=\\\"rasterio\\\", mask_and_scale=False\\n) \\nds_ss_2020_2050 = xr.open_dataset(\\n ds_ss_2020_2050_path, engine=\\\"rasterio\\\", mask_and_scale=False\\n) \\nds_ss_2020_2100 = xr.open_dataset(\\n ds_ss_2020_2100_path, engine=\\\"rasterio\\\", mask_and_scale=False\\n) \";\n var nbb_formatted_code = \"ds_ms_2020_2050 = xr.open_dataset(\\n ds_ms_2020_2050_path, engine=\\\"rasterio\\\", mask_and_scale=False\\n)\\nds_ms_2020_2100 = xr.open_dataset(\\n ds_ms_2020_2100_path, engine=\\\"rasterio\\\", mask_and_scale=False\\n)\\nds_ss_2020_2050 = xr.open_dataset(\\n ds_ss_2020_2050_path, engine=\\\"rasterio\\\", mask_and_scale=False\\n)\\nds_ss_2020_2100 = xr.open_dataset(\\n ds_ss_2020_2100_path, engine=\\\"rasterio\\\", mask_and_scale=False\\n)\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", + "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 39;\n var nbb_unformatted_code = \"ds_ms_2020_2050 = xr.open_dataset(\\n ds_ms_2020_2050_path, engine=\\\"rasterio\\\", mask_and_scale=False\\n) \\nds_ms_2020_2100 = xr.open_dataset(\\n ds_ms_2020_2100_path, engine=\\\"rasterio\\\", mask_and_scale=False\\n) \\nds_ss_2020_2050 = xr.open_dataset(\\n ds_ss_2020_2050_path, engine=\\\"rasterio\\\", mask_and_scale=False\\n) \\nds_ss_2020_2100 = xr.open_dataset(\\n ds_ss_2020_2100_path, engine=\\\"rasterio\\\", mask_and_scale=False\\n) \";\n var nbb_formatted_code = \"ds_ms_2020_2050 = xr.open_dataset(\\n ds_ms_2020_2050_path, engine=\\\"rasterio\\\", mask_and_scale=False\\n)\\nds_ms_2020_2100 = xr.open_dataset(\\n ds_ms_2020_2100_path, engine=\\\"rasterio\\\", mask_and_scale=False\\n)\\nds_ss_2020_2050 = xr.open_dataset(\\n ds_ss_2020_2050_path, engine=\\\"rasterio\\\", mask_and_scale=False\\n)\\nds_ss_2020_2100 = xr.open_dataset(\\n ds_ss_2020_2100_path, engine=\\\"rasterio\\\", mask_and_scale=False\\n)\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", "text/plain": [ "" ] @@ -223,13 +231,13 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 40, "id": "e2288a0f", "metadata": {}, "outputs": [ { "data": { - "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 7;\n var nbb_unformatted_code = \"# Not implemented as geotiffs are less flexible, so checking compliance is not necessary.\";\n var nbb_formatted_code = \"# Not implemented as geotiffs are less flexible, so checking compliance is not necessary.\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", + "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 40;\n var nbb_unformatted_code = \"# Not implemented as geotiffs are less flexible, so checking compliance is not necessary.\";\n var nbb_formatted_code = \"# Not implemented as geotiffs are less flexible, so checking compliance is not necessary.\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", "text/plain": [ "" ] @@ -252,13 +260,13 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 41, "id": "cabbf6ab", "metadata": {}, "outputs": [ { "data": { - "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 8;\n var nbb_unformatted_code = \"# Not implemented\";\n var nbb_formatted_code = \"# Not implemented\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", + "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 41;\n var nbb_unformatted_code = \"# Not implemented\";\n var nbb_formatted_code = \"# Not implemented\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", "text/plain": [ "" ] @@ -289,13 +297,13 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 42, "id": "19d8d5d8", "metadata": {}, "outputs": [ { "data": { - "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 9;\n var nbb_unformatted_code = \"## Variables to include in a loop\\n\\nVARIABLE = \\\"subsidence\\\"\\nSCENARIO = \\\"sterk\\\"\\nTIME = \\\"2100\\\"\\n\\nds = ds_ss_2020_2100\";\n var nbb_formatted_code = \"## Variables to include in a loop\\n\\nVARIABLE = \\\"subsidence\\\"\\nSCENARIO = \\\"sterk\\\"\\nTIME = \\\"2100\\\"\\n\\nds = ds_ss_2020_2100\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", + "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 42;\n var nbb_unformatted_code = \"## Variables to include in a loop\\n\\nVARIABLE = \\\"subsidence\\\"\\nSCENARIO = \\\"sterk\\\"\\nTIME = \\\"2100\\\"\\n\\nds = ds_ss_2020_2100\";\n var nbb_formatted_code = \"## Variables to include in a loop\\n\\nVARIABLE = \\\"subsidence\\\"\\nSCENARIO = \\\"sterk\\\"\\nTIME = \\\"2100\\\"\\n\\nds = ds_ss_2020_2100\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", "text/plain": [ "" ] @@ -316,13 +324,13 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 43, "id": "6c038ac8", "metadata": {}, "outputs": [ { "data": { - "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 10;\n var nbb_unformatted_code = \"## Creating output folders\\n\\ncog_dir = processed_data_dir.joinpath(VARIABLE, \\\"cog\\\")\\ncogs_dir = processed_data_dir.joinpath(VARIABLE, \\\"cogs\\\")\\n\\ncog_dir.mkdir(parents=True, exist_ok=True)\\ncogs_dir.mkdir(parents=True, exist_ok=True)\";\n var nbb_formatted_code = \"## Creating output folders\\n\\ncog_dir = processed_data_dir.joinpath(VARIABLE, \\\"cog\\\")\\ncogs_dir = processed_data_dir.joinpath(VARIABLE, \\\"cogs\\\")\\n\\ncog_dir.mkdir(parents=True, exist_ok=True)\\ncogs_dir.mkdir(parents=True, exist_ok=True)\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", + "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 43;\n var nbb_unformatted_code = \"## Creating output folders\\n\\ncog_dir = processed_data_dir.joinpath(VARIABLE, \\\"cog\\\")\\ncogs_dir = processed_data_dir.joinpath(VARIABLE, \\\"cogs\\\")\\n\\ncog_dir.mkdir(parents=True, exist_ok=True)\\ncogs_dir.mkdir(parents=True, exist_ok=True)\";\n var nbb_formatted_code = \"## Creating output folders\\n\\ncog_dir = processed_data_dir.joinpath(VARIABLE, \\\"cog\\\")\\ncogs_dir = processed_data_dir.joinpath(VARIABLE, \\\"cogs\\\")\\n\\ncog_dir.mkdir(parents=True, exist_ok=True)\\ncogs_dir.mkdir(parents=True, exist_ok=True)\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", "text/plain": [ "" ] @@ -343,13 +351,13 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 44, "id": "279edbbc", "metadata": {}, "outputs": [ { "data": { - "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 11;\n var nbb_unformatted_code = \"## Read metadata (should be in input folder, but this is archived, therefore write in output for now)\\n\\nmetadata_path = processed_data_dir.joinpath(VARIABLE, \\\"metadata_subsidence.json\\\")\\n\\n# NetCDF attribute alterations by means of metadata template\\nf_global = open(metadata_path)\\nmeta_global = json.load(f_global)\";\n var nbb_formatted_code = \"## Read metadata (should be in input folder, but this is archived, therefore write in output for now)\\n\\nmetadata_path = processed_data_dir.joinpath(VARIABLE, \\\"metadata_subsidence.json\\\")\\n\\n# NetCDF attribute alterations by means of metadata template\\nf_global = open(metadata_path)\\nmeta_global = json.load(f_global)\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", + "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 44;\n var nbb_unformatted_code = \"## Read metadata (should be in input folder, but this is archived, therefore write in output for now)\\n\\nmetadata_path = processed_data_dir.joinpath(VARIABLE, \\\"metadata_subsidence.json\\\")\\n\\n# NetCDF attribute alterations by means of metadata template\\nf_global = open(metadata_path)\\nmeta_global = json.load(f_global)\";\n var nbb_formatted_code = \"## Read metadata (should be in input folder, but this is archived, therefore write in output for now)\\n\\nmetadata_path = processed_data_dir.joinpath(VARIABLE, \\\"metadata_subsidence.json\\\")\\n\\n# NetCDF attribute alterations by means of metadata template\\nf_global = open(metadata_path)\\nmeta_global = json.load(f_global)\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", "text/plain": [ "" ] @@ -370,13 +378,13 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 45, "id": "c8c2774e", "metadata": {}, "outputs": [ { "data": { - "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 12;\n var nbb_unformatted_code = \"## Remove the band dimension and add the crs, to include atts to the ds\\n\\nds = ds.isel(band=0).drop('band')\\nds.rio.write_crs(\\\"EPSG:28992\\\")\\n\\n# add all attributes (again)\\nfor attr_name, attr_val in meta_global.items():\\n if attr_name == 'PROVIDERS':\\n attr_val = json.dumps(attr_val)\\n if attr_name == \\\"MEDIA_TYPE\\\": # change media type to tiff, leave the rest as is\\n attr_val = \\\"IMAGE/TIFF\\\"\\n ds.attrs[attr_name] = attr_val\\n\\nds.attrs['Conventions'] = \\\"CF-1.8\\\"\\n\\noutput_dir = cog_dir.joinpath(SCENARIO) # if 1x run, use cog dir, if multiple, use cogs dir\\noutput_dir.mkdir(parents=True, exist_ok=True)\\n\\nfname = f\\\"{TIME}.GeoTiff\\\"\\n\\nout_path = output_dir.joinpath(fname)\\n\\nds.rio.to_raster(out_path, compress=\\\"DEFLATE\\\", driver=\\\"COG\\\")\";\n var nbb_formatted_code = \"## Remove the band dimension and add the crs, to include atts to the ds\\n\\nds = ds.isel(band=0).drop(\\\"band\\\")\\nds.rio.write_crs(\\\"EPSG:28992\\\")\\n\\n# add all attributes (again)\\nfor attr_name, attr_val in meta_global.items():\\n if attr_name == \\\"PROVIDERS\\\":\\n attr_val = json.dumps(attr_val)\\n if attr_name == \\\"MEDIA_TYPE\\\": # change media type to tiff, leave the rest as is\\n attr_val = \\\"IMAGE/TIFF\\\"\\n ds.attrs[attr_name] = attr_val\\n\\nds.attrs[\\\"Conventions\\\"] = \\\"CF-1.8\\\"\\n\\noutput_dir = cog_dir.joinpath(\\n SCENARIO\\n) # if 1x run, use cog dir, if multiple, use cogs dir\\noutput_dir.mkdir(parents=True, exist_ok=True)\\n\\nfname = f\\\"{TIME}.GeoTiff\\\"\\n\\nout_path = output_dir.joinpath(fname)\\n\\nds.rio.to_raster(out_path, compress=\\\"DEFLATE\\\", driver=\\\"COG\\\")\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", + "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 45;\n var nbb_unformatted_code = \"## Remove the band dimension and add the crs, to include atts to the ds\\n\\nds = ds.isel(band=0).drop('band')\\nds.rio.write_crs(28992, inplace=True)\\n\\n# add all attributes (again)\\nfor attr_name, attr_val in meta_global.items():\\n if attr_name == 'PROVIDERS':\\n attr_val = json.dumps(attr_val)\\n if attr_name == \\\"MEDIA_TYPE\\\": # change media type to tiff, leave the rest as is\\n attr_val = \\\"IMAGE/TIFF\\\"\\n ds.attrs[attr_name] = attr_val\\n\\nds.attrs['Conventions'] = \\\"CF-1.8\\\"\\n\\noutput_dir = cog_dir.joinpath(SCENARIO) # if 1x run, use cog dir, if multiple, use cogs dir\\noutput_dir.mkdir(parents=True, exist_ok=True)\\n\\nfname = f\\\"{TIME}.GeoTiff\\\"\\n\\nout_path = output_dir.joinpath(fname)\\n\\nds.rio.to_raster(out_path, compress=\\\"DEFLATE\\\", driver=\\\"COG\\\")\";\n var nbb_formatted_code = \"## Remove the band dimension and add the crs, to include atts to the ds\\n\\nds = ds.isel(band=0).drop(\\\"band\\\")\\nds.rio.write_crs(28992, inplace=True)\\n\\n# add all attributes (again)\\nfor attr_name, attr_val in meta_global.items():\\n if attr_name == \\\"PROVIDERS\\\":\\n attr_val = json.dumps(attr_val)\\n if attr_name == \\\"MEDIA_TYPE\\\": # change media type to tiff, leave the rest as is\\n attr_val = \\\"IMAGE/TIFF\\\"\\n ds.attrs[attr_name] = attr_val\\n\\nds.attrs[\\\"Conventions\\\"] = \\\"CF-1.8\\\"\\n\\noutput_dir = cog_dir.joinpath(\\n SCENARIO\\n) # if 1x run, use cog dir, if multiple, use cogs dir\\noutput_dir.mkdir(parents=True, exist_ok=True)\\n\\nfname = f\\\"{TIME}.GeoTiff\\\"\\n\\nout_path = output_dir.joinpath(fname)\\n\\nds.rio.to_raster(out_path, compress=\\\"DEFLATE\\\", driver=\\\"COG\\\")\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", "text/plain": [ "" ] @@ -389,7 +397,7 @@ "## Remove the band dimension and add the crs, to include atts to the ds\n", "\n", "ds = ds.isel(band=0).drop('band')\n", - "ds.rio.write_crs(\"EPSG:28992\")\n", + "ds.rio.write_crs(28992, inplace=True)\n", "\n", "# add all attributes (again)\n", "for attr_name, attr_val in meta_global.items():\n", @@ -421,13 +429,13 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 46, "id": "00d3e5ee", "metadata": {}, "outputs": [ { "data": { - "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 13;\n var nbb_unformatted_code = \"## Variables to include in a loop\\n\\nVARIABLE = [\\\"subsidence\\\"]\\nSCENARIO = [\\\"sterk\\\", 'mild']\\nTIME = ['2050', \\\"2100\\\"]\\n\\ndataset = {'ds_sterk_2020_2050': ds_ss_2020_2050, \\n 'ds_sterk_2020_2100': ds_ss_2020_2100, \\n 'ds_mild_2020_2050': ds_ms_2020_2050, \\n 'ds_mild_2020_2100': ds_ms_2020_2100}\";\n var nbb_formatted_code = \"## Variables to include in a loop\\n\\nVARIABLE = [\\\"subsidence\\\"]\\nSCENARIO = [\\\"sterk\\\", \\\"mild\\\"]\\nTIME = [\\\"2050\\\", \\\"2100\\\"]\\n\\ndataset = {\\n \\\"ds_sterk_2020_2050\\\": ds_ss_2020_2050,\\n \\\"ds_sterk_2020_2100\\\": ds_ss_2020_2100,\\n \\\"ds_mild_2020_2050\\\": ds_ms_2020_2050,\\n \\\"ds_mild_2020_2100\\\": ds_ms_2020_2100,\\n}\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", + "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 46;\n var nbb_unformatted_code = \"## Variables to include in a loop\\n\\nVARIABLE = [\\\"subsidence\\\"]\\nSCENARIO = [\\\"sterk\\\", 'mild']\\nTIME = ['2050', \\\"2100\\\"]\\n\\ndataset = {'ds_sterk_2020_2050': ds_ss_2020_2050, \\n 'ds_sterk_2020_2100': ds_ss_2020_2100, \\n 'ds_mild_2020_2050': ds_ms_2020_2050, \\n 'ds_mild_2020_2100': ds_ms_2020_2100}\";\n var nbb_formatted_code = \"## Variables to include in a loop\\n\\nVARIABLE = [\\\"subsidence\\\"]\\nSCENARIO = [\\\"sterk\\\", \\\"mild\\\"]\\nTIME = [\\\"2050\\\", \\\"2100\\\"]\\n\\ndataset = {\\n \\\"ds_sterk_2020_2050\\\": ds_ss_2020_2050,\\n \\\"ds_sterk_2020_2100\\\": ds_ss_2020_2100,\\n \\\"ds_mild_2020_2050\\\": ds_ms_2020_2050,\\n \\\"ds_mild_2020_2100\\\": ds_ms_2020_2100,\\n}\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", "text/plain": [ "" ] @@ -451,7 +459,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 48, "id": "26cb71c9", "metadata": {}, "outputs": [ @@ -470,7 +478,7 @@ }, { "data": { - "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 14;\n var nbb_unformatted_code = \"## Loop over variables, scenarios and years:\\n\\nfor var in VARIABLE:\\n print(var)\\n\\n # create output folder:\\n cogs_dir = processed_data_dir.joinpath(var, \\\"cogs\\\")\\n cogs_dir.mkdir(parents=True, exist_ok=True)\\n\\n # read metadata:\\n metadata_path = processed_data_dir.joinpath(var, f\\\"metadata_{var}.json\\\")\\n # NetCDF attribute alterations by means of metadata template\\n f_global = open(metadata_path)\\n meta_global = json.load(f_global)\\n\\n for scen in SCENARIO:\\n print(scen)\\n for time in TIME:\\n print(time)\\n\\n ## Remove the band dimension and add the crs\\n ds = dataset[f'ds_{scen}_2020_{time}'].isel(band=0).drop('band')\\n ds.rio.write_crs(\\\"EPSG:28992\\\")\\n\\n # add all attributes (again)\\n for attr_name, attr_val in meta_global.items():\\n if attr_name == 'PROVIDERS':\\n attr_val = json.dumps(attr_val)\\n if attr_name == \\\"MEDIA_TYPE\\\": # change media type to tiff, leave the rest as is\\n attr_val = \\\"IMAGE/TIFF\\\"\\n ds.attrs[attr_name] = attr_val\\n\\n ds.attrs['Conventions'] = \\\"CF-1.8\\\"\\n\\n # Saving\\n output_dir = cogs_dir.joinpath(scen) # if 1x run, use cog dir, if multiple, use cogs dir\\n output_dir.mkdir(parents=True, exist_ok=True)\\n\\n fname = f\\\"{time}.tif\\\"\\n\\n out_path = output_dir.joinpath(fname)\\n\\n ds.rio.to_raster(out_path, compress=\\\"DEFLATE\\\", driver=\\\"COG\\\")\";\n var nbb_formatted_code = \"## Loop over variables, scenarios and years:\\n\\nfor var in VARIABLE:\\n print(var)\\n\\n # create output folder:\\n cogs_dir = processed_data_dir.joinpath(var, \\\"cogs\\\")\\n cogs_dir.mkdir(parents=True, exist_ok=True)\\n\\n # read metadata:\\n metadata_path = processed_data_dir.joinpath(var, f\\\"metadata_{var}.json\\\")\\n # NetCDF attribute alterations by means of metadata template\\n f_global = open(metadata_path)\\n meta_global = json.load(f_global)\\n\\n for scen in SCENARIO:\\n print(scen)\\n for time in TIME:\\n print(time)\\n\\n ## Remove the band dimension and add the crs\\n ds = dataset[f\\\"ds_{scen}_2020_{time}\\\"].isel(band=0).drop(\\\"band\\\")\\n ds.rio.write_crs(\\\"EPSG:28992\\\")\\n\\n # add all attributes (again)\\n for attr_name, attr_val in meta_global.items():\\n if attr_name == \\\"PROVIDERS\\\":\\n attr_val = json.dumps(attr_val)\\n if (\\n attr_name == \\\"MEDIA_TYPE\\\"\\n ): # change media type to tiff, leave the rest as is\\n attr_val = \\\"IMAGE/TIFF\\\"\\n ds.attrs[attr_name] = attr_val\\n\\n ds.attrs[\\\"Conventions\\\"] = \\\"CF-1.8\\\"\\n\\n # Saving\\n output_dir = cogs_dir.joinpath(\\n scen\\n ) # if 1x run, use cog dir, if multiple, use cogs dir\\n output_dir.mkdir(parents=True, exist_ok=True)\\n\\n fname = f\\\"{time}.tif\\\"\\n\\n out_path = output_dir.joinpath(fname)\\n\\n ds.rio.to_raster(out_path, compress=\\\"DEFLATE\\\", driver=\\\"COG\\\")\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", + "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 48;\n var nbb_unformatted_code = \"## Loop over variables, scenarios and years:\\n\\nfor var in VARIABLE:\\n print(var)\\n\\n # create output folder:\\n cogs_dir = processed_data_dir.joinpath(var, \\\"cogs\\\")\\n cogs_dir.mkdir(parents=True, exist_ok=True)\\n\\n # read metadata:\\n metadata_path = processed_data_dir.joinpath(var, f\\\"metadata_{var}.json\\\")\\n # NetCDF attribute alterations by means of metadata template\\n f_global = open(metadata_path)\\n meta_global = json.load(f_global)\\n\\n for scen in SCENARIO:\\n print(scen)\\n for time in TIME:\\n print(time)\\n\\n ## Remove the band dimension and add the crs\\n ds = dataset[f'ds_{scen}_2020_{time}'].isel(band=0).drop('band')\\n ds.rio.write_crs(28992, inplace=True)\\n\\n # add all attributes (again)\\n for attr_name, attr_val in meta_global.items():\\n if attr_name == 'PROVIDERS':\\n attr_val = json.dumps(attr_val)\\n if attr_name == \\\"MEDIA_TYPE\\\": # change media type to tiff, leave the rest as is\\n attr_val = \\\"IMAGE/TIFF\\\"\\n ds.attrs[attr_name] = attr_val\\n\\n ds.attrs['Conventions'] = \\\"CF-1.8\\\"\\n\\n # Saving\\n output_dir = cogs_dir.joinpath(scen) # if 1x run, use cog dir, if multiple, use cogs dir\\n output_dir.mkdir(parents=True, exist_ok=True)\\n\\n fname = f\\\"{time}.tif\\\"\\n\\n out_path = output_dir.joinpath(fname)\\n\\n ds.rio.to_raster(out_path, compress=\\\"DEFLATE\\\", driver=\\\"COG\\\")\";\n var nbb_formatted_code = \"## Loop over variables, scenarios and years:\\n\\nfor var in VARIABLE:\\n print(var)\\n\\n # create output folder:\\n cogs_dir = processed_data_dir.joinpath(var, \\\"cogs\\\")\\n cogs_dir.mkdir(parents=True, exist_ok=True)\\n\\n # read metadata:\\n metadata_path = processed_data_dir.joinpath(var, f\\\"metadata_{var}.json\\\")\\n # NetCDF attribute alterations by means of metadata template\\n f_global = open(metadata_path)\\n meta_global = json.load(f_global)\\n\\n for scen in SCENARIO:\\n print(scen)\\n for time in TIME:\\n print(time)\\n\\n ## Remove the band dimension and add the crs\\n ds = dataset[f\\\"ds_{scen}_2020_{time}\\\"].isel(band=0).drop(\\\"band\\\")\\n ds.rio.write_crs(28992, inplace=True)\\n\\n # add all attributes (again)\\n for attr_name, attr_val in meta_global.items():\\n if attr_name == \\\"PROVIDERS\\\":\\n attr_val = json.dumps(attr_val)\\n if (\\n attr_name == \\\"MEDIA_TYPE\\\"\\n ): # change media type to tiff, leave the rest as is\\n attr_val = \\\"IMAGE/TIFF\\\"\\n ds.attrs[attr_name] = attr_val\\n\\n ds.attrs[\\\"Conventions\\\"] = \\\"CF-1.8\\\"\\n\\n # Saving\\n output_dir = cogs_dir.joinpath(\\n scen\\n ) # if 1x run, use cog dir, if multiple, use cogs dir\\n output_dir.mkdir(parents=True, exist_ok=True)\\n\\n fname = f\\\"{time}.tif\\\"\\n\\n out_path = output_dir.joinpath(fname)\\n\\n ds.rio.to_raster(out_path, compress=\\\"DEFLATE\\\", driver=\\\"COG\\\")\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", "text/plain": [ "" ] @@ -502,7 +510,7 @@ "\n", " ## Remove the band dimension and add the crs\n", " ds = dataset[f'ds_{scen}_2020_{time}'].isel(band=0).drop('band')\n", - " ds.rio.write_crs(\"EPSG:28992\")\n", + " ds.rio.write_crs(28992, inplace=True)\n", "\n", " # add all attributes (again)\n", " for attr_name, attr_val in meta_global.items():\n", @@ -524,6 +532,524 @@ "\n", " ds.rio.to_raster(out_path, compress=\"DEFLATE\", driver=\"COG\")" ] + }, + { + "cell_type": "code", + "execution_count": 49, + "id": "ee6eaa42", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "CRS.from_epsg(28992)" + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 49;\n var nbb_unformatted_code = \"ds.rio.crs\";\n var nbb_formatted_code = \"ds.rio.crs\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "ds.rio.crs\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d12fbf31", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
<xarray.Dataset>\n",
+       "Dimensions:      (x: 2800, y: 3250)\n",
+       "Coordinates:\n",
+       "  * x            (x) float64 50.0 150.0 250.0 ... 2.798e+05 2.798e+05 2.8e+05\n",
+       "  * y            (y) float64 6.248e+05 6.248e+05 6.246e+05 ... 3e+05 3e+05\n",
+       "    spatial_ref  int32 0\n",
+       "Data variables:\n",
+       "    band_data    (y, x) float64 nan nan nan nan nan nan ... nan nan nan nan nan\n",
+       "Attributes: (12/21)\n",
+       "    TITLE:               Subsidence Prediction Maps of the Netherlands\n",
+       "    TITLE_ABBREVIATION:  SPMN\n",
+       "    DESCRIPTION:         \n",
+       "    SHORT_DESCRIPTION:   \n",
+       "    INSTITUTION:         \n",
+       "    PROVIDERS:           [{"name": "", "url": "", "roles": "", "description":...\n",
+       "    ...                  ...\n",
+       "    DOI:                 \n",
+       "    LONG_NAME:           \n",
+       "    UNITS:               meters\n",
+       "    COMMENT:             \n",
+       "    CRS:                 EPSG:28992\n",
+       "    Conventions:         CF-1.8
" + ], + "text/plain": [ + "\n", + "Dimensions: (x: 2800, y: 3250)\n", + "Coordinates:\n", + " * x (x) float64 50.0 150.0 250.0 ... 2.798e+05 2.798e+05 2.8e+05\n", + " * y (y) float64 6.248e+05 6.248e+05 6.246e+05 ... 3e+05 3e+05\n", + " spatial_ref int32 0\n", + "Data variables:\n", + " band_data (y, x) float64 nan nan nan nan nan nan ... nan nan nan nan nan\n", + "Attributes: (12/21)\n", + " TITLE: Subsidence Prediction Maps of the Netherlands\n", + " TITLE_ABBREVIATION: SPMN\n", + " DESCRIPTION: \n", + " SHORT_DESCRIPTION: \n", + " INSTITUTION: \n", + " PROVIDERS: [{\"name\": \"\", \"url\": \"\", \"roles\": \"\", \"description\":...\n", + " ... ...\n", + " DOI: \n", + " LONG_NAME: \n", + " UNITS: meters\n", + " COMMENT: \n", + " CRS: EPSG:28992\n", + " Conventions: CF-1.8" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 17;\n var nbb_unformatted_code = \"ds.rio.write_crs(28992)\";\n var nbb_formatted_code = \"ds.rio.write_crs(28992)\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "ds.rio.write_crs(28992)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "13047dda", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 19;\n var nbb_unformatted_code = \"ds.rio\";\n var nbb_formatted_code = \"ds.rio\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ", + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "ds.rio\n" + ] } ], "metadata": {