Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

(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 Google Analysis-Ready, Cloud-Optimized (ARCO) ERA5 archive, the Copernicus Data Store (CDS), or the Meteorological Archival and Retrieval System (MARS) at ECMWF computer systems.

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/how-to-api .

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 three methods to download ERA5: from the Google ARCO ERA5 archive (recommended), 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 are extremely 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. Due to CDS request size limits, the model level data is requested in blocks of 6 hours, which are merged after downloading.

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.

Logging

By default, (LS)2D prints formatted log messages to the screen. To use your own logging setup instead, call ls2d.disable_default_logging(); messages are then passed on to your own handlers via the ls2d logger.

Contributing guidelines

Contributions through pull requests are always appreciated. To keep the code style consistent, we stick to PEP8 with two modifications (see project.toml):

  • The maximum line length is set to 120 characters instead of 80.
  • Single quotes are used for strings instead of double quotes.

To ensure consistent formatting, the code should be automatically formatted using ruff. It can be installed via pip and can be run on the entire codebase from the project root (this directory) like

ruff format .

Metadata

Release files for ls2d 1.1.0b3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ls2d 1.1.0b3
File Size Uploaded Provenance Actions
ls2d-1.1.0b3.tar.gz 95.0 kB Without provenance Details for ls2d-1.1.0b3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ls2d 1.1.0b3
File Interpreter ABI Platform Actions
ls2d-1.1.0b3-py3-none-any.whl Python 3 none any Details for ls2d-1.1.0b3-py3-none-any.whl

Total release size: 190.1 kB

Release files / ls2d-1.1.0b3.tar.gz

Download URL ls2d-1.1.0b3.tar.gz
Size 95.0 kB
Tags Source
SHA-256 checksum
How to use checksums
08303608e53c88062331a0857f27217ea2638c335adab37d6ba8ff68e29d71ae
BLAKE2b-256 checksum
How to use checksums
76a3f8728275b6e8e8f201c7f04a4f1dee2d25cd3128b8fd1f76e43056c2cdba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / ls2d-1.1.0b3-py3-none-any.whl

Download URL ls2d-1.1.0b3-py3-none-any.whl
Size 95.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e21b254a400fdbe5d57b4903e8c14caed1fcc8a5cb7e83fa58074fdb3b0ea89
BLAKE2b-256 checksum
How to use checksums
a0cc808f41d640e2a6d936293d8db9f0909ba0b4209ef06faf42e993feeccea6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for ls2d 1.1.0b3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page