cee 150: introduction to hydrology instructor: prof. steve margulis...

25
CEE 150: Introduction to Hydrology • Instructor: Prof. Steve Margulis ( [email protected] ) • TAs: Liz Baldo ([email protected] ) -- Thursday Recitation Laurie Huning ([email protected] ) -- Friday Recitation 1

Upload: dwain-wood

Post on 19-Jan-2016

295 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

1

CEE 150: Introduction to Hydrology• Instructor:

Prof. Steve Margulis ([email protected])• TAs:

Liz Baldo ([email protected]) -- Thursday RecitationLaurie Huning ([email protected]) -- Friday Recitation

Page 2: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

2

Recitation Outline – Week 0

• Introduction: Modeling, data analysis, visualization • SEASNet Setup/MATLAB access/Remote Desktop

• Basic MATLAB Primer

• Instructional and learning assessment survey

• Intro. to MOD-WET, MOD-WET tutorial, setting up your system

Page 3: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

3

Modeling/Analysis/Visualization• What is modeling?

– Representation (simplification) of a real system; can be physical or numerical

• Why are models useful?

– For: understanding phenomena, prediction, analysis, and design

• Analysis/Visualization– As engineers you must become well-versed in handling data (of

different kinds), analyzing data, presenting data (map data, time series data, relationship between variables, etc.)

• MATLAB provides a useful all-in-one framework for modeling/analysis/visualization

Page 4: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

4

Textbook/Modeling System used in CEE 150:

• Textbook:– “Introduction to Hydrology” (Margulis, 2014b

Edition)

• Modeling system:

– Modular Distributed Watershed Educational Toolbox (MOD-WET); consists of over 60+ independent codes and additional wrapper code to link together a spatially-distributed watershed model

Page 5: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

5

Textbook/Modeling System used in CEE 150:MOD-WET and textbook website:http://aqua.seas.ucla.edu/margulis_intro_to_hydro_textbook.html

Files:1. Textbook:

Margulis_Intro_to_Hydro_2015b.ibooksMargulis_Intro_to_Hydro_2015b.pdf (can be downloaded after recitation)

2. MOD-WET source code:MOD_WET.zip

3. MOD-WET user’s guide with tutorial: MOD-WET_User_Guide_2015b.pdf

Save MOD-WET source code and User Guide to your Desktop for now.

Page 6: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

6

SEASNet Setup/Remote Desktop/MATLAB access

• Make sure you have a SEASNet account • Make sure you have access to MATLAB

• MATLAB should be accessible from computer lab terminal and/or via remote desktop (remote.seas.ucla.edu)

• Alternative: Student version of MATLAB for your own computer

Page 7: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

7

Basic MATLAB Primer• Chapter 12 in textbook (and references therein); Matlab Tips for

CEE 150 document (on CCLE) • Key concepts

– File system, RAM, CPU usage– Variable formats/types (arrays/dimensions, structure arrays)– Saved variables in *.mat files; can be loaded into workspace– Toolboxes, MATLAB path– All built-in MATLAB commands are just functions (or *.m) files located

in its directory structure in various “toolboxes” that are defined in its “path”

– Scripts vs. functions for program execution– Built-in help system

• Most of what you need for CEE 150 is:– Writing simple scripts to use built-in and MOD-WET functions– usage of plotting functions for visualization

Page 8: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

8

What is MOD-WET?

• MOD-WET is just a collection of functions organized into its own MATLAB toolbox directory structure (organized by chapters in book, each with its own directory)

• MOD-WET functions can be used just like any other

MATLAB function by giving the function inputs and receiving its outputs

• To generically call a MOD-WET function you must add the full set of directories to your path so MATLAB knows where to look for it

Page 9: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

9

What is MOD-WET?

• MOD-WET functions can be used independently or tied together to form a hydrologic model for a given region (“MOD-WET model”); We will use the model as a basis for learning throughout the quarter

• Key inputs:– Topographic data for the region– Meteorological data (precipitation, air temperature, etc.)– Basic control parameters identifying length of simulation,

timestep, pointers to input files, output frequency, etc.

