polyadcirc.run_framework package¶
Submodules¶
polyadcirc.run_framework.domain module¶
See domain
-
polyadcirc.run_framework.domain.
adjust_factor
(x, x_lims, b_lims=None)¶ Parameters: Return type: Returns: b = bathy adjustment
-
class
polyadcirc.run_framework.domain.
domain
(path, node_num=0, element_num=0, node=None, element=None)¶ Bases:
polyadcirc.pyADCIRC.basic.pickleable
domain
Objects of this class contain all the data needed byrandom_manningsn
andplotADCIRC
for particular mesh(s) or grid(s)- path
- full path to the directory containing the
fort.##
files for this particular mesh(s) or grid(s) - node_num
- number of nodes
- element_num
- number of elements
- node
- list of nodes
- element
- list of elements where each element is a list of nodes
- manningsn_default
- default Manning’s n value
- manningsn_num
- number of non-default nodes
- time
- instance of
time
class - make_domain_map
- (bool) whether or not a domain map has been created
-
add_wall
(box_limits, wall_height=-2, path=None, plotb=False, save=False, show=False)¶ Adds a land wall of default 2 m in area defined by
box_limits
Parameters: - path (string or None) – directory containing the
fort.14
to be adjusted - box_limits (list) – [xmin, xmax, ymin, ymax]
- path (string or None) – directory containing the
-
adjust
(x_lims=None, b_lims=None, path=None, plotb=False)¶ Adds a bathymetry between x-locations defined by
x_lims
with bathymetry linearly interpolated betweenb_lims
Parameters:
-
array_bathymetry
()¶ Return type: numpy.ndarray
of size(1, node_num)Returns: array containing the bathymetry at all nodes in numerical order
-
array_manningsn
()¶ Return type: numpy.ndarray
of size(1, node_num)Returns: array of containing the Manning’s n value at all nodes in numerical order
-
array_x
()¶ Return type: numpy.ndarray
of size(1, node_num)Returns: array containing the x locations at all nodes in numerical order
-
array_y
()¶ Return type: numpy.ndarray
of size(1, node_num)Returns: array containing the y locations at all nodes in numerical order
-
find_neighbors
()¶ Determine the neighbors of each of the nodes and store in
self.node[#].neighbors
as aset()
.
-
get_Triangulation
(path=None, save=True, show=False, ext='.eps', ics=2)¶ Parameters: Returns:
-
make_node_to_element_map
()¶ Create the node to element map
-
plot_bathymetry
(path=None, save=True, show=False, ext='.eps', ics=2)¶ Parameters: Returns: See
bathymetry()
-
plot_station_locations
(path=None, bathymetry=False, save=True, show=False, ext='.eps', ics=2)¶ Parameters: Returns:
-
read_default
(path=None, file_name='fort.13')¶ Read in default nodal value from a
*.13
fileParameters: - path (string or None) – directory containing
fort.13
formatted file - file_name (string) –
fort.13
formatted file name
Returns: See
read_default()
- path (string or None) – directory containing
-
read_nodal_attr
(path=None, file_name='fort.13')¶ Load in nodal attributes from a
*.13
file (only does Manning’s n for now) and return a dictonary (like a MATLAB struct) with these attributes).Parameters: - path (string or None) – directory containing
fort.13
formatted file - file_name (string) –
fort.13
formatted file name
Returns: - path (string or None) – directory containing
-
read_recording_data
()¶ Reads in recording information from
fort.15
in self.pathSee
polyadcirc.pyADCIRC.fort15_management.read_recording_data()
-
read_spatial_grid
()¶ Reads in spatial grid from
fort.14
file in self.pathSee
polyadcirc.pyADCIRC.fort14_management.read_spatial_grid()
-
read_spatial_grid_header
()¶ Reads in spatial grid header from
fort.14
file in self.pathSee
polyadcirc.pyADCIRC.fort14_management.read_spatial_grid()
-
run
(num_procs, base_dir, input_dir=None, global_dir=None, write_option=None, num_writers=None, LorS=None, R=False)¶ Preprocess and run ADCIRC on this domain
See also
Parameters: - num_procs (int) – number of processors for this ADCIRC run
- base_dir (string) – directory containing the padcirc executables
- input_dir (string) – directory containing the input files
- global_dir (string) – directory to write fulldomain output files to
- write_option (string) – (optional) specifiy
W
orWs
flag - num_writers (int) – number of MPI process to dedicate soley to the task of writing ascii files
- LorS (string) – (optional) specify
L
orS
flag - R (string) – (optional) specify
R
flag
-
set_station_bathymetry
(key='fort61', method='linear')¶ Sets they bathymetry for all stations by interpolating w.r.t. the nodal locations
Parameters:
-
update
(path=None)¶ Sets the directory containing files for this domain to self.path
Reads in data from
fort.14
andfort.15
files and updates self accordinglyParameters: path (string or None) – directory containing fort.##
filesSee
read_spatial_grid()
Seeread_recording_data()
-
update_mann
(data, path=None, default=None, file_name='fort.13')¶ Write out fort.13 to path with the attributes contained in Data.
Parameters: - data (
numpy.ndarray
ordict
) – containing the nodal attribute information - path (string or None) – the directory to which the fort.13 file will be written
- default (None or float) – default value
- file_name (string) – the name of the
fort.13
formatted file
- data (
polyadcirc.run_framework.fulldomain module¶
This module contains a set of methods and a class for interacting with NCSU
Subdomain Modeling Python code and associated files. The focus of this module
is the fulldomain
.
-
class
polyadcirc.run_framework.fulldomain.
fulldomain
(path, subdomains=None, node_num=0, element_num=0, node=None, element=None)¶ Bases:
polyadcirc.run_framework.domain.domain
Objects of this class contain all the data needed by
py.genbcs
,py.genfull
, andpy.gensub
for a particular full domain mesh/grid. References topolyadcirc.run_framework.subdomain
objects are also contained in an instantiation of this class.-
add_subdomain
(subdomain)¶ Adds subdomain to self.subdomains.
Parameters: subdomain ( subdomain
) – subdomain within this domain
-
add_subdomains
(subdomains)¶ Adds subdomain to self.subdomains.
Parameters: subdomains (list of subdomain
) – subdomains within this domain
-
check_fulldomain
()¶ Check to see if the
fort.06*
andPE*/fort.065
files existReturn type: bool Returns: False if the fort.06*
files don’t exist
-
check_subdomains
()¶ Check all the subdomains to make sure the
fort.019
file existsReturn type: bool Returns: False if fort.019
is missing from at least one of the subdomains
-
genbcss
(forcing_freq=None, dt=None, nspoolgs=None, h0=None, L=False)¶ Generate the
fort.019
files for the subdomains. This requires the presence of the output files from a fulldomain run,fort.06*
.Parameters: - forcing_freq (list) – number of timesteps at which infomration
is written to a boudnary conditions file (
fort.019
) - dt (list) – One timestep in seconds
- nspoolgs (list) – the number of timesteps at which information is
written to the new output files
fort.06*
- h0 (list) – minimum water depth for a node to be wet
- L (bool) – flag whether or not PADCIRC was run with
-L
flag and if local files need to be post-processed into global files
Return type: Returns: command lines for invoking genbcs.py
- forcing_freq (list) – number of timesteps at which infomration
is written to a boudnary conditions file (
-
genfull
(noutgs=1, nspoolgs=1, subdomains=None)¶ Generate the full domain control file,
fort.015
, and save it toself.path
.Parameters: Return type: Returns: command line for invoking genfull.py
-
read_and_save_output
(ts_names, nts_names, save_file=None, timesteps=None, save=False)¶ Reads in output files from this fulldomain and saves to a file.
NOTE THIS DOES NOT CURRENTLY WORK FOR STATION DATA! ONLY USE FOR GLOBAL DATA i.e files that are fort.*3 or fort.*4
NOTE THIS DOES NOT CURRENTLY WORK FOR ANY NTS DATA EXCEPT FOR MAXELE
Parameters: - ts_names (list) – names of ADCIRC timeseries output files to be recorded from each run
- nts_names (list) – names of ADCIRC non timeseries output files to be recorded from each run
- save_file (string) – name of file to save comparision matricies to
- timesteps (int) – number of timesteps to read from file
Return type: Returns: full_dict
-
setup_all
()¶ Set up all of the subdomains
-
update_subdomains
()¶ Update relational references between fulldomain and it’s subdomains by setting subdomain.fulldomain = self
-
polyadcirc.run_framework.no_ibrun module¶
This file provides a mpirun work-around for clusters that do not have the ibrun command.
-
class
polyadcirc.run_framework.no_ibrun.
random_manningsn
(script_name, fdir)¶ Bases:
object
This class is an implementation of
polyadcirc.run_framework.random_manningsn
that provides ampirun
based work-around for clusters that do not have ibrun. It is probabaly system dependent and might need to be modified.-
write_run_script_no_ibrun
(num_procs, num_jobs, procs_pnode, TpN, screenout=True, num_writers=None)¶ Creates a bash script called
self.script_name
inself.base_dir
and a set of rankfiles namedrankfile_n
to run multiple non-interacting parallel programs in parallel.Parameters: - num_procs (int) – number of processes per job
- num_jobs (int) – number of jobs to run
- procs_pnode (int) – number of processors per node
- screenout (bool) – flag (True – write
ADCIRC
output to screen, False – writeADCIRC
output to temp file) - num_writers (int) – number of MPI processes to dedicate soley to the task of writing ascii files
- TpN (int) – number of tasks (processors to use) per node (wayness)
Return type: Returns: name of bash script for running a batch of jobs within our processor allotment
-
polyadcirc.run_framework.random_manningsn module¶
This module contains functions to pull data from a fort.61
and the
runSet
which controls the running of ADCIRC simulations within a set
of processors allocated by the submission script
-
polyadcirc.run_framework.random_manningsn.
concatenate
(run_data1, run_data2)¶ Combine data from
run_data1
andrun_data2
runSet
with anotherrunSet
(other_run
) and points from both runsTo combine several
run_data
use:run_list = [run1, run2, run3] points_list = [points1, points2, points3] run_data_list = zip(run_list, points_list) reduce(concatenate, run_data_list)
Parameters: - run_data1 – (runSet for run1, sample points for run1)
- run_data2 – (runSet for run2, sample points for run2)
Returns: (run_data, points)
Return type:
-
polyadcirc.run_framework.random_manningsn.
convert_to_days
(time_obs)¶ Converts
time_obs
from seconds to daysParameters: time_obs – observation times in seconds Return type: dict Returns: time_obs
-
polyadcirc.run_framework.random_manningsn.
convert_to_hours
(time_obs)¶ Converts
time_obs
from seconds to hoursParameters: time_obs – observation times in seconds Return type: dict Returns: time_obs
-
polyadcirc.run_framework.random_manningsn.
convert_to_percent
(nts_data, data)¶ Converts
nts_data['tinun63']
from seconds to percent of RNDAYParameters: - nts_data – non-time-series data
- data –
domain
Return type: Returns: nts_data
-
polyadcirc.run_framework.random_manningsn.
fix_dry_data
(ts_data, data)¶ Fix dry elevation station data flags
Parameters: - ts_data – time series data
- data –
domain
Return type: Returns: ts_data
-
polyadcirc.run_framework.random_manningsn.
fix_dry_nodes
(ts_data, data)¶ Fix dry elevation data flags
Parameters: - ts_data – time series data
- data –
domain
Return type: Returns: ts_data
-
polyadcirc.run_framework.random_manningsn.
fix_dry_nodes_nts
(nts_data, data)¶ Fix dry elevation data flags
Parameters: - nts_data – non time series data
- data –
domain
Return type: Returns: nts_data
-
polyadcirc.run_framework.random_manningsn.
loadmat
(save_file, base_dir, grid_dir, save_dir, basis_dir)¶ Loads data from
save_file
into arunSet
object. Reconstructsdomain
. Fixes dry data if it was recorded.Parameters: - save_file (string) – local file name
- grid_dir (string) – directory containing
fort.14
,fort.15
, andfort.22
- save_dir (string) – directory where
RF_directory_*
are saved, and where fort.13 is located - basis_dir (string) – directory where
landuse_*
folders are located - base_dir (string) – directory that contains ADCIRC executables, and
machine specific
in.prep#
files
Return type: tuple of
runSet
anddomain
objectsReturns: (main_run, domain)
-
class
polyadcirc.run_framework.random_manningsn.
runSet
(grid_dir, save_dir, basis_dir, num_of_parallel_runs=10, base_dir=None, script_name=None)¶ Bases:
polyadcirc.pyADCIRC.basic.pickleable
This class controls the running of ADCIRC within the processors allocated by the submission script
- grid_dir
- directory containing
fort.14
,fort.15
, andfort.22
- save_dir
- directory where
RF_directory_*
are saved, and where fort.13 is located - basis_dir
- directory where
landuse_*
folders are located - base_dir
- directory that contains ADCIRC executables, and machine
specific
in.prep#
files - num_of_parallel_runs
- size of batch of jobs to be submitted to queue
- script_name
- name of the bash script
- nts_data
- non timeseries data
- ts_data
- timeseries data
- time_obs
- observation times for timeseries data
-
concatenate
(other_run, points1, points2)¶ Combine data from this
runSet
with anotherrunSet
(other_run
) and points from both runsParam: other_run
Parameters: - points1 (
numpy.ndarray`
) – sample points forself
- points1 – sample points for
other_run
Return type: Returns: (self, points)
- points1 (
-
convert_to_days
()¶ Converts
self.time_obs
from seconds to days
-
convert_to_hours
()¶ Converts
self.time_obs
from seconds to hours
-
convert_to_percent
(data)¶ Converts
self.nts_data['tinun63']
from seconds to percent of RNDAYParameters: data – domain
-
initialize_random_field_directories
(num_procs=12, prepRF=True)¶ Make directories for parallel funs of random fields
Parameters: Return type: Returns: list of paths to
RF_directory_*
-
link_random_field_directories
()¶ Assumes that the pre-preped
RF_directory
isRF_directory_1
. In each of theRF_directory_*
create thePE****
folders copy over thefort.13
and then link thefort.019
,fort.18
,fort.15
, fort.14`` into thePE****
folder. Also linkmetis_graph.txt
andpartmesh.txt
into theRF_directory
.Parameters: num_procs (int) – number of processes per padcirc run
-
make_plots
(points, domain, save=True, show=False, bathymetry=False, ext='.eps', ics=2)¶ Plots
mesh
,station_locations
,basis_functions
,random_fields
,mean_field
,station_data
, and save in save_dir/figs
-
plot_basis_functions
(domain, bv_dict, save=True, show=False, ext='.eps', ics=2)¶ See
basis_functions()
-
plot_mean_field
(domain, points, bv_dict, save=True, show=False, ext='.eps', ics=2)¶ See
mean_field()
-
plot_random_fields
(domain, points, bv_dict, save=True, show=False, ext='.eps', ics=2)¶ See
random_fields()
-
plot_station_data
(save=True, show=False, ext='.eps')¶ See
station_data()
-
remove_random_field_directories
()¶ Remove directories for parallel funs of random fields
-
run_points
(data, points, save_file, num_procs=12, procs_pnode=12, ts_names=['fort.61'], nts_names=['maxele.63'], screenout=True, cleanup_dirs=True, num_writers=None, TpN=None)¶ Runs ADCIRC for all of the configurations specified by
points
and returns a dictonary of arrays containing data from output filesReads in a default Manning’s n value from
self.save_dir
and stores it indata.manningsn_default
Parameters: - data –
domain
- points (
numpy.ndarray
of size (num_of_basis_vec
,num_of_random_fields
)) – containts the weights to be used for each run - save_file (string) – name of file to save
station_data
to - num_procs (int or 12) – number of processors per ADCIRC simulation
- procs_pnode (int) – number of processors per node, 12 on lonestar, and 16 on stampede
- ts_names (list) – names of ADCIRC timeseries output files to be recorded from each run
- nts_names (list) – names of ADCIRC non timeseries output files to be recorded from each run
- screenout (bool) – flag (True – write
ADCIRC
output to screen, False – writeADCIRC
output to temp file - cleanup_dirs (bool) – flag to delete all RF_dirs after run (True – yes, False – no)
- num_writers (int) – number of MPI processes to dedicate soley to the task of writing ascii files. This MUST be < num_procs
- TpN (int) – number of tasks (cores to use) per node (wayness)
Return type: Returns: (
time_obs
,ts_data
,nts_data
)Note
Currently supports ADCIRC output files
fort.6*
,*.63
,fort.7*
, but NOT Hot Start Output (fort.67
,fort.68
)- data –
-
save
(mdict, save_file)¶ Save matrices to a
*.mat
file for use byMATLAB BET
code andloadmat()
Parameters:
-
setup_rfdir
(path, num_procs)¶ Creates the directory path and copies required files from
self.base_dir
intoParameters:
-
update_dir_file
(num_dirs)¶ Create a list of RF_dirs for the prep_script to use.
Parameters: num_dirs (int) – number of RF_dirs to put in dir_list
-
write_prep_script
(n, screenout=False)¶ Creats a bash script to run adcprep with
in.prepn
Parameters: Return type: Returns: name of bash script for prepping a batch of jobs within our processor allotment
-
write_run_script
(num_procs, num_jobs, procs_pnode, TpN, screenout=True, num_writers=None)¶ Creates a bash script called
self.script_name
inself.base_dir
Parameters: - num_procs (int) – number of processors per job
- num_jobs (int) – number of jobs to run
- procs_pnode (int) – number of processors per node
- screenout (bool) – flag (True – write
ADCIRC
output to screen, False – writeADCIRC
output to temp file) - num_writers (int) – number of MPI processes to dedicate soley to the task of writing ascii files
- TpN (int) – number of tasks (cores to use) per node (wayness)
Return type: Returns: name of bash script for running a batch of jobs within our processor allotment
-
write_run_script_ibrun
(num_procs, num_jobs, procs_pnode, TpN, screenout=True, num_writers=None)¶ Creates a bash script called
self.script_name
inself.base_dir
Parameters: - num_procs (int) – number of processors per job
- num_jobs (int) – number of jobs to run
- procs_pnode (int) – number of processors per node
- screenout (bool) – flag (True – write
ADCIRC
output to screen, False – writeADCIRC
output to temp file) - num_writers (int) – number of MPI processes to dedicate soley to the task of writing ascii files
- TpN (int) – number of tasks (cores to use) per node (wayness)
Return type: Returns: name of bash script for running a batch of jobs within our processor allotment
-
write_run_script_noibrun
(num_procs, num_jobs, procs_pnode, TpN, screenout=True, num_writers=None)¶ MPI VERSION 1.4.1 for EUCLID with the modules needed to run ADCIRC
Creates a bash script called
self.script_name
inself.base_dir
and a set of rankfiles namedrankfile_n
to run multiple non-interacting parallel programs in parallel.Parameters: - num_procs (int) – number of processes per job
- num_jobs (int) – number of jobs to run
- procs_pnode (int) – number of processors per node
- screenout (bool) – flag (True – write
ADCIRC
output to screen, False – writeADCIRC
output to temp file) - num_writers (int) – number of MPI processes to dedicate soley to the task of writing ascii files
- TpN (int) – number of tasks (processors to use) per node (wayness)
Return type: Returns: name of bash script for running a batch of jobs within our processor allotment
-
write_run_script_noibrun_MPI19
(num_procs, num_jobs, procs_pnode, TpN, screenout=True, num_writers=None)¶ Creates a bash script called
self.script_name
inself.base_dir
and a set of rankfiles namedrankfile_n
to run multiple non-interacting parallel programs in parallel.Parameters: - num_procs (int) – number of processes per job
- num_jobs (int) – number of jobs to run
- procs_pnode (int) – number of processors per node
- screenout (bool) – flag (True – write
ADCIRC
output to screen, False – writeADCIRC
output to temp file) - num_writers (int) – number of MPI processes to dedicate soley to the task of writing ascii files
- TpN (int) – number of tasks (processors to use) per node (wayness)
Return type: Returns: name of bash script for running a batch of jobs within our processor allotment
polyadcirc.run_framework.random_manningsn_Q module¶
This module contains functions to pull data from ADCIRC output files and the
runSet
which controls the running of ADCIRC simulations within a set
of processors allocated by the submission script
-
polyadcirc.run_framework.random_manningsn_Q.
loadmat
(save_file, base_dir, grid_dir, save_dir, basis_dir)¶ Loads data from
save_file
into arunSet
object. Reconstructsdomain
. Fixes dry data if it was recorded.Parameters: - save_file (string) – local file name
- grid_dir (string) – directory containing
fort.14
,fort.15
, andfort.22
- save_dir (string) – directory where
RF_directory_*
are saved, and where fort.13 is located - basis_dir (string) – directory where
landuse_*
folders are located - base_dir (string) – directory that contains ADCIRC executables, and
machine specific
in.prep#
files
Return type: tuple of
runSet
,domain
objects, and twonumpy.ndarray
Returns: (main_run, domain, mann_pts, Q)
-
class
polyadcirc.run_framework.random_manningsn_Q.
runSet
(grid_dir, save_dir, basis_dir, num_of_parallel_runs=10, base_dir=None, script_name=None)¶ Bases:
polyadcirc.run_framework.random_manningsn.runSet
This class controls the running of ADCIRC within the processors allocated by the submission script
- grid_dir
- directory containing
fort.14
,fort.15
, andfort.22
- save_dir
- directory where
RF_directory_*
are saved, and wherefort.13
is located - basis_dir
- directory where
landuse_*
folders are located - base_dir
- directory that contains ADCIRC executables, and machine specific
in.prep#
files - num_of_parallel_runs
- size of batch of jobs to be submitted to queue
- script_name
- bash script name
- nts_data
- non timeseries data
- ts_data
- timeseries data
- time_obs
- observation times for timeseries data
-
run_nobatch_q
(data, mann_points, save_file, num_procs=12, procs_pnode=12, stations=None, screenout=True, num_writers=None, TpN=None)¶ Runs ADCIRC for all of the configurations specified by
mann_points
and returns a dictonary of arrays containing data from output files. Runs batches of PADCIRC as a single for loop and preps both thefort.13
andfort.14
in the same step.Stores only the QoI at the stations defined in stations`. In this case the QoI is the
maxele63
at the designated station.Reads in a default Manning’s n value from
self.save_dir
and stores it indata.manningsn_default
Note
Currently supports ADCIRC output files
fort.6*
,*.63
,fort.7*
, but NOT Hot Start Output (fort.67
,fort.68
)Parameters: - data –
domain
- mann_points (
numpy.ndarray
of size (num_of_basis_vec
,num_of_random_fields
),num_of_random_fields
) – containts the weights to be used for each run - save_file (string) – name of file to save mdict to
- num_procs (int or 12) – number of processors per ADCIRC simulation, 12 on lonestar, and 16 on stamped
- procs_pnode (int) – number of processors per node
- stations (list) – list of stations to gather QoI from. If
None
uses the stations defined indata
- screenout (bool) – flag (True – write
ADCIRC
output to screen, False – writeADCIRC
output to temp file - num_writers (int) – number of MPI processes to dedicate soley to
the task of writing ascii files. This MUST be less than
num_procs
- TpN (int) – number of tasks (cores to use) per node (wayness)
Return type: Returns: (
time_obs
,ts_data
,nts_data
)- data –
polyadcirc.run_framework.random_wall module¶
This module contains functions to pull data from ADCIRC output files and the
runSet
which controls the running of ADCIRC simulations within a set
of processors allocated by the submission script
-
polyadcirc.run_framework.random_wall.
loadmat
(save_file, base_dir, grid_dir, save_dir, basis_dir)¶ Loads data from
save_file
into arunSet
object. Reconstructsdomain
. Fixes dry data if it was recorded.Parameters: - save_file (string) – local file name
- grid_dir (string) – directory containing
fort.14
,fort.15
, andfort.22
- save_dir (string) – directory where
RF_directory_*
are saved, and where fort.13 is located - basis_dir (string) – directory where
landuse_*
folders are located - base_dir (string) – directory that contains ADCIRC executables, and
machine specific
in.prep#
files
Return type: tuple of
runSet
,domain
objects, and twonumpy.ndarray
Returns: (main_run, domain, mann_pts, wall_pts)
-
polyadcirc.run_framework.random_wall.
plot_walls
(run_set, domain, wall_points, save=True, show=False)¶ Plots the walls with dimenstions described in
wall_points
and saves the plots inself.save_dir
Parameters: - domain –
domain
- wall_points (
numpy.ndarray
of size (5,num_of_walls
)) – containts the box_limits, and wall_height for each wall [ximin, xmax, ymin, ymax, wall_height] - save (bool) – flag for whether or not to save plots
- show (bool) – flag for whether or not to show plots
- domain –
-
class
polyadcirc.run_framework.random_wall.
runSet
(grid_dir, save_dir, basis_dir, num_of_parallel_runs=10, base_dir=None, script_name=None)¶ Bases:
polyadcirc.run_framework.random_manningsn.runSet
This class controls the running of ADCIRC within the processors allocated by the submission script
- grid_dir
- directory containing
fort.14
,fort.15
, andfort.22
- save_dir
- directory where
RF_directory_*
are saved, and where fort.13 is located - basis_dir
- directory where
landuse_*
folders are located - base_dir
- directory that contains ADCIRC executables, and machine
specific
in.prep#
files - num_of_parallel_runs
- size of batch of jobs to be submitted to queue
- script_name
- name of the bash script
- nts_data
- non timeseries data
- ts_data
- timeseries data
- time_obs
- observation times for timeseries data
-
make_plots
(wall_points, mann_points, domain, save=True, show=False, bathymetry=False)¶ Plots
mesh
,station_locations
,basis_functions
,random_fields
,mean_field
,station_data
, and save in save_dir/figsTodo
this uses bv_array everywhere. I might want to change this later when I go to the nested mesh approach
-
plot_walls
(domain, wall_points, save=True, show=False)¶ Plots the walls with dimenstions described in
wall_points
and saves the plots inself.save_dir
Parameters: - domain –
domain
- wall_points (
numpy.ndarray
of size (5,num_of_walls
)) – containts the box_limits, and wall_height for each wall [ximin, xmax, ymin, ymax, wall_height] - save (bool) – flag for whether or not to save plots
- show (bool) – flag for whether or not to show plots
- domain –
-
run_nobatch
(data, wall_points, mann_points, save_file, num_procs=12, procs_pnode=12, ts_names=['fort.61'], nts_names=['maxele.63'], screenout=True, num_writers=None, TpN=None)¶ Runs ADCIRC for all of the configurations specified by
wall_points
andmann_points
and returns a dictonary of arrays containing data from output files. Runs batches of PADCIRC as a single for loop and preps both thefort.13
andfort.14
in the same step.Reads in a default Manning’s n value from
self.save_dir
and stores it indata.manningsn_default
Note
Currently supports ADCIRC output files
fort.6*
,*.63
,fort.7*
, but NOT Hot Start Output (fort.67
,fort.68
)Parameters: - data –
domain
- wall_points (
numpy.ndarray
of size (5,num_of_walls
)) – containts the box_limits, and wall_height for each wall [ximin, xmax, ymin, ymax, wall_height] - mann_points (
numpy.ndarray
of size (num_of_basis_vec
,num_of_random_fields
),num_of_random_fields
MUST be the same asnum_of_walls
. The ith wall will be associated with the ith field specifed by mann_points) – containts the weights to be used for each run - save_file (string) – name of file to save mdict to
- num_procs (int or 12) – number of processors per ADCIRC simulation, 12 on lonestar, and 16 on stamped
- procs_pnode (int) – number of processors per node
- ts_names (list) – names of ADCIRC timeseries output files to be recorded from each run
- nts_names (list) – names of ADCIRC non timeseries output files to be recorded from each run
- screenout (bool) – flag (True – write
ADCIRC
output to screen, False – writeADCIRC
output to temp file - num_writers (int) – number of MPI processes to dedicate soley to the task of writing ascii files. This MUST be less than num_procs
- TpN (int) – number of tasks (cores to use) per node (wayness)
Return type: Returns: (
time_obs
,ts_data
,nts_data
)- data –
-
run_points
(data, wall_points, mann_points, save_file, num_procs=12, procs_pnode=12, ts_names=['fort.61'], nts_names=['maxele.63'], screenout=True, s_p_wall=None, num_writers=None, TpN=None)¶ Runs ADCIRC for all of the configurations specified by
wall_points
andmann_points
and returns a dictonary of arrays containing data from output files. Assumes that the number ofwall_points
is less than the number ofmann_points
. Runs batches of PADCIRC as a double for loop with the ADCPREP prepping thefort.14
file on the exterior loop and thefort.13
file on the interior loop.Reads in a default Manning’s n value from
self.save_dir
and stores it indata.manningsn_default
Note
Currently supports ADCIRC output files
fort.6*
,*.63
,fort.7*
, but NOT Hot Start Output (fort.67
,fort.68
)Parameters: - data –
domain
- wall_points (
numpy.ndarray
of size (5,num_of_walls
)) – containts the box_limits, and wall_height for each wall[xmin, xmax, ymin, ymax, wall_height]
- mann_points (
numpy.ndarray
of size (num_of_basis_vec
,num_of_random_fields
),num_of_random_fields
MUST be a multiple ofnum_of_walls
. The ith wall will be associated with the ith set of i*(num_of_random_fields/num_of_walls) mann_points) – containts the weights to be used for each run - save_file (string) – name of file to save mdict to
- num_procs (int or 12) – number of processors per ADCIRC simulation, 12 on lonestar, and 16 on stamped
- procs_pnode (int) – number of processors per node
- ts_names (list) – names of ADCIRC timeseries output files to be recorded from each run
- nts_names (list) – names of ADCIRC non timeseries output files to be recorded from each run
- screenout (bool) – flag (True – write
ADCIRC
output to screen, False – writeADCIRC
output to temp file - num_writers (int) – number of MPI processes to dedicate soley to the task of writing ascii files. This MUST be less than num_procs.
- TpN (int) – number of tasks (cores to use) per node (wayness)
Return type: Returns: (
time_obs
,ts_data
,nts_data
)- data –
polyadcirc.run_framework.random_wall_Q module¶
This module contains functions to pull data from ADCIRC output files and the
runSet
which controls the running of ADCIRC simulations within a set
of processors allocated by the submission script
-
polyadcirc.run_framework.random_wall_Q.
loadmat
(save_file, base_dir, grid_dir, save_dir, basis_dir)¶ Loads data from
save_file
into arunSet
object. Reconstructsdomain
. Fixes dry data if it was recorded.Parameters: - save_file (string) – local file name
- grid_dir (string) – directory containing
fort.14
,fort.15
, andfort.22
- save_dir (string) – directory where
RF_directory_*
are saved, and where fort.13 is located - basis_dir (string) – directory where
landuse_*
folders are located - base_dir (string) – directory that contains ADCIRC executables, and
machine specific
in.prep#
files
Return type: tuple of
runSet
,domain
objects, and twonumpy.ndarray
Returns: (main_run, domain, mann_pts, wall_pts)
-
class
polyadcirc.run_framework.random_wall_Q.
runSet
(grid_dir, save_dir, basis_dir, num_of_parallel_runs=10, base_dir=None, script_name=None)¶ Bases:
polyadcirc.run_framework.random_wall.runSet
This class controls the running of ADCIRC within the processors allocated by the submission script
- grid_dir
- directory containing
fort.14
,fort.15
, andfort.22
- save_dir
- directory where
RF_directory_*
are saved, and where fort.13 is located - basis_dir
- directory where
landuse_*
folders are located - base_dir
- directory that contains ADCIRC executables, and machine specific
in.prep#
files - num_of_parallel_runs
- size of batch of jobs to be submitted to queue
- script_name
- name of the bash script to create
- nts_data
- non timeseries data
- ts_data
- timeseries data
- time_obs
- observation times for timeseries data
-
run_nobatch_q
(data, wall_points, mann_points, save_file, num_procs=12, procs_pnode=12, stations=None, screenout=True, num_writers=None, TpN=None)¶ Runs ADCIRC for all of the configurations specified by
wall_points
andmann_points
and returns a dictonary of arrays containing data from output files. Runs batches of PADCIRC as a single for loop and preps both thefort.13
andfort.14
in the same step.Stores only the QoI at the stations defined in stations`. In this case the QoI is the
maxele63
at the designated station.Reads in a default Manning’s n value from
self.save_dir
and stores it indata.manningsn_default
Note
Currently supports ADCIRC output files
fort.6*
,*.63
,fort.7*
, but NOT Hot Start Output (fort.67
,fort.68
)Parameters: - data –
domain
- wall_points (
numpy.ndarray
of size (5,num_of_walls
)) – containts the box_limits, and wall_height for each wall[xmin, xmax, ymin, ymax, wall_height]
- mann_points (
numpy.ndarray
of size (num_of_basis_vec
,num_of_random_fields
),num_of_random_fields
MUST be the same asnum_of_walls
. The ith wall will be associated with the ith field specifed by mann_points) – containts the weights to be used for each run - save_file (string) – name of file to save mdict to
- num_procs (int or 12) – number of processors per ADCIRC simulation, 12 on lonestar, and 16 on stamped
- procs_pnode (int) – number of processors per node
- stations (list) – list of stations to gather QoI from. If
None
uses the stations defined indata
- screenout (bool) – flag (True – write
ADCIRC
output to screen, False – writeADCIRC
output to temp file - num_writers (int) – number of MPI processes to dedicate soley to the task of writing ascii files. This MUST be less than num_procs
- TpN (int) – number of tasks (cores to use) per node (wayness)
Return type: Returns: (
time_obs
,ts_data
,nts_data
)- data –
polyadcirc.run_framework.subdomain module¶
This module contains a set of methods and a class for interacting with NCSU
Subdomain Modeling Python code and associated files. The focus of this module
is the subdomain
.
-
polyadcirc.run_framework.subdomain.
ellipse_properties
(x, y, w)¶ Given a the (x,y) locations of the foci of the ellipse and the width return the center of the ellipse, width, height, and angle relative to the x-axis.
Parameters: - x (double) – x-coordinates of the foci
- y (double) – y-coordinates of the foci
- w (double) – width of the ellipse
Return type: tuple of doubles
Returns: (center_coordinates, width, height, angle_in_rads)
-
polyadcirc.run_framework.subdomain.
loadmat
(save_file, base_dir, grid_dir, save_dir, basis_dir)¶ Loads data from
save_file
into arunSet
object. Reconstructssubdomain
.Parameters: - save_file (string) – local file name
- grid_dir (string) – directory containing
fort.14
,fort.15
, andfort.22
- save_dir (string) – directory where
RF_directory_*
are saved, and where fort.13 is located - basis_dir (string) – directory where
landuse_*
folders are located - base_dir (string) – directory that contains ADCIRC executables, and
machine specific
in.prep#
files
Return type: tuple of
runSet
anddomain
objectsReturns: (main_run, domain)
-
class
polyadcirc.run_framework.subdomain.
subdomain
(path, node_num=0, element_num=0, node=None, element=None)¶ Bases:
polyadcirc.run_framework.domain.domain
Objects of this class contain all the data needed by
py.genbcs
,py.genfull
, andpy.gensub
for a particular subdomain mesh/grid. References topolyadcirc.run_framework.subdomain
objects are also contained in an instantiation of this class.-
check
()¶ Check to make sure the
fort.019
file existsReturn type: bool Returns: False the fort.019
doesn’t exist
-
check_fulldomain
()¶ Check to see if the
fort.06*
andPE*/fort.065
files existReturn type: bool Returns: False if the fort.06*
files don’t exist
-
circle
(x, y, r)¶ Generate a subdomain shape file for a circular subdomain
Parameters: Return type: Returns: flag for
py.gensub()
-
compare_runSet
(ts_data, nts_data, ts_names=None, nts_names=None, save_file=None)¶ Reads in
polyadcirc.random_manningsn.runSet
output from this subdomain and from it’s fulldomain and compares them.NOTE THIS DOES NOT CURRENTLY WORK FOR STATION DATA! ONLY USE FOR GLOBAL DATA i.e files that are fort.*3 or fort.*4
comparision_data = fulldomain_data - subdomain_data
Parameters: - ts_data (list) – (ts_data_subdomain, ts_data_fulldomain)
- nts_data (list) – (nts_data_subdomain, nts_data_fulldomain)
- ts_names (list) – names of ADCIRC timeseries output files to be recorded from each run
- nts_names (list) – names of ADCIRC non timeseries output files to be recorded from each run
- save_file (string) – name of file to save comparision matricies to
Return type: Returns: (ts_error, nts_error)
-
compare_to_fulldomain
(ts_names, nts_names, save_file=None, timesteps=None, savefull=True, readmatfull=False, savesub=True, readmatsub=False, fulldict=None)¶ Reads in output files from this subdomain and from it’s fulldomain and compares them.
NOTE THIS DOES NOT CURRENTLY WORK FOR STATION DATA! ONLY USE FOR GLOBAL DATA i.e files that are fort.*3 or fort.*4
NOTE THIS DOES NOT CURRENTLY WORK FOR ANY NTS DATA EXCEPT FOR MAXELE
comparision_data = fulldomain_data - subdomain_data
Parameters: - ts_names (list) – names of ADCIRC timeseries output files to be recorded from each run
- nts_names (list) – names of ADCIRC non timeseries output files to be recorded from each run
- save_file (string) – name of file to save comparision matricies to
- timesteps (int) – number of timesteps to read from file
Return type: Returns: (ts_error, nts_error, time_obs, ts_data, nts_data)
-
create_fort15
()¶ Copy the
fort.15
fromfulldomain.path
toself.path
and modify for a subdomain run.
-
ellipse
(x, y, w)¶ Generate a subdomain shape file for an elliptical subdomain
Parameters: Return type: Returns: flag for
py.gensub()
-
ellipse_properties
(x, y, w)¶ Given a the (x,y) locations of the foci of the ellipse and the width return the center of the ellipse, width, height, and angle relative to the x-axis.
Parameters: - x (double) – x-coordinates of the foci
- y (double) – y-coordinates of the foci
- w (double) – width of the ellipse
Return type: tuple of doubles
Returns: (center_coordinates, width, height, angle_in_rads)
-
genbcs
(forcing_freq=1, dt=None, nspoolgs=1, h0=None, L=False)¶ Generate the
fort.019
which is the boundary conditions file needed for a subdomain run of ADCIRC. This requires the presence of the output files from a fulldomain run,fort.06*
.Parameters: - forcing_freq (int) – number of timesteps at which infomration
is written to a boudnary conditions file (
fort.019
) THIS MUST BE A MULTIPLE OF NSPOOLGS - dt (float) – One timestep in seconds
- nspoolgs (int) – the number of timesteps at which information is
written to the new output files
fort.06*
- h0 (float) – minimum water depth for a node to be wet
- L (bool) – flag whether or not PADCIRC was run with
-L
flag and if local files need to be post-processed into global files
Return type: Returns: command line for invoking genbcs.py
- forcing_freq (int) – number of timesteps at which infomration
is written to a boudnary conditions file (
-
genfull
(noutgs=1, nspoolgs=1)¶ Generate the full domain control file,
fort.015
, and save it toself.fulldomain.path
.Parameters: Return type: Returns: command line for invoking genfull.py
-
gensub
(bound_ele=1, bound_vel=1, bound_wd=1, winddir=None)¶ Generate the subdomain input files (
fort.13
,fort.14
,fort.015
,py.141
,py.140
) and shape file. Createsfort.15
based on thefort.15
inpolyadcirc.run_framework.fulldomain
toself.path
, and creates symbolic links to meterological forcing files (fort.22*
).Parameters: - bound_ele (int) – a flag determining whether surface elevations of the boundary nodes of a subdomain are enforced using a boundary condition file.
- bound_vel (int) – a flag determining whether velocities of the boundary nodes of a subdomain are enforced using a boundary condition file.
- bound_wd (int) – a flag determining whether wet/dry status of the boundary nodes of a subdomain are enforced using a boundary condition file.
Return type: Returns: command line for invoking gensub.py
-
link_fort22
(fdir=None)¶ Create symboolic links to
fort.22*
meterological files in this subdomain folder from the fulldomain folder.
-
read_bv_fort13
()¶ Read the boundary value nodal values for Manning’s n from
self.fulldomain
and save as adict
asself.bv_fort13
.
-
read_bv_nodes
()¶ Read in the nodes on the boundary and store in
self.bv_nodes
as a list.Return type: list Returns: list of boundary nodes
-
read_circle
()¶ Read in the parameters used to define the circular subdomain cut out and store them as
self.x
,self.y
, andself.r
Return type: tuple Returns: (x, y, r)
-
read_ellipse
()¶ Read in the parameters used to define the circular subdomain cut out and store them as
self.x
,self.y
, andself.r
Return type: tuple Returns: (x, y, w)
-
read_py_ele
()¶ Read in the subdomain to fulldomain element map
Store as
self.sub2full_element = dict()
where key = subdomain element #, value = fulldomain element #
-
read_py_node
()¶ Read in the subdomain to fulldomain node map
Store as
self.sub2full_node = dict()
where key = subdomain node #, value = fulldomain node #
-
set_bv_fort13
(mann_data)¶ Replace the boundary nodal values with the boundary nodal values in the fulldomain.
Parameters: mann_data ( numpy.ndarray
ordict
) – containing the nodal attribute informationReturn type: numpy.ndarray
ordict
Returns: dictionary or array of nodal values
-
set_fulldomain
(fulldomain)¶ Sets the fulldomain of this subdomain to fulldomain and adds this subdomain to that fulldomain.
Parameters: fulldomain ( fulldomain
) – the fulldomain for this subdomain
-
setup
(flag=None, bound_ele=1, bound_vel=1, bound_wd=1, winddir=None)¶ Generate the subdomain input files (
fort.13
,fort.14
,fort.015
,py.141
,py.140
) and shape file. Createsfort.15
based on thefort.15
inpolyadcirc.run_framework.fulldomain
toself.path
, and creates symbolic links to meterological forcing files (fort.22*
).Parameters: - flag (int) – flag determining whether or not the subdomain is an ellipse (0) or a circle (1)
- bound_ele (int) – a flag determining whether surface elevations of the boundary nodes of a subdomain are enforced using a boundary condition file.
- bound_vel (int) – a flag determining whether velocities of the boundary nodes of a subdomain are enforced using a boundary condition file.
- bound_wd (int) – a flag determining whether wet/dry status of the boundary nodes of a subdomain are enforced using a boundary condition file.
Return type: Returns: command line for invoking gensub.py
-
trim_fort13
(old_fort13, new_fort13)¶ Trim
old_fort13
to match the nodes in this subdomain and save asnew_fort13
. This only assumes that apy.140
file exists.Parameters:
-
trim_multiple_fort13
(old_fort13, new_fort13)¶ Trim
old_fort13
to match the nodes in this subdomain and save asnew_fort13
. This only assumes that apy.140
file exists.Parameters:
-
update_mann
(data, path=None, default=None, file_name='fort.13')¶ Write out fort.13 to path with the attributes contained in Data.
Parameters: - data (
numpy.ndarray
ordict
) – containing the nodal attribute information - path (string or None) – the directory to which the fort.13 file will be written
- default (None or float) – default value
- file_name (string) – the name of the
fort.13
formatted file
- data (
-
update_sub2full_map
()¶ Read in the subdomain to fulldomain element and node maps
-
-
polyadcirc.run_framework.subdomain.
trim_fort13
(old_fort13, new_fort13, pynode_map)¶ Trim
old_fort13
to match the nodes in this subdomain and save asnew_fort13
. This only assumes that apy.140
file exists.Parameters:
-
polyadcirc.run_framework.subdomain.
trim_multiple_fort13
(old_fort13, new_fort13, pynode_map)¶ Trim
old_fort13
to match the nodes in this subdomain and save asnew_fort13
. This only assumes that apy.140
file exists.Parameters:
Module contents¶
This subpackage contains
domain
a container object for a data specific to a particular mesh(es), grid(s)random_manningsn
a class and associated set of methods to run a set of ADCIRC simulations with varying parameters