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:
  • x (float) – current x value
  • x_lims (float) – box of x values to adjust
  • b_lims (float) – bathy adj at x_lims
Return type:

float

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 by random_manningsn and plotADCIRC 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]
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 between b_lims

Parameters:
  • x_lims (list) – [x_min, x_max]
  • b_lims (list) – [b_min, b_max]
  • path (string or None) – directory containing the fort.14 to be adjusted
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
dict_bathymetry()
Return type:dict
Returns:key – node number, value – bathymetry
dict_manningsn()
Return type:dict
Returns:key – node number, value – manningsn
find_neighbors()

Determine the neighbors of each of the nodes and store in self.node[#].neighbors as a set().

get_Triangulation(path=None, save=True, show=False, ext='.eps', ics=2)
Parameters:
  • path (string) – directory containing figs/ folder
  • save (bool) – flag
  • show (bool) – flag
Returns:

See get_Triangulation()

make_node_to_element_map()

Create the node to element map

plot_bathymetry(path=None, save=True, show=False, ext='.eps', ics=2)
Parameters:
  • path (string) – directory containing figs/ folder
  • save (bool) – flag
  • show (bool) – flag
Returns:

See bathymetry()

plot_station_locations(path=None, bathymetry=False, save=True, show=False, ext='.eps', ics=2)
Parameters:
  • path (string) – directory containing figs/ folder
  • bathymetry (bool) – flag whether or not to plot bathymetry in the background
  • save (bool) – flag
  • show (bool) – flag
Returns:

See station_locations()

read_default(path=None, file_name='fort.13')

Read in default nodal value from a *.13 file

Parameters:
  • path (string or None) – directory containing fort.13 formatted file
  • file_name (string) – fort.13 formatted file name
Returns:

See read_default()

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:

See read_nodal_attr()

read_recording_data()

Reads in recording information from fort.15 in self.path

See polyadcirc.pyADCIRC.fort15_management.read_recording_data()

read_spatial_grid()

Reads in spatial grid from fort.14 file in self.path

See polyadcirc.pyADCIRC.fort14_management.read_spatial_grid()

read_spatial_grid_header()

Reads in spatial grid header from fort.14 file in self.path

See 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

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 or Ws flag
  • num_writers (int) – number of MPI process to dedicate soley to the task of writing ascii files
  • LorS (string) – (optional) specify L or S 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:
  • key (string) – key for domain.stations[key]
  • method (string) – linear interpolation method see scipy.interpolate.griddata()
update(path=None)

Sets the directory containing files for this domain to self.path

Reads in data from fort.14 and fort.15 files and updates self accordingly

Parameters:path (string or None) – directory containing fort.## files

See read_spatial_grid() See read_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 or dict) – 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

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, and py.gensub for a particular full domain mesh/grid. References to polyadcirc.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* and PE*/fort.065 files exist

Return 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 exists

Return 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:

list

Returns:

command lines for invoking genbcs.py

genfull(noutgs=1, nspoolgs=1, subdomains=None)

Generate the full domain control file, fort.015, and save it to self.path.

Parameters:
  • noutgs (int) – flag controlling whether or not fort.06* will be written out
  • nspoolgs (int) – the number of timesteps at which information is written to the new output files fort.06*
Return type:

string

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:

dict

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 a mpirun 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 in self.base_dir and a set of rankfiles named rankfile_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 – write ADCIRC 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:

string

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 and run_data2 runSet with another runSet (other_run) and points from both runs

To 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:

tuple

polyadcirc.run_framework.random_manningsn.convert_to_days(time_obs)

Converts time_obs from seconds to days

Parameters: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 hours

Parameters: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 RNDAY

Parameters:
  • nts_data – non-time-series data
  • datadomain
Return type:

dict

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
  • datadomain
Return type:

dict

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
  • datadomain
Return type:

dict

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
  • datadomain
Return type:

dict

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 a runSet object. Reconstructs domain. Fixes dry data if it was recorded.

Parameters:
  • save_file (string) – local file name
  • grid_dir (string) – directory containing fort.14, fort.15, and fort.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 and domain objects

Returns:

