HWRF
trunk@4391
|
This class reads one or more tcvitals files and rewrites them as requested. More...
This class reads one or more tcvitals files and rewrites them as requested.
Definition at line 38 of file revital.py.
Public Member Functions | |
def | __init__ |
Creates a Revital object: More... | |
def | append (self, vital) |
Appends a vital entry to self.vitals. More... | |
def | extend (self, vitals) |
Given the specified iterable object, appends its contents to my own. More... | |
def | copy (self) |
Returns a deep copy of this Revital. More... | |
def | readvitals |
Same as readfiles except the tcvitals have already been parsed and the vitals are being passed in, not the filelist. More... | |
def | readfiles |
Reads the list of files and parses them as tcvitals files. More... | |
def | move_latlon (self, vital, dt) |
Returns a tuple containing the latitude and longitude of the storm at a different position according to the storm motion vector. More... | |
def | readcarq (self, longstormid) |
Tries to find the CARQ data for the specified storm. More... | |
def | clean_up_vitals |
Calls the hwrf.storminfo.clean_up_vitals on this object's vitals. More... | |
def | renumber |
Renumbers storms with numbers 90-99, if possible, to have the same number as later 1-49 numbered storms. More... | |
def | delete_invest_duplicates (self) |
Deletes Invest entries that have the same location and time as non-invest entries. More... | |
def | swap_numbers (self) |
Calls swap_numbers on all vitals to swap old and new storm IDs. More... | |
def | mirror_renumbered_vitals (self) |
Duplicates all vitals that have been renumbered, creating one StormInfo with the old number and one with the new number. More... | |
def | discard_except (self, keep_condition) |
Discards all vitals except those for which the keep_condition function returns True. More... | |
def | swap_names (self) |
This subroutine undoes the effect of renaming by swapping old and new names. | |
def | rename (self) |
This subroutine renames storms so that they have the last name seen for their storm number. More... | |
def | add_stormtype (self) |
Add the storm type parameter from the CARQ entries in the A deck. More... | |
def | sort_by_function (self, cmpfun) |
Resorts the vitals using the specified cmp-like function. More... | |
def | sort_by_storm (self) |
Resorts the vitals by storm instead of date. More... | |
def | __iter__ (self) |
Iterates over all vitals, yielding StormInfo objects for each one. More... | |
def | each |
Iterates over all vitals that match the specified stormid. More... | |
def | print_vitals |
Print the vitals to the given stream in a specified format. More... | |
def | hrd_multistorm_sorter (self, a, b) |
A drop-in replacement for "cmp" that can be used for sorting or comparison. More... | |
def | multistorm_priority (self) |
Does nothing. More... | |
Public Attributes | |
carqdat | |
Contains CARQ entries read from the adeckdir A deck files. More... | |
carqfail | |
Set of longstormid entries that had no CARQ data. More... | |
vitals | |
The list of hwrf.storminfo.StormInfo objects being revitalized. More... | |
search_dx | |
Search radius in km for deciding whether two storms are the same. More... | |
search_dt | |
Search timespan for finding two storms that are the same. | |
logger | |
The logging.Logger to use for log messages. | |
debug | |
If True, send numerous extra log messages at DEBUG level. More... | |
invest_number_name | |
Rename stores to have the last non-INVEST name seen. | |
adeckdir | |
Directory with A deck files. More... | |
is_cleaned | |
Has clean_up_vitals() been called since the last operation that modified the vitals? | |
Protected Member Functions | |
def | renumber_one (self, vital, lastvit, vit_motion, other_motion, threshold) |
Internal function that handles renumbering of storms. More... | |
def hwrf.revital.Revital.__init__ | ( | self, | |
logger = None , |
|||
invest_number_name = False , |
|||
stormid = None , |
|||
adeckdir = None , |
|||
renumberlog = None , |
|||
search_dx = 200e3 , |
|||
search_dt = None , |
|||
debug = True , |
|||
copy = None |
|||
) |
Creates a Revital object:
logger | A logging.Logger object for logging or None to disable. Default: None |
invest_number_name | Rename storms to have the last non-INVEST name seen |
stormid | Ignored. |
adeckdir | Directory with A deck files. This is used to read the storm type information from CARQ entries and append them to produce vitals with the storm type from vitals that lack it. |
renumberlog | Ignored. |
search_dx | Search radius in km for deciding whether two storms are the same. |
search_dt | Search timespan for finding two storms that are the same. |
debug | If True, enables DEBUG level logging. |
copy | Used by copy() to make a shallow copy of a Revital. If specified, the other arguments are ignored, and the copy's contents are copied. Do not use this argument. If you need a copy, use copy() instead. |
Definition at line 43 of file revital.py.
def hwrf.revital.Revital.__iter__ | ( | self | ) |
Iterates over all vitals, yielding StormInfo objects for each one.
Definition at line 576 of file revital.py.
def hwrf.revital.Revital.add_stormtype | ( | self | ) |
Add the storm type parameter from the CARQ entries in the A deck.
Definition at line 541 of file revital.py.
def hwrf.revital.Revital.append | ( | self, | |
vital | |||
) |
Appends a vital entry to self.vitals.
vital | an hwrf.storminfo.StormInfo to append |
Definition at line 130 of file revital.py.
def hwrf.revital.Revital.clean_up_vitals | ( | self, | |
name_number_checker = None , |
|||
basin_center_checker = None , |
|||
vitals_cmp = None |
|||
) |
Calls the hwrf.storminfo.clean_up_vitals on this object's vitals.
The optional arguments are passed to hwrf.storminfo.clean_up_vitals.
name_number_checker | a function like hwrf.storminfo.name_number_okay() for validating the storm name and number |
vitals_cmp | a cmp-like function for ordering hwrf.storminfo.StormInfo objects |
basin_center_checker | a function like hwrf.storminfo.basin_center_okay() for checking the storm basin and forecast center (RSMC) |
Definition at line 243 of file revital.py.
Referenced by hwrf.revital.Revital.readcarq(), and hwrf.revital.Revital.renumber().
def hwrf.revital.Revital.copy | ( | self | ) |
Returns a deep copy of this Revital.
Modifying the copy will not modify the original.
Definition at line 142 of file revital.py.
Referenced by produtil.mpiprog.MPIRanksSPMD.__add__(), hwrf.storminfo.StormInfo.__add__(), produtil.mpiprog.MPIRank.__add__(), produtil.mpiprog.MPIRank.__getitem__(), produtil.prog.ImmutableRunner.runner(), hwrf.wrf.WRFSimulation.swcorner_dynamic(), and hwrf.wrf.WRFSimulation.swcorner_dynamic_multistorm().
def hwrf.revital.Revital.delete_invest_duplicates | ( | self | ) |
Deletes Invest entries that have the same location and time as non-invest entries.
Definition at line 453 of file revital.py.
Referenced by hwrf.revital.Revital.renumber().
def hwrf.revital.Revital.discard_except | ( | self, | |
keep_condition | |||
) |
Discards all vitals except those for which the keep_condition function returns True.
keep_condition | A function that receives a StormInfo object as its only argument, returning True if the vital should be kept and False if not. |
Definition at line 498 of file revital.py.
def hwrf.revital.Revital.each | ( | self, | |
stormid = None , |
|||
old = False |
|||
) |
Iterates over all vitals that match the specified stormid.
If no stormid is given, iterates over all vitals.
stormid | the storm ID to search for. This can be a stormid3, stormid4 or longstormid. |
old | If old=True, also searches the old_ copy of the stormid. Any of stormid3, stormid4 or longstormid are accepted. |
Definition at line 580 of file revital.py.
Referenced by hwrf.revital.Revital.print_vitals().
def hwrf.revital.Revital.extend | ( | self, | |
vitals | |||
) |
Given the specified iterable object, appends its contents to my own.
vitals | an iterable object filled with hwrf.storminfo.StormInfo |
Definition at line 136 of file revital.py.
def hwrf.revital.Revital.hrd_multistorm_sorter | ( | self, | |
a, | |||
b | |||
) |
A drop-in replacement for "cmp" that can be used for sorting or comparison.
Returns -1 if a<b, 1 if a>b or 0 if a=b. Decision is made in this order:
If all of the above values are equal, 0 is returned.
a,b | the vitals to compare |
Definition at line 660 of file revital.py.
def hwrf.revital.Revital.mirror_renumbered_vitals | ( | self | ) |
Duplicates all vitals that have been renumbered, creating one StormInfo with the old number and one with the new number.
Definition at line 486 of file revital.py.
def hwrf.revital.Revital.move_latlon | ( | self, | |
vital, | |||
dt | |||
) |
Returns a tuple containing the latitude and longitude of the storm at a different position according to the storm motion vector.
vital | the hwrf.storminfo.StormInfo for the storm fix being extrapolated |
dt | the time difference in hours |
Definition at line 202 of file revital.py.
Referenced by hwrf.revital.Revital.renumber_one().
def hwrf.revital.Revital.multistorm_priority | ( | self | ) |
Does nothing.
Definition at line 690 of file revital.py.
def hwrf.revital.Revital.print_vitals | ( | self, | |
stream, | |||
renumberlog = None , |
|||
format = 'line' , |
|||
stormid = None , |
|||
old = False |
|||
) |
Print the vitals to the given stream in a specified format.
stream | The stream (eg.: opened file) to receive the vitals. |
format | Either "tcvitals" to reformat as tcvitals (cleaning up any errors); or "line" to simply print the original data for each line; or "HHS" to use the HHS output format. (Do not use the "HHS" option unless you are HHS.) |
renumberlog | If given, sends information about renaming and renumbering of the vitals to a second stream. |
stormid | The "stormid" argument is used to restrict printing to only a certain stormid. |
old | If True, then vitals with an old_stormid that matches are also printed. |
Definition at line 626 of file revital.py.
Referenced by hwrf.revital.Revital.each().
def hwrf.revital.Revital.readcarq | ( | self, | |
longstormid | |||
) |
Tries to find the CARQ data for the specified storm.
Reads it into the self.carqdat array, or adds the stormid to self.carqfail if the data cannot be read in.
longstormid | the long stormid of the storm to read |
Definition at line 222 of file revital.py.
Referenced by hwrf.revital.Revital.add_stormtype().
def hwrf.revital.Revital.readfiles | ( | self, | |
filelist, | |||
raise_all = True |
|||
) |
Reads the list of files and parses them as tcvitals files.
filelist | a list of string filenames |
raise_all | if True, all exceptions are raised. If False, then exceptions are ignored, and the function will attempt to process all files, even if earlier ones failed. |
Definition at line 169 of file revital.py.
def hwrf.revital.Revital.readvitals | ( | self, | |
vitalslist, | |||
raise_all = True |
|||
) |
Same as readfiles except the tcvitals have already been parsed and the vitals are being passed in, not the filelist.
This was created to handle the multistorm fake storm. This is being used to validate any self generated vitals by the fake storm.
vitalslist | a list of strings with tcvitals data |
raise_all | if True, raise exceptions for any parsing errors. |
Definition at line 147 of file revital.py.
def hwrf.revital.Revital.rename | ( | self | ) |
This subroutine renames storms so that they have the last name seen for their storm number.
Definition at line 522 of file revital.py.
def hwrf.revital.Revital.renumber | ( | self, | |
unrenumber = False , |
|||
clean = True , |
|||
threshold = 0 , |
|||
discard_duplicates = True |
|||
) |
Renumbers storms with numbers 90-99, if possible, to have the same number as later 1-49 numbered storms.
Loops over all vitals from last to first, renumbering 90-99 storms to have the same storm number as later 1-49 storms.
threshold | If a threshold is given, then a cycle will only be considered for renumbering if it is either above that threshold, or is not an Invest. |
unrenumber | If unrenumber is True, the original storm numbers are restored after renumbering. |
discard_duplicate | If True, discard invests that are duplicates of non-invests. This feature is disabled if unrenumber is enabled or cleaning is disabled. |
clean | If clean is True (the default), then self.clean_up_vitals is called, which will (among other things) delete vitals lines that have the same time and storm ID. The cleaning is done after unrenumbering, so if both options are turned on, the result will contain only one entry per storm ID per time, but with all storm IDs that are available for a given storm at any one time. |
Definition at line 382 of file revital.py.
Referenced by hwrf.revital.Revital.renumber_one().
|
protected |
Internal function that handles renumbering of storms.
This is an internal implementation function that should never be called directly. It handles part of the work of renumbering storms in the list of vitals. You should call "renumber" instead.
vital | the vital being renumbered |
lastvit | the last vital seen |
vit_motion | time since vital |
other_motion | time since other storms vital |
threshold | cold start threshold, used to decide when to stop connecting an invest to a non-invest |
Definition at line 265 of file revital.py.
Referenced by hwrf.revital.Revital.renumber().
def hwrf.revital.Revital.sort_by_function | ( | self, | |
cmpfun | |||
) |
Resorts the vitals using the specified cmp-like function.
cmpfun | a cmp-like function for comparing hwrf.storminfo.StormInfo objects |
Definition at line 567 of file revital.py.
def hwrf.revital.Revital.sort_by_storm | ( | self | ) |
Resorts the vitals by storm instead of date.
See hwrf.storminfo.vit_cmp_by_storm for details.
Definition at line 572 of file revital.py.
def hwrf.revital.Revital.swap_numbers | ( | self | ) |
Calls swap_numbers on all vitals to swap old and new storm IDs.
Definition at line 480 of file revital.py.
Referenced by hwrf.revital.Revital.renumber().
hwrf.revital.Revital.adeckdir |
Directory with A deck files.
This is used to read the storm type information from CARQ entries and append them to produce vitals with the storm type from vitals that lack it.
Definition at line 83 of file revital.py.
Referenced by hwrf.revital.Revital.__init__(), and hwrf.revital.Revital.readcarq().
hwrf.revital.Revital.carqdat |
Contains CARQ entries read from the adeckdir A deck files.
Definition at line 70 of file revital.py.
Referenced by hwrf.revital.Revital.add_stormtype(), and hwrf.revital.Revital.readcarq().
hwrf.revital.Revital.carqfail |
Set of longstormid entries that had no CARQ data.
Definition at line 75 of file revital.py.
Referenced by hwrf.revital.Revital.readcarq().
hwrf.revital.Revital.debug |
If True, send numerous extra log messages at DEBUG level.
Definition at line 81 of file revital.py.
Referenced by hwrf.revital.Revital.__init__(), hwrf.revital.Revital.add_stormtype(), hwrf.revital.Revital.readfiles(), hwrf.revital.Revital.readvitals(), hwrf.revital.Revital.rename(), hwrf.revital.Revital.renumber(), and hwrf.revital.Revital.renumber_one().
hwrf.revital.Revital.search_dx |
Search radius in km for deciding whether two storms are the same.
Definition at line 78 of file revital.py.
Referenced by hwrf.revital.Revital.__init__(), and hwrf.revital.Revital.renumber_one().
hwrf.revital.Revital.vitals |
The list of hwrf.storminfo.StormInfo objects being revitalized.
Definition at line 76 of file revital.py.
Referenced by hwrf.revital.Revital.__iter__(), hwrf.revital.Revital.add_stormtype(), hwrf.revital.Revital.clean_up_vitals(), hwrf.revital.Revital.delete_invest_duplicates(), hwrf.revital.Revital.discard_except(), hwrf.revital.Revital.each(), setup_hurricane.StormCurses.event_loop(), setup_hurricane.StormCurses.fill_source_and_priority(), setup_hurricane.StormCurses.get_curses_mouse(), setup_hurricane.StormCurses.init_hwrf_gfdl(), setup_hurricane.StormCurses.make_storm_indices(), hwrf.revital.Revital.mirror_renumbered_vitals(), hwrf.revital.Revital.readfiles(), hwrf.revital.Revital.readvitals(), hwrf.revital.Revital.rename(), hwrf.revital.Revital.renumber(), setup_hurricane.StormCurses.resort(), setup_hurricane.StormCurses.setup(), setup_hurricane.StormCurses.setup_confirmation(), setup_hurricane.StormCurses.show_storm_details(), setup_hurricane.StormCurses.show_storm_screen(), setup_hurricane.StormCurses.show_storm_table(), setup_hurricane.StormCurses.show_storm_table_line(), hwrf.revital.Revital.sort_by_function(), hwrf.revital.Revital.sort_by_storm(), hwrf.revital.Revital.swap_names(), hwrf.revital.Revital.swap_numbers(), and setup_hurricane.StormCurses.toggle_run().