• MOD-WET model simulates hydrologic processes that occur over specified region

Page 10: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

10

• Pre-test assessment offered in Week 0 during recitation

• Follow-up “post-tests” at midterm and final

• Part of ongoing educational assessment research project

• Full-credit for participating (in all three tests)

Learning Assessment Survey

Page 11: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

11

Files to Download from CCLE:CCLE course website: https://ccle.ucla.edu/course/view/15F-CEE150-1

Files:1. Topographic data: Digital Elevation Model (DEM) file:

upper_kaweah_dem_data.mat– Note: In tutorial, we will replace “emerald_lake_dem_data.mat” with this

file name

2. Meteorological data file: upper_kaweah_met_forcing_WY09.mat

– Note: In tutorial, we will replace “emerald_lake_met_forcing_WY1997.mat” with this file name

Save files to your Desktop for now.

Page 12: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

12

MOD-WET Tutorial

• We will go through the MOD-WET Tutorial document (MOD-WET_User_Guide_2015b.pdf) to get you setup on SEASNet (will follow step-by-step instructions on your machine)

• Goal: Working model before leaving today. Will prepare you for problem sets

Page 13: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

13

Plotting Data

• Start with some basics on plotting of data and how you should present it

• Note: You will be plotting a variety of data types in a variety of formats for this course (mapped data, time series data, scatter plots, etc.)

• It is important that you become comfortable with not only the commands to generate figures, but most importantly using figures as a means to communicate key ideas

– A picture is worth a thousand words … (but only if you present it appropriately)

Page 14: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

14

As engineer you need to become good at presenting and interpreting data...

… this is not only an analysis exercise, but a communication exercise.

Of utmost importance in doing so is quality control of presented data: Take time to ALWAYS convey results in a meaningful way that can be understood by someone else!

Page 15: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

15

Spatial distribution of elevations (in meters) for a given location in the Sierra Nevada

Highest elevations? Lowest elevations?

Page 16: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

16

Distribution of elevations (in meters) for a given location in the Sierra Nevada

c) Same colormap as a), but printed in black and white

a) colormap or colormap(jet) b) colormap(gray)

Good quality figures: a) and b)

Poor quality figures: c)

Important:Figures without properly conveyed meaning are meaningless; such figures will receive no partial credit!

Ele

v. (

m)

Ele

v. (

m)

Ele

v. (

m)

Page 17: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

17

Page 18: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

18

% Generate new figurefigure

