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

generate and manipulate wrf namelists, predict output filenames More...

Detailed Description

generate and manipulate wrf namelists, predict output filenames

The WRFSimulation class is at the core of the HWRF scripting system. It stores information about every aspect of the WRF namelist, and can manipulate it in complex ways. It automatically generates I/O information, and can predict output and input filenames no matter what crazy timesteps and start/end times you select. There are a number of safeguards that will raise exceptions in Python if you try to set up a simulation that is not possible in WRF.

Definition at line 663 of file wrf.py.

Inheritance diagram for hwrf.wrf.WRFSimulation:
hwrf.wrfbase.WRFDomains

Public Member Functions

def copy (self)
 Makes a deep copy of this object. More...
 
def __init__
 Creates a new WRFSimulation object: More...
 
def set_nprocs
 Sets nproc_x and nproc_y in the namelist. More...
 
def add_hifreq (self, nestlevel)
 
def set_dm_task_split
 
def has_output (self, stream)
 Does this stream have any outputs? More...
 
def set_io_servers
 Sets the I/O server configuration in WRF. More...
 
def nio_tasks_per_group (self)
 The number of I/O server tasks per group.
 
def nio_groups (self)
 The number of I/O server groups.
 
def set_bdystep (self, step)
 Sets the boundary input interval (interval_seconds) More...
 
def bdystep (self)
 Returns the boundary input interval (interval_seconds) More...
 
def bdyepsilon (self)
 Returns the epsilon for boundary time equality comparison. More...
 
def bdytimes (self)
 Iterates over boundary times. More...
 
def num_tiles (self)
 Returns the number of OpenMP tiles per MPI patch. More...
 
def set_tiling (self, x, y)
 Sets the OpenMP tiling information. More...
 
def wrf_namelist
 Generates a Conf2Namelist for this simulation. More...
 
def analysis_out
 Requests that this WRF simulation write analysis files. More...
 
def analysis_in
 Requests that this WRF simulation read an analysis file. More...
 
def set_wrfanl_outname (self, pattern)
 Sets the WRF wrfanl output file pattern for all domains. More...
 
def analysis_name (self, domain)
 Returns the wrfanl name for the specified domain. More...
 
def restart_in (self, restartsource)
 Requests reading of a restart file. More...
 
def set_active_io_form_to (self, io_form)
 Sets the io_form for all active streams. More...
 
def set_io_form
 Sets the io_form for the given stream. More...
 
def set_timing
 sets the simulation start and tend times, and timestep More...
 
def set_metgrid_levels_from
 Sets the num_metgrid_levels and num_metgrid_soil_levels. More...
 
def swcorner_dynamic
 Suns swcorner_dynamic to set domain start locations. More...
 
def swcorner_dynamic_multistorm
 
- Public Member Functions inherited from hwrf.wrfbase.WRFDomains
def copy (self)
 duplicates this object More...
 
def __init__
 WRFDomains constructor. More...
 
def fill_auto_starts
 sets i_parent_start and j_parent_start if needed More...
 
def fill_auto_starts_multistorm
 
def simstart (self)
 Returns the simulation start time as a datetime.datetime. More...
 
def simend (self)
 Returns the simulation end time as a datetime.datetime. More...
 
def timestep (self)
 Returns the simulation timestep as a datetime.time_delta. More...
 
def nocolons (self)
 Should colons be omitted from filenames? More...
 
def get_nocolons (self)
 Force a recheck of whether colons be omitted from filenames. More...
 
def get_io_form (self)
 Gets the default io_form. More...
 
def set_io_form (self, i)
 Sets the default io_form. More...
 
def io_form_for (self, stream)
 Returns the io_form for the specified stream. More...
 
def get_moad (self)
 returns the MOAD as a WRFDomain. More...
 
def get_last (self)
 returns the last domain added to this WRF. More...
 
def add_output
 request output from one or more streams More...
 
def make_restart_time_scalar (self)
 Ensure that only one restart frequency is set. More...
 
