bdschism package

Subpackages

Submodules

bdschism.analyze_dt module

bdschism.analyze_dt.load_data(ncfile, time_step=None)[source]

Load time step and mesh data from a SCHISM NetCDF file.

Parameters:
  • ncfile (str) – Path to the NetCDF file.

  • time_step (int or None) – Specific time index to select. If None, load all.

Returns:

Time step values, x-coordinates, y-coordinates.

Return type:

tuple of (np.ndarray, np.ndarray, np.ndarray)

bdschism.analyze_dt.plot_summarized_bad_actors(bad_actors, all_x, all_y, label_top=None)[source]
bdschism.analyze_dt.summarize_elements(ncfile, top_n, min_count, ref_nth=25)[source]
bdschism.analyze_dt.write_bad_csv(csv_out, points)[source]
bdschism.analyze_dt.write_bad_shp(shp_out, points, all_x, all_y)[source]

Write bad actor points to shapefile using geopandas.

bdschism.barrier_status module

bdschism.calc_ndoi module

bdschism.ccf_gate_height module

bdschism.combine_hotstart module

bdschism.combine_nc module

bdschism.combine_nc.combine_nc(input_files, outfile)[source]

Combines multiple NetCDF files (e.g., out2d_1.nc, out2d_2.nc, etc.) into a single NetCDF file along the time dimension.

bdschism.combine_nc.combine_uv3d(start_num, end_num, outfile, tmp_out_dir='./outputs.tropic/uv3d')[source]
bdschism.combine_nc.compare_dataarray_all_axes(validate_da, check_da, atol=1e-06, rtol=1e-06)[source]

Check two DataArrays match on dims, coords, shape, and values.

bdschism.combine_nc.get_selected_files(template, start_num, end_num)[source]

Get a sorted list of files matching the template and within the specified number range.

bdschism.combine_nc.validate_time_step_consistency(time_values, atol=1e-09, max_report=20)[source]

Validate constant time step and report exact mismatch locations.

bdschism.config_cli module

bdschism.diff_gr3 module

bdschism.diff_gr3.diff_congruent_gr3(fname0, fname1, fout)[source]

bdschism.gen_elev2d module

bdschism.generate_realtime_elev2d module

bdschism.generate_visit_filelist module

bdschism.generate_visit_filelist.visit_list(output_dir, var, start, end, filename)[source]

Generate a file containing a list of SCHISM output files to be visualized on VisIt.

Parameters:
  • output_dir (str) – Outputs directory containing SCHISM output files.

  • var (str) – variable name for SCHISM output files (e.g., horizontalVelX).

  • start (int) – Starting index for the file list.

  • end (int) – Ending index for the file list.

  • filename (str) – Filename for the list of SCHISM output files.

bdschism.hotstart_date module

bdschism.hotstart_from_hotstart module

bdschism.hotstart_nudging_data module

bdschism.nc_metadata module

bdschism.nc_metadata.nc_metadata(ncfile, attr_name, attr_value, write, read, overwrite)[source]

Read or write NetCDF global metadata.

bdschism.parse_cu module

bdschism.plot_input_boundaries module

bdschism.port_boundary module

bdschism.profile_plot module

bdschism.profile_plot.get_index_bounds()[source]
bdschism.profile_plot.nearest_neighbor_fill(arr)[source]
bdschism.profile_plot.profile_plot(x, z, data, ax, context_label=None, add_labels=False, xlabel=None, xmin=None, xmax=None, max_depth=None)[source]

UnTRIM-like profile plot of salinity xmin,xmax are the bounds (in km) of the profile max_depth is the maximum depth, data assumed to be

bdschism.profile_plot.set_index_bounds(min_station, max_station, max_depth)[source]
bdschism.profile_plot.vertical_fill(arr)[source]

bdschism.read_dss module

bdschism.run_sequence module

bdschism.runtime_hotstart module

bdschism.set_mode module

bdschism.set_nudging module

bdschism.settings module

Create a link between a source file and a target path based on system-specific link styles.

This function creates a symbolic link, junction, or copies the file, depending on the system settings. The link style is determined dynamically from get_settings(), which specifies the preferred linking method for the operating system.

Parameters:
  • source (str) – The path to the source file that will be linked.

  • symlink (str) – The target path where the link (or copy) will be created.

  • config_log (bool, optional) – If True, log the configuration source being used.

Raises:

ValueError – If the link style retrieved from get_settings() is unsupported.

Notes

  • If a symbolic link already exists at symlink, it is removed before creating a new one.

  • On Windows, the function supports creating junction links (mklink), symbolic links, or copying the file instead.

  • On Unix-based systems, it defaults to using symbolic links.

Examples

Create a symbolic link on Unix-like systems or an appropriate alternative on Windows:

>>> create_link("/path/to/source.txt", "/path/to/symlink.txt")
bdschism.settings.get_output_from_interpolate_variables(varname, config_log=False)[source]

Get the output filename for the interpolate_variables function.

Parameters:
  • varname (str) – The variable name for which to retrieve the output filename (e.g., ‘uv3d’).

  • config_log (bool, optional) – If True, log the configuration source being used.

Returns:

The output filename for the interpolate_variables utility.

Return type:

str