% Generate mapimagesc(static_maps.easting,static_maps.northing,static_maps.elev); % Properly orient the figureset(gca,'ydir','normal'); % Add colorbarc=colorbar; % Specify color mapcolormap(gray) % Add labelsxlabel('Easting (m)')ylabel('Northing (m)')ylabel(c,'Elev. (m)’) % Maintains the aspect ratio using the x and y dataaxis image % Specify limits of the color mapcaxis([2500 3500])

Only difference between the figures

Page 19: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

19

Useful Matlab Commands• clear, clc, who, whos, close, help, load, save • CONTROL + C : Kills current Matlab task• reshape• find• mean: mean(var,1) vs. mean(var,2); mean(mean(var)) vs.

mean(var(:));

Page 20: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

20

Plottingimagescsurfcontour

Page 21: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

21

clear all; close all; clc;% Specify root directorydataroot='E:/'; % Add pathsaddpath(genpath([dataroot 'Recitation/']))addpath([dataroot 'toolbox/']) % Load *.mat fileload PitmanDEM_Outlet.mat % Delineate Pitman watershed[mask,flowacc,flowdir,slope,watershed_outline_coords,x_stream,y_stream]= ... watershed_area_and_stream_delineation(easting, northing, elev, ... outlet_coordinate); % Mapsfigure(200)imagesc(easting,northing,elev);% Adjust orientationset(gca,'ydir','normal') % Contour mapsfigurecontour(easting,northing,elev)% Add colorbarcolorbar% Label axesxlabel('Easting [m]');ylabel('Northing [m]');zlabel('Elevation [m]')% Add titletitle('Pitman Watershed DEM [m]')

Example 1

Page 22: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

22

% Surface plotfigureh=surf(easting,northing,elev);% Remove edge colorset(h, 'edgecolor','none')% Add colorbarcolorbar% Label axesxlabel('Easting [m]');ylabel('Northing [m]');zlabel('Elevation [m]')% Add titletitle('Pitman Watershed DEM [m]’)

Example 1

Page 23: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

23

%% Sample script for recitation #1 (Week 0)% Startup directory: C:\Users\Laurie Huning\Documents\MATLABpwd % Add path to single directoryaddpath('C:\Users\Laurie Huning\Dropbox\Teaching\CEE150\Fall2014\MOD_WET\chapter1') % % Add path to MOD-WET directory and its subdirectories% addpath(genpath('C:\Users\Laurie Huning\Dropbox\Teaching\CEE150\Fall2014\MOD_WET')) %%load ..\..\Dropbox\Teaching\CEE150\Fall2014\Recitation\Recitiation_wk0\data\emerald_lake_basin_90m_dem_and_delineation_data%%% Specify Emerald Lake outlet coordinatesoutlet_coordinate=[349940 4051800]; % Call delineation[mask,~,flowdir,~,watershed_outline_coords,x_stream,y_stream]= ... watershed_area_and_stream_delineation(easting,northing,elev, ... outlet_coordinate,0.05);

Example 2

Page 24: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

24

%%figure(200);imagesc(easting,northing,elev);colorbar;axis imageset(gca,'ydir','normal');hold onh1EL=plot(watershed_outline_coords.x,watershed_outline_coords.y,'.k');h2EL=plot(outlet_coordinate(1),outlet_coordinate(2),'pk','linewidth',2,'markersize',10);plot([easting(1) easting(end)],[4.051E6 4.051E6],'-w','linewidth',2)% caxis([2200 3500])xlabel('Easting (m)')ylabel('Northing (m)')%%figure(201)v=2800:50:max(elev(:)); [C,h]=contour(easting,northing,elev,v,'linewidth',2);%colorbar;clabel(C,h,'LabelSpacing',300)axis imageset(gca,'ydir','normal');hold onplot([easting(1) easting(end)],[4.051E6 4.051E6],'--k','linewidth',2)xlabel('Easting (m)')ylabel('Northing (m)')title('Topographic map (Elev. in meters)')%%figure(300)[~,Inorth]=min(abs(northing-4.051E6)); plot(easting,elev(Inorth,:),'linewidth',2)grid onaxis tightset(gca,'xminortick','on','yminortick','on')ylim([3000 3300])axis imagexlabel('Easting (m)')ylabel('Elevation (m)')

Example 2

Page 25: CEE 150: Introduction to Hydrology Instructor: Prof. Steve Margulis (margulis@seas.ucla.edu)margulis@seas.ucla.edu TAs: Liz Baldo (liz.baldo@gmail.com)

25

%%figure(400)surf(easting,northing,elev);colorbarxlabel('Easting (m)')ylabel('Northing (m)')zlabel('Elevation (m)') figure(401)h=surf(easting,northing,(elev-min(elev(:))).*mask,elev); set(gca,'YDir','normal');set(h, 'edgecolor','none')colorbarxlabel('Easting (m)')ylabel('Northing (m)')zlabel('Elevation above outlet (m)')%% % Determine resolution of DEMabs(mean(diff(easting(:))))abs(mean(diff(northing(:)))) % Save to filedx=90; dy=dx;% save emerald_lake_watershed_data.mat easting northing elev dx dy flowacc flowdir mask outlet_coordinate watershed_outline_coords x_stream y_stream% % clear all %%% Change directory to MOD-WET CH. 11cd ..\..\Dropbox\Teaching\CEE150\Fall2014\MOD_WET\chapter11\ % % Add path to MOD-WET directory and its subdirectories% addpath(genpath('C:\Users\Laurie Huning\Dropbox\Teaching\CEE150\Fall2014\MOD_WET')) % Open file and edit paths: MOD_WET_model_static_and_control_parameters%% Run MOD-WETMOD_WET_model_driver %%

Example 2