HWRF
trunk@4391
|
This class implements a user interface for selecting which storms GFDL and HWRF should run. More...
This class implements a user interface for selecting which storms GFDL and HWRF should run.
Definition at line 129 of file setup_hurricane.py.
Public Member Functions | |
def | __init__ |
Creates a StormCurses object that will assist the SDM in choosing between the storms in the listed vitals. More... | |
def | __enter__ (self) |
Sets up the curses library. More... | |
def | __exit__ (self, type, value, tb) |
Ends the curses library and restores standard terminal functions. More... | |
def | test_screen (self) |
This routine is for testing only. More... | |
def | make_storm_indices (self) |
Sets the "hwrfmessage" and "gfdlmessage" attributes in all of self.vitals[*] to "messageN" (for an integer N), "-CANNOT-" or "---NO---" using setattr. More... | |
def | init_hwrf_gfdl (self) |
Decides if HWRF and GFDL can or should run each storm listed in the vitals. More... | |
def | toggle_run |
Turns on or off the GFDL and/or HWRF model for the storm at index istorm of self.vitals. More... | |
def | hasmessage (self, i, field) |
Returns True if there are warnings or errors for storm i, and False otherwise. More... | |
def | adderr |
Records that vitals at index i cannot be used by either model due to an error in the specified field. More... | |
def | addwarn (self, i, field, reason, details) |
def | quit_confirmation (self) |
Clears the screen and informs the user that they asked to quit. More... | |
def | setup_confirmation (self) |
Clears the screen and shows a setup confirmation screen, displaying what models will run what storms. More... | |
def | show_storm_screen |
Prints the storm selection screen starting at line 0, and returns the number of lines printed. More... | |
def | show_storm_heading (self, iline) |
Prints the storm selection table header starting at the specified line, and returns iline+2. More... | |
def | show_storm_table_line |
Prints one line of the storm list table, for storm self.vitals[istorm], at line iline on the console. More... | |
def | show_storm_table |
Fills self.stdscr with a list of storms starting at line iline on the screen. More... | |
def | addstr |
Puts a string s on the screen at the given y column and x row. More... | |
def | show_storm_details (self, iline, istorm) |
Shows details about a storm self.vitals[istorm] starting on the given line number. More... | |
def | show_message_queue (self) |
If the message queue is not empty, clears the screen and shows the contents of the message queue. More... | |
def | resort (self) |
Re-sorts the vitals into priority order. More... | |
def | fill_source_and_priority (self) |
Sets the "priority" attribute in all vitals to storm1...stormN. | |
def | get_curses_mouse (self) |
Gets a curses mouse event's details. More... | |
def | event_loop |
The main event loop for the storm selection and setup confirmation screens. More... | |
def | setup (self, conf) |
Either setup the models, or print what would be done. More... | |
Public Attributes | |
YMDH | |
the cycle of interst | |
YMDHm6 | |
the cycle before the cycle of interest | |
messagequeue | |
a list of messages to display | |
vitals | |
a list of hwrf.storminfo.StormInfo to select from | |
stdscr | |
the curses screen used for display of text | |
logger | |
a logging.Logger for log messages | |
maxhwrf | |
Maximum number of HWRF storms allowed. More... | |
maxgfdl | |
Maximum number of GFDL storms allowed. More... | |
fake_sources | |
True=tcvitals in use, False=storm files. | |
C_NORMAL | |
Normal font. | |
C_SELECT | |
Font for selected text. | |
C_WARN | |
Font for text of storms that have warning messages. | |
C_WARN_SELECT | |
Font for text of storms that are selected AND have warning messages. | |
C_OCEAN | |
Unused: font for ocean locations on the map. | |
C_LAND | |
Unused: font for land locations on the map. | |
warnings | |
A mapping from storm to list of warning messages for that storm. | |
gfdlcannot | |
Array of logical telling whether each storm cannot be run by GFDL. | |
hwrfcannot | |
Array of logical telling whether each storm cannot be run by HWRF. | |
gfdlwill | |
Array of logical telling whether GFDL will be run by each storm. | |
hwrfwill | |
Array of logical telling whether HWRF will be run by each storm. | |
def setup_hurricane.StormCurses.__init__ | ( | self, | |
vitals, | |||
YMDH, | |||
logger = None , |
|||
maxhwrf = 8 , |
|||
maxgfdl = 5 , |
|||
fake_sources = False |
|||
) |
Creates a StormCurses object that will assist the SDM in choosing between the storms in the listed vitals.
vitals | the list of hwrf.storminfo.StormInfo objects to select from |
YMDH | the cycle of interest |
logger | a logging.Logger for log messages |
maxhwrf | maximum number of HWRF storms |
maxgfdl | maximum number of GFDL storms |
fake_sources | if True, we're using TCVitals for a test run; if False, we're using the NHC and JTWC storm files |
Definition at line 133 of file setup_hurricane.py.
def setup_hurricane.StormCurses.__enter__ | ( | self | ) |
Sets up the curses library.
Use in a Python "with" block.
Definition at line 245 of file setup_hurricane.py.
def setup_hurricane.StormCurses.__exit__ | ( | self, | |
type, | |||
value, | |||
tb | |||
) |
Ends the curses library and restores standard terminal functions.
Use in a Python "with" block.
type,value,tb | exception information |
Definition at line 272 of file setup_hurricane.py.
def setup_hurricane.StormCurses.adderr | ( | self, | |
i, | |||
field, | |||
reason, | |||
details, | |||
gfdl = True , |
|||
hwrf = True |
|||
) |
Records that vitals at index i cannot be used by either model due to an error in the specified field.
The "reason" is a short string explaining why and the "details" is a longer string with a full explanation.
i | index of the storm in self.vitals |
field | the field that is having trouble |
reason | why the storm cannot run |
details | detailed reason why the storm cannot be run |
gfdl,hwrf | if True, that model cannot run |
Definition at line 460 of file setup_hurricane.py.
Referenced by setup_hurricane.StormCurses.init_hwrf_gfdl().
def setup_hurricane.StormCurses.addstr | ( | self, | |
y, | |||
x, | |||
s, | |||
a = None |
|||
) |
Puts a string s on the screen at the given y column and x row.
Optionally, sets the attributes a. This is a simple wrapper around the curses addstr command. It ignores any curses errors, which allows one to write a string that is not entirely on the terminal.
y,x | curses location |
s | string to print |
a | curses attributes |
Definition at line 702 of file setup_hurricane.py.
Referenced by setup_hurricane.StormCurses.quit_confirmation(), setup_hurricane.StormCurses.setup_confirmation(), setup_hurricane.StormCurses.show_message_queue(), setup_hurricane.StormCurses.show_storm_details(), setup_hurricane.StormCurses.show_storm_heading(), setup_hurricane.StormCurses.show_storm_screen(), setup_hurricane.StormCurses.show_storm_table_line(), and setup_hurricane.StormCurses.test_screen().
def setup_hurricane.StormCurses.addwarn | ( | self, | |
i, | |||
field, | |||
reason, | |||
details | |||
) |
Records that there is a problem with the specified field in the vitals entry at index i. The "reason" variable gives a short 1-2 word reason, while the "details" variable gives a potentially long explanation of what is wrong. @param i index of the storm in self.vitals @param field the field with problems @param reason,details short and long explanation of the problem
Definition at line 474 of file setup_hurricane.py.
Referenced by setup_hurricane.StormCurses.adderr(), and setup_hurricane.StormCurses.init_hwrf_gfdl().
def setup_hurricane.StormCurses.event_loop | ( | self, | |
iselect = 0 |
|||
) |
The main event loop for the storm selection and setup confirmation screens.
Handles mouse and key events.
iselect | first storm selected (highlighted) |
Definition at line 852 of file setup_hurricane.py.
def setup_hurricane.StormCurses.get_curses_mouse | ( | self | ) |
Gets a curses mouse event's details.
!returns a tuple containing a string, and an index within self.vitals. The string is "HWRF" if an hwrf message was clicked, "GFDL" for a GFDL message or "select" if the user clicked outside the message selection region. If no vitals were clicked, this routine returns (None,None).
Definition at line 831 of file setup_hurricane.py.
Referenced by setup_hurricane.StormCurses.event_loop().
def setup_hurricane.StormCurses.hasmessage | ( | self, | |
i, | |||
field | |||
) |
Returns True if there are warnings or errors for storm i, and False otherwise.
i | index of the storm in self.vitals |
field | the field of interest |
Definition at line 450 of file setup_hurricane.py.
Referenced by setup_hurricane.StormCurses.show_storm_table_line().
def setup_hurricane.StormCurses.init_hwrf_gfdl | ( | self | ) |
Decides if HWRF and GFDL can or should run each storm listed in the vitals.
Sets any warning or error flags for various fields.
Definition at line 320 of file setup_hurricane.py.
def setup_hurricane.StormCurses.make_storm_indices | ( | self | ) |
Sets the "hwrfmessage" and "gfdlmessage" attributes in all of self.vitals[*] to "messageN" (for an integer N), "-CANNOT-" or "---NO---" using setattr.
Uses self.hwrfwill, self.gfdlwill, self.hwrfcannot and self.gfdlcannot to make these judgements.
Definition at line 296 of file setup_hurricane.py.
Referenced by setup_hurricane.StormCurses.init_hwrf_gfdl(), setup_hurricane.StormCurses.setup(), and setup_hurricane.StormCurses.toggle_run().
def setup_hurricane.StormCurses.quit_confirmation | ( | self | ) |
Clears the screen and informs the user that they asked to quit.
Waits for a keypress and then returns True.
Definition at line 484 of file setup_hurricane.py.
Referenced by setup_hurricane.StormCurses.event_loop().
def setup_hurricane.StormCurses.resort | ( | self | ) |
Re-sorts the vitals into priority order.
Definition at line 798 of file setup_hurricane.py.
def setup_hurricane.StormCurses.setup | ( | self, | |
conf | |||
) |
Either setup the models, or print what would be done.
conf | Uses the specified configuration object (ideally, an HWRFConfig) to find output locations. |
Definition at line 920 of file setup_hurricane.py.
def setup_hurricane.StormCurses.setup_confirmation | ( | self | ) |
Clears the screen and shows a setup confirmation screen, displaying what models will run what storms.
Asks the user if they're sure. Returns True if the user is sure, or False otherwise.
Definition at line 495 of file setup_hurricane.py.
Referenced by setup_hurricane.StormCurses.event_loop().
def setup_hurricane.StormCurses.show_message_queue | ( | self | ) |
If the message queue is not empty, clears the screen and shows the contents of the message queue.
Waits for any key press, then clears the message queue and returns.
Definition at line 781 of file setup_hurricane.py.
Referenced by setup_hurricane.StormCurses.event_loop().
def setup_hurricane.StormCurses.show_storm_details | ( | self, | |
iline, | |||
istorm | |||
) |
Shows details about a storm self.vitals[istorm] starting on the given line number.
iline | the line number |
istorm | the index of the storm in self.vitals |
Definition at line 721 of file setup_hurricane.py.
Referenced by setup_hurricane.StormCurses.show_storm_screen().
def setup_hurricane.StormCurses.show_storm_heading | ( | self, | |
iline | |||
) |
Prints the storm selection table header starting at the specified line, and returns iline+2.
iline | the starting line |
Definition at line 596 of file setup_hurricane.py.
Referenced by setup_hurricane.StormCurses.show_storm_table().
def setup_hurricane.StormCurses.show_storm_screen | ( | self, | |
ihighlight = None |
|||
) |
Prints the storm selection screen starting at line 0, and returns the number of lines printed.
ihighlight | index of the highlighted storm in self.vitals. To highlight nothing, provide None or an invalid index. |
Definition at line 575 of file setup_hurricane.py.
Referenced by setup_hurricane.StormCurses.event_loop().
def setup_hurricane.StormCurses.show_storm_table | ( | self, | |
iline, | |||
ihighlight = None |
|||
) |
Fills self.stdscr with a list of storms starting at line iline on the screen.
If ihighlight is not None, then it specifies the 1-based index of the storm that is presently highlighted.
iline | first line |
ihighlight | index of the storm in self.vitals to highlight, or None to highlight no storms |
Definition at line 687 of file setup_hurricane.py.
Referenced by setup_hurricane.StormCurses.show_storm_screen().
def setup_hurricane.StormCurses.show_storm_table_line | ( | self, | |
iline, | |||
istorm, | |||
highlight = False |
|||
) |
Prints one line of the storm list table, for storm self.vitals[istorm], at line iline on the console.
If highlight=True, then the line is highlighted. Returns iline+1.
iline | the starting line |
istorm | index of the storm in self.vitals |
highlight | if True, highlight that line |
Definition at line 608 of file setup_hurricane.py.
Referenced by setup_hurricane.StormCurses.show_storm_table().
def setup_hurricane.StormCurses.test_screen | ( | self | ) |
This routine is for testing only.
It displays text with all color combinations used by this class.
Definition at line 282 of file setup_hurricane.py.
def setup_hurricane.StormCurses.toggle_run | ( | self, | |
istorm, | |||
hwrf = True , |
|||
gfdl = True |
|||
) |
Turns on or off the GFDL and/or HWRF model for the storm at index istorm of self.vitals.
istorm | index of the storm in self.vitals |
hwrf | if True, toggle HWRF |
gfdl | if True, toggle GFDL |
Definition at line 415 of file setup_hurricane.py.
Referenced by setup_hurricane.StormCurses.event_loop().
setup_hurricane.StormCurses.maxgfdl |
Maximum number of GFDL storms allowed.
Definition at line 152 of file setup_hurricane.py.
Referenced by setup_hurricane.StormCurses.init_hwrf_gfdl(), and setup_hurricane.StormCurses.toggle_run().
setup_hurricane.StormCurses.maxhwrf |
Maximum number of HWRF storms allowed.
Definition at line 151 of file setup_hurricane.py.
Referenced by setup_hurricane.StormCurses.init_hwrf_gfdl(), and setup_hurricane.StormCurses.toggle_run().