adbo package
Submodules
adbo.ani module
afdorce.ani.py
- adbo.ani.plot_gps(path_in='mult1', gp_file='gp_model_outputs.nc', plot_acq=False, add_name='', verbose=False, save_pdf={}, side_length=3)
Plot GPs. Now supports 1D and 2D plots.
Function currently assumes that the GP file contains the following variables: - ypred: GP prediction - yvar: GP variance - acq: acquisition function
And has the following dimensions: - call: number of calls Either x1 or x1 and x2.
Reads bo-config.json to determine the order of the variables.
- Parameters:
- Return type:
adbo.constants module
This file is used to save all possible project wide constants.
Includes source folder, the project path, etc.
Example
Import statement at top of script:
from tcpips.constants import PROJECT_PATH, FIGURE_PATH
adbo.create_test_set module
- adbo.create_test_set.convert_best_bo_run_to_swegnn(bayesopt_run_folder, output_nc_path)
Finds the best run from a BO folder, converts it to SWE-GNN format, and saves it.
(This is the same function as before).
- Return type:
- adbo.create_test_set.find_best_run_from_json(json_path)
Parses an ‘experiments.json’ file to find the run with the highest ‘res’.
This file format is defined in the add_query_to_output function in adbo/exp.py.
- Parameters:
json_path (
str) – The full path to the ‘experiments.json’ file.- Return type:
- Returns:
The full path to the simulation directory (e.g., ‘…/exp_0025’) that had the highest ‘res’ value, or None if not found.
Doctests: >>> import tempfile >>> import json >>> from pathlib import Path >>> with tempfile.TemporaryDirectory() as tmpdir: … p = Path(tmpdir) … run1_path = p / “exp_0001” … run2_path = p / “exp_0002” … run1_path.mkdir() … run2_path.mkdir() … json_path = p / “experiments.json” … data = { … “0”: {“res”: 5.2, “”: str(run1_path), “displacement”: 0.1}, … “1”: {“res”: 8.5, “”: str(run2_path), “displacement”: 0.5}, … “2”: {“res”: 7.1, “”: str(run1_path), “displacement”: 0.2} … } … with open(json_path, ‘w’) as f: … json.dump(data, f) … best_run = find_best_run_from_json(str(json_path)) … # The best path should be the one from run “1” … str(best_run) == str(run2_path) True
- adbo.create_test_set.process_all_bo_runs(base_exp_dir, output_base_dir, folder_names, skip_existing=True)
Iterates over a list of BO experiment folders and converts the best run from each into a SWE-GNN NetCDF file.
- Parameters:
base_exp_dir (
str) – The root directory where all BO folders live (e.g., ‘/work/n01/n01/sithom/adcirc-swan/tcpips/exp’).output_base_dir (
str) – The target directory to save .nc files (e.g., ‘/work/n01/n01/sithom/adcirc-swan/SurgenetTestPH’).folder_names (
List[str]) – A list of string names for the subfolders within base_exp_dir to process.skip_existing (
bool) – If True, skips processing if the output .nc file already exists.
- Return type:
adbo.exp module
adbo.exp_1d module
adbo.exp_2d module
adbo.exp_3d module
adbo.gp_exp module
adbo.plot module
Plot results from adcirc Bayesian optimization experiments.
- adbo.plot.custom_parallel_coordinates(df, class_column=None, cols=None, colors=None, constraints=None, balance=False, legend=True, ax=None)
Plots a parallel coordinates chart where each column has its own vertical scale.
- Parameters:
df (pd.DataFrame) – DataFrame with data to plot.
class_column (str, optional) – Column to use for coloring. Defaults to None.
cols (list, optional) – Columns to plot. Defaults to None.
colors (dict, optional) – Colors to use for each class. Defaults to None.
constraints (dict, optional) – Constraints for each column. Defaults to None.
balance (bool, optional) – Balance the data. Defaults to False.
legend (bool, optional) – Show legend. Defaults to True.
ax (Optional[plt.Axes], optional) – Axis to plot on. Defaults to None.
- Returns:
Axis with plot.
- Return type:
plt.Axes
- adbo.plot.find_argdifference(stationid)
Find difference in max value between two years.
- adbo.plot.find_argmax(exp)
Find argmax value in experiment.
- adbo.plot.find_difference(stationid)
Find difference in max value between two years.
- adbo.plot.find_max(exp)
Find max value in experiment.
- adbo.plot.get_max_from_ib_list(iblist)
Get max from ib list.
- adbo.plot.listify(exp, key)
Listify the values of a key in a dictionary.
- adbo.plot.make_argmax_table(daf='mes')
We want to make a table of the argmax values for each experiment.
- Parameters:
daf (str, optional) – DAF name. Defaults to “mes”. Also ran an “ei” experiment.
- Return type:
- Columns:
Name (e.g New Orleans, Galverston, Miami)
Year (e.g 2015, 2100)
Trial (e.g 0, 1, 2)
Argmax index (1 to 50)
Displacement
Angle
Translation Speed
Max SSH
- adbo.plot.plot_diff(exps=('miami-2015', 'miami-2100'), figure_name='2015-vs-2100-miami.pdf')
Plot difference between two years.
- adbo.plot.plot_many(year='2015')
Plot difference between two years.
- adbo.plot.plot_multi_argmax()
- adbo.plot.plot_places(bbox=[('Latitude bounds', [28.0, 31.3], 'degrees_north'), ('Longitude bounds', [-92.5, -86.0], 'degrees_east'), 'New Orleans Area Bounding Box padded by 0.5 degrees'], path_to_maxele='/home/docs/checkouts/readthedocs.org/user_builds/worstsurge/checkouts/latest/exp/8729840-2015/exp_0001/maxele.63.nc')
Plot observation places.
adbo.rescale module
Rescale the parameter inputs to fall in 0.0 to 1.0 range.
This is used to rescale the inputs to the GP, and then rescale the outputs back to the original range.
The parameters are defined in the constraints config file, and the rescaling is done by subtracting the minimum value, and dividing by the range.
Input/output numpy arrays are assumed to be of shape [N, F] where N is the number of points and F is the number of features.
- adbo.rescale.rescale(inputs, constraints, verbose=False)
Rescale the numbers to fall in 0.0 to 1.0 range.
- adbo.rescale.rescale_inverse(inputs, constraints, verbose=False)
Rescale back the numbers to fall in original range.
- Parameters:
- Returns:
rescaled array size [N, F] where N is number of points and F is number of features.
- Return type:
np.ndarray