-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
env.yml update for visualization tool (#278)
* env.yml update for visualization tool * Add visualization utilities * corrected accidental git deletion * Revert "corrected accidental git deletion" This reverts commit d32c4b3. --------- Co-authored-by: dzalkind <dzalkind@nrel.gov> Co-authored-by: Cory Frontin <cory.frontin@nrel.gov>
- Loading branch information
1 parent
86724c1
commit e43a159
Showing
3 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |