falwa: Finite-amplitude local wave activity
falwa is a python library that provides tools to measure and study life cycle of large-scale extreme weather events. It implements the finite-amplitude local wave activity and flux diagnostic presented in:
Citing this package
We would be grateful if you mention falwa and cite our software package paper published in the Geoscience Data Journal upon usage:
@article{falwa_csyhuang_cpolster,
author={Clare S. Y. Huang and Christopher Polster and Noboru Nakamura},
title={falwa: Python package to implement Finite-amplitude Local Wave Activity diagnostics on climate data},
journal={Geoscience Data Journal},
note = {(in press)},
year = {2025},
doi = {10.1002/GDJ3.70006},
publisher={Wiley Online Library}}
Package Installation
Attention: substantial changes took place in release v2.0.0. Installation in develop mode is no longer available.
Since release v2.0.0, the F2PY modules in falwa is compiled with meson (See Issue #95 for details) to cope with the deprecation of numpy.disutils in python 3.12.
First-time installation
To build the package from source, you need a fortran compiler (e.g., [gfortran](http://hpc.sourceforge.net/)) to implement the installation.
Clone the package repo by git clone https://github.com/csyhuang/hn2016_falwa.git .
Navigate into the repository and set up a python environment satisfying the installation requirement by conda env create -f environment.yml. The environment name in the file is set to be falwa_env (which users can change).
Install the package with the command python -m pip install .. The compile modules will be saved to python site-packages directory.
If the installation is successful, you should be able to run through all unit tests in the folder tests/ by executing pytest tests/.
Get updated code from new releases
To incorporate updates, first, pull the new version of the code from GitHub by git pull.
Uninstall existing version of falwa: pip uninstall falwa
If there is change in environment.yml, remove the existing environment by conda remove –name falwa_env –all and create the environment again from the updated YML file: conda env create -f environment.yml.
Reinstall the updated version by python -m pip install ..
Run through all unit tests in the folder tests/ by executing pytest tests/ to make sure the package has been properly installed.
Quick start
There are some readily run python scripts (in scripts/) and jupyter notebooks (in notebooks/) which you can start with. The netCDF files needed can be found in Clare’s Dropbox folder.
Depending on what you want to do, the methods to be use may be different.
If you solely want to compute equivalent latitude and local wave activity from a 2D field, you can refer to notebooks/simple/Example_barotropic.ipynb. This is useful for users who want to use LWA to quantify field anomalies.
If you want to compute zonal wind reference states and wave activity fluxes in QG Formalism, look at notebooks/nh2018_science/demo_script_for_nh2018.ipynb for the usage of QGField. This notebook demonstrates how to compute wave activity and reference states presented in Nakamura and Huang (2018). To make sure the package is properly installed in your environment, run through the notebook after installation to see if there is error.
Issues Reporting
If you are interested in getting email message related to update of this package, please leave your contact here such that I can keep you updated of any changes made.
If you encounter coding issues/bugs when using the package, please create an Issue ticket.
If you have scientific questions, please create a thread in the Discussion Board with the category “General” or “Q&A” according to the circumstance.
Modules
- Example Notebooks
- Demo script for the analyses done in Nakamura and Huang (2018, Science)
- Demo script for the analyses done in Nakamura and Huang (2018, Science): using xarray
- Direct inversion algorithm for reference state computation (Neal et al 2023 GRL)
- Using
barotropic_qglat_lwato compute equivalent latitude and local wave activity (total, cyclonic and anticyclonic) - Using
qgpv_eqlat_lwato compute equivalent latitude and local wave activity from QGPV on a pressure level - Using the object-oriented interface (
BarotropicField) to compute equivalent latitude and local wave activity (total, cyclonic and anticyclonic)
- Object Oriented Interface
- Data Storage
- Xarray Interface
- Barotropic Field
- Utility Functions
- Plot Utilities
- netCDF Utilities
- Statistics Utilities
- Basis Functions
- Wrapper Functions