{ "cells": [ { "cell_type": "markdown", "id": "95957d8e-e713-4661-88bc-956bfa1f0b6a", "metadata": {}, "source": [ "# Download daily ERA5 data from 1940 onwards (with using papermill) \n", "(script only downloads the not already downloaded data)" ] }, { "cell_type": "code", "execution_count": 1, "id": "6c4b3ad0-54a1-4545-ad5f-e80f750571e5", "metadata": {}, "outputs": [], "source": [ "import papermill as pm" ] }, { "cell_type": "code", "execution_count": 2, "id": "cf087dc8-1fd2-4107-948a-db5f7cf2db67", "metadata": { "tags": [ "parameters" ] }, "outputs": [], "source": [ "year1 = 1940\n", "year2 = 2026 # 2026" ] }, { "cell_type": "code", "execution_count": 3, "id": "d433db37-aab4-416e-9afd-dfcadfc1ce19", "metadata": {}, "outputs": [], "source": [ "years = [f'{y:04d}' for y in range(year1, year2)]\n", "#months = [f'{m:02d}' for m in range(4, 13)] # 1\n", "months = [f'{m:02d}' for m in range(1, 13)] # 1" ] }, { "cell_type": "markdown", "id": "b559087e-a4a0-4161-baef-1d40237f2fd5", "metadata": {}, "source": [ "**Check if data is already correctly available ... otherwise download it**" ] }, { "cell_type": "code", "execution_count": 4, "id": "9c40bcb4-d67d-4e92-9518-ef4ffb4e214f", "metadata": {}, "outputs": [], "source": [ "import os\n", "import time\n", "base_dir = '/home/www/oggm/climate/era5/daily/v1.2/unflattened/' " ] }, { "cell_type": "code", "execution_count": 5, "id": "c50c63a8-6b3b-44ed-8ecc-c15708ed0f97", "metadata": {}, "outputs": [], "source": [ "missing_files = []\n", "for year in years:\n", " for month in months:\n", " filename_t2m = f\"ERA5_Daily_t2m_{year}_{month}.nc\"\n", " filepath_t2m = os.path.join(base_dir, filename_t2m)\n", " filename_tp = f\"ERA5_Daily_tp_{year}_{month}.nc\"\n", " filepath_tp = os.path.join(base_dir, filename_tp)\n", " \n", " if not os.path.exists(filepath_tp) or not os.path.exists(filepath_t2m):\n", " missing_files.append(f'{year}_{month}')" ] }, { "cell_type": "code", "execution_count": 6, "id": "fc1aa34a-7b1d-4054-b820-2b9d20a055eb", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "missing_files" ] }, { "cell_type": "code", "execution_count": 7, "id": "272f7eb5-b997-4a97-b75f-ffe8cf0af91f", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/users/lschuster/mambaforge/envs/oggm_env_2025/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", " from .autonotebook import tqdm as notebook_tqdm\n", "Executing: 100%|██████████████████████████████| 12/12 [02:21<00:00, 11.81s/cell]\n", "Executing: 100%|██████████████████████████████| 12/12 [00:55<00:00, 4.65s/cell]\n" ] } ], "source": [ "for f in missing_files:\n", " year, month = f.split('_')\n", " pm.execute_notebook('download_papermill.ipynb',\n", " f'papermill_download_notebooks/'+f'download_{year}_{month}.ipynb',\n", " parameters=dict(year=year, month=month)\n", " )\n", " time.sleep(5) # maybe that helps to have less throttling " ] }, { "cell_type": "code", "execution_count": null, "id": "a127def3-7f2d-401a-91e1-3196bf10528c", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python [conda env:oggm_env_2025]", "language": "python", "name": "conda-env-oggm_env_2025-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.11.14" } }, "nbformat": 4, "nbformat_minor": 5 }