Skip to main content

Python toolkit to downscale ERA5 with doubly-periodic large-eddy simulation

Project description

(LS)2D: LES and SCM - Large Scale Dynamics

PyPI version Static Badge

(LS)2D is a Python toolkit, developed to simplify all the steps required to downscale ERA5 with doubly-periodic large-eddy simulation (LES), or single-column models (SCMs). For the retrieval of ERA data, it relies on the Copernicus Data Store (CDS), or the Meteorological Archival and Retrieval System (MARS) at ECMWF computer systems.

[!IMPORTANT] In September 2024, Copernicus upgraded the Copernicus and Atmosphere Data Stores (CDS/ADS), introducing changes in the NetCDF file structure. The updated files now have different dimension names, time units, and even some reordered dimensions (!!). Unfortunately, these changes made the new NetCDF files incompatible with older versions or files extracted from MARS. Although (LS)2D briefly supported the new format, this led to several issues. Therefore, starting November 2024, (LS)2D will automatically patch new NetCDF files to ensure compatibility with the previous NetCDF file structure. On the user side, nothing should change:

  • Old NetCDF files from CDS or MARS remain compatible.
  • New NetCDF files from CDS/ADS are automatically patched after download.
  • Unpatched new NetCDF files are patched once prior to reading.

To upgrade to the new CDS and ADS, please follow the steps described here. If (LS)2D was installed using pip, upgrade (LS)2D with pip install --upgrade ls2d.

References

(LS)2D is described in:

B.J.H. van Stratum, C.C. van Heerwaarden, & J. Vilà-Guerau de Arellano (2023). The benefits and challenges of downscaling a global reanalysis with doubly-periodic large-eddy simulations. JAMES, https://doi.org/10.1029/2023MS003750

If you use (LS)2D, we kindly request citing this paper.

Installation

If you want to use CDS to download the ERA5 data, then please start by following the steps explained at https://cds.climate.copernicus.eu/api-how-to .

PyPI

It is easiest to install (LS)2D from PyPI:

pip install ls2d

By default, this excludes the cdsapi as a dependency. If you do want to install that as a dependency, use:

pip install ls2d[cds]

Manual

For a manual installation, you can clone the package from Github:

git clone https://github.com/LS2D/LS2D.git

In each script where you want to use (LS)2D, add the (LS)2D root directory to the Python path:

import sys
sys.path.append('/path/to/LS2D')

You will have to manually install the dependencies with pip install numpy scipy netCDF4 matplotlib cdsapi.

Usage

Some examples are provided at https://github.com/LS2D/LS2D/tree/main/examples. The script example_1.py downloads the ERA5 data, calculates the initial conditions and large scale forcings, and creates an example plot.

The examples directory also contains example cases for MicroHH (https://github.com/microhh/microhh).

Downloading ERA5 data

(LS)2D contains two methods to download ERA5: through the Copernicus Data Store (open for everyone), or using MARS at ECMWF systems.

The ERA5 model level data that (LS)2D requires is stored on tape archives, so downloads using CDS tend to be slow with long queueing times. For that reason, ls2d.download_era5() will stop the Python script once the download requests are submitted to CDS. On subsequent calls of ls2d.download_era5(), (LS)2D will check the status of the CDS request, and if the request is finished, download the ERA5 data.

The settings dictionary

All settings for (LS)2D are wrapped in a dictionary:

  • central_lat: central latitude of LES/SCM domain
  • central_lon: central longitude of LES/SCM domain
  • area_size: spatial size of ERA5 download (central lat/lon +/- area_size degrees)
  • era5_path: storage location of ERA5 downloads/data
  • era5_expver: ERA5 experiment version number (1=normal ERA5, 5=near realtime). With CDS, only 1 works.
  • case_name: experiment name, only used to create subdirectory in era5_path.
  • start_date: Python datetime object with start date/time
  • end_date: Python datetime object with end date/time
  • write_log: Write ERA5 download to screen (False) or log file (True)
  • data_source: Download method (CDS or MARS). MARS only works on e.g. the ECMWF supercomputer.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ls2d-1.0.13.tar.gz (86.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ls2d-1.0.13-py3-none-any.whl (82.5 kB view details)

Uploaded Python 3

File details

Details for the file ls2d-1.0.13.tar.gz.

File metadata

  • Download URL: ls2d-1.0.13.tar.gz
  • Upload date:
  • Size: 86.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.10

File hashes

Hashes for ls2d-1.0.13.tar.gz
Algorithm Hash digest
SHA256 d9f402236148538b6c949047694d33b3f14bfb02a8473402a387c6a5f9753d34
MD5 ec4f7fd3bfe11a869f99ec65416c4875
BLAKE2b-256 6604c6d89cbbd4b25c8cf9bb59bdaa7294edd565f966a1109f0f720794f794ce

See more details on using hashes here.

File details

Details for the file ls2d-1.0.13-py3-none-any.whl.

File metadata

  • Download URL: ls2d-1.0.13-py3-none-any.whl
  • Upload date:
  • Size: 82.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.10

File hashes

Hashes for ls2d-1.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 37d575c2099c4c9320f8bb08c742b8a8df37d211f22f44dc6a6135c0e0c18189
MD5 733289b3c892f7249be7569cc178ec59
BLAKE2b-256 e678f35b250cc1b3ed678b48a6c3912abdfe78a9176b4657e60d915cbcc7f91c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page