HWRF  trunk@4391
exceptions.py
1 """!Exceptions raised by the hwrf package
2 
3 This module contains exceptions raised by the hwrf package. The only
4 exceptions are the hwrf.revital and hwrf.storminfo modules which
5 contain their own exceptions for backward compatibility to old
6 scripts."""
7 
8 class HWRFError(Exception):
9  """!Base class of all exceptions in this module.
10 
11  This is the base class of exceptions raised by the HWRF module
12  due to HWRF-specific failures. It is possible to get other
13  exceptions from the StandardException hierarchy in certain failure
14  cases. For example, trying to obtain the fifth of three domains
15  may raise KeyError. Also, see pom.exceptions for exceptions that
16  may be raised from the pom package. See the produtil package for
17  exceptions that may come from lower levels."""
18 
19 ########################################################################
20 # CONFIGURATION EXCEPTIONS
21 
23  """!Raised when more than one task is registered with the same
24  name in an HWRFConfig object."""
25 
27  """!Raised when one tries to use an invalid string for an option
28  name."""
29 
30 ########################################################################
31 # ARCHIVING EXCEPTIONS
32 
33 
34 ########################################################################
35 # NAMELIST-RELATED EXCEPTIONS
36 
37 class NamelistValueError(ValueError):
38  """!Raised when hwrf.namelist cannot convert a value to or from
39  Fortran namelist format."""
40 class NamelistKeyError(KeyError):
41  """!Raised when an hwrf.namelist is asked for a key that does not
42  exist."""
43  ##@var section
44  # the section that was searched
45 
46  ##@var var
47  # the option that was requested
48 
49  ##@var message
50  # the exception message
51 
52  def __init__(self,message,section,var):
53  """!Constructor.
54  @param message the string message
55  @param section the section that was searched
56  @param var the option that was requested"""
57  super(NamelistKeyError,self).__init__(message)
58  self.section=section
59  self.var=var
60  self.message=message
61  def __str__(self):
62  """!Generates a string description of this exception."""
63  if self.section=='-trait-':
64  return 'trait %s: %s' % (self.var,self.message)
65  else:
66  return '&%s %s: %s' % (self.section,self.var,self.message)
67  def __repr__(self):
68  """!Generates a string representation of this object."""
69  return 'NamelistError(%s,%s,%s)' % \
70  ( repr(self.message), repr(self.section), repr(self.var) )
71 
72 ########################################################################
73 # SANITY CHECKER EXCEPTIONS
74 
76  """!Base class of all sanity checker exceptions."""
77 class HWRFDirInsane(HWRFSanityError):
78  """!Raised when a directory is unspecified, missing or invalid."""
79  ##@var dir
80  # The directory in question.
81 
82  def __init__(self,message,dir):
83  """!HWRFDirInsane constructor.
84  @param message a string explanation of the problem
85  @param dir the directory in question"""
86  super(HWRFDirInsane,self).__init__(message)
87  self.dir=dir
89  """!Raised when the requested configuration conf or hwrf_expt files
90  fail a sanity check."""
91 class HWRFConfigUnsupported(HWRFConfigInsane):
92  """!Raised when the user requests a configuration that makes sense,
93  but is not supported."""
95  """!Raised when configuration files were specified in the wrong order."""
97  """!Raised when the configuration had a different storm than expected."""
99  """!Raised when the configuration had a different cycle than expected."""
101  """!Raised when a sanity check on a variable's value failed."""
103  """!Raised when input files to HWRF fail a sanity check."""
105  """!Raised when HWRF scripts fail a sanity check."""
107  """!Raised when the HWRF executables fail a sanity check."""
109  """!Raised when the HWRF fix files fail a sanity check."""
111  """!Raised when the sanity check of the HWRF archiving settings
112  fails."""
113 
114 ########################################################################
115 # OCEAN AND WAVE EXCEPTIONS
116 
117 #NOTE: See pom.exceptions for more
119  """!Raised when the ocean init did not produce some expected outputs."""
121  """Raised when the parent global ocean model data was unavailable."""
123  """Raised when the HyCOM init foregets to choose an executable for
124  the forecast job."""
125 
127  """Raised when the wave initialization failes."""
129  """Raised when the wavewatch 3 cannot find necessary input."""
130 
131 ########################################################################
132 # COUPLING EXCEPTIONS
133 
135  """Superclass of atmosphere-ocean-wave-otherthings coupling
136  exceptions."""
138  """Raised when one requests a coupled forecast without specifying
139  what is being coupled."""
141  """Raised when the NCEP Coupler is to be used for coupling but its
142  namelist file is empty or missing."""
143 
144 ########################################################################
145 # GSI EXCEPTIONS
146 
148  """!Raised when GSI cannot find a required input file."""
149 
150 ########################################################################
151 # TRACKER EXCEPTIONS
152 
154  """!Base class of hwrf.tracker exceptions."""
156  """!Raised when an impossible tracker configuration is requested,
157  such as running with a grid that is both regional and global."""
159  """!Raised when multiple storms are requested, but only one was
160  expected."""
162  """!Base class of exceptions raised when the tracker's input files
163  are missing or invalid."""
165  """!Not currently used, this would be raised when GRIB inputs to
166  the tracker are missing."""
168  """!Raised when no location is specified for a tracker input GRIB
169  file."""
170 
171 ########################################################################
172 # TIME-RELATED EXCEPTIONS (used by many modules)
173 
175  """!Base class used for time-related HWRF exceptions."""
176 
177 # Time and timestep exceptions:
179  """!Raised when a timestep is invalid, such as a negative timestep
180  for a situation that requires a positive one."""
182  """!Called when one hour is not divisable by the WRF output
183  timestep."""
185  """!Raised when an output time is specified in two redundant ways.
186 
187  For example, one could specify a forecast time directly, and also
188  specify the analysis time and forecast time delta."""
190  """!Raised when a time was required, but none was provided."""
192  """!Raised when a timezone is provided. The hwrf package does not
193  support timezones: all times are in UTC."""
195  """!Raised when a time was requested with higher precision than available.
196 
197  Raised when a time was provided that contained fractions of a
198  second, for a function that cannot handle that. For example, the
199  WRF output files must be exactly on a second boundary."""
201  """!Raised when a time is outside the range of times being
202  processed by a function."""
204  """!Raised when an operation has a set of known times, but another
205  provided time is not near one of those known times."""
206 
208  """!Superclass of exceptions relating to groups of one or more
209  distinct times and relationships between them."""
210  ##@var start
211  # the start of the problematic timespan
212 
213  ##@var end
214  # the end of the problematic timespan
215 
216  def __init__(self,message,start,end):
217  """! Constructor for InvalidTimespan
218 
219  @param message the string explanation of the problem
220  @param start the start of the timespan
221  @param end the end of the timespan"""
222  super(InvalidTimespan,self).__init__(message)
223  self.start=start
224  self.end=end
226  """!Raised when the end of a timespan is before the beginning."""
227 class EndNotTimestep(InvalidTimespan):
228  """!Raised when the end of a timespan is not a timestep.
229  Presently unused.
230 
231  Presently unused, this was to indicate that the end of a timespan
232  is not on a timestep, for temporally discrete processes. Such end
233  times are allowed in WRF, so this exception is unused."""
235  """!Raised when a timespan's beginning is not at a timestep."""
237  """!Raised when a timestep is too long for the process under
238  consideration."""
240  """!Raised when a timestep is too short for the process under
241  consideration."""
243  """!Raised when a timespan was expected, but none was available."""
244 
245 ########################################################################
246 # REGRIB-RELATED EXCEPTIONS (mostly hwrf.regrib and hwrf.gribtask)
247 
249  """!Superclass of errors used by Regrib."""
251  """!Raised when a GRIB file is invalid.
252 
253  Raised when a GRIB file is provided, but that file is invalid.
254  This can be due to either an input to an operation, or the output
255  from the operation."""
257  """!Raised when a Regrib was expecting a GRIB subsetter function,
258  but no such function was provided."""
259 
261  """!Debug assetion in hwrf.regrib used to detect type mismatches.
262 
263  Part of debug assertions in hwrf.regrib, this is raised when the
264  wrong type is generated by the "make" function."""
265 
267  """!Superclass of errors relating to regrib products."""
269  """!Raised when an operation that produces input to Regrib should
270  have produced a Product, but produced nothing at all."""
272  """!Raised when an operation that provides input to Regrib produces
273  more than one product."""
275  """!Raised when a GRIB file should have an index file already, but
276  doesn't."""
277 
279  """!Base class of errors from the hwrf.regrib.RegribMany"""
281  """!Raised when a RegribMany is given an invalid name: one that
282  does not match a known grid or operation."""
283 
285  """!Base class of grid-related regrib errors."""
287  """!Raised when a grid was expected but none was provided."""
289  """!Raised when two GRIB files have non-matching grids, but a
290  matching grid is required."""
291 
293  """!Exceptions for hwrf.regrib.GRIBTask for certain internal errors.
294 
295  Raised by GRIBTask for unexpected errors that did not come from
296  the underlying RegribAll object. This is used in GRIBTask.run's
297  "run it now" mode, when setting raiseall=True."""
298 
299 ########################################################################
300 # WRF EXCEPTIONS
301 
303  """!Base class of WRF-related errors."""
305  """!Raised when it is no longer possible to add domains, but the
306  caller tried to add one."""
308  """!Base class of errors related to a WRF domain."""
309  def __init__(self,message,domainname=None):
310  """! WRFDomainError constructor.
311  @param message the string description of the message
312  @param domainname the name of the hwrf.wrf.WRFDomain in question"""
313  super(WRFDomainError,self).__init__(message)
314  self.domainname=domainname
315  ##@var domainname
316  # The domain in question, or None if unknown.
317 
319  """!Raised when the hwrf.wrf.WRFDomain start type is unrecognized.
320 
321  Raised when the conf value specifying the type of domain parent
322  start information contains invalid data (not "fixed" or "auto.")"""
323 class DomainExists(WRFDomainError):
324  """!Raised when adding a domain, if a domain by the same name
325  already exists."""
327  """!Raised when attempting to obtain information about when a WRF
328  stream outputs, if the stream is disabled."""
330  """!Raised when failing to run the real_nmm program."""
332  """!Raised when failing to set the parent start location via the
333  set_nest (set_ij_start) program."""
334 
335 ########################################################################
336 # FORECAST INPUT DATA EXCEPTIONS
337 
339  """!Parent class of exceptions specific to the hwrf.fcsttask module"""
341  """!Raised when wrf or real want to run but needed input data is missing."""
343  """!Raised when wrf or real want to run but geogrid data is missing"""
345  """!Raised when wrf or real want to run, but metgrid data is missing."""
347  """!Raised when wrf or real want to run, but wrfinput files are missing."""
349  """!Raised when wrf or real want to run, but wrfbdy files are missing."""
351  """!Raised when wrf or real want to run, but wrfanl files are missing."""
353  """!Raised when real wants prep_hybrid data, but that data is missing"""
354 
355 ########################################################################
356 # WPS EXCEPTIONS
357 
359  """!Base class of WPS-related exceptions."""
361  """!Raised when WPS inputs are implausable."""
363  """!Raised when geogrid did not create a log file."""
365  """!Raised when a geogrid output file is missing or empty."""
367  """!Raised when ungrib cannot find an input file it needs."""
369  """!Raised for hwrf.wps.Ungrib input problems.
370 
371  Raised when ungrib cannot figure out if an input file is GRIB1 or
372  GRIB2. This error usually means it is neither file type (or it is
373  empty)."""
375  """!Raised when wgrib or wgrib2 generates an empty or invalid file."""
377  """!Raised when hwrf.wps.Ungrib cannot subset files as requested.
378 
379  Raised when the caller wants to merge and subset GRIB files in
380  a single operation. The Ungrib class does not presently support
381  that."""
382 
383 ########################################################################
384 # PrepHybrid exceptions:
385 
387  """!Base class of exceptions related to the prep_hybrid program."""
389  """!Raised when the prep_hybrid program cannot find WPS geogrid
390  output data."""
392  """!Raised when the spectral input files to prep_hybrid do not
393  exist after some specified amount of time."""
394 
395 ########################################################################
396 # INPUT EXCEPTIONS
397 
399  """!Base class of exceptions related to the hwrf.input module."""
401  """!Raised when a configuration file requests a DataCatalog class
402  that does not exist."""
404  """!Raised when an input source is missing the location, or both
405  histprio and fcstprio."""
407  """!Raised when a file transfer, done by an InputSource, was
408  incomplete."""
410  """!Raised when a configuration file requests an unsupported data
411  transfer method (such as carrier pigeon)."""
412 
413 ########################################################################
414 # Post exceptions
415 
417  """!Raised upon errors that would cause a retry, in the
418  PostOneWRF.run when passed the raiseall=True argument."""
419 
421  """!Raised when the post's input file is not available and
422  raiseall=True in PostOneWRF.run"""
423 
424 ########################################################################
425 # Relocation exceptions
426 
428  """!Raised when something in the vortex relocation fails."""
430  """!Raised when required inputs to the relocation are missing."""
432  """!Raised when an impossible configuration is requested."""
434  """!Raised when a relocation program did not produce an expected
435  output file."""
437  """!Raised when the relocation could not find the prior cycle's 6hr
438  forecast, but it expected to be able to."""
440  """!Raised when the merge cannot find the storm_radius file in the
441  relocate or fix directory."""
443  """!Raised by hwrf.input when trying to get the wrong domain from
444  its hwrf.relocate.Relocate child objects."""
446  """Raised when the relocation could not find the prior cycle's
447  ensemble forecast track, but it expected to be able to."""
Raised when failing to set the parent start location via the set_nest (set_ij_start) program...
Definition: exceptions.py:331
Raised when a timestep is too long for the process under consideration.
Definition: exceptions.py:236
def __init__
WRFDomainError constructor.
Definition: exceptions.py:309
Raised when input files to HWRF fail a sanity check.
Definition: exceptions.py:102
Raised when one tries to use an invalid string for an option name.
Definition: exceptions.py:26
Raised when required inputs to the relocation are missing.
Definition: exceptions.py:429
def __init__(self, message, dir)
HWRFDirInsane constructor.
Definition: exceptions.py:82
Superclass of errors used by Regrib.
Definition: exceptions.py:248
def __init__(self, message, section, var)
Constructor.
Definition: exceptions.py:52
domainname
The domain in question, or None if unknown.
Definition: exceptions.py:314
Raised when an operation that provides input to Regrib produces more than one product.
Definition: exceptions.py:271
Raised when wgrib or wgrib2 generates an empty or invalid file.
Definition: exceptions.py:374
Raised when configuration files were specified in the wrong order.
Definition: exceptions.py:94
Raised when HWRF scripts fail a sanity check.
Definition: exceptions.py:104
Raised when a timestep is too short for the process under consideration.
Definition: exceptions.py:239
def __init__(self, message, start, end)
Constructor for InvalidTimespan.
Definition: exceptions.py:216
Raised when the relocation could not find the prior cycle's 6hr forecast, but it expected to be able ...
Definition: exceptions.py:436
Raised upon errors that would cause a retry, in the PostOneWRF.run when passed the raiseall=True argu...
Definition: exceptions.py:416
Raised when geogrid did not create a log file.
Definition: exceptions.py:362
Base class of WPS-related exceptions.
Definition: exceptions.py:358
Raised when an input source is missing the location, or both histprio and fcstprio.
Definition: exceptions.py:403
Raised when a Regrib was expecting a GRIB subsetter function, but no such function was provided...
Definition: exceptions.py:256
Raised when hwrf.namelist cannot convert a value to or from Fortran namelist format.
Definition: exceptions.py:37
Raised when a sanity check on a variable's value failed.
Definition: exceptions.py:100
end
the end of the problematic timespan
Definition: exceptions.py:224
Raised when the spectral input files to prep_hybrid do not exist after some specified amount of time...
Definition: exceptions.py:391
Raised when wrf or real want to run but needed input data is missing.
Definition: exceptions.py:340
Raised when wrf or real want to run, but wrfbdy files are missing.
Definition: exceptions.py:348
Base class of exceptions related to the hwrf.input module.
Definition: exceptions.py:398
start
the start of the problematic timespan
Definition: exceptions.py:223
Raised when an impossible configuration is requested.
Definition: exceptions.py:431
Base class of exceptions related to the prep_hybrid program.
Definition: exceptions.py:386
Raised when a file transfer, done by an InputSource, was incomplete.
Definition: exceptions.py:406
Raised when the HWRF executables fail a sanity check.
Definition: exceptions.py:106
Raised when more than one task is registered with the same name in an HWRFConfig object.
Definition: exceptions.py:22
Raised when it is no longer possible to add domains, but the caller tried to add one.
Definition: exceptions.py:304
Raised when two GRIB files have non-matching grids, but a matching grid is required.
Definition: exceptions.py:288
Raised when a geogrid output file is missing or empty.
Definition: exceptions.py:364
Base class used for time-related HWRF exceptions.
Definition: exceptions.py:174
Raised when a grid was expected but none was provided.
Definition: exceptions.py:286
Raised when wrf or real want to run but geogrid data is missing.
Definition: exceptions.py:342
Raised when the configuration had a different cycle than expected.
Definition: exceptions.py:98
Raised when a configuration file requests an unsupported data transfer method (such as carrier pigeon...
Definition: exceptions.py:409
Called when one hour is not divisable by the WRF output timestep.
Definition: exceptions.py:181
Raised when attempting to obtain information about when a WRF stream outputs, if the stream is disabl...
Definition: exceptions.py:326
Raised when an impossible tracker configuration is requested, such as running with a grid that is bot...
Definition: exceptions.py:155
Raised when the configuration had a different storm than expected.
Definition: exceptions.py:96
Base class of all exceptions in this module.
Definition: exceptions.py:8
Raised when no location is specified for a tracker input GRIB file.
Definition: exceptions.py:167
Raised when a configuration file requests a DataCatalog class that does not exist.
Definition: exceptions.py:400
Raised when wrf or real want to run, but wrfanl files are missing.
Definition: exceptions.py:350
Raised when wrf or real want to run, but wrfinput files are missing.
Definition: exceptions.py:346
Base class of exceptions raised when the tracker's input files are missing or invalid.
Definition: exceptions.py:161
Raised when an operation has a set of known times, but another provided time is not near one of those...
Definition: exceptions.py:203
Raised when the merge cannot find the storm_radius file in the relocate or fix directory.
Definition: exceptions.py:439
Raised when the sanity check of the HWRF archiving settings fails.
Definition: exceptions.py:110
Raised when the end of a timespan is before the beginning.
Definition: exceptions.py:225
Raised when a time was requested with higher precision than available.
Definition: exceptions.py:194
section
Raised when an hwrf.namelist is asked for a key that does not exist.
Definition: exceptions.py:58
Raised when failing to run the real_nmm program.
Definition: exceptions.py:329
Raised when a relocation program did not produce an expected output file.
Definition: exceptions.py:433
dir
The directory in question.
Definition: exceptions.py:87
Raised when a timespan was expected, but none was available.
Definition: exceptions.py:242
Raised when a timestep is invalid, such as a negative timestep for a situation that requires a positi...
Definition: exceptions.py:178
def __str__(self)
Generates a string description of this exception.
Definition: exceptions.py:61
var
the option that was requested
Definition: exceptions.py:59
message
the exception message
Definition: exceptions.py:60
Raised when something in the vortex relocation fails.
Definition: exceptions.py:427
Raised when the ocean init did not produce some expected outputs.
Definition: exceptions.py:118
Base class of WRF-related errors.
Definition: exceptions.py:302
Raised when an operation that produces input to Regrib should have produced a Product, but produced nothing at all.
Definition: exceptions.py:268
Raised when a time was required, but none was provided.
Definition: exceptions.py:189
def __repr__(self)
Generates a string representation of this object.
Definition: exceptions.py:67
Superclass of exceptions relating to groups of one or more distinct times and relationships between t...
Definition: exceptions.py:207
Raised when hwrf.wps.Ungrib cannot subset files as requested.
Definition: exceptions.py:376
Raised when the post's input file is not available and raiseall=True in PostOneWRF.run.
Definition: exceptions.py:420
Raised when WPS inputs are implausable.
Definition: exceptions.py:360
Raised when a timespan's beginning is not at a timestep.
Definition: exceptions.py:234
Parent class of exceptions specific to the hwrf.fcsttask module.
Definition: exceptions.py:338
Raised when a timezone is provided.
Definition: exceptions.py:191
Base class of grid-related regrib errors.
Definition: exceptions.py:284
Raised for hwrf.wps.Ungrib input problems.
Definition: exceptions.py:368
Raised when an hwrf.namelist is asked for a key that does not exist.
Definition: exceptions.py:40
Base class of errors related to a WRF domain.
Definition: exceptions.py:307
Raised when wrf or real want to run, but metgrid data is missing.
Definition: exceptions.py:344
Raised when a RegribMany is given an invalid name: one that does not match a known grid or operation...
Definition: exceptions.py:280
Base class of hwrf.tracker exceptions.
Definition: exceptions.py:153
Exceptions for hwrf.regrib.GRIBTask for certain internal errors.
Definition: exceptions.py:292
Base class of all sanity checker exceptions.
Definition: exceptions.py:75
Base class of errors from the hwrf.regrib.RegribMany.
Definition: exceptions.py:278
Raised when a time is outside the range of times being processed by a function.
Definition: exceptions.py:200
Raised when an output time is specified in two redundant ways.
Definition: exceptions.py:184
Raised when a GRIB file is invalid.
Definition: exceptions.py:250
Raised when the prep_hybrid program cannot find WPS geogrid output data.
Definition: exceptions.py:388
Raised by hwrf.input when trying to get the wrong domain from its hwrf.relocate.Relocate child object...
Definition: exceptions.py:442
Raised when ungrib cannot find an input file it needs.
Definition: exceptions.py:366
Raised when GSI cannot find a required input file.
Definition: exceptions.py:147
Not currently used, this would be raised when GRIB inputs to the tracker are missing.
Definition: exceptions.py:164
Raised when the HWRF fix files fail a sanity check.
Definition: exceptions.py:108
Raised when multiple storms are requested, but only one was expected.
Definition: exceptions.py:158
Raised when a GRIB file should have an index file already, but doesn't.
Definition: exceptions.py:274
Raised when the requested configuration conf or hwrf_expt files fail a sanity check.
Definition: exceptions.py:88
Raised when real wants prep_hybrid data, but that data is missing.
Definition: exceptions.py:352
Debug assetion in hwrf.regrib used to detect type mismatches.
Definition: exceptions.py:260
Superclass of errors relating to regrib products.
Definition: exceptions.py:266
Raised when the hwrf.wrf.WRFDomain start type is unrecognized.
Definition: exceptions.py:318