{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Make your own forcing data from ERA5\n", "\n", "Introduction: There are lots of forcing data can be used to drive the model, such as ERA5, NCEP (https://psl.noaa.gov/data/gridded/data.ncep.reanalysis.html), etc. Here, we recommend ERA5 to make your own single point forcing as the NCEP and others are too big to download. The ERA5 data can be obtained in a small scale, which usually light weight to download and store." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**New updates**: The ERA5 source updated time-series data which is faster and more efficient and get forcing from the ERA5 (grided) source.\n", "\n", "We update the workflow to use the new ERA5 source, you can use the `source='gee'` and `source='era5-land-ts'` for getting the forcing data efficiently.\n", "\n", "**Notes**: There are some differences in the calculation of source era5-land-ts and cds. This means you can use this dataset for experimenting with CLMU, but for prediction purposes, you will need to validate the output. Ideally, you should use your own forcing inputs for the best results." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 1 Download the required variables from the GEE" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Before running using `source='gee'`, make sure to install the Earth Engine API:\n", "`pip install earthengine-api`" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "pyclmuapp version: 0.0.2\n", "Get ERA5 data from 2018-07-01 to 2018-10-01 for (51.5, 0.12)\n", " - 2018-07-01 ~ 2018-08-01\n", " - 2018-08-01 ~ 2018-09-01\n", " - 2018-09-01 ~ 2018-10-01\n", "CPU times: user 730 ms, sys: 181 ms, total: 911 ms\n", "Wall time: 9.13 s\n" ] }, { "data": { "text/plain": [ "'/home/junjie/github/pyclmuapp/docs/notebooks/own/era5_data/era5_gee_forcing_51.5_0.12_30_2018_7_2018_9.nc'" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%%time\n", "\n", "import pyclmuapp\n", "from pyclmuapp import get_forcing\n", "\n", "print(f\"pyclmuapp version: {pyclmuapp.__version__}\")\n", "\n", "lat=51.5\n", "lon=0.12\n", "zbot=30\n", "start_year=2018\n", "end_year=2018\n", "start_month=7\n", "end_month=9\n", "get_forcing(\n", " lat=lat, lon=lon, zbot=zbot, \n", " start_year=start_year, end_year=end_year, \n", " start_month=start_month, end_month=end_month,\n", " source='gee')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 2 Download the required variables from the cdsapi\n", "\n", "First, we will use the `cdsapi` package to download the data. If you don't have the package installed, you can install it using the following command:\n", "\n", "```\n", "pip install cdsapi\n", "\n", "cat < ~/.cdsapirc\n", "url: {api-url}\n", "key: {uid}:{api-key}\n", "EOF \n", "```\n", "\n", "[How to get your CDS API?](https://cds.climate.copernicus.eu/how-to-api)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**note: it will take a long time to run this script, so you can run it in the background and check the output file later.**" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We also can use the interface to download the data. The code below is an example of how to download the data using the interface.\n", "\n", "ref: https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-single-levels?tab=form" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "pyclmuapp version: 0.0.2\n" ] } ], "source": [ "import pyclmuapp\n", "from pyclmuapp import get_forcing\n", "\n", "print(f\"pyclmuapp version: {pyclmuapp.__version__}\")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Downloading data for 51.5, 0.1, 2018-07-01 to 2018-10-01...\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2026-01-10 23:17:06,727 WARNING [2025-06-04T00:00:00] This dataset provides user-selected location timeseries of [ERA5 Land data](https://doi.org/10.24381/cds.e2161bac) for a limited set of variables. Its content may be undergo changes over time (e.g. file format, data file structure, deprecation etc) and is **not recommended for use in a production environment**. \n", "\n", "For users interested in large regions, the original ERA5 Land catalogue entry remains the more efficient option. \n", "We will make every effort to notify users of changes, either through this banner and/or the [Forum](https://forum.ecmwf.int/).\n", "2026-01-10 23:17:06,727 INFO Request ID is cc48820b-f777-4f81-a0af-bca1178bb679\n", "2026-01-10 23:17:07,735 INFO status has been updated to accepted\n", "2026-01-10 23:17:22,599 INFO status has been updated to successful\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "da7daea52a3d4befa0c56758820c279a", "version_major": 2, "version_minor": 0 }, "text/plain": [ "73a571ffd3d133dc1701ebf431a3f344.zip: 0%| | 0.00/207k [00:00