From ee62dee82be8a008aa010f8e02937e80c5da515e Mon Sep 17 00:00:00 2001 From: floriscalkoen Date: Tue, 8 Oct 2024 10:25:50 +0200 Subject: [PATCH] rm intro nb to slippy map tiles because its irrelevant --- ...3_access_shorelinemonitor_raw_series.ipynb | 1797 +++++++++++++++++ notebooks/boxes.ipynb | 89 - 2 files changed, 1797 insertions(+), 89 deletions(-) create mode 100644 notebooks/33_access_shorelinemonitor_raw_series.ipynb delete mode 100644 notebooks/boxes.ipynb diff --git a/notebooks/33_access_shorelinemonitor_raw_series.ipynb b/notebooks/33_access_shorelinemonitor_raw_series.ipynb new file mode 100644 index 0000000..8d79cbb --- /dev/null +++ b/notebooks/33_access_shorelinemonitor_raw_series.ipynb @@ -0,0 +1,1797 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "9f74bead-f0dc-4443-b34a-903395579d47", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-11T06:28:36.164758Z", + "iopub.status.busy": "2024-06-11T06:28:36.164600Z", + "iopub.status.idle": "2024-06-11T06:28:40.556713Z", + "shell.execute_reply": "2024-06-11T06:28:40.556417Z", + "shell.execute_reply.started": "2024-06-11T06:28:36.164747Z" + } + }, + "outputs": [ + { + "data": { + "application/javascript": [ + "(function(root) {\n", + " function now() {\n", + " return new Date();\n", + " }\n", + "\n", + " var force = true;\n", + " var py_version = '3.4.1'.replace('rc', '-rc.').replace('.dev', '-dev.');\n", + " var reloading = false;\n", + " var Bokeh = root.Bokeh;\n", + "\n", + " if (typeof (root._bokeh_timeout) === \"undefined\" || force) {\n", + " root._bokeh_timeout = Date.now() + 5000;\n", + " root._bokeh_failed_load = false;\n", + " }\n", + "\n", + " function run_callbacks() {\n", + " try {\n", + " root._bokeh_onload_callbacks.forEach(function(callback) {\n", + " if (callback != null)\n", + " callback();\n", + " });\n", + " } finally {\n", + " delete root._bokeh_onload_callbacks;\n", + " }\n", + " console.debug(\"Bokeh: all callbacks have finished\");\n", + " }\n", + "\n", + " function load_libs(css_urls, js_urls, js_modules, js_exports, callback) {\n", + " if (css_urls == null) css_urls = [];\n", + " if (js_urls == null) js_urls = [];\n", + " if (js_modules == null) js_modules = [];\n", + " if (js_exports == null) js_exports = {};\n", + "\n", + " root._bokeh_onload_callbacks.push(callback);\n", + "\n", + " if (root._bokeh_is_loading > 0) {\n", + " console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n", + " return null;\n", + " }\n", + " if (js_urls.length === 0 && js_modules.length === 0 && Object.keys(js_exports).length === 0) {\n", + " run_callbacks();\n", + " return null;\n", + " }\n", + " if (!reloading) {\n", + " console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n", + " }\n", + "\n", + " function on_load() {\n", + " root._bokeh_is_loading--;\n", + " if (root._bokeh_is_loading === 0) {\n", + " console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n", + " run_callbacks()\n", + " }\n", + " }\n", + " window._bokeh_on_load = on_load\n", + "\n", + " function on_error() {\n", + " console.error(\"failed to load \" + url);\n", + " }\n", + "\n", + " var skip = [];\n", + " if (window.requirejs) {\n", + " window.requirejs.config({'packages': {}, 'paths': {}, 'shim': {}});\n", + " root._bokeh_is_loading = css_urls.length + 0;\n", + " } else {\n", + " root._bokeh_is_loading = css_urls.length + js_urls.length + js_modules.length + Object.keys(js_exports).length;\n", + " }\n", + "\n", + " var existing_stylesheets = []\n", + " var links = document.getElementsByTagName('link')\n", + " for (var i = 0; i < links.length; i++) {\n", + " var link = links[i]\n", + " if (link.href != null) {\n", + "\texisting_stylesheets.push(link.href)\n", + " }\n", + " }\n", + " for (var i = 0; i < css_urls.length; i++) {\n", + " var url = css_urls[i];\n", + " if (existing_stylesheets.indexOf(url) !== -1) {\n", + "\ton_load()\n", + "\tcontinue;\n", + " }\n", + " const element = document.createElement(\"link\");\n", + " element.onload = on_load;\n", + " element.onerror = on_error;\n", + " element.rel = \"stylesheet\";\n", + " element.type = \"text/css\";\n", + " element.href = url;\n", + " console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n", + " document.body.appendChild(element);\n", + " } var existing_scripts = []\n", + " var scripts = document.getElementsByTagName('script')\n", + " for (var i = 0; i < scripts.length; i++) {\n", + " var script = scripts[i]\n", + " if (script.src != null) {\n", + "\texisting_scripts.push(script.src)\n", + " }\n", + " }\n", + " for (var i = 0; i < js_urls.length; i++) {\n", + " var url = js_urls[i];\n", + " if (skip.indexOf(url) !== -1 || existing_scripts.indexOf(url) !== -1) {\n", + "\tif (!window.requirejs) {\n", + "\t on_load();\n", + "\t}\n", + "\tcontinue;\n", + " }\n", + " var element = document.createElement('script');\n", + " element.onload = on_load;\n", + " element.onerror = on_error;\n", + " element.async = false;\n", + " element.src = url;\n", + " console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", + " document.head.appendChild(element);\n", + " }\n", + " for (var i = 0; i < js_modules.length; i++) {\n", + " var url = js_modules[i];\n", + " if (skip.indexOf(url) !== -1 || existing_scripts.indexOf(url) !== -1) {\n", + "\tif (!window.requirejs) {\n", + "\t on_load();\n", + "\t}\n", + "\tcontinue;\n", + " }\n", + " var element = document.createElement('script');\n", + " element.onload = on_load;\n", + " element.onerror = on_error;\n", + " element.async = false;\n", + " element.src = url;\n", + " element.type = \"module\";\n", + " console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", + " document.head.appendChild(element);\n", + " }\n", + " for (const name in js_exports) {\n", + " var url = js_exports[name];\n", + " if (skip.indexOf(url) >= 0 || root[name] != null) {\n", + "\tif (!window.requirejs) {\n", + "\t on_load();\n", + "\t}\n", + "\tcontinue;\n", + " }\n", + " var element = document.createElement('script');\n", + " element.onerror = on_error;\n", + " element.async = false;\n", + " element.type = \"module\";\n", + " console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", + " element.textContent = `\n", + " import ${name} from \"${url}\"\n", + " window.${name} = ${name}\n", + " window._bokeh_on_load()\n", + " `\n", + " document.head.appendChild(element);\n", + " }\n", + " if (!js_urls.length && !js_modules.length) {\n", + " on_load()\n", + " }\n", + " };\n", + "\n", + " function inject_raw_css(css) {\n", + " const element = document.createElement(\"style\");\n", + " element.appendChild(document.createTextNode(css));\n", + " document.body.appendChild(element);\n", + " }\n", + "\n", + " var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.4.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.4.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.4.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.4.1.min.js\", \"https://cdn.holoviz.org/panel/1.4.4/dist/panel.min.js\"];\n", + " var js_modules = [];\n", + " var js_exports = {};\n", + " var css_urls = [];\n", + " var inline_js = [ function(Bokeh) {\n", + " Bokeh.set_log_level(\"info\");\n", + " },\n", + "function(Bokeh) {} // ensure no trailing comma for IE\n", + " ];\n", + "\n", + " function run_inline_js() {\n", + " if ((root.Bokeh !== undefined) || (force === true)) {\n", + " for (var i = 0; i < inline_js.length; i++) {\n", + "\ttry {\n", + " inline_js[i].call(root, root.Bokeh);\n", + "\t} catch(e) {\n", + "\t if (!reloading) {\n", + "\t throw e;\n", + "\t }\n", + "\t}\n", + " }\n", + " // Cache old bokeh versions\n", + " if (Bokeh != undefined && !reloading) {\n", + "\tvar NewBokeh = root.Bokeh;\n", + "\tif (Bokeh.versions === undefined) {\n", + "\t Bokeh.versions = new Map();\n", + "\t}\n", + "\tif (NewBokeh.version !== Bokeh.version) {\n", + "\t Bokeh.versions.set(NewBokeh.version, NewBokeh)\n", + "\t}\n", + "\troot.Bokeh = Bokeh;\n", + " }} else if (Date.now() < root._bokeh_timeout) {\n", + " setTimeout(run_inline_js, 100);\n", + " } else if (!root._bokeh_failed_load) {\n", + " console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n", + " root._bokeh_failed_load = true;\n", + " }\n", + " root._bokeh_is_initializing = false\n", + " }\n", + "\n", + " function load_or_wait() {\n", + " // Implement a backoff loop that tries to ensure we do not load multiple\n", + " // versions of Bokeh and its dependencies at the same time.\n", + " // In recent versions we use the root._bokeh_is_initializing flag\n", + " // to determine whether there is an ongoing attempt to initialize\n", + " // bokeh, however for backward compatibility we also try to ensure\n", + " // that we do not start loading a newer (Panel>=1.0 and Bokeh>3) version\n", + " // before older versions are fully initialized.\n", + " if (root._bokeh_is_initializing && Date.now() > root._bokeh_timeout) {\n", + " root._bokeh_is_initializing = false;\n", + " root._bokeh_onload_callbacks = undefined;\n", + " console.log(\"Bokeh: BokehJS was loaded multiple times but one version failed to initialize.\");\n", + " load_or_wait();\n", + " } else if (root._bokeh_is_initializing || (typeof root._bokeh_is_initializing === \"undefined\" && root._bokeh_onload_callbacks !== undefined)) {\n", + " setTimeout(load_or_wait, 100);\n", + " } else {\n", + " root._bokeh_is_initializing = true\n", + " root._bokeh_onload_callbacks = []\n", + " var bokeh_loaded = Bokeh != null && (Bokeh.version === py_version || (Bokeh.versions !== undefined && Bokeh.versions.has(py_version)));\n", + " if (!reloading && !bokeh_loaded) {\n", + "\troot.Bokeh = undefined;\n", + " }\n", + " load_libs(css_urls, js_urls, js_modules, js_exports, function() {\n", + "\tconsole.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n", + "\trun_inline_js();\n", + " });\n", + " }\n", + " }\n", + " // Give older versions of the autoload script a head-start to ensure\n", + " // they initialize before we start loading newer version.\n", + " setTimeout(load_or_wait, 100)\n", + "}(window));" + ], + "application/vnd.holoviews_load.v0+json": "(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n var py_version = '3.4.1'.replace('rc', '-rc.').replace('.dev', '-dev.');\n var reloading = false;\n var Bokeh = root.Bokeh;\n\n if (typeof (root._bokeh_timeout) === \"undefined\" || force) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks;\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, js_modules, js_exports, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n if (js_modules == null) js_modules = [];\n if (js_exports == null) js_exports = {};\n\n root._bokeh_onload_callbacks.push(callback);\n\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls.length === 0 && js_modules.length === 0 && Object.keys(js_exports).length === 0) {\n run_callbacks();\n return null;\n }\n if (!reloading) {\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n }\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n window._bokeh_on_load = on_load\n\n function on_error() {\n console.error(\"failed to load \" + url);\n }\n\n var skip = [];\n if (window.requirejs) {\n window.requirejs.config({'packages': {}, 'paths': {}, 'shim': {}});\n root._bokeh_is_loading = css_urls.length + 0;\n } else {\n root._bokeh_is_loading = css_urls.length + js_urls.length + js_modules.length + Object.keys(js_exports).length;\n }\n\n var existing_stylesheets = []\n var links = document.getElementsByTagName('link')\n for (var i = 0; i < links.length; i++) {\n var link = links[i]\n if (link.href != null) {\n\texisting_stylesheets.push(link.href)\n }\n }\n for (var i = 0; i < css_urls.length; i++) {\n var url = css_urls[i];\n if (existing_stylesheets.indexOf(url) !== -1) {\n\ton_load()\n\tcontinue;\n }\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error;\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n } var existing_scripts = []\n var scripts = document.getElementsByTagName('script')\n for (var i = 0; i < scripts.length; i++) {\n var script = scripts[i]\n if (script.src != null) {\n\texisting_scripts.push(script.src)\n }\n }\n for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n if (skip.indexOf(url) !== -1 || existing_scripts.indexOf(url) !== -1) {\n\tif (!window.requirejs) {\n\t on_load();\n\t}\n\tcontinue;\n }\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n for (var i = 0; i < js_modules.length; i++) {\n var url = js_modules[i];\n if (skip.indexOf(url) !== -1 || existing_scripts.indexOf(url) !== -1) {\n\tif (!window.requirejs) {\n\t on_load();\n\t}\n\tcontinue;\n }\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n element.type = \"module\";\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n for (const name in js_exports) {\n var url = js_exports[name];\n if (skip.indexOf(url) >= 0 || root[name] != null) {\n\tif (!window.requirejs) {\n\t on_load();\n\t}\n\tcontinue;\n }\n var element = document.createElement('script');\n element.onerror = on_error;\n element.async = false;\n element.type = \"module\";\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n element.textContent = `\n import ${name} from \"${url}\"\n window.${name} = ${name}\n window._bokeh_on_load()\n `\n document.head.appendChild(element);\n }\n if (!js_urls.length && !js_modules.length) {\n on_load()\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.4.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.4.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.4.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.4.1.min.js\", \"https://cdn.holoviz.org/panel/1.4.4/dist/panel.min.js\"];\n var js_modules = [];\n var js_exports = {};\n var css_urls = [];\n var inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {} // ensure no trailing comma for IE\n ];\n\n function run_inline_js() {\n if ((root.Bokeh !== undefined) || (force === true)) {\n for (var i = 0; i < inline_js.length; i++) {\n\ttry {\n inline_js[i].call(root, root.Bokeh);\n\t} catch(e) {\n\t if (!reloading) {\n\t throw e;\n\t }\n\t}\n }\n // Cache old bokeh versions\n if (Bokeh != undefined && !reloading) {\n\tvar NewBokeh = root.Bokeh;\n\tif (Bokeh.versions === undefined) {\n\t Bokeh.versions = new Map();\n\t}\n\tif (NewBokeh.version !== Bokeh.version) {\n\t Bokeh.versions.set(NewBokeh.version, NewBokeh)\n\t}\n\troot.Bokeh = Bokeh;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n }\n root._bokeh_is_initializing = false\n }\n\n function load_or_wait() {\n // Implement a backoff loop that tries to ensure we do not load multiple\n // versions of Bokeh and its dependencies at the same time.\n // In recent versions we use the root._bokeh_is_initializing flag\n // to determine whether there is an ongoing attempt to initialize\n // bokeh, however for backward compatibility we also try to ensure\n // that we do not start loading a newer (Panel>=1.0 and Bokeh>3) version\n // before older versions are fully initialized.\n if (root._bokeh_is_initializing && Date.now() > root._bokeh_timeout) {\n root._bokeh_is_initializing = false;\n root._bokeh_onload_callbacks = undefined;\n console.log(\"Bokeh: BokehJS was loaded multiple times but one version failed to initialize.\");\n load_or_wait();\n } else if (root._bokeh_is_initializing || (typeof root._bokeh_is_initializing === \"undefined\" && root._bokeh_onload_callbacks !== undefined)) {\n setTimeout(load_or_wait, 100);\n } else {\n root._bokeh_is_initializing = true\n root._bokeh_onload_callbacks = []\n var bokeh_loaded = Bokeh != null && (Bokeh.version === py_version || (Bokeh.versions !== undefined && Bokeh.versions.has(py_version)));\n if (!reloading && !bokeh_loaded) {\n\troot.Bokeh = undefined;\n }\n load_libs(css_urls, js_urls, js_modules, js_exports, function() {\n\tconsole.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n\trun_inline_js();\n });\n }\n }\n // Give older versions of the autoload script a head-start to ensure\n // they initialize before we start loading newer version.\n setTimeout(load_or_wait, 100)\n}(window));" + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/javascript": [ + "\n", + "if ((window.PyViz === undefined) || (window.PyViz instanceof HTMLElement)) {\n", + " window.PyViz = {comms: {}, comm_status:{}, kernels:{}, receivers: {}, plot_index: []}\n", + "}\n", + "\n", + "\n", + " function JupyterCommManager() {\n", + " }\n", + "\n", + " JupyterCommManager.prototype.register_target = function(plot_id, comm_id, msg_handler) {\n", + " if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n", + " var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n", + " comm_manager.register_target(comm_id, function(comm) {\n", + " comm.on_msg(msg_handler);\n", + " });\n", + " } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n", + " window.PyViz.kernels[plot_id].registerCommTarget(comm_id, function(comm) {\n", + " comm.onMsg = msg_handler;\n", + " });\n", + " } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n", + " google.colab.kernel.comms.registerTarget(comm_id, (comm) => {\n", + " var messages = comm.messages[Symbol.asyncIterator]();\n", + " function processIteratorResult(result) {\n", + " var message = result.value;\n", + " console.log(message)\n", + " var content = {data: message.data, comm_id};\n", + " var buffers = []\n", + " for (var buffer of message.buffers || []) {\n", + " buffers.push(new DataView(buffer))\n", + " }\n", + " var metadata = message.metadata || {};\n", + " var msg = {content, buffers, metadata}\n", + " msg_handler(msg);\n", + " return messages.next().then(processIteratorResult);\n", + " }\n", + " return messages.next().then(processIteratorResult);\n", + " })\n", + " }\n", + " }\n", + "\n", + " JupyterCommManager.prototype.get_client_comm = function(plot_id, comm_id, msg_handler) {\n", + " if (comm_id in window.PyViz.comms) {\n", + " return window.PyViz.comms[comm_id];\n", + " } else if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n", + " var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n", + " var comm = comm_manager.new_comm(comm_id, {}, {}, {}, comm_id);\n", + " if (msg_handler) {\n", + " comm.on_msg(msg_handler);\n", + " }\n", + " } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n", + " var comm = window.PyViz.kernels[plot_id].connectToComm(comm_id);\n", + " comm.open();\n", + " if (msg_handler) {\n", + " comm.onMsg = msg_handler;\n", + " }\n", + " } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n", + " var comm_promise = google.colab.kernel.comms.open(comm_id)\n", + " comm_promise.then((comm) => {\n", + " window.PyViz.comms[comm_id] = comm;\n", + " if (msg_handler) {\n", + " var messages = comm.messages[Symbol.asyncIterator]();\n", + " function processIteratorResult(result) {\n", + " var message = result.value;\n", + " var content = {data: message.data};\n", + " var metadata = message.metadata || {comm_id};\n", + " var msg = {content, metadata}\n", + " msg_handler(msg);\n", + " return messages.next().then(processIteratorResult);\n", + " }\n", + " return messages.next().then(processIteratorResult);\n", + " }\n", + " }) \n", + " var sendClosure = (data, metadata, buffers, disposeOnDone) => {\n", + " return comm_promise.then((comm) => {\n", + " comm.send(data, metadata, buffers, disposeOnDone);\n", + " });\n", + " };\n", + " var comm = {\n", + " send: sendClosure\n", + " };\n", + " }\n", + " window.PyViz.comms[comm_id] = comm;\n", + " return comm;\n", + " }\n", + " window.PyViz.comm_manager = new JupyterCommManager();\n", + " \n", + "\n", + "\n", + "var JS_MIME_TYPE = 'application/javascript';\n", + "var HTML_MIME_TYPE = 'text/html';\n", + "var EXEC_MIME_TYPE = 'application/vnd.holoviews_exec.v0+json';\n", + "var CLASS_NAME = 'output';\n", + "\n", + "/**\n", + " * Render data to the DOM node\n", + " */\n", + "function render(props, node) {\n", + " var div = document.createElement(\"div\");\n", + " var script = document.createElement(\"script\");\n", + " node.appendChild(div);\n", + " node.appendChild(script);\n", + "}\n", + "\n", + "/**\n", + " * Handle when a new output is added\n", + " */\n", + "function handle_add_output(event, handle) {\n", + " var output_area = handle.output_area;\n", + " var output = handle.output;\n", + " if ((output.data == undefined) || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n", + " return\n", + " }\n", + " var id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n", + " var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n", + " if (id !== undefined) {\n", + " var nchildren = toinsert.length;\n", + " var html_node = toinsert[nchildren-1].children[0];\n", + " html_node.innerHTML = output.data[HTML_MIME_TYPE];\n", + " var scripts = [];\n", + " var nodelist = html_node.querySelectorAll(\"script\");\n", + " for (var i in nodelist) {\n", + " if (nodelist.hasOwnProperty(i)) {\n", + " scripts.push(nodelist[i])\n", + " }\n", + " }\n", + "\n", + " scripts.forEach( function (oldScript) {\n", + " var newScript = document.createElement(\"script\");\n", + " var attrs = [];\n", + " var nodemap = oldScript.attributes;\n", + " for (var j in nodemap) {\n", + " if (nodemap.hasOwnProperty(j)) {\n", + " attrs.push(nodemap[j])\n", + " }\n", + " }\n", + " attrs.forEach(function(attr) { newScript.setAttribute(attr.name, attr.value) });\n", + " newScript.appendChild(document.createTextNode(oldScript.innerHTML));\n", + " oldScript.parentNode.replaceChild(newScript, oldScript);\n", + " });\n", + " if (JS_MIME_TYPE in output.data) {\n", + " toinsert[nchildren-1].children[1].textContent = output.data[JS_MIME_TYPE];\n", + " }\n", + " output_area._hv_plot_id = id;\n", + " if ((window.Bokeh !== undefined) && (id in Bokeh.index)) {\n", + " window.PyViz.plot_index[id] = Bokeh.index[id];\n", + " } else {\n", + " window.PyViz.plot_index[id] = null;\n", + " }\n", + " } else if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n", + " var bk_div = document.createElement(\"div\");\n", + " bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n", + " var script_attrs = bk_div.children[0].attributes;\n", + " for (var i = 0; i < script_attrs.length; i++) {\n", + " toinsert[toinsert.length - 1].childNodes[1].setAttribute(script_attrs[i].name, script_attrs[i].value);\n", + " }\n", + " // store reference to server id on output_area\n", + " output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n", + " }\n", + "}\n", + "\n", + "/**\n", + " * Handle when an output is cleared or removed\n", + " */\n", + "function handle_clear_output(event, handle) {\n", + " var id = handle.cell.output_area._hv_plot_id;\n", + " var server_id = handle.cell.output_area._bokeh_server_id;\n", + " if (((id === undefined) || !(id in PyViz.plot_index)) && (server_id !== undefined)) { return; }\n", + " var comm = window.PyViz.comm_manager.get_client_comm(\"hv-extension-comm\", \"hv-extension-comm\", function () {});\n", + " if (server_id !== null) {\n", + " comm.send({event_type: 'server_delete', 'id': server_id});\n", + " return;\n", + " } else if (comm !== null) {\n", + " comm.send({event_type: 'delete', 'id': id});\n", + " }\n", + " delete PyViz.plot_index[id];\n", + " if ((window.Bokeh !== undefined) & (id in window.Bokeh.index)) {\n", + " var doc = window.Bokeh.index[id].model.document\n", + " doc.clear();\n", + " const i = window.Bokeh.documents.indexOf(doc);\n", + " if (i > -1) {\n", + " window.Bokeh.documents.splice(i, 1);\n", + " }\n", + " }\n", + "}\n", + "\n", + "/**\n", + " * Handle kernel restart event\n", + " */\n", + "function handle_kernel_cleanup(event, handle) {\n", + " delete PyViz.comms[\"hv-extension-comm\"];\n", + " window.PyViz.plot_index = {}\n", + "}\n", + "\n", + "/**\n", + " * Handle update_display_data messages\n", + " */\n", + "function handle_update_output(event, handle) {\n", + " handle_clear_output(event, {cell: {output_area: handle.output_area}})\n", + " handle_add_output(event, handle)\n", + "}\n", + "\n", + "function register_renderer(events, OutputArea) {\n", + " function append_mime(data, metadata, element) {\n", + " // create a DOM node to render to\n", + " var toinsert = this.create_output_subarea(\n", + " metadata,\n", + " CLASS_NAME,\n", + " EXEC_MIME_TYPE\n", + " );\n", + " this.keyboard_manager.register_events(toinsert);\n", + " // Render to node\n", + " var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n", + " render(props, toinsert[0]);\n", + " element.append(toinsert);\n", + " return toinsert\n", + " }\n", + "\n", + " events.on('output_added.OutputArea', handle_add_output);\n", + " events.on('output_updated.OutputArea', handle_update_output);\n", + " events.on('clear_output.CodeCell', handle_clear_output);\n", + " events.on('delete.Cell', handle_clear_output);\n", + " events.on('kernel_ready.Kernel', handle_kernel_cleanup);\n", + "\n", + " OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n", + " safe: true,\n", + " index: 0\n", + " });\n", + "}\n", + "\n", + "if (window.Jupyter !== undefined) {\n", + " try {\n", + " var events = require('base/js/events');\n", + " var OutputArea = require('notebook/js/outputarea').OutputArea;\n", + " if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n", + " register_renderer(events, OutputArea);\n", + " }\n", + " } catch(err) {\n", + " }\n", + "}\n" + ], + "application/vnd.holoviews_load.v0+json": "\nif ((window.PyViz === undefined) || (window.PyViz instanceof HTMLElement)) {\n window.PyViz = {comms: {}, comm_status:{}, kernels:{}, receivers: {}, plot_index: []}\n}\n\n\n function JupyterCommManager() {\n }\n\n JupyterCommManager.prototype.register_target = function(plot_id, comm_id, msg_handler) {\n if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n comm_manager.register_target(comm_id, function(comm) {\n comm.on_msg(msg_handler);\n });\n } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n window.PyViz.kernels[plot_id].registerCommTarget(comm_id, function(comm) {\n comm.onMsg = msg_handler;\n });\n } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n google.colab.kernel.comms.registerTarget(comm_id, (comm) => {\n var messages = comm.messages[Symbol.asyncIterator]();\n function processIteratorResult(result) {\n var message = result.value;\n console.log(message)\n var content = {data: message.data, comm_id};\n var buffers = []\n for (var buffer of message.buffers || []) {\n buffers.push(new DataView(buffer))\n }\n var metadata = message.metadata || {};\n var msg = {content, buffers, metadata}\n msg_handler(msg);\n return messages.next().then(processIteratorResult);\n }\n return messages.next().then(processIteratorResult);\n })\n }\n }\n\n JupyterCommManager.prototype.get_client_comm = function(plot_id, comm_id, msg_handler) {\n if (comm_id in window.PyViz.comms) {\n return window.PyViz.comms[comm_id];\n } else if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n var comm = comm_manager.new_comm(comm_id, {}, {}, {}, comm_id);\n if (msg_handler) {\n comm.on_msg(msg_handler);\n }\n } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n var comm = window.PyViz.kernels[plot_id].connectToComm(comm_id);\n comm.open();\n if (msg_handler) {\n comm.onMsg = msg_handler;\n }\n } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n var comm_promise = google.colab.kernel.comms.open(comm_id)\n comm_promise.then((comm) => {\n window.PyViz.comms[comm_id] = comm;\n if (msg_handler) {\n var messages = comm.messages[Symbol.asyncIterator]();\n function processIteratorResult(result) {\n var message = result.value;\n var content = {data: message.data};\n var metadata = message.metadata || {comm_id};\n var msg = {content, metadata}\n msg_handler(msg);\n return messages.next().then(processIteratorResult);\n }\n return messages.next().then(processIteratorResult);\n }\n }) \n var sendClosure = (data, metadata, buffers, disposeOnDone) => {\n return comm_promise.then((comm) => {\n comm.send(data, metadata, buffers, disposeOnDone);\n });\n };\n var comm = {\n send: sendClosure\n };\n }\n window.PyViz.comms[comm_id] = comm;\n return comm;\n }\n window.PyViz.comm_manager = new JupyterCommManager();\n \n\n\nvar JS_MIME_TYPE = 'application/javascript';\nvar HTML_MIME_TYPE = 'text/html';\nvar EXEC_MIME_TYPE = 'application/vnd.holoviews_exec.v0+json';\nvar CLASS_NAME = 'output';\n\n/**\n * Render data to the DOM node\n */\nfunction render(props, node) {\n var div = document.createElement(\"div\");\n var script = document.createElement(\"script\");\n node.appendChild(div);\n node.appendChild(script);\n}\n\n/**\n * Handle when a new output is added\n */\nfunction handle_add_output(event, handle) {\n var output_area = handle.output_area;\n var output = handle.output;\n if ((output.data == undefined) || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n return\n }\n var id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n if (id !== undefined) {\n var nchildren = toinsert.length;\n var html_node = toinsert[nchildren-1].children[0];\n html_node.innerHTML = output.data[HTML_MIME_TYPE];\n var scripts = [];\n var nodelist = html_node.querySelectorAll(\"script\");\n for (var i in nodelist) {\n if (nodelist.hasOwnProperty(i)) {\n scripts.push(nodelist[i])\n }\n }\n\n scripts.forEach( function (oldScript) {\n var newScript = document.createElement(\"script\");\n var attrs = [];\n var nodemap = oldScript.attributes;\n for (var j in nodemap) {\n if (nodemap.hasOwnProperty(j)) {\n attrs.push(nodemap[j])\n }\n }\n attrs.forEach(function(attr) { newScript.setAttribute(attr.name, attr.value) });\n newScript.appendChild(document.createTextNode(oldScript.innerHTML));\n oldScript.parentNode.replaceChild(newScript, oldScript);\n });\n if (JS_MIME_TYPE in output.data) {\n toinsert[nchildren-1].children[1].textContent = output.data[JS_MIME_TYPE];\n }\n output_area._hv_plot_id = id;\n if ((window.Bokeh !== undefined) && (id in Bokeh.index)) {\n window.PyViz.plot_index[id] = Bokeh.index[id];\n } else {\n window.PyViz.plot_index[id] = null;\n }\n } else if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n var bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n var script_attrs = bk_div.children[0].attributes;\n for (var i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].childNodes[1].setAttribute(script_attrs[i].name, script_attrs[i].value);\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n}\n\n/**\n * Handle when an output is cleared or removed\n */\nfunction handle_clear_output(event, handle) {\n var id = handle.cell.output_area._hv_plot_id;\n var server_id = handle.cell.output_area._bokeh_server_id;\n if (((id === undefined) || !(id in PyViz.plot_index)) && (server_id !== undefined)) { return; }\n var comm = window.PyViz.comm_manager.get_client_comm(\"hv-extension-comm\", \"hv-extension-comm\", function () {});\n if (server_id !== null) {\n comm.send({event_type: 'server_delete', 'id': server_id});\n return;\n } else if (comm !== null) {\n comm.send({event_type: 'delete', 'id': id});\n }\n delete PyViz.plot_index[id];\n if ((window.Bokeh !== undefined) & (id in window.Bokeh.index)) {\n var doc = window.Bokeh.index[id].model.document\n doc.clear();\n const i = window.Bokeh.documents.indexOf(doc);\n if (i > -1) {\n window.Bokeh.documents.splice(i, 1);\n }\n }\n}\n\n/**\n * Handle kernel restart event\n */\nfunction handle_kernel_cleanup(event, handle) {\n delete PyViz.comms[\"hv-extension-comm\"];\n window.PyViz.plot_index = {}\n}\n\n/**\n * Handle update_display_data messages\n */\nfunction handle_update_output(event, handle) {\n handle_clear_output(event, {cell: {output_area: handle.output_area}})\n handle_add_output(event, handle)\n}\n\nfunction register_renderer(events, OutputArea) {\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n var toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[0]);\n element.append(toinsert);\n return toinsert\n }\n\n events.on('output_added.OutputArea', handle_add_output);\n events.on('output_updated.OutputArea', handle_update_output);\n events.on('clear_output.CodeCell', handle_clear_output);\n events.on('delete.Cell', handle_clear_output);\n events.on('kernel_ready.Kernel', handle_kernel_cleanup);\n\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n safe: true,\n index: 0\n });\n}\n\nif (window.Jupyter !== undefined) {\n try {\n var events = require('base/js/events');\n var OutputArea = require('notebook/js/outputarea').OutputArea;\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n } catch(err) {\n }\n}\n" + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.holoviews_exec.v0+json": "", + "text/html": [ + "
\n", + "
\n", + "
\n", + "" + ] + }, + "metadata": { + "application/vnd.holoviews_exec.v0+json": { + "id": "p1002" + } + }, + "output_type": "display_data" + } + ], + "source": [ + "import sys\n", + "\n", + "sys.path.insert(0, \"../src\")\n", + "\n", + "from coastmonitor.io.drive_config import configure_instance\n", + "\n", + "configure_instance(branch=\"dev\")\n", + "import dask\n", + "\n", + "dask.config.set({\"datatframe.query-planning\": False})\n", + "import logging\n", + "import os\n", + "import pathlib\n", + "\n", + "import duckdb\n", + "import geopandas as gpd\n", + "import hvplot.pandas\n", + "import pandas as pd\n", + "import pystac\n", + "from dotenv import load_dotenv\n", + "\n", + "from coastmonitor.io.utils import read_items_extent\n", + "from coastmonitor.query_engine import HREFQueryEngine, STACQueryEngine\n", + "\n", + "load_dotenv(override=True)\n", + "\n", + "# NOTE: access tokens to the data are available upon request.\n", + "sas_token = os.getenv(\"AZURE_STORAGE_SAS_TOKEN\")\n", + "account_name = os.getenv(\"AZURE_STORAGE_ACCOUNT_NAME\")\n", + "storage_options = {\"account_name\": account_name, \"credential\": sas_token}\n", + "\n", + "# These are the URL's to the STAC catalog that we can use to efficiently index the data\n", + "COCLICO_STAC_URL = \"https://coclico.blob.core.windows.net/stac/v1/catalog.json\"\n", + "\n", + "# Global Coastal Transect System (publicly available and in review)\n", + "GCTS_COLLECTION_NAME = \"gcts\"\n", + "\n", + "# Global Coastal Transect Repository (unreleased; access keys provided upon request). This dataset consists\n", + "# of GCTS + several other characteristics, such as intersection distance to nearest coastline.\n", + "GCTR_COLLECTION_NAME = \"gctr\"\n", + "\n", + "# ShorelineMonitor Raw Series (unreleased; access keys provided upon request). This dataset consists\n", + "# ShorelineMonitor Shorlines that are mapped onto the Global Coastal Transect System (Raw Series) that\n", + "# have a wide range of additional statistics used to filter out the primary, high-quality observations.\n", + "SM_COLLECTION_NAME = \"shorelinemonitor-raw-series\"" + ] + }, + { + "cell_type": "markdown", + "id": "69a12c6f-52ba-45b6-a285-65d5ac478a89", + "metadata": {}, + "source": [ + "## Read the STAC collections" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "eee2b814-a52d-4064-b393-83b4b6268498", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-11T06:28:41.841222Z", + "iopub.status.busy": "2024-06-11T06:28:41.841039Z", + "iopub.status.idle": "2024-06-11T06:28:42.558456Z", + "shell.execute_reply": "2024-06-11T06:28:42.558156Z", + "shell.execute_reply.started": "2024-06-11T06:28:41.841208Z" + } + }, + "outputs": [], + "source": [ + "coclico_catalog = pystac.Catalog.from_file(COCLICO_STAC_URL)\n", + "sm_collection = coclico_catalog.get_child(SM_COLLECTION_NAME)\n", + "gcts_collection = coclico_catalog.get_child(GCTS_COLLECTION_NAME)" + ] + }, + { + "cell_type": "markdown", + "id": "c9c7c92b-5a0e-42d9-be62-e4328fc82585", + "metadata": {}, + "source": [ + "## Show the spatial extents of both collections" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "3e484dd4-a314-4687-8cea-fb1be5f6b306", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-11T06:28:43.489729Z", + "iopub.status.busy": "2024-06-11T06:28:43.489532Z", + "iopub.status.idle": "2024-06-11T06:28:51.287365Z", + "shell.execute_reply": "2024-06-11T06:28:51.287100Z", + "shell.execute_reply.started": "2024-06-11T06:28:43.489714Z" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Make this Notebook Trusted to load map: File -> Trust Notebook
" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sm_extents = read_items_extent(sm_collection)\n", + "gcts_extents = read_items_extent(gcts_collection)\n", + "sm_extents[[\"geometry\"]].explore()" + ] + }, + { + "cell_type": "markdown", + "id": "16022dd4-323b-46af-8acd-64f0860edaed", + "metadata": {}, + "source": [ + "## Create a interactive map that we use to define our region of interest" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "9c82a2e7-a7ca-4e93-ade6-371213d2619e", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-11T06:28:58.837367Z", + "iopub.status.busy": "2024-06-11T06:28:58.836942Z", + "iopub.status.idle": "2024-06-11T06:28:58.859106Z", + "shell.execute_reply": "2024-06-11T06:28:58.858601Z", + "shell.execute_reply.started": "2024-06-11T06:28:58.837353Z" + } + }, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "9bae9ca04bac4b7691ae67828c58f115", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Map(center=[53.4, 5.4], controls=(ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_title', 'zoom_out_…" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from ipyleaflet import Map, basemaps\n", + "\n", + "m = Map(basemap=basemaps.Esri.WorldImagery, scroll_wheel_zoom=True)\n", + "m.center = 53.4, 5.4\n", + "m.zoom = 11\n", + "m.layout.height = \"800px\"\n", + "m" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "b727f162-4437-44a3-ba4f-1ff102bf3359", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-11T06:29:18.725728Z", + "iopub.status.busy": "2024-06-11T06:29:18.725544Z", + "iopub.status.idle": "2024-06-11T06:29:18.727927Z", + "shell.execute_reply": "2024-06-11T06:29:18.727540Z", + "shell.execute_reply.started": "2024-06-11T06:29:18.725711Z" + } + }, + "outputs": [], + "source": [ + "# NOTE: these coordiantes are extracted from the interactive map above\n", + "minx, miny, maxx, maxy = m.west, m.south, m.east, m.north" + ] + }, + { + "cell_type": "markdown", + "id": "7c029f3b-a8db-474c-a743-606d27ea5de6", + "metadata": {}, + "source": [ + "## Create a DuckDB query engine to retrieve data from cloud storage" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "995919d2-069a-4993-a815-4651f8056a5e", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-11T06:29:19.790210Z", + "iopub.status.busy": "2024-06-11T06:29:19.790055Z", + "iopub.status.idle": "2024-06-11T06:29:20.458346Z", + "shell.execute_reply": "2024-06-11T06:29:20.458067Z", + "shell.execute_reply.started": "2024-06-11T06:29:19.790200Z" + } + }, + "outputs": [], + "source": [ + "shoreline_engine = STACQueryEngine(\n", + " stac_collection=sm_collection,\n", + " storage_backend=\"azure\",\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "1debe7c8-bf96-4c41-8eda-67bf7f8d2bba", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-11T06:29:22.073350Z", + "iopub.status.busy": "2024-06-11T06:29:22.073120Z", + "iopub.status.idle": "2024-06-11T06:30:15.519335Z", + "shell.execute_reply": "2024-06-11T06:30:15.519032Z", + "shell.execute_reply.started": "2024-06-11T06:29:22.073330Z" + } + }, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "782d115c92c44d789fc5e94f513bba1e", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "FloatProgress(value=0.0, layout=Layout(width='auto'), style=ProgressStyle(bar_color='black'))" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "shorelines = shoreline_engine.get_data_within_bbox(minx, miny, maxx, maxy)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "888b5e5e-0a6c-474c-92dd-bc4a0b3504f2", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-11T06:30:28.684998Z", + "iopub.status.busy": "2024-06-11T06:30:28.684825Z", + "iopub.status.idle": "2024-06-11T06:31:51.602695Z", + "shell.execute_reply": "2024-06-11T06:31:51.602083Z", + "shell.execute_reply.started": "2024-06-11T06:30:28.684987Z" + } + }, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "6af497aa908d484b8c9fbf1c1c0a67af", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "FloatProgress(value=0.0, layout=Layout(width='auto'), style=ProgressStyle(bar_color='black'))" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "transects_engine = STACQueryEngine(\n", + " stac_collection=gcts_collection, storage_backend=\"azure\"\n", + ")\n", + "transects = transects_engine.get_data_within_bbox(minx, miny, maxx, maxy)" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "id": "3315e30d-a656-46f4-9eb6-495fb83a3000", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-11T09:32:58.085102Z", + "iopub.status.busy": "2024-06-11T09:32:58.084198Z", + "iopub.status.idle": "2024-06-11T09:32:58.170311Z", + "shell.execute_reply": "2024-06-11T09:32:58.169992Z", + "shell.execute_reply.started": "2024-06-11T09:32:58.085046Z" + } + }, + "outputs": [], + "source": [ + "s = shorelines.loc[shorelines[\"shoreline_position\"].isna()].copy()\n", + "s = shorelines.copy()\n", + "last_obs = (\n", + " s.sort_values(by=[\"time\"])\n", + " .groupby(\"tr_name\")[\"shoreline_chainage\"]\n", + " .last()\n", + " .rename(\"last_obs\")\n", + ")\n", + "s = s.merge(last_obs, on=\"tr_name\", how=\"left\")\n", + "s[\"shoreline_position\"] = s[\"shoreline_chainage\"] - s[\"last_obs\"]\n", + "# s[\"shoreline_position\"] = s[\"shoreline_chainage\"] - s[\"last_obs\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "id": "aef25d17-96b6-4d35-90a1-9307fd7e6741", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-11T09:35:31.057468Z", + "iopub.status.busy": "2024-06-11T09:35:31.057284Z", + "iopub.status.idle": "2024-06-11T09:35:31.061373Z", + "shell.execute_reply": "2024-06-11T09:35:31.060952Z", + "shell.execute_reply.started": "2024-06-11T09:35:31.057453Z" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "16829" + ] + }, + "execution_count": 54, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(~shorelines.obs_is_primary).sum()" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "id": "9729b9f8-e1a2-4759-9a59-d1c587fadb4c", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-11T09:34:39.236328Z", + "iopub.status.busy": "2024-06-11T09:34:39.235501Z", + "iopub.status.idle": "2024-06-11T09:34:39.252230Z", + "shell.execute_reply": "2024-06-11T09:34:39.251612Z", + "shell.execute_reply.started": "2024-06-11T09:34:39.236296Z" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "16829" + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(~shorelines.loc[shorelines[\"shoreline_position\"].isna()].obs_is_primary).sum()" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "id": "27e42d8e-ed4e-4b70-9fdd-6ec88f0dc401", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-11T09:30:40.859669Z", + "iopub.status.busy": "2024-06-11T09:30:40.858951Z", + "iopub.status.idle": "2024-06-11T09:30:40.883192Z", + "shell.execute_reply": "2024-06-11T09:30:40.882754Z", + "shell.execute_reply.started": "2024-06-11T09:30:40.859413Z" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "1999.7294" + ] + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "s[\"last_obs\"].max(" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "id": "a8dec00a-0866-4288-92d9-5327238b6f20", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-11T09:30:13.599719Z", + "iopub.status.busy": "2024-06-11T09:30:13.599065Z", + "iopub.status.idle": "2024-06-11T09:30:13.619193Z", + "shell.execute_reply": "2024-06-11T09:30:13.618522Z", + "shell.execute_reply.started": "2024-06-11T09:30:13.599689Z" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "-1917.6342" + ] + }, + "execution_count": 43, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "s[\"shoreline_position\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "729b0334-0863-47e0-91aa-8d098cd951b0", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-11T09:26:46.180286Z", + "iopub.status.busy": "2024-06-11T09:26:46.180053Z", + "iopub.status.idle": "2024-06-11T09:26:46.184971Z", + "shell.execute_reply": "2024-06-11T09:26:46.184407Z", + "shell.execute_reply.started": "2024-06-11T09:26:46.180269Z" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "tr_name\n", + "cl32202s00tr00040733 1965.734497\n", + "cl32202s00tr00040833 1893.284058\n", + "cl32202s00tr00040933 1904.746704\n", + "cl32202s00tr00041033 1989.813477\n", + "cl32202s00tr00041133 1949.802490\n", + " ... \n", + "cl32202s00tr00354033 1193.104248\n", + "cl32202s00tr00354133 1241.480835\n", + "cl32202s00tr00354233 1234.818115\n", + "cl32202s00tr00354333 1161.321533\n", + "cl32202s00tr00354833 1146.246948\n", + "Name: last_obs, Length: 1332, dtype: float32" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "last_obs" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5f18ee1d-51b1-4885-bc93-f809e3a2cbbe", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "a9b8021a-f24e-4eff-a4aa-75bee96f7622", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-11T09:13:43.523443Z", + "iopub.status.busy": "2024-06-11T09:13:43.522999Z", + "iopub.status.idle": "2024-06-11T09:13:43.585539Z", + "shell.execute_reply": "2024-06-11T09:13:43.585208Z", + "shell.execute_reply.started": "2024-06-11T09:13:43.523420Z" + } + }, + "outputs": [], + "source": [ + "from typing import List, Tuple\n", + "\n", + "import pandas as pd\n", + "from pandas import DataFrame\n", + "\n", + "\n", + "def flag_obs_ht_max_step_change(\n", + " df: DataFrame,\n", + " max_step_change: float = 50,\n", + " max_n_step_changes: int = 4,\n", + " max_year_interval: int = 10,\n", + ") -> DataFrame:\n", + " \"\"\"\n", + " Detects significant step changes in shoreline positions across different transects within a DataFrame.\n", + " A step change is identified based on the difference between consecutive measurements exceeding a specified threshold.\n", + "\n", + " The function also flags entire transects as 'unsteady' if the number of step changes exceeds a certain threshold.\n", + "\n", + " Args:\n", + " df (DataFrame): A pandas DataFrame containing shoreline position data. The DataFrame must include\n", + " the columns 'time', 'tr_name', 'shoreline_position', and 'geometry'.\n", + " max_step_change (float): Threshold for detecting significant step changes. Default is 50.\n", + " max_n_step_changes (int): Maximum number of step changes allowed per transect before flagging as 'unsteady'. Default is 4.\n", + " max_year_interval (int): Maximum year difference for considering a step change significant. Default is 10.\n", + "\n", + " Returns:\n", + " DataFrame: A modified copy of the input DataFrame with additional columns indicating detected\n", + " step changes ('obs_ht_max_step_change') and unsteady transects ('tr_is_unsteady').\n", + " \"\"\"\n", + " # Copy relevant columns\n", + " df = df[[\"time\", \"tr_name\", \"shoreline_position\", \"geometry\"]].copy()\n", + "\n", + " # Calculate differences and year shifts\n", + " df[\"backward_diff\"] = df.groupby(\"tr_name\")[\"shoreline_position\"].diff()\n", + " df[\"forward_diff\"] = df[\"backward_diff\"].shift(-1)\n", + " df[\"year\"] = df[\"time\"].dt.year\n", + " df[\"dt_backward\"] = df.groupby(\"tr_name\")[\"year\"].diff()\n", + " df[\"dt_forward\"] = df[\"dt_backward\"].shift(-1)\n", + "\n", + " # Detect step changes in the middle of the time series\n", + " df[\"mid_step_change\"] = (\n", + " (df[\"backward_diff\"].abs() > max_step_change)\n", + " & (df[\"forward_diff\"].abs() > max_step_change)\n", + " & (df[\"backward_diff\"] * df[\"forward_diff\"] < 0)\n", + " & (df[\"dt_backward\"] < max_year_interval)\n", + " & (df[\"dt_forward\"] < max_year_interval)\n", + " )\n", + "\n", + " # Group by the observations per transect\n", + " g = df.groupby(\"tr_name\")[[\"tr_name\", \"backward_diff\", \"forward_diff\"]]\n", + "\n", + " # Get the first observation\n", + " first = g.nth(0).reset_index(drop=False).set_index(\"tr_name\")\n", + " # First observation is a step change if the first difference exceeds max_step_change and is followed by a small difference\n", + " first[\"first_step_change\"] = (first[\"forward_diff\"].abs() > max_step_change) & (\n", + " g.nth(1).set_index(\"tr_name\")[\"forward_diff\"] < max_step_change\n", + " )\n", + " # Merge the flag to the primary DataFrame\n", + " df[\"first_step_change\"] = first.set_index(\"index\")[\"first_step_change\"]\n", + "\n", + " # Get the last observation\n", + " last = g.tail(1).reset_index(drop=False).set_index(\"tr_name\")\n", + " return last\n", + " # Last observation is a step change if the last difference exceeds max_step_change and is preceded by a small difference\n", + " last[\"last_step_change\"] = (last[\"backward_diff\"].abs() > max_step_change) & (\n", + " g.tail(2).iloc[::2].set_index(\"tr_name\")[\"backward_diff\"].abs()\n", + " < max_step_change\n", + " )\n", + " # Merge the flag to the primary DataFrame\n", + " df[\"last_step_change\"] = last.set_index(\"index\")[\"last_step_change\"]\n", + "\n", + " # Combine mid, first, and last step change flags\n", + " df[\"obs_ht_max_step_change\"] = (\n", + " df[\"mid_step_change\"] | df[\"first_step_change\"] | df[\"last_step_change\"]\n", + " )\n", + "\n", + " # Drop intermediate columns\n", + " df = df.drop(\n", + " columns=[\n", + " \"backward_diff\",\n", + " \"forward_diff\",\n", + " \"mid_step_change\",\n", + " \"first_step_change\",\n", + " \"last_step_change\",\n", + " \"dt_backward\",\n", + " \"dt_forward\",\n", + " \"year\",\n", + " ]\n", + " )\n", + "\n", + " # Count the number of step changes per transect\n", + " tr_step_change = df.groupby(\"tr_name\")[\"obs_ht_max_step_change\"].sum().reset_index()\n", + " \"obs_ht_max_step_change\"\n", + "\n", + " # Flag transects that have step changes exceeding the allowed number of step changes\n", + " tr_step_change[\"tr_is_unsteady\"] = (\n", + " tr_step_change[\"obs_ht_max_step_change\"] >= max_n_step_changes\n", + " )\n", + "\n", + " # Merge \"tr_is_unsteady\" to the DataFrame\n", + " df = df.merge(tr_step_change[[\"tr_name\", \"tr_is_unsteady\"]], on=\"tr_name\")\n", + "\n", + " return df\n", + "\n", + "\n", + "def clean_raw_shorelinemonitor_series(\n", + " df: DataFrame,\n", + " columns: List[str] = [\"time\", \"tr_name\", \"shoreline_position\", \"geometry\"],\n", + " sinuosity_threshold: float = 10,\n", + " mdn_offset_multiplier: float = 3,\n", + " min_obs_count: int = 5,\n", + " max_step_change: float = 50,\n", + " max_n_step_changes: int = 4,\n", + " max_year_interval: int = 10,\n", + ") -> DataFrame:\n", + " \"\"\"\n", + " Cleans and filters shoreline position data based on specified criteria.\n", + "\n", + " Args:\n", + " df (DataFrame): Raw shoreline position data with required columns:\n", + " 'shoreline_sinuosity', 'is_shoal', 'obs_is_primary',\n", + " 'tr_is_qa', 'mdn_offset', 'tr_stdev', 'obs_is_outlier',\n", + " 'obs_count', 'time', 'tr_name', 'shoreline_position', 'geometry'.\n", + " columns (List[str]): List of columns to include in the cleaned DataFrame. Default is [\"time\", \"tr_name\", \"shoreline_position\", \"geometry\"].\n", + " sinuosity_threshold (float): Threshold for sinuosity. Default is 10.\n", + " mdn_offset_multiplier (float): Multiplier for the standard deviation to filter based on median offset. Default is 3.\n", + " min_obs_count (int): Minimum observation count per transect. Default is 5.\n", + " max_step_change (float): Threshold for detecting significant step changes. Default is 50.\n", + " max_n_step_changes (int): Maximum number of step changes allowed per transect before flagging as 'unsteady'. Default is 4.\n", + " max_year_interval (int): Maximum year difference for considering a step change significant. Default is 10.\n", + "\n", + " Returns:\n", + " DataFrame: Cleaned shoreline positions with selected columns and recalculated observation count per transect.\n", + " \"\"\"\n", + " # Filtering criteria for clean shoreline positions\n", + " df = df[\n", + " (df[\"shoreline_sinuosity\"] < sinuosity_threshold)\n", + " & (~df[\"is_shoal\"])\n", + " & (df[\"obs_is_primary\"])\n", + " & (df[\"tr_is_qa\"])\n", + " & (df[\"mdn_offset\"] < mdn_offset_multiplier * df[\"tr_stdev\"])\n", + " & (df[\"obs_count\"] >= min_obs_count)\n", + " & (df[\"obs_is_outlier\"] != 1)\n", + " ].copy()\n", + "\n", + " # Detect and flag step changes\n", + " df = flag_obs_ht_max_step_change(\n", + " df,\n", + " max_step_change=max_step_change,\n", + " max_n_step_changes=max_n_step_changes,\n", + " max_year_interval=max_year_interval,\n", + " )\n", + "\n", + " return df\n", + "\n", + " # # DEBUG\n", + " # df = df.loc[(~df[\"tr_is_unsteady\"]) & (~df[\"obs_ht_max_step_change\"])]\n", + "\n", + " # # Count the clean observations on each transect\n", + " # obs_count = (\n", + " # df.groupby(\"tr_name\")[\"shoreline_position\"]\n", + " # .count()\n", + " # .rename(\"obs_count\")\n", + " # .reset_index()\n", + " # )\n", + " # df = df.merge(obs_count, on=\"tr_name\")\n", + "\n", + " # # # Organize the clean shoreline position DataFrame\n", + " # # df = (\n", + " # # df.rename(columns={\"shoreline_position\": \"shoreline_position\"})\n", + " # # .reset_index(drop=True)\n", + " # # )\n", + "\n", + " # return df[columns]\n", + "\n", + "\n", + "df_clean = clean_raw_shorelinemonitor_series(\n", + " shorelines,\n", + " columns=[\"time\", \"tr_name\", \"shoreline_position\", \"geometry\", \"obs_count\"],\n", + " sinuosity_threshold=10,\n", + " mdn_offset_multiplier=3,\n", + " min_obs_count=5,\n", + " max_step_change=50,\n", + " max_n_step_changes=4,\n", + " max_year_interval=10,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "6e327c60-e650-45ca-997d-b60a903c8a22", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-11T09:13:48.373503Z", + "iopub.status.busy": "2024-06-11T09:13:48.369714Z", + "iopub.status.idle": "2024-06-11T09:13:48.392147Z", + "shell.execute_reply": "2024-06-11T09:13:48.391552Z", + "shell.execute_reply.started": "2024-06-11T09:13:48.373340Z" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
indexbackward_diffforward_diff
tr_name
cl32202s00tr0004093313NaNNaN
cl32202s00tr0004103318NaNNaN
cl32202s00tr0004113328-275.721924NaN
cl32202s00tr0004123348-8.287720NaN
cl32202s00tr0004133379-8.977295NaN
............
cl32202s00tr00354433110095-20.047974NaN
cl32202s00tr00354533110117-13.715820NaN
cl32202s00tr00354633110137-13.153931NaN
cl32202s00tr00354733110157-7.036743NaN
cl32202s00tr00354833110179-7.485718NaN
\n", + "

2894 rows × 3 columns

\n", + "
" + ], + "text/plain": [ + " index backward_diff forward_diff\n", + "tr_name \n", + "cl32202s00tr00040933 13 NaN NaN\n", + "cl32202s00tr00041033 18 NaN NaN\n", + "cl32202s00tr00041133 28 -275.721924 NaN\n", + "cl32202s00tr00041233 48 -8.287720 NaN\n", + "cl32202s00tr00041333 79 -8.977295 NaN\n", + "... ... ... ...\n", + "cl32202s00tr00354433 110095 -20.047974 NaN\n", + "cl32202s00tr00354533 110117 -13.715820 NaN\n", + "cl32202s00tr00354633 110137 -13.153931 NaN\n", + "cl32202s00tr00354733 110157 -7.036743 NaN\n", + "cl32202s00tr00354833 110179 -7.485718 NaN\n", + "\n", + "[2894 rows x 3 columns]" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_clean" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "63ef5a34-735f-4211-b153-3d665a059648", + "metadata": { + "execution": { + "iopub.status.busy": "2024-06-11T06:31:52.281618Z", + "iopub.status.idle": "2024-06-11T06:31:52.281746Z", + "shell.execute_reply": "2024-06-11T06:31:52.281686Z", + "shell.execute_reply.started": "2024-06-11T06:31:52.281680Z" + } + }, + "outputs": [], + "source": [ + "import numpy as np\n", + "from scipy import linalg, signal\n", + "from tqdm import tqdm\n", + "\n", + "\n", + "def ols_AC(group):\n", + " \"\"\"\n", + " Performs ordinary least squares (OLS) regression to find the slope and intercept\n", + " of shoreline positions as a function of time for a given group of data.\n", + "\n", + " Parameters:\n", + " group (DataFrame): A pandas DataFrame containing the columns 'shoreline_position' and 'time',\n", + " where 'time' is a datetime object.\n", + "\n", + " Returns:\n", + " tuple:\n", + " - A tuple containing the intercept and slope of the regression line (p),\n", + " - The sum of the squared residuals of the regression (res).\n", + "\n", + " Notes:\n", + " The design matrix is constructed with a constant term and a linear term for the year extracted\n", + " from the 'time' datetime object.\n", + " \"\"\"\n", + " y = group.shoreline_position.values\n", + " x = group.time.dt.year.values # - 1984)\n", + "\n", + " # create design matrix\n", + " M = x[:, np.newaxis] ** [0, 1]\n", + "\n", + " # calculate least square solution\n", + " p, res, _, _ = linalg.lstsq(M, y)\n", + "\n", + " return p, res\n", + "\n", + "\n", + "def all_AC(shoreline_positions):\n", + " \"\"\"\n", + " Applies OLS regression across groups of shoreline position data, each group identified by 'tr_name',\n", + " and aggregates the results into a DataFrame.\n", + "\n", + " This function iterates over each transect name group, performs OLS regression if the group has more than\n", + " two data points, and collects the regression coefficients and residuals.\n", + "\n", + " Parameters:\n", + " shoreline_positions (DataFrame): A pandas DataFrame containing 'shoreline_position', 'time', and 'tr_name',\n", + " where 'time' must be a datetime object and 'tr_name' is the identifier\n", + " for each group.\n", + "\n", + " Returns:\n", + " DataFrame: A DataFrame with columns 'tr_name' for the transect names, 'intercept' and 'rate' for the\n", + " OLS regression coefficients, and 'residues' for the sum of squared residuals of each regression.\n", + " \"\"\"\n", + " names = []\n", + " intercepts = []\n", + " slopes = []\n", + " residues = []\n", + "\n", + " for name, group in tqdm(\n", + " shoreline_positions.groupby(\"tr_name\"),\n", + " total=shoreline_positions.tr_name.unique().size,\n", + " ):\n", + " # for name, group in shoreline_positions.groupby(\"tr_name\"):\n", + " if group.obs_count.iloc[0] > 5:\n", + " p, res = ols_AC(group)\n", + "\n", + " names.append(name)\n", + " intercepts.append(p[0])\n", + " slopes.append(p[1])\n", + " residues.append(res)\n", + "\n", + " ols_ = pd.DataFrame(\n", + " {\n", + " \"tr_name\": names,\n", + " \"intercept\": intercepts,\n", + " \"rate\": slopes,\n", + " \"residues\": residues,\n", + " }\n", + " )\n", + "\n", + " return ols_\n", + "\n", + "\n", + "ambient_change = all_AC(df_clean)\n", + "ambient_change = ambient_change.merge(\n", + " transects[[\"tr_name\", \"geometry\"]],\n", + " on=\"tr_name\",\n", + " how=\"left\",\n", + ")\n", + "ambient_change = gpd.GeoDataFrame(ambient_change, crs=4326)[\n", + " [\"rate\", \"geometry\", \"tr_name\"]\n", + "]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "50767b50-74f1-4a63-8f5e-e672d56b653b", + "metadata": {}, + "outputs": [], + "source": [ + "plot = ambient_change.hvplot(\n", + " kind=\"line\",\n", + " # x=\"alongshore_dist_km\",\n", + " y=[\"rate\"],\n", + " # groupby=[\"coastline\"],\n", + " xlabel=\"Alongshore Distance [km]\",\n", + " color=\"blue\",\n", + " alpha=0.2,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fabb94ac-a59a-47a4-946a-fc54da8f8b08", + "metadata": {}, + "outputs": [], + "source": [ + "import colorcet as cc\n", + "import holoviews as hv\n", + "\n", + "hv.extension(\"bokeh\")\n", + "\n", + "ambient_change.hvplot(\n", + " geo=True,\n", + " tiles=\"ESRI\",\n", + " color=\"rate\",\n", + " line_width=3,\n", + " title=\"Transects Colored by Rate\",\n", + " width=800,\n", + " colorbar=True,\n", + " cnorm=\"linear\",\n", + " cmap=cc.CET_D3[::-1],\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "761c9852-1806-4046-a210-6b67bef35c92", + "metadata": {}, + "outputs": [], + "source": [ + "{}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d75d72a4-bff6-4834-b2a4-31d0132bc674", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ccd3cf1f-2522-46ac-a1bf-1be240d7c81d", + "metadata": {}, + "outputs": [], + "source": [ + "gpd.GeoSeries.from_xy()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python [conda env:coastal] *", + "language": "python", + "name": "conda-env-coastal-py" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/notebooks/boxes.ipynb b/notebooks/boxes.ipynb deleted file mode 100644 index 68c4d2d..0000000 --- a/notebooks/boxes.ipynb +++ /dev/null @@ -1,89 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "id": "7fd0662f-d6ca-4fd2-97fe-3806ff4f90e9", - "metadata": {}, - "source": [ - "# Global box system\n", - "\n", - "Create global box system following OSM slippy map tile definition. The box system can be used to run geospatial computations in parallel" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "f151b6d8-923d-4849-a76e-cadf45c61fac", - "metadata": {}, - "outputs": [], - "source": [ - "import os\n", - "import pathlib\n", - "import sys\n", - "\n", - "# make coclico library importable by appending src from project root to path\n", - "cwd = pathlib.Path().resolve()\n", - "sys.path.append(os.path.join(os.path.dirname(cwd), \"src\"))" - ] - }, - { - "cell_type": "markdown", - "id": "a8607aa6-3135-406d-8727-6cdf2ba3b3c0", - "metadata": {}, - "source": [ - "## Generate a global box system \n", - "\n", - "This is just to demonstrate that by appending the ./src directory to path, we can now import \"source code\" from the coclico library. \n", - "\n", - "This global box system was taken from https://github.com/floriscalkoen/coastpy and is generated according to the OpenStreetMap slippy tilenames. These box systems are useful when the workload is spatially partitioned. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "a31255bb-ea02-4c99-bd23-b8e8dc72f321", - "metadata": {}, - "outputs": [], - "source": [ - "# this is just to demostrate that we can import coclico \"source code\"\n", - "from coclico.utils.boxes import make_boxes\n", - "\n", - "# global box system\n", - "boxes = make_boxes(zoom_level=7, output_crs=\"EPSG:4326\")\n", - "print(boxes.shape)\n", - "# natural earth low resolution to get approximately all European boxes (except Russia)\n", - "world = gpd.read_file(gpd.datasets.get_path(\"naturalearth_lowres\"))\n", - "eu = world.loc[(world[\"continent\"] == \"Europe\") & (world[\"name\"] != \"Russia\")]\n", - "boxes = gpd.sjoin(boxes, eu)[boxes.columns]\n", - "print(boxes.shape)\n", - "boxes.explore()" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.6" - }, - "vscode": { - "interpreter": { - "hash": "c0ebfe0da1198dfcf84fb64f221c7b7e35641f7728e9dc12fbc80e97aca2df12" - } - } - }, - "nbformat": 4, - "nbformat_minor": 5 -}