def set_outname (self, stream, outname)
 Set the wrf output filename for a stream. More...
 
def set_io_form (self, stream, io_form)
 Sets the io_form for the specified stream. More...
 
def get_io_suffix
 Return the suggested output suffix for filenames. More...
 
def get (self, what)
 return the specified domain More...
 
def maxdom (self)
 returns the highest domain number, which is also the number of domains. More...
 
def can_add (self)
 Can we still add domains to this simulation? More...
 
def add
 Add a WRFDomain to this simulation. More...
 
def __getitem__ (self, what)
 Same as self.get(what) More...
 
def __len__ (self)
 Same as self.maxdom(). More...
 
def __contains__ (self, what)
 does this simulation contain this domain? More...
 
def __iter__ (self)
 Iterates over all WRFDomain objects in this WRFDomains. More...
 

Additional Inherited Members

- Public Attributes inherited from hwrf.wrfbase.WRFDomains
 nl
 the hwrf.namelist.Conf2Namelist with domain-independent namelist information like eta_levels and debug=2. More...
 
- Properties inherited from hwrf.wrfbase.WRFDomains
 io_form
 the default io_form if none is specified More...
 

Constructor & Destructor Documentation

def hwrf.wrf.WRFSimulation.__init__ (   self,
  conf,
  section,
  moad,
  simstart,
  simend,
  timestep = None,
  dup = None 
)

Creates a new WRFSimulation object:

Creates a new WRFSimulation object.

Parameters
confthe HWRFConfig to provide configuration information
sectionthe section to use in that config object
moadthe Mother of All Domains, as a WRFDomain
simstart,simend- simulation start and end times
timestepthe simulation timestep
dupdo not use. This is used by the self.copy() do do a deep copy of a WRFDomains.

Definition at line 687 of file wrf.py.

Member Function Documentation

def hwrf.wrf.WRFSimulation.add_hifreq (   self,
  nestlevel 
)
Adds the WRF hifreq_d<domain>.htcf product to the 
specified domains of nestlevel in this simulation.

Definition at line 801 of file wrf.py.

def hwrf.wrf.WRFSimulation.analysis_in (   self,
  io_form = None 
)

Requests that this WRF simulation read an analysis file.

Sets up the namelist settings for reading analysis files

Parameters
io_formthe io_form for restart (wrfanl) files
Returns
self

Definition at line 1031 of file wrf.py.

def hwrf.wrf.WRFSimulation.analysis_name (   self,
  domain 
)

Returns the wrfanl name for the specified domain.

Produces an analysis filename for the specified domain. NOTE: this function assumes all domains have the same wrfanl filename format.

Parameters
domainthe wrf domain of interest (integer grid_id, string name or a WRFDomain object)
Returns
the filename as a string

Definition at line 1057 of file wrf.py.

def hwrf.wrf.WRFSimulation.analysis_out (   self,
  io_form = None 
)

Requests that this WRF simulation write analysis files.

Sets up the namelist settings for writing analysis files

Parameters
io_formthe io_form for restart (wrfanl) files
Returns
self

Definition at line 1020 of file wrf.py.

def hwrf.wrf.WRFSimulation.bdyepsilon (   self)

Returns the epsilon for boundary time equality comparison.

Returns the largest difference between two times such that they are considered identical. This is used in the context of WRF boundary input times. This is equal to bdystep()/10

Returns
a fractions.Fraction with the suggested epsilon for equality comparisons of boundary output time.

Definition at line 951 of file wrf.py.

def hwrf.wrf.WRFSimulation.bdystep (   self)

Returns the boundary input interval (interval_seconds)

Computes the interval at which this WRF simulation expects boundary conditions as a datetime.timedelta. This is done using the "bdystep" trait.

Returns
the boundary input interval (interval_seconds) as a datetime.timedelta

Definition at line 942 of file wrf.py.

Referenced by hwrf.wrf.WRFSimulation.bdytimes().

def hwrf.wrf.WRFSimulation.bdytimes (   self)

Iterates over boundary times.

Iterates over times at which this WRF simulation expects boundary conditions. Yields datetime objects for each time.

Definition at line 960 of file wrf.py.

def hwrf.wrf.WRFSimulation.copy (   self)

Makes a deep copy of this object.

Returns a deep copy of this object, providing new data structures so modifying the copy will not modify the original. The underlying WRFDomain objects and their data structures are also duplicated.

Definition at line 674 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.WRFSimulation.has_output (   self,
  stream 
)

Does this stream have any outputs?

Determines if the specified stream has output.

Returns
True if the stream if add_output() has been called for this stream, for any domain, and False otherwise.
Parameters
streamthe string name of the stream (lower-case).

Definition at line 871 of file wrf.py.

def hwrf.wrf.WRFSimulation.num_tiles (   self)

Returns the number of OpenMP tiles per MPI patch.

Gets the number of WRF tiles in each WRF patch, returning 1 if tiling is not in use.

Definition at line 972 of file wrf.py.

def hwrf.wrf.WRFSimulation.restart_in (   self,
  restartsource 
)

Requests reading of a restart file.

Raises NotImplementedError(). This would request that this WRF simulation read a restart file. This is not implemented since the restart capability was broken as of the writing of this function.

Definition at line 1072 of file wrf.py.

def hwrf.wrf.WRFSimulation.set_active_io_form_to (   self,
  io_form 
)

Sets the io_form for all active streams.

Changes the io_form for all streams to the specified io_form

Parameters
io_formthe io_form as an integer

Definition at line 1082 of file wrf.py.

def hwrf.wrf.WRFSimulation.set_bdystep (   self,
  step 
)

Sets the boundary input interval (interval_seconds)

Sets the interval at which this WRF simulation expects boundary conditions. Accepts anything that can be passed to to_timedelta.

Parameters
stepboundary input interval. Can be anything accepted by to_timedelta.
Returns
self

Definition at line 928 of file wrf.py.

def hwrf.wrf.WRFSimulation.set_dm_task_split (   self,
  comm_start,
  nest_pes_x,
  nest_pes_y,
  comm_start_d01 = -1,
  nest_pes_x_d01 = -1,
  nest_pes_y_d01 = -1 
)
Sets the WRF namelist values of comm_start, nest_pes_x and 
nest_pes_y, which configures task geometry.  Default 
values are -1, which tells WRF to automatically decide the
task geometry.

The nest_pes_x or nest_pes_y MUST BE either a comma
seperated string, list of ints, or a single int.
nest_pes_x 
nest_pes_y

Definition at line 811 of file wrf.py.

Referenced by hwrf.wrf.WRFSimulation.add_hifreq().

def hwrf.wrf.WRFSimulation.set_io_form (   self,
  stream,
  io_form = None 
)

Sets the io_form for the given stream.

Changes the io_form for the specified stream

Parameters
streamthe string name of the stream, lower-case
io_formthe io_form to use. If unspecified or None, then self.io_form_for(stream) is called

Definition at line 1094 of file wrf.py.

Referenced by hwrf.wrfbase.WRFDomains.add_output().

def hwrf.wrf.WRFSimulation.set_io_servers (   self,
  tasks_per_group,
  groups,
  poll_servers = True 
)

Sets the I/O server configuration in WRF.

Sets the WRF I/O server configuration in the &namelist_quilt setting.

Returns
self
Parameters
tasks_per_groupthe nio_tasks_per_group setting, which specifies the number of I/O server tasks in each I/O server group.
groupsthe nio_groups setting, an integer which specifies the number of I/O server groups.
poll_serversthe poll_servers setting, a logical that specifies whether I/O server polling should be enabled.

Definition at line 882 of file wrf.py.

def hwrf.wrf.WRFSimulation.set_metgrid_levels_from (   self,
  exepath,
  metgrid_out_file,
  logger = None 
)

Sets the num_metgrid_levels and num_metgrid_soil_levels.

Overrides the num_metgrid_levels in &domains to equal the value in the specified metgrid file. Does this by analyzing the output of metgrid.