bdschism.settings.get_settings(config_log: bool = False)[source]

Load and return application settings from a configuration file.

This function retrieves configuration settings using a hierarchy of possible sources: 1. A package-level default configuration file (bds_config.yaml within the package). 2. A project-level configuration file (bds_config.yaml in the current working directory). 3. An environment-specific configuration file, if BDS_CONFIG is set and points to a valid file.

The function uses Dynaconf to load settings, ensuring that the highest-priority configuration (environment variable, project-level, or package default) is used.

Returns:

A Dynaconf object containing the loaded configuration settings.

Return type:

Dynaconf

Notes

  • The package-level configuration file provides default settings.

  • If a project-level configuration file exists in the current directory, it overrides the package default.

  • If an environment variable BDS_CONFIG is set and points to a valid file, it takes the highest precedence.

  • The function logs the configuration source being used.

Examples

Load settings from the highest-priority available configuration file:

>>> settings = get_settings()
Using configuration from: /path/to/highest-priority-config.yaml current env development

Access settings:

>>> settings.some_setting
'some_value'
bdschism.settings.interpolate_variables(config_log=False)[source]

interpolate SCHISM variables from background grid to foreground grid for elevation, tracers, or uv3D

Parameters:

config_log (bool, optional) – If True, log the configuration source being used.

Raises:

ValueError – If the link style retrieved from get_settings() is unsupported.

Notes

  • interpolate_variables8 is the version of interpolate_variables associated with SCHISM 5.11

Examples

Interpolate SCHISM variables on Unix-like systems or an appropriate alternative on Windows:

>>> interpolate_variables()

bdschism.smscg_log_2_schism_th module

bdschism.synthetic_copy module

bdschism.synthetic_sflux module

bdschism.three_point_linear_norm module

class bdschism.three_point_linear_norm.ThreePointLinearNorm(*args: Any, **kwargs: Any)[source]

Bases: Normalize

autoscale(A)[source]

Set vmin, vmax to min, max of A.

autoscale_None(A)[source]

autoscale only None-valued vmin or vmax

inverse(value)[source]
scaled()[source]

return true if vmin and vmax set

bdschism.tide module

class bdschism.tide.Node(name, record_length_hours=166440)[source]

Bases: object

add_child(child_node)[source]

Adds a child node to this node’s children list.

add_parent(parent_node)[source]

Adds a parent node to this node’s parent list.

get_ancestors()[source]

retrieves the list of ancestors of this node.

get_descendants()[source]

retrieves the list of descendants of this node.

num_ancestors()[source]

Recursively counts the total number of ancestors of this node.

num_descendants()[source]

Recursively counts the total number of descendants of this node.

bdschism.tide.gen_constituents_tree()[source]

This function generates the constituent trees of Choice of constituents and Rayleigh comparison pairs It returns a list of root nodes for subtide, diurnal, semidiurnal and terdiurnal, and a list of shallow water constituents that have multiple parents. It is implementation from Table 1 to Table 5 in “MANUAL FOR TIDAL HEIGHTS ANALYSIS AND PREDICTION” by M.G.G. Foreman (1996).

bdschism.tide.get_astro_constituent_names(astro_group, record_length_hours=0)[source]

Recursivly Retrieves the names of all constituents in the astro_group that can be analyazed by the specified record_length_hours.

Args: astro_group: list of root nodes for the main constituent groups (slow, diurnal, semidiurnal, terdiurnal). record_length_hours: the length of the record in hours, used to determine which constituents can be analyzed.

Returns: A sorted list of constituent names that can be analyzed with the given record length.

bdschism.tide.get_constituents(record_length_hours=0)[source]

Retrieves the names of all constituents in the astro_group and shallow_group that can be analyazed by the specified record_length_hours.

Parameters:
  • astro_group – list of root nodes for the main constituent groups (slow, diurnal, semidiurnal, terdiurnal).

  • shallow_group – list of nodes for shallow water constituents that have multiple parents.

  • record_length_hours – the length of the record in hours, used to determine which constituents can be analyzed.

Returns: A sorted list of constituent names that can be analyzed with the given record length.

bdschism.uv3d module

bdschism.x2_buildpoints module

bdschism.x2_time_series module

bdschism.zone_utils module

Created on Fri May 5 09:45:12 2023

@author: qshu

bdschism.zone_utils.face_aver(node_depth_average, node_num, face_num, ele_table)[source]
bdschism.zone_utils.face_aver_inst(inst_node_depth_average, node_num, face_num, ele_table)[source]
bdschism.zone_utils.fill_ele_area(face_num, ele_table, node_x, node_y, ele_area)[source]
bdschism.zone_utils.fill_ele_area510(face_num, ele_table, node_x, node_y, ele_area)[source]
bdschism.zone_utils.gen_node_neibor_ele(mesh_node, max_node_in_a_cell, num_ele, num_node)[source]
bdschism.zone_utils.gen_node_wet_dry(node_wet_dry, ele_wet_dry, num_step, num_node, max_ele_at_node, el)[source]
bdschism.zone_utils.quad_area(x1, y1, x2, y2, x3, y3, x4, y4)[source]
bdschism.zone_utils.triangle_area(x1, y1, x2, y2, x3, y3)[source]

Module contents