# Predicting rainfall with governing equations

Which model is a good starting point for predicting precipitation (rain) for 24 hours in advance? I looked at Kalnay's Atmospheric modeling, data assimilation and predictability, and Holton's An Introduction to Dynamic Meteorology as well as various other sources. These are great references but I could not figure out which part I could use to compute what I needed. It seems there are governing equations which are solved numerically, the output is used for a prediction. I am knowledgeable on numerically solving ODEs, PDEs, and am familiar with Matlab, Python, but there aren't any references that I could find providing clear formula -> data -> code -> output.

The most talked about model with clear solution is the Barotropic Vorticity Equation, which, I believe, models wind and pressure. This model was proposed by Charney, Fjortoft and von Neumann during the 50s, and solved with a computer, the results are recreated by Peter Lynch on 2008 (Matlab code available). Could this model be used for rainfall prediction?

If one has to dig in the basic equations, which part of the governing equations should I focus on? Any pointers, references with running code is most welcome.

The Barotropic vorticity equation is insufficient to model rain. Part of this is due to the word 'Barotropic,' which indicates a lack of thermal gradient. The other reason is that while vorticity is a useful quantity, it lacks explicit information on the atmospheric state.

The primitive equations are a system of partial differential equations that are used by most numerical weather prediction models to model various quantities. Rainfall rate is a parameterized variable, a diagnosed formula (or formulas) based on atmospheric state, based on research. Sometimes the results of the research can give wildly different answers given the same data, which is a weakness of parameterizations. The idea is to model the Reynolds-averaged primitive equations and intermittently invoke the parameterizations (including turbulence, radiation, cloud cover, and so on).

Here is a good book that discusses parameterization schemes in general.

TL;DR: Global NWP models such as NCEP's GFS (free access) and ECMWF's IFS (restricted access) provide forecasts at a horizontal scale of a few tens of kilometers every few hours. Starting from global NWP data, NCAR's WRF (free) can be used to produce results at a resolution of a few kilometers and stored every few minutes in time.

I felt I could give some insights. This answer aims to provide further practical references regarding well-known NWP models. It centers on places to look at and what can be done with available resources. I will only briefly try to illustrate why the underlying physics can be seen as intrinsically complex.

Numerical Weather Prediction (NWP) models are interested in the system composed of the Earth's atmosphere and surface. This system encompasses physical features and processes with a wide range of scales: weather front across thousands of kilometers, cumulus spanning a few kilometers, soil layers varying over a few meters, rain drops smaller than a few millimeters in diameter, interactions with solar radiations shorter than a few micrometers in wavelength, ... The models work at a large scale, trying to resolve the movement of air masses by solving PDEs on a grid, and use physical parametrizations to work on the unresolved subgrid phenomenons. Due to the strong sensitivity to initial conditions, the quality of the input data is of paramount importance. This is especially true if fast varying localized features such as rain are of interest.

Global NWP models consider the entire system. They typically have a horizontal resolution of a few tens of kilometers. The initial conditions can come from many different sources of observations (weather radars, radiosoundings, buoys, satellites, airplanes, ...). The data assimilation job is hardly the easiest part and requires fetching all that data in the first place. Those two centers propose global NWP products:

• the National Center for Environmental Prediction (NCEP) with the Global Forecast System (GFS). It is freely available and you can download whole datasets directly quite easily.
• the European Centre for Medium-Range Weather Forecasts (ECMWF) with the Integrated Forecast System (IFS). You need to register to download data. Operational forecasts or analyses are not available for free but re-analyses such as ERA-Interim are. The recent resolution is better than GFS's. Among other ways to retrieve data, besides the web interface, is a python API. The IFS parameter database can also be useful to visit. The IFS documentation is available online 5 and is a good entry point to understand the constitutive equations and the rest. Look at "Part IV Physical Processes, Chapter 7: Clouds and large-scale precipitation" if you are interested in what they do for rain.

Regional NWP models can use global NWP data as initial and boundary conditions. Possibly the best-known freely available regional model is the National Center for Atmospheric Research (NCAR) Weather Research and Forecasting (WRF) model. Relevant downloads to run the model are the source code for WRFV3, WPS, and the static geographic data (a few GBs!). It has a comprehensive installation procedure, and the WRF tutorials and forums may help too. The user's guide and the description of the physics are very interesting to look at besides the code. You can find the original references for the implemented parametrizations, and many presentations from their workshops (e.g. on the microphysics). Speaking of the microphysics, looking at WRFV3/phys, you can find individual Fortran modules for some of the parametrization:

