General Information

qgs is a Python implementation of an atmospheric model for midlatitudes. It models the dynamics of a 2-layer quasi-geostrophic (QG) channel atmosphere on a beta-plane, coupled to a simple land or shallow-water ocean component.

Statement of need

Reduced-order spectral quasi-geostrophic models of the atmosphere with a large number of modes offer a good representation of the dry atmospheric dynamics [OBrienB89]. The dynamics thus obtained allow one to identify typical features of the atmospheric circulation, such as blocked and zonal circulation regimes, and low-frequency variability. However, these models are less often considered in literature than other toy models, despite their demonstration of more realistic behavior.

qgs aims to popularize these systems by providing a fast and easy-to-use Python framework for researchers and teachers to integrate this kind of model.

The choice to use Python was specifically made to facilitate its use in Jupyter notebooks and the multiple recent machine learning libraries that are available in this language.

Installation

The easiest way to run qgs is to use an appropriate environment created through Anaconda.

First install Anaconda and clone the repository:

git clone https://github.com/Climdyn/qgs.git

Then install and activate the Python3 Anaconda environment:

conda env create -f environment.yml
conda activate qgs

You can then perform a test by running the script

python qgs_rp.py

to see if everything runs smoothly (this should take less than a minute).

Note for Windows and MacOS users

Presently, qgs is compatible with Windows and MacOS but users wanting to use qgs inside their Python scripts must guard the main script with a

if __name__ == "__main__":

clause and add the following lines below

from multiprocessing import freeze_support
freeze_support()

About this usage, see for example the main scripts qgs_rp.py and qgs_maooam.py in the root folder. Note that the Jupyter notebooks are not concerned by this recommendation and work perfectly well on both operating systems.

Note

Why? These lines are required to make the multiprocessing library works with these operating systems. See this page for more details, and in particular this section.

Activating DifferentialEquations.jl optional support

In addition to the qgs builtin Runge-Kutta integrator, the qgs model can alternatively be integrated with a package called DifferentialEquations.jl written in Julia, and available through the diffeqpy python package. The diffeqpy package first installation step is done by Anaconda in the qgs environment but then you must install Julia and follow the final manual installation instruction found in the diffeqpy README.

These can be summed up as opening a terminal and doing:

conda activate qgs
python

and then inside the Python command line interface do:

>>> import diffeqpy
>>> diffeqpy.install()

which will then finalize the installation. An Example of DiffEqPy usage notebook using this package is available in the documentation.

Documentation

To build the documentation, please run (with the conda environment activated):

cd documentation
make html

You may need to install make if it is not already present on your system. Once built, the documentation is available here.

Usage

qgs can be used by editing and running the script found in the main folder:

python qgs_rp.py

or

python qgs_maooam.py

For more advanced usages, please read the User guide.

Examples

Another nice way to run the model is through the use of Jupyter notebooks. Simple examples can be found in the notebooks folder. For instance, running

conda activate qgs
cd notebooks
jupyter-notebook

will lead you to your favorite browser where you can load and run the examples.

Dependencies

qgs needs mainly:

  • Numpy for numeric support

  • sparse for sparse multidimensional arrays support

  • Numba for code acceleration

  • Sympy for symbolic manipulation of inner products

Check the yaml file environment.yml for the full list of dependencies.

Forthcoming developments

  • Scientific development (short-to-mid-term developments)

    • Dynamical equilibrium temperature equations

    • Non-autonomous equation (seasonality, etc…)

    • Quartic T⁴ temperature tendencies

  • Technical mid-term developments

    • Dimensionally robust Parameter class operation

  • Long-term development track

    • Active advection

    • True quasi-geostrophic ocean when using ocean model version

    • Salinity in the ocean

    • Symbolic PDE equation specification

    • Numerical basis of function

Contributing to qgs

If you want to contribute actively to the roadmap detailed above, please contact the main authors.

In addition, if you have made changes that you think will be useful to others, please feel free to suggest these as a pull request on the qgs Github repository.

A review of your pull request will follow with possibly suggestions of changes before merging it in the master branch. Please consider the following guidelines before submitting:

  • Before submitting a pull request, double check that the branch to be merged contains only changes you wish to add to the master branch. This will save time in reviewing the code.

  • For any changes to the core model files, please check your submission by running the tests found in the folder model_test to ensure that the model tensors are still valid (see the section 5. Developers information of the User guide). Please do not make changes to existing test cases.

  • For substantial additions of code, including a test case (using unittest) in the folder model_test is recommended.

  • Please document the new functionalities in the documentation. Code addition without documentation addition will not be accepted. The documentation is done with sphinx and follows the Numpy conventions. Please take a look to the actual code to get an idea about how to document the code.

  • If your addition can be considered as a tool not directly related to the core of the model, please develop it in the toolbox folder.

  • The team presently maintaining qgs is not working full-time on it, so please be patient as the review of the submission may take some time.

For more information about git, Github and the pull request framework, a good source of information is the contributing guide of the MITgcm.

Reporting issues with the software and getting support

Issues can be reported and support can be asked directly on the qgs GitHub repository issues page. However, please be patient as the qgs team is quite small.

Other atmospheric models in Python

Non-exhaustive list:

  • Q-GCM: A mid-latitude grid based ocean-atmosphere model like MAOOAM. Code in Fortran, interface is in Python.

  • pyqg: A pseudo-spectral python solver for quasi-geostrophic systems.

  • Isca: Research GCM written in Fortran and largely configured with Python scripts, with internal coding changes required for non-standard cases.

References

OBrienB89

Enda O’Brien and Lee Branscome. Minimal modeling of the extratropical general circulation. Tellus A: Dynamic Meteorology and Oceanography, 41(4):292–307, 1989. URL: https://doi.org/10.3402/tellusa.v41i4.11842.