Vous êtes sur la page 1sur 6

1

MOD-WET Tutorial: Model Setup and Execution



This tutorial summarizes the steps required to run MOD-WET on the SEASNet computers. You are free
to run the code on your local machine or another set of computers; however, this overview will
summarize how to set up your file structure, paths, etc. on the SEASNet computers. Note: The file
structure and saving of files shown below can be done outside of the Matlab environment; here it is done
in the Matlab environment to ensure it is done properly.

When you open Matlab on a SEASNet computer, you can determine your default directory by typing the
following in the Matlab command window:
% Print current working directory
pwd

Suppose you type this and find that your default directory is: Z:\Documents\MATLAB. This tutorial will
demonstrate how to create a directory structure in your home directory (Z:\). It is possible that when you
typed pwd into the command window, you found a different path/directory structure. In this case, you can
use the following steps as a guide for your setup; however you will have to make additional modifications
to follow your particular file structure. Note: If you are working on a SEASNet computer via Remote
Desktop or in the computer lab, you should have access to the Z:\ drive and should be able to save your
files there.

I. Setting up a file structure in Matlab and placing the data files in their appropriate directories
1. From the command line in Matlab, execute the following lines of code to generate a directory structure
for use in this class:

% Change directory to your home directory
cd Z:\
% Create a new directory called CEE150 to store all files for this course
mkdir CEE150
% Change directories to the CEE150 folder you just created
cd CEE150
% Create a directory called Homework that contains a subdirectory called PS1.
% Store the Problem Set #1 scripts that you write for this homework
% assignment in PS1.
mkdir('Homework','PS1')
% Create a new directory to store data files
mkdir Data
% Change directory to your home directory
cd Z:\

You should see that the CEE150 directory is now located in Z:\. If you expand the directories in the
Current Folder window on the left-hand-side of the Matlab window, you should have the same
directory structure as shown in the red box.

2



2. Download MOD_WET.zip from http://aqua.seas.ucla.edu/margulis_intro_to_hydro_textbook.html and
save it to your Desktop.

3. Unzip the MOD_WET.zip file and place it in the CEE150 directory. To perform these actions from the
Matlab command line, execute the following line of code:

!unzip Z:\Desktop\MOD_WET.zip -d Z:\CEE150\

This may take a few minutes to complete. As shown in the figure below, you should see that the MOD_WET
directory is now located in Z:\CEE150 along with its subdirectories chapter1 chapter11.




3


4. Download the following files from CCLE and save them to your Desktop:
emerald_lake_basin_90m_dem.mat
emerald_lake_forcings_wy1997_15min_res.mat

5. Place these files in their appropriate directories:
% Move the DEM file to your Data directory
movefile('Z:\Desktop\emerald_lake_basin_90m_dem.mat','Z:\CEE150\Data\.')

% Move the meteorological data file to the directory
% Z:\CEE150\MOD_WET\chapter11\test_basin_data\met_data
movefile('Z:\Desktop\emerald_lake_forcings_wy1997_15min_res.mat',
'Z:\CEE150\MOD_WET\chapter11\test_basin_files\met_data\.')

These files are highlighted in the figure below with red arrows.



II. Watershed delineation to generate the basin data file containing the DEM and delineation data
Create a new script to execute commands for this homework and save it in your PS1 directory. You
should add the path to the MOD_WET directory at this time to be able to access all of the functions
contained in the MOD_WET directory and its subdirectories:
addpath(genpath('Z:\CEE150\MOD_WET\'))
% Add additional paths to your Homework and Data directories
addpath(genpath('Z:\CEE150\Homework\'))
addpath(genpath('Z:\CEE150\Data\'))

% Load DEM data
load Z:\CEE150\Data\emerald_lake_basin_90m_dem.mat

% Specify the outlet_coordinate, percent_basin_area, dx, and dy variables
% as appropriate
.
.
.
4


% Run the watershed_area_and_stream_delineation.m function
.
.
.

% Save the watershed delineation output to the directory
% Z:\CEE150\MOD_WET\chapter11\test_basin_files\basin_data\
save
Z:\CEE150\MOD_WET\chapter11\test_basin_files\basin_data\emerald_lake_basin_90
m_dem_and_delineation_data.mat easting northing elev dx dy flowacc flowdir
mask outlet_coordinate watershed_outline_coords x_stream y_stream

As shown in the figure below, verify that this file
(emerald_lake_basin_90m_dem_and_delineation_data.mat) is saved in the directory:
Z:\CEE150\MOD_WET\chapter11\test_basin_files\basin_data\.




III. Modify the MOD-WET input file
1. Open/edit the MOD_WET_model_static_and_control_parameters.m function contained in
Z:\CEE150\MOD_WET\chapter11\. The figure below indicates the file you should open and the
window that will display the function once you have opened it.

5



You should modify the following lines of code in the
MOD_WET_model_static_and_control_parameters.m function as follows:

Line #38: Specify path to root directory for Hydrology Toolbox functions (i.e. MOD-WET)
Original line of code:
control_params.toolbox_path='~/Dropbox/CEE150/MOD_WET';
Change this to:
control_params.toolbox_path='Z:\CEE150\MOD_WET';

Line #74: Specify the output file name
Original line of code:
control_params.output_filename='/Users/margulis/Dropbox/CEE150/MOD_WET/chapte
r11/test_basin_files/output/nominal_toy_basin_full_year_outputs.mat';
Change this to:
control_params.output_filename='Z:\CEE150\MOD_WET\chapter11\test_basin_files\
output\emerald_lake_90m_full_year_outputs_wy1997.mat';

Line #79: Specify location of DEM data
Original line of code:
control_params.dem_filename='/Users/margulis/Dropbox/CEE150/MOD_WET/chapter11
/test_basin_files/basin_data/nominal_toy_basin_dem_and_delineation_data.mat';
Change this to:
control_params.dem_filename='Z:\CEE150\MOD_WET\chapter11\test_basin_files\bas
in_data\emerald_lake_basin_90m_dem_and_delineation_data.mat';

Line #92: Specify the location of the meteorological data
Original line of code:
control_params.met_data_filename='/Users/margulis/Dropbox/CEE150/MOD_WET/chap
ter11/test_basin_files/met_data/full_year_15min_resolution.mat';
Change this to:
control_params.met_data_filename='Z:\CEE150\MOD_WET\chapter11\test_basin_file
s\met_data\emerald_lake_forcings_wy1997_15min_res.mat';

6

After making these edits to the MOD_WET_model_static_and_control_parameters.m function,
save your changes. You are now ready to run the MOD-WET watershed model.


IV. Run the MOD-WET code
% Change directory
cd Z:\CEE150\MOD_WET\chapter11

% Execute code
MOD_WET_model_driver

Vous aimerez peut-être aussi