Focal Point River Jobsheets

Remove Watches/Advisories from River Flood Recommender

Purpose:

This jobsheet explains the steps needed for removing the potential to recommend watches and advisories from the river flood recommender

Tasks:

PYTHON DIFFICULTY NOTE: This involves involves some moderate Python skills. Focal Points should practice careful editing, as reminders of proper syntax cannot be provided at every step. In general, pitfalls to watch out for include:

  1. Indentation: Consistency... typically, items within [ ] or { } brackets be indented one tab more than their "parent," and should match their "siblings". Functions, for- or while-loops, and if/then conditional statements all expect an additional indent in their body commands.
  2. Bracketing: Be sure that each pair of [ ] and { } brackets have matching opening and closing symbols
  3. Quote Marks: Make sure quotation marks surrounding string variables use MATCHING quotation marks (don't mix single or double quotes for a single value) and have opening and closing marks around them.
  4. Colons/Commas: There is a colon (:) between the all dictionary "key": "value" pairs AND a comma after EVERY LINE on which a key:vale pair occurs (including after the closing } brackets which wrap up each alert entry). Also, list items should be properly separated by commas.
  5. Spelling: Simple errors in how variables or key/value pairs are spelled will cause problems and may not get caught by the Localization Perspective validator. It's worth the effort to proofread now

SUMMARY: This task will produce a class override of the RiverFloodRecommender.py file, and in particular modify just two methods from the base version: defineDialog, in which choices for watches and advisories will be removed from the interface; and filterHazardsByType, in which advisory and watch hazards will be filtered from the returned events.

 

ORIENTATION (optional):

Follow these quick steps to understand what we're changing.

  1. Launch Hazard Services in the Hydro perspective
  2. Click the "SETUP" (gear) icon, select "Load Settings", and double-click "Hydrology_All" so that we can see all hazards and ensure the River Flood Recommender is accessible
  3. In the Tools menu, open the River Flood Recommender
  4. Observe the following default layout:
    1. There are radio buttons for "Watch" and "Advisory" under the "Type" group that we want to remove
  5. Close the recommender and continue to making the actual changes.

 

MAKING THE CHANGES:

  1. In the Localization Perspective, navigate to the Recommenders sub-directory under the Hazard Services folder.
  2. Double click on RiverFloodRecommender.py to show the available versions
  3. Create a user override version if none exists (user override is best practice for testing changes):
    1. If there is only a BASE version: right click on BASE and select Create Override File, then select User
    2. If there is another version (e.g. SITE) you wish to use: right click on that file and select Copy To, then select User
  4. Double click on the User version of RiverFloodRecommender.py to open it for editing if it is not open
  5. (No action in this step) Notice, if this is a new override file, that the Localization Perspective auto-populated the same class statement as the reference file as an important first step in your override. In this case, your new file should look like the example below:
     
    class Recommender(RecommenderTemplate.Recommender):
        pass
    
    1. You can delete the "pass" line if you like, although it's not required as long as you proceed with adding code to the class. The "pass" line is simply a needed placeholder in new, empty class overrides, which does nothing.
  6. Open a reference copy of the existing RiverFloodRecommender.py file, which will be used for comparing to and copying existing code for overrides.
  7. Find the line beginning with choiceFieldDict["choices"] in the defineDialogMethod (this line provides the choices for the megawidget with the fieldName "forecastType")
    1. You will see that it calls the method "getEventSigChoices" from the "self." class, meaning that this method is defined within the class it is being called in. 
    2. We can find the method called "getEventSigChoices" to see if this is where changes should be made. However, we find that this method calls yet another method named "definedEventSigs", also defined in the same class (as noted by use of "self."). 
    3. Looking just a few lines above we see where the method "definedEventSigs" is defined, and here we can see the list of "Warning", "Watch", "Advisory", and "Statement", so this is the method that will need to be overriden
  8. Copy and paste the definedEventSigs entire method into the USER override for the River Flood Recommender,
  9. Delete or comment out the options for "Watch" and "Advisory" from the list of options in this USER override
  10. You're finished with the needed edits! Proofread for Python syntax mistakes in any areas you edited.
  11. When finished, save the file by hitting Ctrl+S, or selecting Save from the File menu
    1. If a "File Version Conflict" is encountered, click OK to accept merge
    2. In the two-panel "Merge" tab that opens, make no changes and once again save the file by hitting Ctrl+s
    3. When a "File Changed" message appears,  click Yes.
    4. This behavior will only be encountered each time a new override file that did not exist before is created and saved
  12. Review, test, and (if desired) promote the file to the appropriate localization level
  13. Task Complete!
  14. INFO: While the radio button options were removed from the HID by changing the method called definedEventSigs (a method called within getEventSigChoices which is called by defineDialog), the choices returned from this method also propagate through to a method called filterHazardsByType. filterHazardsByType is called during execution of the RFR, and serves the purpose of excluding certain hazards from the returned event set, which is useful here in preventing watches and advisories from being recommended. Since the methods used are all connected in this process, no additional action is needed to make the RFR run correctly with the implemented changes! 

 

To  see changes implemented:

  • No restarts needed, except for closing and reloading the River Flood Recommender dialogue if open

New behavior to expect:

  • The changes made in this jobsheet have two effects:
    • The RFR window will no longer display "Watch" or "Advisory" options in the "Type" radio buttons group
    • Even if FL.A and FL.Y hazards somehow were detected (as is possible if user selects "ALL" in the RFR Type section), they will be filtered out from the returned results.