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 theGlobal 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 theIntegrated 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 apython API. TheIFS parameter databasecan also be useful to visit. TheIFS documentationis available online5and 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 acomprehensive installation procedure, and the WRF tutorials and forums may help too. Theuser's guideand thedescription of the physicsare very interesting to look at besides the code. You can find theoriginal referencesfor the implemented parametrizations, and manypresentations从他们的车间(如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 insome 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
- http://www.ncdc.noaa.gov/data-access/model-data/model-datasets/global-forcast-system-gfs/"NCEP Global Forecast System"
- http://apps.ecmwf.int/auth/login/"ECMWF Mars catalogue"
- http://software.ecmwf.int/wiki/display/WEBAPI/Accessing+ECMWF+data+servers+in+batch/"ECMWF. Accessing ECMWF data servers in batch"
- http://apps.ecmwf.int/codes/grib/param-db"ECMWF Parameter database"
- http://www.ecmwf.int/search/elibrary/part?title=part&secondary_title=43R1"ECMWF IFS Documentation"
- http://www2.mmm.ucar.edu/wrf/users/download/get_source.html"NCAR: WRF Source Codes and Graphics Software Downloads"
- http://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php"NCAR. How to Compile WRF: The Complete Process"
- 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"
- http://www2.mmm.ucar.edu/wrf/users/docs/arw_v3.pdf"NCAR. A Description of the Advanced Research WRF Version 3"
- http://www2.mmm.ucar.edu/wrf/users/phys_references.html"NCAR. WRF Model Physics Options and References"
- http://www2.mmm.ucar.edu/wrf/users/workshops/WS2010/presentations/Lectures/Microphysics10.pdf"NCAR. Microphysics Options in WRF"
- 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."