Margulis Research Group

Department of Civil and Environmental Engineering


Home PeopleResearch ThemesResearch ProjectsStudent/Postdoc OpportunitiesTeachingContact

Freely-distributed "Introduction to Hydrology" e-textbook

Over the last several years we have developed a freely-distributed electronic textbook for use in hydrology courses. It is currently used as the required textbook for the "C&EE 150: Introduction to Hydrology" undergraduate course at UCLA. The textbook provides a broad foundation in the topics of hydrologic science including: mass balance, basic atmospheric thermodynamics, radiation, atmospheric circulation, precipitation, snow, evapotranspiration, unsaturated flow and infiltration, groundwater, and runoff. The book is available in iBooks and PDF format and leverages many embedded multimedia resources to convey the topics. An emphasis is placed on real problem solving including numerical applications. As such a "Modular Distributed Watershed Educational Toolbox (MOD-WET)" of MATLAB functions are included with the book. The MOD-WET codes build up to a fully-distributed watershed model that is described in the final chapter. The fully-coupled MOD-WET model provides a basis for integrating the set of concepts covered in the class in the context of both qualitative and quantitative demonstrations and experiments. The book is optimized for use within iBooks (i.e. on an iPad or iBooks reader) to take full advantage of multimedia, but a PDF version is also provided (with embedded movies that play when using Adobe Reader) for those who would prefer that format.

The book was first offered in 2014. It is currently on its fourth major edition. Below we provide the new 2017a version (posted on 08/18/2017). The new edition primarily differs only in fixing typos and adding clarification.

If you plan to use the textbook or model in your course, please email me ( with Subject Line: "Intro. to Hydro. Textbook/MOD-WET 2017a" so that we can track usage and notify you of any major bugs found in the model. Also please refer students to download the book/codes from links on this site.


Textbook downloads:

The iBooks version is available for download at the iBooks store:

iBooks Version (2017a Edition)

If you'd prefer a PDF version instead you can you can download it directly:

PDF Version (2017a Edition)

MOD-WET downloads:

The MOD-WET functions (and some test basin files) are provided in the zipped file shown below with functions grouped by chapter in the textbook:

zipped MOD-WET codes

Additionally, there is a "User Guide" for the model provided below:

MOD-WET 2017a User Guide

A presentation designed to provide a tutorial for MOD-WET setup is given in the following video (in 3 parts):

MOD-WET Tutorial (part 1 of 3)

MOD-WET Tutorial (part 2 of 3)

MOD-WET Tutorial (part 3 of 3)

Slides that can accompany the text may be useful to students and/or instructors:

Slides for each chapter

For instructors:

Solutions for problems in the textbook are available upon request.

Contact info:

Steve Margulis (

Errata/Omissions (for 2017a Edition): A running tabulation of errors (typographical or otherwise) will be kept here along with any MOD-WET modifications until the next edition is created.

-- September 09, 2017: We have found a bug in the new MOD-WET code that was uploaded on August 18th, 2017. In an effort to speed up the MOD-WET model driver, several physical constants were made globals in the individual model functions. This worked fine for runs using the full model, but when used individually, the variables were not being properly defined and thus causing errors. This mainly effected functions in Chapter 2, but there were others impacted as well. A fix has been implemented in all of these functions. The code provided above contains the corrected functions and should be downloaded and used to replace the code posted on August 18, 2017.

-- October 03, 2017: We found a large bug that was created in the MOD_WET_model_driver.m code in going from 2016b to 2017a. Specifically, the bug only impacts the outlet hydrograph. Most of the changes in going from 2016b to 2017a involved changing how variables were stored and in doing so the variables that carried over inflows/outflows in the streamflow routing from one time step to the other were ignored. A fix has been implemented in the MOD_WET_model_driver.m function. The code provided above contains the corrected function and should be downloaded and used to replace the code posted on September 09, 2017.