{ "cells": [ { "cell_type": "markdown", "id": "87870edf-37c1-428a-a437-9c792d185a8a", "metadata": {}, "source": [ "# Notebook to understand and check what kind of daily ERA5 data is already downloaded" ] }, { "cell_type": "markdown", "id": "59ba9ba8-2829-4acb-98de-6ed094ea4c2e", "metadata": {}, "source": [ "currently data is available ere: https://cluster.klima.uni-bremen.de/~oggm/climate/wip/era5_daily/global/" ] }, { "cell_type": "markdown", "id": "c49eaea7-19b8-4a40-a26c-0cea21c4ce21", "metadata": {}, "source": [ "\n", "goal: download data from the earliest possible until the latest possible with an easy possibility of an extension, once available\n", "- need daily data (best to download separately for every month)\n", "- + monthly data" ] }, { "cell_type": "markdown", "id": "053d8ec1-bf34-4a66-9f86-f5690cdb3999", "metadata": {}, "source": [ " currently using `conda env: ggm_env_2025`" ] }, { "cell_type": "markdown", "id": "6b580b87-5613-4b88-a960-e1d9b8786d32", "metadata": {}, "source": [ "What is the difference between tmp/ERA5_Daily_t2m_2010_01.nc and ERA5_Daily_t2m_2010_01.nc ? \n", "- `tmp/`: raw data as downloaded from the cdsapi ECMWF server\n", "- `/`: minimally postprocessed data (changing some names and attributes)" ] }, { "cell_type": "code", "execution_count": 1, "id": "1ca22bee-33f0-4f71-b2de-2cdd2cc80d1b", "metadata": {}, "outputs": [], "source": [ "import xarray as xr" ] }, { "cell_type": "code", "execution_count": 7, "id": "ca3c7784-ed04-4b43-82f2-3abbb5c6e627", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "❌ Missing files:\n", " /home/www/oggm/climate/wip/era5_daily/global/ERA5_Daily_tp_2022_05.nc\n", "\n", "Total missing: 1\n" ] } ], "source": [ "import os\n", "\n", "base_dir = \"/home/www/oggm/climate/wip/era5_daily/global\"\n", "variables = [\"t2m\", \"tp\"]\n", "\n", "year_start = 2010\n", "year_end = 2025\n", "month_end = 3 # up to March 2025\n", "\n", "missing_files = []\n", "\n", "for year in range(year_start, year_end + 1):\n", " for month in range(1, 13):\n", " # Stop after March 2025\n", " if year == 2025 and month > month_end:\n", " break\n", "\n", " for var in variables:\n", " filename = f\"ERA5_Daily_{var}_{year}_{month:02d}.nc\"\n", " filepath = os.path.join(base_dir, filename)\n", "\n", " if not os.path.exists(filepath):\n", " missing_files.append(filepath)\n", "\n", "# --- Reporting ---\n", "if missing_files:\n", " print(\"❌ Missing files:\")\n", " for f in missing_files:\n", " print(\" \", f)\n", " print(f\"\\nTotal missing: {len(missing_files)}\")\n", "else:\n", " print(\"✅ All expected NetCDF files are present!\")" ] }, { "cell_type": "markdown", "id": "53674e5b-43fa-4bae-a7af-8a387daae640", "metadata": {}, "source": [ "ok, there was just one month and only tp missing (i.e., 2022_05), I rerun that manually again, and it is now in `www_lschuster/2025_10_era5_daily/tmp`" ] }, { "cell_type": "code", "execution_count": null, "id": "e0707d94-210d-4835-8316-6c853a493869", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 1, "id": "22d5b175-b7e8-4b3f-9f7e-e2a0afb08846", "metadata": { "scrolled": true }, "outputs": [ { "ename": "ValueError", "evalue": "did not find a match in any of xarray's currently installed IO backends ['netcdf4', 'scipy', 'rasterio']. Consider explicitly selecting one of the installed engines via the ``engine`` parameter, or installing additional IO dependencies, see:\nhttps://docs.xarray.dev/en/stable/getting-started-guide/installing.html\nhttps://docs.xarray.dev/en/stable/user-guide/io.html", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", "Cell \u001b[0;32mIn[1], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mxarray\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mxr\u001b[39;00m\n\u001b[1;32m 2\u001b[0m base_dir \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m/home/users/www_oggm/climate/wip/era5_daily/global\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m----> 3\u001b[0m \u001b[43mxr\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mopen_dataset\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43mf\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43mbase_dir\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[38;5;124;43m/download_2010_1.ipynb\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n", "File \u001b[0;32m~/mambaforge/envs/oggm_working_env/lib/python3.11/site-packages/xarray/backends/api.py:569\u001b[0m, in \u001b[0;36mopen_dataset\u001b[0;34m(filename_or_obj, engine, chunks, cache, decode_cf, mask_and_scale, decode_times, decode_timedelta, use_cftime, concat_characters, decode_coords, drop_variables, inline_array, chunked_array_type, from_array_kwargs, backend_kwargs, **kwargs)\u001b[0m\n\u001b[1;32m 566\u001b[0m kwargs\u001b[38;5;241m.\u001b[39mupdate(backend_kwargs)\n\u001b[1;32m 568\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m engine \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m--> 569\u001b[0m engine \u001b[38;5;241m=\u001b[39m \u001b[43mplugins\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mguess_engine\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfilename_or_obj\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 571\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m from_array_kwargs \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 572\u001b[0m from_array_kwargs \u001b[38;5;241m=\u001b[39m {}\n", "File \u001b[0;32m~/mambaforge/envs/oggm_working_env/lib/python3.11/site-packages/xarray/backends/plugins.py:197\u001b[0m, in \u001b[0;36mguess_engine\u001b[0;34m(store_spec)\u001b[0m\n\u001b[1;32m 189\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 190\u001b[0m error_msg \u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m 191\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mfound the following matches with the input file in xarray\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124ms IO \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 192\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mbackends: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mcompatible_engines\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m. But their dependencies may not be installed, see:\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 193\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhttps://docs.xarray.dev/en/stable/user-guide/io.html \u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 194\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhttps://docs.xarray.dev/en/stable/getting-started-guide/installing.html\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 195\u001b[0m )\n\u001b[0;32m--> 197\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(error_msg)\n", "\u001b[0;31mValueError\u001b[0m: did not find a match in any of xarray's currently installed IO backends ['netcdf4', 'scipy', 'rasterio']. Consider explicitly selecting one of the installed engines via the ``engine`` parameter, or installing additional IO dependencies, see:\nhttps://docs.xarray.dev/en/stable/getting-started-guide/installing.html\nhttps://docs.xarray.dev/en/stable/user-guide/io.html" ] } ], "source": [ "import xarray as xr\n", "base_dir = \"/home/users/www_oggm/climate/wip/era5_daily/global\"\n", "_ds = xr.open_dataset(f'{base_dir}/ERA')" ] }, { "cell_type": "code", "execution_count": null, "id": "74ed38ca-6281-4d2b-baf5-a8919f688f70", "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 }