• module_mp_kessler.F (~ 250 LOC) (vapor, rain, cloud water),
• module_mp_lin.F (~ 3000 LOC) (vapor, rain, cloud water, cloud ice, snow, graupel).

So it might not be completely unreasonable to speak of ~1000 LOC for rain in NWP, but this would be ignoring the many other thousands LOC needed to run the rest of the physics. For the processing of the outputs many options are described in the manual, and you might be interested in some post-processing code in python.

In conclusion I think an accurate forecast for rain is unrealistic without the entire NWP machinery. For anybody to apply it by him/herself require to get acquainted with available datasets and softwares. With ~1000 LOC of python you can at least draft a framework around GFS/ECMWF data and WRF, and possibly some other work, that suits some of your needs/desires regarding rain forecasts.

As a side note, local/national weather services may otherwise have interesting products from their own models (some of them possibly free). Also, applications that do not actually require an accurate forecast (e.g. only valid on a statistical basis) can rely on other rain models outside of NWPs and use less input data (e.g. only long term rain rate measurements). Some "rain cells" models used in radioscience may fit this description.

## References

1. http://www.ncdc.noaa.gov/data-access/model-data/model-datasets/global-forcast-system-gfs/ "NCEP Global Forecast System"
3. http://software.ecmwf.int/wiki/display/WEBAPI/Accessing+ECMWF+data+servers+in+batch/ "ECMWF. Accessing ECMWF data servers in batch"
4. http://apps.ecmwf.int/codes/grib/param-db "ECMWF Parameter database"
5. http://www.ecmwf.int/search/elibrary/part?title=part&secondary_title=43R1 "ECMWF IFS Documentation"
7. http://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php "NCAR. How to Compile WRF: The Complete Process"
8. http://www2.mmm.ucar.edu/wrf/users/docs/user_guide_V3/contents.html "NCAR. User’s Guides for the Advanced Research WRF (ARW) Modeling System, Version 3"
9. http://www2.mmm.ucar.edu/wrf/users/docs/arw_v3.pdf "NCAR. A Description of the Advanced Research WRF Version 3"
10. http://www2.mmm.ucar.edu/wrf/users/phys_references.html "NCAR. WRF Model Physics Options and References"
11. http://www2.mmm.ucar.edu/wrf/users/workshops/WS2010/presentations/Lectures/Microphysics10.pdf "NCAR. Microphysics Options in WRF"
12. http://github.com/NCAR/wrf-python "NCAR. A collection of diagnostic and interpolation routines for use with output from the Weather Research and Forecasting (WRF-ARW) Model."

You could look further into how currently used weather models actually work. If you want to do a prediction you will have to run a model which is not just as simple as your question would imply. There are actually many equations in parallel and that describe how motions in a grid behave. Sub grid phenomena like rain are parametrized also. Rain depends e.g. on moisture convergence and aerosol physics describing water droplet growth. This is really a broad question and I suggest you to ask another question if you want information about something more specific about forecasting.

• Do you know any Matlab / Python / Fortran code that can run an NWP and generate this moisture / water droplet growth numbers, preferably tied to a book that explains also the model? There are a lot of formulas out there, with no code, when there is code, it is not focused on rainfalls. I have no problem digging into this stuff, but I need to look at something running. – BBDynSys Jul 31 '17 at 11:39
• Simply: It's not that simple. – Communisty Jul 31 '17 at 12:50
• @user423805 It is not odd. You may be underestimating the complexity of the problem. The basic system of primitive equations (dynamics) can be coded up in several hundred lines of Fortran. Sub-grid physics schemes (turbulence, cloud microphysics etc) each can go to thousand lines of code. – milancurcic Jul 31 '17 at 15:38
• For appropriate literature explaining the model, you will need to dig through both the code manuals and academic journals describing the dynamics, numerics, and subgrid parameterizations. Yes, unfortunately, there is no wiki summarizing all that yet. – milancurcic Jul 31 '17 at 15:45
• I wonder if there are any free models you can download? By getting your hand on actual code would quickly show what I mean. – Communisty Aug 1 '17 at 6:56