Thursday, June 22, 2017

Python Advanced #14 - Using Lambda in Python for Interpolation

In my post on November 13, 2016, I showed how to interpolate values by using a function in Python.

That function is shown below.

The full post is located here:

Link for Interpolating Values Post

The function shown above computed a flow value given a stage along with the stages and flows above and below in the rating table.

In this post, I show how to perform the same computation using lambda in Python.  The coding to do this is shown below.

The results of this computation are given below.  Since I entered 2.5 as the stage value, I would expect the flow value to return 250 based on the values that I supplied for the bounding values of stage and flow.

Wednesday, June 21, 2017

When to Use Multiple Reservoir Networks in HEC-ResSim

This post details the use of multiple reservoir networks within an HEC-ResSim model.

This post is a continuation of the post titled, "When to Use Multiple Watershed Configurations in HEC-ResSim", from 30May2017.

That post is found here:

Multiple Watershed Configurations Link

Basically, multiple reservoir networks are needed whenever you want to vary a physical parameter of the system while also preserving the original parameter.  These parameters can include:

  • Routing parameters
  • Outlet capacity or number of outlets
  • Storage elevation tables
For example, in the model shown below, I use null routing for the stream reaches.  To compare the differences in results from using various routing methods, multiple reservoir networks can be created with the various routing methods.

In this model, I have a single controlled outlet.  If the capacity of this outlet has changed or additional outlets have been added or proposed, the impacts of the physical changes can be examined by creating a new reservoir network that reflects these changes.

As I mentioned above, the impact of an updated storage-elevation table can be examined by updating that rating within a new reservoir network.  Running alternatives with the original storage-elevation relationship and the updated storage-elevation relationship, for example, can allow the modeler to determine the impact of reservoir sedimentation on peak release and peak pool elevation from an historic or synthetic event.  

Thursday, June 15, 2017

Python Advanced #13 - Computing average annual flow from a csv file

In this post I extracted daily data for the year 2016 for the White River at Newport gage from the USGS site and saved it in a csv file.  I then computed the average of the daily values from this csv file using Python.

USGS White River at Newport data

I import the data into a csv file.  A portion of the file is shown below.

To compute the average of the daily values, I use the code shown below.  To create this code, I modified an example given in a lesson from Coursera.

Link to Coursera

The code is shown below and was run using Anaconda available from the following site:

Where I downloaded Anaconda from

The result of running this code is as follows:

Note that this is the average for the entire year and not just for the values shown above.

Friday, June 9, 2017

Microsoft Excel Advanced #6 - Extracting a Value on a Specific Day and Month for Multiple Years

This post will demonstrate how to extract a value on 01 April for multiple years in Microsoft Excel.  I used the coding example from the following link to guide the development of the needed equations.

Example from

Below is the data that I am using for this example.  It is in columns A and B of the Excel worksheet.  There are three instances where the date is 01 April.

I write an IF statement that checks if the month is April and the day is 1.  If it is, a number is added to column C that represents the number of occurrences of 01 April that have occurred up to that row.

This IF statement is added to all appropriate rows in column C.  The results are shown below.

I then use the following equation in column E to extract the date if there is a value in column C.

I then use the following equation in column F to extract the value if there is a value in column C.

The results of applying these equations is shown below.

The explanation of the methods used above are as follows (from Excel help menu).