HWRF  trunk@4391
Public Member Functions | Public Attributes | List of all members
setup_hurricane.StormCurses Class Reference

This class implements a user interface for selecting which storms GFDL and HWRF should run. More...

Detailed Description

This class implements a user interface for selecting which storms GFDL and HWRF should run.

Definition at line 129 of file setup_hurricane.py.

Inheritance diagram for setup_hurricane.StormCurses:

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.
 

Constructor & Destructor Documentation

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.

Parameters
vitalsthe list of hwrf.storminfo.StormInfo objects to select from
YMDHthe cycle of interest
loggera logging.Logger for log messages
maxhwrfmaximum number of HWRF storms
maxgfdlmaximum number of GFDL storms
fake_sourcesif 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.

Member Function Documentation

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.

Parameters
type,value,tbexception 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.

Parameters
iindex of the storm in self.vitals
fieldthe field that is having trouble
reasonwhy the storm cannot run
detailsdetailed reason why the storm cannot be run
gfdl,hwrfif 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.

Parameters
y,xcurses location
sstring to print
acurses attributes
Returns
the number of characters printed (0 or len(s))

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.

Parameters
iselectfirst storm selected (highlighted)
Returns
True if the user asked to setup the models, and confirmed the setup request. Returns False or None otherwise.

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.

Parameters
iindex of the storm in self.vitals
fieldthe 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.

Parameters
confUses 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.

Parameters
ilinethe line number
istormthe 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.

Parameters
ilinethe 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.

Parameters
ihighlightindex 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.

Parameters
ilinefirst line
ihighlightindex 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.

Parameters
ilinethe starting line
istormindex of the storm in self.vitals
highlightif 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.

Parameters
istormindex of the storm in self.vitals
hwrfif True, toggle HWRF
gfdlif True, toggle GFDL

Definition at line 415 of file setup_hurricane.py.

Referenced by setup_hurricane.StormCurses.event_loop().

Member Data Documentation

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().


The documentation for this class was generated from the following file: