wrf module¶
The wrf module contains functions related to WRF/WPS.
-
class
wrf.wps_domains.WPSDomainLCC(dom_id, cfg, parent=None)[source]¶ A top-level Lambert Conic Conformal projection domain.
-
latlon_to_ij(lat, lon)[source]¶ Convert latitude and longitude into grid coordinates.
If this is a child domain, it asks it’s parent to do the projectiona and then remaps it into its own coordinate system via parent_start and cell size ratio.
Parameters: - lat – latitude
- lon – longitude
Returns: the i, j position in grid coordinates
-
-
class
wrf.wps_domains.WPSDomainConf(cfg)[source]¶ Represents a domain configuration for WPS, that is one or more domains with one top-level domain.
-
prepare_for_geogrid(wps_nml, input_nml=None, wrfxpy_dir=None, wps_dir=None)[source]¶ Update the namelists for geogrid processing - write the domain configurations. Additionally
Parameters: - wps_nml – the WPS namelist
- input_nml – the input namelist, if None that skipped
- wrfxpy_dir – the installation directory of wrfxpy (if None, no linking is done)
- wps_dir – the WPS working directory
-
-
class
wrf.wrf_data.WRFModelData(path, variables=['T2', 'Q2', 'PSFC', 'RAINNC', 'RAINC'])[source]¶ This class represents information obtained from a wrfout or wrfinput as generated by WPS or WRF. Methods for loading data and deriving new variables on the fly are provided.
-
compute_rainfall_per_timestep()[source]¶ Compute the rainfall per timestep at each grid point from WRF variables RAINNC and RAINC.
-
get_domain_extent()[source]¶ Return smallest enclosing aligned rectangle of domain. return is a tuple (min(lon), min(lat), max(lon), max(lat)).
-
-
exception
wrf.wrf_exec.OutputCheckFailed[source]¶ Carries info about the failure of a subprocess execution.
-
class
wrf.wrf_exec.Executor(work_dir, exec_name)[source]¶ A class that handles execution of external processes for the system with make-like functionality.
This class works for serially (not using MPI) and synchronously (not using a queuing system) launched executables.
-
execute()[source]¶ Execute the file in given working directory.
The execute method first checks whether the expected output is present and if it indicates success, if yes, nothing is executed. If not, the file is executed and its output is redirected: stdout goes to <exec_name>.stdout, stderr goes to <exec_name>.stderr Then the output is checked for markers indicating success, if found, function returns. Otherwise an exception is raised indicating the external process failed.
Returns: raises OutputCheckFailed if return code is non-zero
-
-
class
wrf.wrf_exec.Real(work_dir)[source]¶ Handles real.exe execution.
-
check_output()[source]¶ Checks if the output file for real contains the string “SUCCESS COMPLETE REAL_EM INIT”
Returns: raises OutputCheckFailed
-
execute()[source]¶ Execute real.exe in given working directory.
This method is redefined here as real.exe needs special treatment. DMPAR compilation of WRF causes real.exe to output stdout and stderr into rsl.out.0000 and rsl.error.0000 respectively. We don’t redirect these (we can’t) but we rename the output files after the fact.
NOTE: on some machines it is OK to run real.exe from command line, but generally mpirun is required!
Returns: raises OutputCheckFailed if return code is non-zero
-
-
class
wrf.wrf_exec.Submitter(work_dir, qsys_id)[source]¶ Class that abstract jobs that must be submitted to a queue manager.
-
submit(task_id, exec_path, nodes, ppn, wall_time_hrs)[source]¶ Build a job script and submit it to the queue manager.
Parameters: - task_id – the name of the task in the queue
- exec_path – the path to the parallel executable
- nodes – number of nodes to request for parallel job
- ppn – processors per nodes to request
- wall_time_hrs – wall time to request for job
Returns: job number string to be used in further queue manager commands
-
-
class
wrf.wrf_exec.WRF(work_dir, qman)[source]¶ Handles job submission for wrf.exe into a job manager.
-
submit(task_id, nodes, ppn, wall_time_hrs)[source]¶ Submits a WRF job with the given parameters via queue manager setup during construction.
Fills out executable name and lets submitter do the heavy lifting.
Parameters: - task_id – the name of the task in the queue
- nodes – number of nodes to request for parallel job
- ppn – processors per nodes to request
- wall_time_hrs – wall time to request for job
Returns: job number string to be used in further queue manager commands
-