From 816772d54d3ce57e81be3a4260926f5944a2cb3a Mon Sep 17 00:00:00 2001 From: Mares2022 <mario.fuentesmonjaraz@deltares.nl> Date: Tue, 16 Jul 2024 11:17:30 +0200 Subject: [PATCH] Changing .tiff format Changing .tiff format --- ...d_subsidence_prediction_maps_updated.ipynb | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) 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 d038e78d..831c7623 100644 --- a/STAC/data/notebooks/10_Land_subsidence_prediction_maps_updated.ipynb +++ b/STAC/data/notebooks/10_Land_subsidence_prediction_maps_updated.ipynb @@ -128,7 +128,7 @@ "outputs": [ { "data": { - "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 4;\n var nbb_unformatted_code = \"# Define (local and) remote drives\\nraw_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\\nraw_data_dir = p_drive.joinpath(\\n \\\"archivedprojects\\\",\\n \\\"11208003-latedeo2022\\\",\\n \\\"020_InternationalDeltaPortfolio\\\",\\n \\\"datasets\\\",\\n \\\"00_bodemdalingsvoorspellingskaarten\\\",\\n)\\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 = 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 ", "text/plain": [ "<IPython.core.display.Javascript object>" ] @@ -223,13 +223,13 @@ }, { "cell_type": "code", - "execution_count": 222, + "execution_count": 7, "id": "e2288a0f", "metadata": {}, "outputs": [ { "data": { - "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 222;\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 = 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 ", "text/plain": [ "<IPython.core.display.Javascript object>" ] @@ -252,13 +252,13 @@ }, { "cell_type": "code", - "execution_count": 223, + "execution_count": 8, "id": "cabbf6ab", "metadata": {}, "outputs": [ { "data": { - "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 223;\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 = 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 ", "text/plain": [ "<IPython.core.display.Javascript object>" ] @@ -289,13 +289,13 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 9, "id": "19d8d5d8", "metadata": {}, "outputs": [ { "data": { - "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 7;\n var nbb_unformatted_code = \"VARIABLE = \\\"subsidence\\\"\\nSCENARIO = \\\"sterk\\\"\\nTIME = \\\"2100\\\"\\n\\nds = ds_ss_2020_2100\";\n var nbb_formatted_code = \"VARIABLE = \\\"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 = 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 ", "text/plain": [ "<IPython.core.display.Javascript object>" ] @@ -316,13 +316,13 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 10, "id": "6c038ac8", "metadata": {}, "outputs": [ { "data": { - "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 8;\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 = 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 ", "text/plain": [ "<IPython.core.display.Javascript object>" ] @@ -343,13 +343,13 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 11, "id": "279edbbc", "metadata": {}, "outputs": [ { "data": { - "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 9;\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 = 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 ", "text/plain": [ "<IPython.core.display.Javascript object>" ] @@ -370,13 +370,13 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 12, "id": "c8c2774e", "metadata": {}, "outputs": [ { "data": { - "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 15;\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)\\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(SCENARIO)\\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 = 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 ", "text/plain": [ "<IPython.core.display.Javascript object>" ] @@ -421,13 +421,13 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 13, "id": "00d3e5ee", "metadata": {}, "outputs": [ { "data": { - "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 43;\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 = 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 ", "text/plain": [ "<IPython.core.display.Javascript object>" ] @@ -451,7 +451,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 14, "id": "26cb71c9", "metadata": {}, "outputs": [ @@ -470,7 +470,7 @@ }, { "data": { - "application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 44;\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}.GeoTiff\\\"\\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}.GeoTiff\\\"\\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 = 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 ", "text/plain": [ "<IPython.core.display.Javascript object>" ] @@ -518,7 +518,7 @@ " 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}.tiff\"\n", + " fname = f\"{time}.tif\"\n", "\n", " out_path = output_dir.joinpath(fname)\n", "\n",