Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

env.yml update for visualization tool #278

Merged
merged 5 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ channels:
- defaults

dependencies:
- dash
- dill
- jsonmerge
- mat4py
Expand All @@ -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:
Expand Down
Empty file added weis/visualization/__init__.py
Empty file.
84 changes: 84 additions & 0 deletions weis/visualization/utils.py
Original file line number Diff line number Diff line change
@@ -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
Loading