HWRF  trunk@4391
Public Member Functions | Public Attributes | Properties | List of all members
hwrf.wrf.WRFDomain Class Reference

A domain in a WRF simulation. More...

Detailed Description

A domain in a WRF simulation.

This subclass of WRFDomainsBase adds needed details that let it provide information about a domain in a WRF simulation. It can predict output and input filenames based on timesteps and start/end times. It can do complex manipulations of the WRF namelist. Most functionality should be accessed via the WRFSimulation, after a WRFDomain is created.

Note that after you provide a WRFDomain to a WRFSimulation, the WRFSimulation makes its own copy of that WRFDomain. The original is unmodified. That means that if you want details on the namelist and output files added by the WRFSimultion, you must obtain its copy of the WRFDomain like so:

1 moad=WRFDomain(conf,'moad')
2 storm1outer=WRFDomain(conf,'storm1outer')
3 storm1inner=WRFDomain(conf,'storm1inner')
4 wrf=WRFSimulation(conf,'wrf',moad,conf.cycle,
5  conf.cycle+hwrf.numerics.to_timedelta(fcstlen*3600))
6 wrf.add(storm1outer,moad)
7 wrf.add(storm1inner,storm1outer)
8 wrf.add_output('history',step=3600*3,end=9*3600)
9 sim_moad=wrf[moad]
10 sim_storm1outer=wrf[storm1outer]
11 sim_storm1inner=wrf[storm1inner]

In this example, the sim_moad, sim_storm1inner and sim_storm1outer will be new objects, contained within the WRFSimulation named "wrf". They will contain additional information about the WRFDomain that is not in the original moad, storm1inner and storm1outer.

Definition at line 117 of file wrf.py.

Inheritance diagram for hwrf.wrf.WRFDomain:
hwrf.wrfbase.WRFDomainBase

Public Member Functions

def __init__
 WRFDomain constructor. More...
 
def add_hifreq (self)
 
def moad_ratio (self)
 Returns the nesting ratio between this domain and the MOAD. More...
 
def getdt (self)
 Returns the timestep for this domain. More...
 
def __repr__ (self)
 A string description of this domain.
 
def copy (self)
 Returns a deep copy of this object. More...
 
def set_timing (self, start, end, timestep)
 Sets start and end times and timestep. More...
 
def get_grid_id (self)
 Returns the WRF grid id. More...
 
def is_moad (self)
 Is this the outermost domain? More...
 
def nx (self)
 The number of grid cells the X direction. More...
 
def ny (self)
 The number of grid cells the Y direction. More...
 
def nz (self)
 The number of grid cells the Z direction. More...
 
def init_domain (self, grid_id)
 Internal helper function that initializes variables common to all domains. More...
 
def init_as_moad (self, simstart, simend, simdt, eta_levels)
 Called by WRFSimulation to initialize this as the outermost domain. More...
 
def init_as_nest (self, parent, grid_id, start, end)
 Called by WRFSimulation to initialize this domain as a nest. More...
 
def make_namelist (self)
 Creates the WRF namelist contents and returns it as a string. More...
 
def has_output (self, stream)
 Returns True if the domain will output to the specified stream. More...
 
def get_output_range (self, stream)
 Returns the range of times that has output for the given stream. More...
 
def hifreq_file (self)
 Returns the hifreq filename for this domain. More...
 
def trackpatcf_file (self)
 
def get_all_outputs
 Iterate over all output files for a specified time. More...
 
def get_outputs (self, stream)
 Iterates over all outputs for a specified stream. More...
 
def get_output
 Get output for a specified time and stream. More...
 
def no_output (self, stream)
 Forget that output was requested for a given stream. More...
 
def hide_output (self, stream)
 Disable output for a specified stream, if the stream was requested before. More...
 
def add_output
 Adds output to the specified stream. More...
 
def interval_for (self, stream)
 Return the output interval for the stream. More...
 
- Public Member Functions inherited from hwrf.wrfbase.WRFDomainBase
def __init__
 Creates a new WRFDomainBase. More...
 
def __hash__ (self)
 an integer representation for hashing
 
def __repr__ (self)
 a detailed string representation
 
def __cmp__ (self, other)
 integer comparison for sorting, like the cmp function. More...
 
def __str__ (self)
 synonym for repr()
 
def get_anl_time (self)
 returns the analysis time More...
 
def get_grid_id (self)
 Raises NotImplementedError. More...
 
def remove_forbidden (self)
 removes forbidden namelist entries More...
 
def copy (self)
 Returns a copy of this object. More...
 
def set_timing (self, start, end, timestep)
 sets the start and end times of this domain, and the domain timestep More...
 
def init_domain (self, grid_id)
 initializes grid ID and non-nesting-related variables More...
 
def init_as_moad (self, simstart, simend, simdt, eta_levels)
 initializes this domain as the outermost domain More...
 