Parameters
exepathpath to the hwrf_metgrid_levels program
metgrid_out_filepath to the metgrid out file to read
loggeroptional logging.Logger for logging

Definition at line 1131 of file wrf.py.

def hwrf.wrf.WRFSimulation.set_nprocs (   self,
  nproc_x = -1,
  nproc_y = -1 
)

Sets nproc_x and nproc_y in the namelist.

Sets the WRF namelist values of nproc_x and nproc_y, which configure task geometry. Default values are -1, which tells WRF to automatically decide the task geometry.

Parameters
nproc_x,nproc_ythe new values, which default to -1

Definition at line 788 of file wrf.py.

def hwrf.wrf.WRFSimulation.set_tiling (   self,
  x,
  y 
)

Sets the OpenMP tiling information.

Sets the number of WRF OpenMP tiles in each WRF MPI patch to x by y. Don't use this: OpenMP is not supported by WRF-NMM

Definition at line 981 of file wrf.py.

def hwrf.wrf.WRFSimulation.set_timing (   self,
  start = None,
  end = None,
  timestep = None 
)

sets the simulation start and tend times, and timestep

Sets the simulation start and end times, and timestep. The start may be anything accepted by to_datetime. The end is passed through to_datetime_rel, relative to start. The timestep must be accepted by to_fraction.

Parameters
start,endsimulation start and end times
timestepthe outermost domain timestep

Definition at line 1111 of file wrf.py.

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

def hwrf.wrf.WRFSimulation.set_wrfanl_outname (   self,
  pattern 
)

Sets the WRF wrfanl output file pattern for all domains.

Sets the output file pattern for the wrfanl file. It sets this for ALL domains.

Parameters
patternthe pattern for all wrfout files. Make sure you include at least one <domain> in the pattern
Bug:
this function ignores the pattern argument. It always sets the pattern to "wrfanl_d<domain>_<date>"

Definition at line 1045 of file wrf.py.

def hwrf.wrf.WRFSimulation.swcorner_dynamic (   self,
  exepath,
  storminfo,
  domlat,
  domlon,
  logger = None 
)

Suns swcorner_dynamic to set domain start locations.

Runs the swcorner_dynamic program to fill in this WRFSimulation's domain start locations. Returns the resulting namelist as a multi-line string.

Parameters
exepathfull path to the hwrf_swcorner_dynamic
storminfoan hwrf.storminfo.StormInfo object for the storm of interest
domlat,domlonthe outermost domain center lat & lon, which is also the projection center
loggeroptional logger.Logger object for logging

Definition at line 1154 of file wrf.py.

def hwrf.wrf.WRFSimulation.swcorner_dynamic_multistorm (   self,
  exepath,
  all_storminfo,
  domlat,
  domlon,
  logger = None 
)
Runs the swcorner_dynamic program to fill in this
WRFSimulation's domain start locations.  Returns the resulting
namelist as a multi-line string.

Inputs:
  exepath = full path to the hwrf_swcorner_dynamic

  all_storminfo = a list of hwrf.storminfo.StormInfo objects
    for all the real storms in the multistorm run.


  domlat, domlon = the outermost domain center lat & lon,
    which is also the projection center

  logger = optional: a logger.Logger object for logging

Definition at line 1213 of file wrf.py.

def hwrf.wrf.WRFSimulation.wrf_namelist (   self,
  section_sorter = None,
  var_sorters = None 
)

Generates a Conf2Namelist for this simulation.

Generates a Conf2Namelist object for the namelist that should be input to wrf.exe

Parameters
section_sorterthe section_sorter argument to hwrf.namelist.Conf2Namelist.__init__
var_sortersthe var_sorters argument to hwrf.namelist.Conf2Namelist.__init__
Returns
an hwrf.namelist.Conf2Namelist object that can generate namelists for this simulation

Definition at line 990 of file wrf.py.

Referenced by hwrf.wrf.WRFSimulation.swcorner_dynamic(), and hwrf.wrf.WRFSimulation.swcorner_dynamic_multistorm().


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