diff --git a/environment.yml b/environment.yml index 017dd3ce2..9da80ec39 100644 --- a/environment.yml +++ b/environment.yml @@ -3,6 +3,7 @@ channels: - defaults dependencies: + - dash - dill - jsonmerge - mat4py @@ -15,6 +16,8 @@ dependencies: - smt - wisdem - pip: + - dash-bootstrap-components + - dash-mantine-components - dearpygui - marmot-agents # Needs to be done outside of environment file: diff --git a/weis/visualization/__init__.py b/weis/visualization/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/weis/visualization/utils.py b/weis/visualization/utils.py new file mode 100644 index 000000000..46bc6d5a3 --- /dev/null +++ b/weis/visualization/utils.py @@ -0,0 +1,84 @@ +''' +Various functions for help visualizing WEIS outputs +''' +from weis.aeroelasticse.FileTools import load_yaml +import pandas as pd +import numpy as np +import openmdao.api as om + + +try: + import ruamel_yaml as ry +except Exception: + try: + import ruamel.yaml as ry + except Exception: + raise ImportError('No module named ruamel.yaml or ruamel_yaml') + +def read_cm(cm_file): + """ + Function originally from: + https://github.com/WISDEM/WEIS/blob/main/examples/16_postprocessing/rev_DLCs_WEIS.ipynb + + Parameters + __________ + cm_file : The file path for case matrix + + Returns + _______ + cm : The dataframe of case matrix + dlc_inds : The indices dictionary indicating where corresponding dlc is used for each run + """ + cm_dict = load_yaml(cm_file, package=1) + cnames = [] + for c in list(cm_dict.keys()): + if isinstance(c, ry.comments.CommentedKeySeq): + cnames.append(tuple(c)) + else: + cnames.append(c) + cm = pd.DataFrame(cm_dict, columns=cnames) + + return cm + +def parse_contents(data): + """ + Function from: + https://github.com/WISDEM/WEIS/blob/main/examples/09_design_of_experiments/postprocess_results.py + """ + collected_data = {} + for key in data.keys(): + if key not in collected_data.keys(): + collected_data[key] = [] + + for key_idx, _ in enumerate(data[key]): + if isinstance(data[key][key_idx], int): + collected_data[key].append(np.array(data[key][key_idx])) + elif len(data[key][key_idx]) == 1: + try: + collected_data[key].append(np.array(data[key][key_idx][0])) + except: + collected_data[key].append(np.array(data[key][key_idx])) + else: + collected_data[key].append(np.array(data[key][key_idx])) + + df = pd.DataFrame.from_dict(collected_data) + + return df + + +def load_OMsql(log): + """ + Function from : + https://github.com/WISDEM/WEIS/blob/main/examples/09_design_of_experiments/postprocess_results.py + """ + # logging.info("loading ", log) + cr = om.CaseReader(log) + rec_data = {} + cases = cr.get_cases('driver') + for case in cases: + for key in case.outputs.keys(): + if key not in rec_data: + rec_data[key] = [] + rec_data[key].append(case[key]) + + return rec_data \ No newline at end of file