def init_as_nest (self, parent, grid_id, start, end)
 initializes this domain as a nest More...
 
def make_namelist (self)
 creates the wrf namelist as a string, and returns it. More...
 

Public Attributes

 nestlevel
 The WRF domain nesting level.
 
 parent
 The parent WRFDomain.
 
 nocolons
 True if colons should be omitted from filenames.
 
 dx
 the resolution in the rotated longitude direction
 
 dy
 the resolution in the rotated latitude direction
 
 nl
 The hwrf.namelist.Conf2Namelist for this domain.
 
 name
 The name of this domain. More...
 
- Public Attributes inherited from hwrf.wrfbase.WRFDomainBase
 nestlevel
 the wrf nesting level
 
 parent
 the parent domain
 
 nocolons
 should colons be eliminated from filenames?
 
 nl
 the hwrf.namelist.Conf2Namelist with namelist information for this domain
 
 name
 the name of this domain
 

Properties

 dt = property(getdt,None,None,'The timestep for this domain.')
 read-only property containing the domain timestep
 

Constructor & Destructor Documentation

def hwrf.wrf.WRFDomain.__init__ (   self,
  conf,
  section,
  name = None,
  copy = None 
)

WRFDomain constructor.

Creates a new WRFDomain based on the information in a section of the HWRFConfig object conf. The domain's name is in "name." The "copy" argument should never be specified: it is used by self.copy for deep copies of a WRFDomain.

Definition at line 174 of file wrf.py.

Member Function Documentation

def hwrf.wrf.WRFDomain.add_output (   self,
  stream,
  start = None,
  end = None,
  step = None,
  outname = None,
  frames_per_outfile = None,
  io_form = None,
  simstart = None 
)

Adds output to the specified stream.

Other arguments are optional:

