Giter Club home page Giter Club logo

message-passing-for-da's Introduction

Scalable Data Assimilation via Message Passing

A message passing algorithm, implemented in JAX, for approximately computing the posterior marginal distribution of a Gaussian Markov random field (GMRF). It can scale to fields with millions of variables. The algorithm is designed for data assimilation in weather models, which is the process of updating a model of the atmosphere based on observations.

For more details, see our accompanying paper Scalable Data Assimilation with Message Passing; Oscar Key*, So Takao*, Daniel Giles*, Marc Peter Deisenroth.

In this repository we include:

  • Tools for defining a Matérn Gaussian process prior on a rectangle or sphere and generating a corresponding GMRF prior
  • Three methods for performing inference with this prior
    • Ours: a re-weighted message passing algorithm with multi grid support based on Ruozzi 2013 (GPU accelerated)
    • Baseline 1: 3D-Var, computes the posterior mean using optimisation (GPU accelerated)
    • Baseline 2: exact inference, by launching R-INLA (CPU only)
  • Code to reproduce the experiments in the paper

Message passing implementation

As our message passing implementation is specialised to GMRFs, we can make some assumptions which improve the efficiency:

  • Variables are connected by at most pairwise factors: we do not explicity represent factors, only variables and connections between variables (which implies connection via a pairwise factor)
  • Almost all variables have the same degree, as the graph representing the GMRF has a regular structure except at the boundaries: we can use a regular, GPU-ameanable data structure for the factor graph

To set up the environment

  • Install Python 3.11 (e.g. using pyenv)
  • Install Poetry
  • Run poetry install, or poetry install --with plotting to also include the dependencies required for plotting
  • Optionally: install R and R-INLA if you'd like to run the baseline experiments

Experiments

To run an experiment: python src/experiments/[script].py, where script is:

  • Try out the methods on simulated data: mp_demo.py, mp_multigrid_demo.py, threedvar_demo.py, inla_demo.py
  • Reproduce Table 1: comparison_table.py
  • Reproduce the grid search over the message passing learning rate and c hyperparameters: lr_c_grid_search.py
  • Reproduce the grid search over the early stopping hyperparameters for message passing and 3D-Var: early_stopping_search.py

The experiments on spherical temperature data are in temperature.py. Unfortunately they depend on data from the Met Office's Unified Model which we are unable to include in this repository. Thus, this code is for reference only.

Development tools

  • Format:
    • black **/*.py
    • isort **/*.py
  • Run tests: pytest
  • Run type checker:
    • mypy -p damp
    • mypy src/experiments

License

We release this code under the MIT license, see LICENSE.

message-passing-for-da's People

Contributors

oscarkey avatar dangiles avatar

Watchers

 avatar

Forkers

peikalunci

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.