Tuesday, January 31, 2017

Python Advanced #9 - Reading Two Columns from a Justified Text File and Writing to a New File

In this post, we start with a justified text file as shown below.  This file is titled sampletext.txt.


Our objective is to extract the date along with the values in the last column and to write those values to a different text file.  We do this by using the code below.

We first open the file and then read each line.  As each line is read, we extract the date and the values in the last column and append them to lists named vals1 and vals2.  Once that is completed, we create a new text file titled twocoloutput.txt and write each pair of values in the lists to this file with each pair of values appearing on a separate line.



The results of this program are shown below.


Python Advanced #8 - Reading One Column from a Justified Text File and Writing to a New File

In this post, we start with a justified text file as shown below.  This file is titled justified.txt.



Our objective is to extract the middle value and write those values to a different text file.  We do this by using the code below.

We first open the file and then read each line.  As each line is read, we extract the middle value and append it to the list named vals.  Once that is completed, we create a new text file titled justextract.txt and write each value in the list to this file with each value appearing on a separate line.



The results of this program are shown below.

Monday, January 9, 2017

Overtopping of Dam in HEC-ResSim

This post will demonstrate the computation in HEC-ResSim that occurs when the dam is overtopped.  For this post, I have developed a simple model with two reservoirs on a single stream.  The schematic is shown below.




The upstream reservoir is the reservoir that will be overtopped.  The elevation of the top of dam and the length at the top of the dam are used in the overtopping computation.  For this example, the top of dam elevation is 100 ft and the length at top of dam is 1000 ft.  The 1000 ft will be the overflow length.  The upstream reservoir has a controlled outlet with a physical capacity of 500 cfs.  These parameters are shown below.



The inflow into the upstream reservoir is a constant 1,000 cfs.  This means that the physical capacity of the controlled outlet is less than the inflow for this example.  The inflow is shown below.




To make sure the dam overtops in this example, I code a maximum release rule of 10 cfs for the flood control and conservation zones.  Once the pool is above the top of the flood control zone (100 ft), the full physical capacity of the controlled outlet can be used.  This rule is shown below.





In the figure below, the pool elevation rises from 90 ft to above the top of the flood control zone due to the inflow being above the maximum release of 10 cfs.  Once the top of the flood control zone is reached, the release increases.



In the release decision report shown below, we can see that on 09Jan2016 at 02:00, the pool elevation is 100.06 ft (0.06 ft above the top of the dam).  The controlled outlet flow (last column) is at its maximum of 500 cfs.  The flow going over the dam is computed to be 44.46 cfs (second to last column).  This continues for the subsequent time steps with 500 cfs going through the controlled outlet and the overtopping flow increasing with increasing pool elevation.



The pool elevation crests at 100.30 ft (shown below) once the weir flow and controlled outlet flow match (or nearly match) the inflow.





Note in the release decision report shown above that the overtopping flow seems to vary even though the elevation appears constant.  Taking the values to additional decimal places does show slight differences.  I have been unable to verify the equation used for overtopping.  The following from Open Channel Flow by M. Hanif Chaudhry provides an answer that is close to that of ResSim, but not exactly the same.