Parameters
streamthe stream: "history" or "auxhistN" for an integer N>0
startoutput start time (anything accepted by to_datetime) Default: simulation start time.
endoutput end time (anything accepted by to_datetime. Default: simulation end time.
stepoutput interval, sent into to_out_interval(). Default: trait stream+"_interval" or 6hrs
outnameoutput name or array of output names (one per domain). Can only specify for all domains, not for only one. Default: leave unspecified, and let WRF use its defaults.
frames_per_outfilehow many output times per output file
io_formWRF IO form. Simply calls self.set_io_form(stream,io_form)
simstartthe simulation start time which must be provided fi start or end times are given

Definition at line 553 of file wrf.py.

Referenced by hwrf.wrf.WRFDomain.hide_output().

def hwrf.wrf.WRFDomain.copy (   self)

Returns a deep copy of this object.

Returns a deep copy of this object. The copy has its own data structures, so modifying the copy will not modify the original.

Definition at line 240 of file wrf.py.

Referenced by produtil.mpiprog.MPIRanksSPMD.__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.wrf.WRFDomain.get_all_outputs (   self,
  time = None 
)

Iterate over all output files for a specified time.

Iterates over all output files as WRFOutput objects. If a time is specified, then only outputs for that time are yielded.

Parameters
timethe time of interest, or None (the default)

Definition at line 455 of file wrf.py.

def hwrf.wrf.WRFDomain.get_grid_id (   self)

Returns the WRF grid id.

Definition at line 261 of file wrf.py.

Referenced by hwrf.wrf.WRFDomain.hifreq_file(), hwrf.wrf.WRFDomain.is_moad(), and hwrf.wrf.WRFDomain.trackpatcf_file().

def hwrf.wrf.WRFDomain.get_output (   self,
  stream,
  time,
  logger = None 
)

Get output for a specified time and stream.

Returns a WRFOutput object for the output file for the specified stream and time, or None if no such file exists. Will return the first output time not before the given time.

Parameters
streamthe desired stream
timethe desired time
loggerif specified, a logging.Logger to log to

Definition at line 491 of file wrf.py.

Referenced by hwrf.wrf.WRFDomain.get_all_outputs().

def hwrf.wrf.WRFDomain.get_output_range (   self,
  stream 
)

Returns the range of times that has output for the given stream.

Returns
a tuple containing the first output time, last output time and output interval for this domain and the specified stream.
Parameters
streamthe stream for whom output is requested

Definition at line 389 of file wrf.py.

Referenced by hwrf.wrf.WRFDomain.get_output(), and hwrf.wrf.WRFDomain.get_outputs().

def hwrf.wrf.WRFDomain.get_outputs (   self,
  stream 
)

Iterates over all outputs for a specified stream.

Iterates over all output files for the specified stream, as WRFOutput objects.

Parameters
streamthe string name of the output stream

Definition at line 468 of file wrf.py.

Referenced by hwrf.wrf.WRFDomain.get_all_outputs().

def hwrf.wrf.WRFDomain.getdt (   self)

Returns the timestep for this domain.

Definition at line 218 of file wrf.py.

def hwrf.wrf.WRFDomain.has_output (   self,
  stream 
)

Returns True if the domain will output to the specified stream.

Checks the internal data structures maintained by add_output to see if output was requested for the specified stream.

Parameters
streamthe stream to check
Returns
True if the domain will output to the specified stream, and False if it won't (as far as we know).

Definition at line 379 of file wrf.py.

Referenced by hwrf.wrf.WRFDomain.get_output_range().

def hwrf.wrf.WRFDomain.hide_output (   self,
  stream 
)

Disable output for a specified stream, if the stream was requested before.

If output is enabled for the specified stream, moves the output start time to after the end of the simulation. That way any WRF code relying on the output frequency will still work, but no output will be generated. Will not work for restart stream since that is not controlled on a per-domain basis. Note that code that queries the output times will break if this is called.

Parameters
streamthe string name of the stream of disinterest

Definition at line 522 of file wrf.py.

def hwrf.wrf.WRFDomain.hifreq_file (   self)

Returns the hifreq filename for this domain.

Definition at line 409 of file wrf.py.

Referenced by hwrf.wrf.WRFDomain.trackpatcf_file().

def hwrf.wrf.WRFDomain.init_as_moad (   self,
  simstart,
  simend,
  simdt,
  eta_levels 
)

Called by WRFSimulation to initialize this as the outermost domain.

Do not call this function directly. It is called by the WRFSimulation to initialize the domain as the Mother Of All Domains (MOAD).

Parameters
simstartthe simulation start time
simendthe simulation end time
simdtthe outermost domain timestep
eta_levelsthe NMM eta levels

Definition at line 298 of file wrf.py.

def hwrf.wrf.WRFDomain.init_as_nest (   self,
  parent,
  grid_id,
  start,
  end 
)

Called by WRFSimulation to initialize this domain as a nest.

Do not call this function directly. It is called by the WRFSimulation to initialize the domain as a nest

Parameters
parentthe parent WRFDomain
grid_idthe integer grid_id
startthe domain start time
endthe domain end time

Definition at line 328 of file wrf.py.

def hwrf.wrf.WRFDomain.init_domain (   self,
  grid_id 
)

Internal helper function that initializes variables common to all domains.

Initializes domain variables that are needed by all domains. This is called as a helper function to the other domain initialization variables.

Definition at line 284 of file wrf.py.

Referenced by hwrf.wrfbase.WRFDomainBase.init_as_nest().

def hwrf.wrf.WRFDomain.interval_for (   self,
  stream 
)

Return the output interval for the stream.

Returns the output interval for the specified stream, or None if the stream is disabled.

Parameters
streamthe stream of interest

Definition at line 651 of file wrf.py.

def hwrf.wrf.WRFDomain.is_moad (   self)

Is this the outermost domain?

Returns True if this is the WRF Mother of All Domains (MOAD) and False otherwise. The MOAD is the outermost domain.

Definition at line 264 of file wrf.py.

Referenced by hwrf.wrf.WRFDomain.add_output(), and hwrf.wrf.WRFDomain.hide_output().

def hwrf.wrf.WRFDomain.make_namelist (   self)

Creates the WRF namelist contents and returns it as a string.

Definition at line 376 of file wrf.py.

def hwrf.wrf.WRFDomain.moad_ratio (   self)

Returns the nesting ratio between this domain and the MOAD.

Definition at line 211 of file wrf.py.

def hwrf.wrf.WRFDomain.no_output (   self,
  stream 
)

Forget that output was requested for a given stream.

Removes the specified stream from the internal data structures. Its output will revert to the WRF default, and will be unavailable via this WRFDomain.

Parameters
streamthe string name of the stream of disinterest

Definition at line 514 of file wrf.py.

def hwrf.wrf.WRFDomain.nx (   self)

The number of grid cells the X direction.

Definition at line 273 of file wrf.py.

def hwrf.wrf.WRFDomain.ny (   self)

The number of grid cells the Y direction.

Definition at line 277 of file wrf.py.

def hwrf.wrf.WRFDomain.nz (   self)

The number of grid cells the Z direction.

Definition at line 281 of file wrf.py.

def hwrf.wrf.WRFDomain.set_timing (   self,
  start,
  end,
  timestep 
)

Sets start and end times and timestep.

Sets this WRFDomain's idea of the simulation start and end times and timestep.

Parameters
startthe start time of the domain
endthe end time of the domain
timestepthe domain's timestep

Definition at line 247 of file wrf.py.

Referenced by hwrf.wrfbase.WRFDomainBase.init_as_nest().

def hwrf.wrf.WRFDomain.trackpatcf_file (   self)
Returns the track patcf file for this domain. 

Definition at line 413 of file wrf.py.

Member Data Documentation

hwrf.wrf.WRFDomain.name

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