Task 1. Create a Script to Display a Simple Plot.

  1. Start HEC-DSSVue if it is not already executing on your computer.
  2. Launch the Script Editor by selecting Tools→Script Editor from the menu.
  3. Create a new script named "GagePlot"  using the File→New Menu.
    1. Enter "GagePlot" for the label
    2. Notice that DSSVue added some common import statements to the script already.
  4. Open the GagePlot.txt file from the workshop directory using Notepad.exe or a similar program.
  5. Copy the text from this file and paste it into the Editor Pane, replacing the automatically added import statements.
  6. Verify that the path to the filename is pointing to the ScriptingWorkshop.dss file
    (e.g., dssFilename = "C:/Class/DSS/DSSVueScriptingWorkshop/ScriptingWorkshop.dss")
  7. Replace the comments that begin with the string "###"  with code that performs the actions described in the comments. Use the Lecture slides 18-24 or documentation and examples in Reading and Writing to HEC-DSS Files as necessary.
    1. Open the dss file using the HecDss.open(...)
    2. Set the time window using the setTimeWindow method(...) 
    3. Access data using the get method
    4. create a plot object using  Plot.newPlot("GagePlot")
    5. add data to the plot using the plot.addData(...) method as shown in Example 16 above.
    6. Save and test the script.
    7. Correct any problems until the script executes correctly.
      1. Use the console output (Advanced>Console> Output) to see what went wrong.

Question 1.  What does the pink text represent in the text editor?

The pink text represents strings. Notice all the pink text starts and ends with quotes

Question 2. What does the green text represent in the text editor?

The green text represents comments. These lines will not be interpreted as code.

Question 3. How much precipitation fell during the 15:00, 16:00, and 17:00 hours of 12 Jun 2009?

0.01", 1.50", and 0.01', respectively

Question 4.  How did you arrive at your answer?

By selecting File→ Tabulate from the plot menu and then subtracting subsequent values.


Task 2. Modify the Script to Display the Precipitation as a Hanging Hyetograph

  1. Use the File→Save As menu item on the Script Editor to save the GagePlot script to GagePlot2.
    1. Hint: GagePlot must first be open for editing. Enter the new name in the Save As dialog box.

Question 5. What is the file name of the new script (including the full path)?

C:\...\HEC\HEC-DSSVue\scripts\GagePlot2.py.

This is displayed in the “Script” field of the Script Editor.

      2. Modify the line that reads the precipitation:  precipData = dssFile.get(precipPathname) : 

    1. Change dssFile.get(...) to instead be dssFile.read(...) to retrieve a TimeSeriesMath object instead of a TimeSeriesContainer for the precipitation. 
    2. Modify the script to apply the successiveDifferences() method to the precipitation TimeSeriesMath object.
      1. Search for "successiveDifferences" in Scripting Math Functions, to learn how to use the sucessiveDifferences() method.
    3. Convert the TimeSeriesMath object back to a TimeSeriesContainer by using the getData() method.
      1. See Slide 20 or search for "getData" in Scripting Math Functions, to learn how to use the getData() method.
    4. Test the script to see that it now displays incremental precipitation instead of accumulated precipitation.

      3. Use Slide 23 or the Plotting Basics documentation as a guide to make the y axis increase downward for the precipitation. Note: Be sure to place any new lines after the plot.showPlot() line.

    1. Get the viewport that the precipitation is in. Use the getViewport(...) method with an integer argument.
      1. Note that viewports are indexed in top-down order as they appear on the plot.
    2. Get the "Y1" axis of that viewport use the getAxis method(...)
      1. Note that the X1 axis is the (shared) x axis, the Y1 axis is the left y axis and the Y2 axis is the right y axis of any viewport.
    3. Set the axis to increase downward. The parameter of the setReversed(...) method should be one of True or False
    4. Test the script to see if the precipitation axis is reversed. If not, try another value for the setReversed(...) method

Question 6.  What value did you use for the getViewport(...) method to get the desired veiwport

0

Question 7.  What value did you use for the setReversed(...) method to get the desired effect?

False


      4. Modify the Script to Customize the Plot Layout and Curve Colors:

    1. Use the same method as above to create a new script named "GagePlot3" from the GagePlot3.txt file.
    2. Replace the comments that begin with the string "###" with the code that performs the actions described in the comments.
      1. Use Slides 23-24 or the Plotting Basics and Plot Component Properties documentation as a guide. 
    3. Save and test the script.
    4. Correct any problems  utilizing the Console output until the script executes correctly.

      5. Execute Scripts from the Menu, Toolbar, and Script Selector.

    1. Open the Script Selector by selecting Tools→Script Selector from the HEC-DSSVue menu.
    2. Execute one or more of the scripts from the menu, toolbar, and Script Selector.
    3. Edit one or more of the scripts, un-checking the Show in Scripts Menu, Show in Script Selector, and/or Display Script on Toolbar checkboxes before saving.
      1. Notice the effects on the scripts menu, Script Selector, and toolbar.

Question 8.  How can you execute a script if Show in Scripts Menu, Show in Script Selector, and Display Script on Toolbar checkboxes are all unchecked?

  1. By using the "Save and Test" button on the Script Editor
  2. By executing it from the command line