Configure Unsampled Edit Areas - Hazard Services
Configure Unsampled Edit Areas
Purpose:
This jobsheet demonstrates the process for configuring edit areas where weather grids should not be sampled for a given hazard type.Tasks:
AT-A-GLANCE:
- What? Include a comma-separated list of edit areas in the "unsampledAreaNames" variable, in an override of LocalEffects.py
- Hazard Options. Make the unsampledAreaNames vary by hazard types with conditional logic if desired
Follow the steps below for more detailed guidance.
- [OPTIONAL] Create a hazard in your areas to test the initial sampling behavior (IMPORTANT: You need real or fake grid data to see any weather sampling)
- Launch Hazard Services in in GFE
- Draw a hazard which partially overlaps the edit areas you plan to exclude from sampling in this jobsheet, using the freehand polygon or another technique
- Select a category (e.g. Winter) and hazard (e.g. BZ.W), then click "Preview" to generate a product
- Look at the "What:" text field to see the accumulation or other synopsis phrase, which will originally sample all overlapped edit areas
- Switch to the Localization Perspective by clicking on the "Open Perspective" icon at the top-right of your CAVE window, and choosing "Localization"
- In the Localization Perspective, navigate to the Utilities sub-directory under the Hazard Services folder.
- Double click on LocalEffects.py to show the available versions
- Create a user override version if none exists (user override is best practice for testing changes):
- If there is only a BASE version: right click on BASE and select Create Override File, then select User
- If this is the initial creation of this override, the override file will contain:
class LocalEffect(object): pass class LocalEffectArea(object): pass class LocalEffects(object): pass
- If this is the initial creation of this override, the override file will contain:
- If there is another version (e.g. SITE) you wish to use: right click on that file and select Copy To, then select User (this lets you work on an updated SITE version to replace the original when you're finished)
- If there is only a BASE version: right click on BASE and select Create Override File, then select User
- Double click on the USER version of LocalEffects.py to open it for editing
- Open a reference copy of the existing LocalEffects.py file, which will be used for comparison and copying existing code for overrides.
- It's typically best to open the BASE version because most methods have not already been overridden in a higher-level override
- In the reference file you opened, scroll or search to find the "unsampledAreaNames" method (whose first line appears as "def unsampledAreaNames(self, hazardType):" in LocalEffects.py)
- Once found, select the entire unsampledAreaNames by clicking and dragging from (and including) the "def unsampledAreaNames(self, hazardTypes):" line which begins the function, all the way to (and including) the last line of the function which has the "return unsampledAreaNames" statement.
- Copy the selected contents by right-clicking and selecting "Copy" from the pop-up menu, or by hitting CTRL-C on your keyboard
- Switch back to the USER override you were working on
- Paste the unsampledAreaNames method into your USER override on a blank line after the "class LocalEffects" (beware that there is also a class called "LocalEffect" so do not get these confused. LocalEffects should be the last of three class statements) and "pass" lines (or after any pre-existing override methods in the file), by right-clicking and selecting "Paste" from the pop-up menu, or by hitting CTRL-V on your keyboard
- Locate the unsampledAreaNames variable, shown below, which will have an empty list assigned to it to start with:
unsampledAreaNames = []
- Decide on one or more edit areas you'll use as unsampled areas.
- To choose valid edit areas, refer to the "GFE" > "Edit Areas" directory in the utility tree
- Pick one or more file-names (without the .xml suffix) for edit areas (Example: BOU_Above_10000.xml defines an edit area with the name "BOU_Above_10000")
- Populate the edit areas to not sample in one of the following ways...
- To set one or more edit areas never to sample by default, just edit the list contents with quoted, comma-separated edit area names like this (changes shown in bold):
unsampledAreaNames = ["BOU_Above_10000","Mountains"] # List edit areas never to sample by default
When the method returns this list, it prevents any sampling of weather elements in these edit areas, no matter the hazard. - OR, to make a phensig-dependent assignments of unsampled edit areas, use logic like the following example for BZ.W (changes shown in bold):
unsampledAreaNames = [] # Leave empty or populate with default areas not to sample if hazardType in ["BZ.W"]: unsampledAreaNames=["BOU_Above_10000","Mountains"] # List edit areas never to sample for the BZ.W hazard type
This logic makes a conditional assignment of the unsampledAreaNames, by checking the hazardType argument (passed into the method) against a list or one or more hazard types to trigger this assignment. If the hazardType condition doesn't match, the default value of unsampledAreaNames (either empty [ ] or populated) gets returned. Use as many hazardType conditions as you like to control the assignment here.
- To set one or more edit areas never to sample by default, just edit the list contents with quoted, comma-separated edit area names like this (changes shown in bold):
- When finished, save the file by hitting Ctrl+S, or selecting Save from the File menu
- If a "File Version Conflict" is encountered, click OK to accept merge
- In the two-panel "Merge" tab that opens, make no changes, once again save the file by hitting Ctrl+s, then close the "Merge" tab
- When a "File Changed" message appears, click Yes.
- This behavior will only be encountered each time a new override file that did not exist before is created and saved
- [OPTIONAL, HIGHLY RECOMMENDED] Test your new unsampled edit areas by generating a hazard which partially overlaps the excluded areas
- No need to fully issue - just generate a hazard (use the correct hazard type if you made a phensig-specific rule) and check the "What" text field to verify that your sampling looks correct for excluding the unsampled edit areas
- Finished!