(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, and fort.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 another runSet (other_run) and points from both runs

Param:

other_run

Parameters:
  • points1 (numpy.ndarray`) – sample points for self
  • points1 – sample points for other_run
Return type:

tuple

Returns:

(self, points)

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 RNDAY

Parameters:datadomain
fix_dry_data(data)

Fix dry elevation station data flags

Parameters:datadomain
fix_dry_nodes(data)

Fix dry elevation data flags

Parameters:datadomain
fix_dry_nodes_nts(data)

Fix dry elevation data flags

Parameters:datadomain
initialize_random_field_directories(num_procs=12, prepRF=True)

Make directories for parallel funs of random fields

Parameters:
  • num_procs (int) – number of processes per padcirc run
  • prep (bool) – flag wether or not to run adcprep
Return type:

list

Returns:

list of paths to RF_directory_*

Assumes that the pre-preped RF_directory is RF_directory_1. In each of the RF_directory_* create the PE**** folders copy over the fort.13 and then link the fort.019, fort.18, fort.15, fort.14`` into the PE**** folder. Also link metis_graph.txt and partmesh.txt into the RF_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 files

Reads in a default Manning’s n value from self.save_dir and stores it in data.manningsn_default

Parameters:
  • datadomain
  • 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 – write ADCIRC 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:

(numpy.ndarray, numpy.ndarray, numpy.ndarray)

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)

save(mdict, save_file)

Save matrices to a *.mat file for use by MATLAB BET code and loadmat()

Parameters:
  • mdict (dict) – dictonary of run data
  • save_file (string) – file name
setup_rfdir(path, num_procs)

Creates the directory path and copies required files from self.base_dir into

Parameters:
  • path (string) – folder_name
  • num_procs (int) – number of processors per ADCIRC run
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
update_mdict(mdict)

Set up references for mdict

Parameters:mdict (dict) – dictonary of run data
write_prep_script(n, screenout=False)

Creats a bash script to run adcprep with in.prepn

Parameters:
  • n (int) – n for in.prepn input to ADCPREP
  • num_jobs (int) – number of jobs to run
  • screenout (bool) – flag (True – write ADCPREP output to screen, False – write ADCPREP output to prep_o.txt file)
Return type:

string

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 in self.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 – write ADCIRC 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:

string

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 in self.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 – write ADCIRC 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:

string

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 in self.base_dir and a set of rankfiles named rankfile_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 – write ADCIRC 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:

str

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 in self.base_dir and a set of rankfiles named rankfile_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 – write ADCIRC 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:

string

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 a runSet object. Reconstructs domain. Fixes dry data if it was recorded.

Parameters:
  • save_file (string) – local file name
  • grid_dir (string) – directory containing fort.14, fort.15, and fort.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 two numpy.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, and fort.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
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 the fort.13 and fort.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 in data.manningsn_default

Note

Currently supports ADCIRC output files fort.6*, *.63, fort.7*, but NOT Hot Start Output (fort.67, fort.68)

Parameters:
  • datadomain
  • 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 in data
  • screenout (bool) – flag (True – write ADCIRC output to screen, False – write ADCIRC 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:

(numpy.ndarray, numpy.ndarray, numpy.ndarray)

Returns:

(time_obs, ts_data, nts_data)

update_mdict(mdict)

Set up references for mdict

Parameters:mdict (dict) – dictionary of run 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 a runSet object. Reconstructs domain. Fixes dry data if it was recorded.

Parameters:
  • save_file (string) – local file name
  • grid_dir (string) – directory containing fort.14, fort.15, and fort.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 two numpy.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 in self.save_dir

Parameters:
  • domaindomain
  • 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
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, and fort.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/figs

Todo

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 in self.save_dir

Parameters:
  • domaindomain
  • 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
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 and 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 the fort.13 and fort.14 in the same step.

Reads in a default Manning’s n value from self.save_dir and stores it in data.manningsn_default

Note

Currently supports ADCIRC output files fort.6*, *.63, fort.7*, but NOT Hot Start Output (fort.67, fort.68)

Parameters:
  • datadomain
  • 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 as num_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 – write ADCIRC 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:

(numpy.ndarray, numpy.ndarray, numpy.ndarray)

Returns:

(time_obs, ts_data, nts_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 and mann_points and returns a dictonary of arrays containing data from output files. Assumes that the number of wall_points is less than the number of mann_points. Runs batches of PADCIRC as a double for loop with the ADCPREP prepping the fort.14 file on the exterior loop and the fort.13 file on the interior loop.

Reads in a default Manning’s n value from self.save_dir and stores it in data.manningsn_default

Note

Currently supports ADCIRC output files fort.6*, *.63, fort.7*, but NOT Hot Start Output (fort.67, fort.68)

Parameters:
  • datadomain
  • 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 of num_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 – write ADCIRC 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:

(numpy.ndarray, numpy.ndarray, numpy.ndarray)

Returns:

(time_obs, ts_data, nts_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 a runSet object. Reconstructs domain. Fixes dry data if it was recorded.

Parameters:
  • save_file (string) – local file name
  • grid_dir (string) – directory containing fort.14, fort.15, and fort.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 two numpy.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, and fort.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 and 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 the fort.13 and fort.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 in data.manningsn_default

Note

Currently supports ADCIRC output files fort.6*, *.63, fort.7*, but NOT Hot Start Output (fort.67, fort.68)

Parameters:
  • datadomain
  • 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 as num_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 in data
  • screenout (bool) – flag (True – write ADCIRC output to screen, False – write ADCIRC 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:

(numpy.ndarray, numpy.ndarray, numpy.ndarray)

Returns:

(time_obs, ts_data, nts_data)

update_mdict(mdict)

Set up references for mdict

Parameters:mdict (dict) – dictionary of run 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 a runSet object. Reconstructs subdomain.

Parameters:
  • save_file (string) – local file name
  • grid_dir (string) – directory containing fort.14, fort.15, and fort.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 and domain objects

Returns:

(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, and py.gensub for a particular subdomain mesh/grid. References to polyadcirc.run_framework.subdomain objects are also contained in an instantiation of this class.

check()

Check to make sure the fort.019 file exists

Return type:bool
Returns:False the fort.019 doesn’t exist
check_fulldomain()

Check to see if the fort.06* and PE*/fort.065 files exist

Return 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:
  • x (float) – x coordinate of circle center
  • y (float) – y coordinate of circle center
  • r (float) – radius of circle
Return type:

int

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:

tuple

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:

tuple

Returns:

(ts_error, nts_error, time_obs, ts_data, nts_data)

create_fort15()

Copy the fort.15 from fulldomain.path to self.path and modify for a subdomain run.

ellipse(x, y, w)

Generate a subdomain shape file for an elliptical subdomain

Parameters:
  • x (list) – x coordinates of the first and second focal points
  • y (list) – y coordinates of the first and second focal points
  • w (float) – width of ellipse
Return type:

int

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:

string

Returns:

command line for invoking genbcs.py

genfull(noutgs=1, nspoolgs=1)

Generate the full domain control file, fort.015, and save it to self.fulldomain.path.

Parameters:
  • noutgs (int) – flag controlling whether or not fort.06* will be written out
  • nspoolgs (int) – the number of timesteps at which information is written to the new output files fort.06*
Return type:

string

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. Creates fort.15 based on the fort.15 in polyadcirc.run_framework.fulldomain to self.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:

string

Returns:

command line for invoking gensub.py

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 a dict as self.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, and self.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, and self.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 or dict) – containing the nodal attribute information
Return type:numpy.ndarray or dict
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. Creates fort.15 based on the fort.15 in polyadcirc.run_framework.fulldomain to self.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:

string

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 as new_fort13. This only assumes that a py.140 file exists.

Parameters:
  • old_fort13 (string) – path to the old fort.13 file to be trimmed
  • new_fort13 (string) – path to save the new fort.13 file
trim_multiple_fort13(old_fort13, new_fort13)

Trim old_fort13 to match the nodes in this subdomain and save as new_fort13. This only assumes that a py.140 file exists.

Parameters:
  • old_fort13 (string) – path to the old fort.13 file to be trimmed
  • new_fort13 (string) – path to save the new fort.13 file
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 or dict) – 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
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 as new_fort13. This only assumes that a py.140 file exists.

Parameters:
  • old_fort13 (string) – path to the old fort.13 file to be trimmed
  • new_fort13 (string) – path to save the new fort.13 file
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 as new_fort13. This only assumes that a py.140 file exists.

Parameters:
  • old_fort13 (string) – path to the old fort.13 file to be trimmed
  • new_fort13 (string) – path to save the new fort.13 file

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