{ "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.8.5" }, "orig_nbformat": 2, "kernelspec": { "name": "python385jvsc74a57bd0af5367a4e8a2ca361a3c88b0377b2a3996ab6bf2607e8877f415f397c628cd17", "display_name": "Python 3.8.5 64-bit ('base': conda)" } }, "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", "Local file already exists, skip download.\n", "Download https://automodelstorage.blob.core.windows.net/globalaltimetry/ERA5_waves_102017.nc \n", "to ../data/ERA5_waves_102017.nc\n", "Local file already exists, skip download.\n", "Download https://automodelstorage.blob.core.windows.net/globalaltimetry/NWW3_hs_201710.grib \n", "to ../data/NWW3_hs_201710.grib\n", "Local file already exists, skip download.\n", "Download https://automodelstorage.blob.core.windows.net/globalaltimetry/NWW3_pwd_201710.grib \n", "to ../data/NWW3_pwd_201710.grib\n", "Local file already exists, skip download.\n", "Download https://automodelstorage.blob.core.windows.net/globalaltimetry/NWW3_tp_201710.grib \n", "to ../data/NWW3_tp_201710.grib\n", "Local file already exists, skip download.\n", "Download https://automodelstorage.blob.core.windows.net/globalaltimetry/NWW3_wind10m_201710.grib \n", "to ../data/NWW3_wind10m_201710.grib\n", "Local file already exists, skip download.\n", "Download https://automodelstorage.blob.core.windows.net/globalaltimetry/\\WAVERYS_20171027_R20171027.nc \n", "to ../data/\\WAVERYS_20171027_R20171027.nc\n" ] }, { "output_type": "display_data", "data": { "text/plain": "HBox(children=(HTML(value=''), FloatProgress(value=0.0, max=215.0), HTML(value='')))", "application/vnd.jupyter.widget-view+json": { "version_major": 2, "version_minor": 0, "model_id": "d3b9206540dc436ca4d4045adc849675" } }, "metadata": {} }, { "output_type": "stream", "name": "stdout", "text": [ "\n", "Download https://automodelstorage.blob.core.windows.net/globalaltimetry/WAVERYS_20171028_R20171028.nc \n", "to ../data/WAVERYS_20171028_R20171028.nc\n", "Local file already exists, skip download.\n", "Download https://automodelstorage.blob.core.windows.net/globalaltimetry/WAVERYS_20171029_R20171029.nc \n", "to ../data/WAVERYS_20171029_R20171029.nc\n", "Local file already exists, skip download.\n" ] } ], "source": [ "filenames = [\"altimetry_3a_2018_filter1.dfs0\",\n", " \"SW_gwm_3a_extracted_2018.dfs0\",\n", " \"SW_gwm_domain_Hm0_201801.dfsu\",\n", " \"ERA5_waves_102017.nc\",\n", " \"NWW3_hs_201710.grib\",\n", " \"NWW3_pwd_201710.grib\",\n", " \"NWW3_tp_201710.grib\",\n", " \"NWW3_wind10m_201710.grib\",\n", " \"\\WAVERYS_20171027_R20171027.nc\",\n", " \"WAVERYS_20171028_R20171028.nc\",\n", " \"WAVERYS_20171029_R20171029.nc\",\n", " ]\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": {} } ] }