{ "metadata": { "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.7.6-final" }, "orig_nbformat": 2, "kernelspec": { "name": "python3", "display_name": "Python 3.7.6 64-bit (conda)", "metadata": { "interpreter": { "hash": "af5367a4e8a2ca361a3c88b0377b2a3996ab6bf2607e8877f415f397c628cd17" } } } }, "nbformat": 4, "nbformat_minor": 2, "cells": [ { "source": [ "# Download additional (large) test data\n", "\n", "Download additional large test data from public sources to '../data'.\n", "\n", "Data is used for performance testing and some of the notebooks.\n", "\n" ], "cell_type": "markdown", "metadata": {} }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# make data dir (already in .gitignore)\n", "import os\n", "data_dir = \"../data\"\n", "if not os.path.exists(data_dir):\n", " os.makedirs(data_dir)" ] }, { "source": [ "File download from url to filename" ], "cell_type": "markdown", "metadata": {} }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from tqdm.notebook import tqdm\n", "import requests\n", "\n", "def file_download(url,filename):\n", " print(f\"Download {url} \\nto {filename}\")\n", " r = requests.get(url, stream=True)\n", " size = int(r.headers.get('content-length', 0))\n", " if os.path.exists(filename):\n", " if size == os.path.getsize(filename):\n", " print(\"Local file already exists, skip download.\")\n", " return\n", " pbar = tqdm(total=size, unit='iB', unit_scale=True) \n", " with open(filename, 'wb') as file:\n", " for chunk in r.iter_content(1024*1024*2): # To-Do: best choice for chunk size?\n", " pbar.update(len(chunk))\n", " file.write(chunk)\n", " pbar.close()" ] }, { "source": [ "## Altimetry test data from DHI blob storage" ], "cell_type": "markdown", "metadata": {} }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Download https://automodelstorage.blob.core.windows.net/globalaltimetry/altimetry_3a_2018_filter1.dfs0 \n", "to ../data/altimetry_3a_2018_filter1.dfs0\n", "Local file already exists, skip download.\n", "Download https://automodelstorage.blob.core.windows.net/globalaltimetry/SW_gwm_3a_extracted_2018.dfs0 \n", "to ../data/SW_gwm_3a_extracted_2018.dfs0\n", "Local file already exists, skip download.\n", "Download https://automodelstorage.blob.core.windows.net/globalaltimetry/SW_gwm_domain_Hm0_201801.dfsu \n", "to ../data/SW_gwm_domain_Hm0_201801.dfsu\n" ] }, { "output_type": "display_data", "data": { "text/plain": "HBox(children=(FloatProgress(value=0.0, max=1580035484.0), HTML(value='')))", "application/vnd.jupyter.widget-view+json": { "version_major": 2, "version_minor": 0, "model_id": "413bb08e251640068b6e4a3f6a523d83" } }, "metadata": {} }, { "output_type": "stream", "name": "stdout", "text": [ "\n" ] } ], "source": [ "filenames = [\"altimetry_3a_2018_filter1.dfs0\",\n", " \"SW_gwm_3a_extracted_2018.dfs0\",\n", " \"SW_gwm_domain_Hm0_201801.dfsu\"]\n", "for fn in filenames:\n", " url = f\"https://automodelstorage.blob.core.windows.net/globalaltimetry/{fn}\"\n", " fn_target = f\"{data_dir}/{fn}\"\n", " file_download(url,fn_target)" ] }, { "source": [ "## NDBC buoy data" ], "cell_type": "markdown", "metadata": {} }, { "source": [ "## CFSR ..." ], "cell_type": "markdown", "metadata": {} } ] }