• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

WISDEM / WEIS / 11975795765

22 Nov 2024 03:50PM UTC coverage: 78.802% (-0.9%) from 79.662%
11975795765

push

github

web-flow
WEIS v1.4 (#322)

* Viz tool integration (#301)

* utils update for viz tool

* hotfix for length error in viz utils

* slightly improved hotfix

* trim edge case

* working integration with weis

* add text field for reloading diff yaml file

* f-string typo fix to pass py3.11 unit test

* remove duplicated fields on raft opt

* elevate 'weis_viz' to a command within the conda env

* add optimization type

* reformating vizgen and adding 'weis_viz_input_gen' as a command

---------

Co-authored-by: Cory Frontin <cory.frontin@nrel.gov>
Co-authored-by: sryu <Sora.Ryu@nrel.gov>
Co-authored-by: Sora Ryu <sryu@x1007c0s0b0n0.hsn.cm.kestrel.hpc.nrel.gov>
Co-authored-by: Sora Ryu <sryu@kl3.head.cm.kestrel.hpc.nrel.gov>

* bug fix in vizFileGen and changes to handle Jul 2024 Kestrel updates (#306)

* bug fix in vizFileGen and fixes to handle Jul 2024 Kestrel updates

* change type settings and default channels

* match type with WEIS level

* minor update on type setting - dlc

---------

Co-authored-by: Sora Ryu <sryu@x1000c0s0b0n0.hsn.cm.kestrel.hpc.nrel.gov>
Co-authored-by: Sora Ryu <sryu@kl2.head.cm.kestrel.hpc.nrel.gov>

* no need to manipulate turbsim grid for olaf anymore (#313)

* Debug arg parsing error while launching the app & Contribute Initial Documentation (#307)

* fix bug of args parse while running app

* delete unnecessary prints

* change horizontal subplots to vertical ones

* initial documentation

* delete readme file

* minor changes on graph layout

* update on kestrel set up

* merge weis viz docs into existing weis docs

* delete initial weis viz documentation

* update on docs after changing opt type setting

* Revise documentation

---------

Co-authored-by: sryu <Sora.Ryu@nrel.gov>
Co-authored-by: dzalkind <dzalkind@nrel.gov>

* Remove duplicate numpydoc

* Sync readthedocs yaml with WISDEM

* Add numpydoc to environment

* Set up readthedocs inputs... (continued)

43 of 375 new or added lines in 12 files covered. (11.47%)

6 existing lines in 3 files now uncovered.

21658 of 27484 relevant lines covered (78.8%)

0.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/weis/visualization/opt_plotting.py
1
import glob
×
2

3
import glob
×
4
import json
×
5
import multiprocessing as mp
×
6

7
import pandas as pd
×
8
import numpy as np
×
9
import matplotlib.pyplot as plt
×
10

11
import openmdao.api as om
×
12

13
from weis.visualization.utils import *
×
14

15

16
def plot_conv(
×
17
    keyset_in,
18
    map_dataOM_vars,
19
    use_casewise_feasibility=False,
20
    feas_tol=1e-5,
21
    figax=None,
22
    alpha=None,
23
):
24
    """
25
    plot a set of keys
26

27
    args:
28
        keyset_in: list[str]
29
            list of keys to plot the convergence data for
30
        map_dataOM_vars: dict[str -> dict]
31
            map from a case of interest by name to an OM data dict to plot
32
        use_casewise_feasibility: bool
33
            if plotting a constraint should we plot feasibility w.r.t. that constraint (vs. all)
34

35
    returns:
36
        fig : plt.Figure
37
        ax : plt.Axes
38
    """
39

40
    if len(keyset_in) == 0:
×
41
        return
×
42

43
    markerstyle = "x"
×
44
    markersize = 5
×
45
    linestyle = "-"
×
46

47

NEW
48
    fig, axes = figax if figax else plt.subplots(
×
49
        len(keyset_in),
50
        1,
51
        sharex=True,
52
        figsize=(6, 0.60 * 4 * len(keyset_in)),
53
        squeeze=False,
54
        dpi=150,
55
    )
56

57
    has_ref_vals = type(keyset_in) == dict
×
58

59
    if has_ref_vals:
×
60
        key_val_map = keyset_in
×
61
        keyset = keyset_in.keys()
×
62
    else:
63
        keyset = keyset_in
×
64

65
    pt_imethod = []
×
66
    for imethod, method in enumerate(map_dataOM_vars.keys()):
×
67
        if imethod == 0:
×
68
            markerstyle = "o"
×
69
        elif imethod == 1:
×
70
            markerstyle = "p"
×
71
        elif imethod == 2:
×
72
            markerstyle = "s"
×
73
        else:
74
            markerstyle = "P"
×
75

76
        pt0 = axes[0, 0].plot(
×
77
            [],
78
            [],
79
            markerstyle + linestyle,
80
            label=method,
81
            markersize=markersize,
82
            # color=(0.5,0.5,0.5),
83
            alpha=alpha,
84
        )
85
        dataOM = map_dataOM_vars[method][0]
×
86
        vars = map_dataOM_vars[method][1]
×
87
        tfeas, varfeas = get_feasible_iterations(dataOM, vars, feas_tol=feas_tol)
×
88

89
        for idx_ax, key in enumerate(keyset):
×
90
            if key in ["rank", "iter",]: continue
×
91
            if use_casewise_feasibility and key in varfeas.keys():
×
92
                feas_val = varfeas[key]
×
93
            else:
94
                feas_val = tfeas  # use total feasibility
×
95

96
            axes[idx_ax, 0].plot(
×
97
                np.squeeze(dataOM[key]),
98
                linestyle,
99
                label="".join(["_", method, "_"]),
100
                color=pt0[-1].get_color(),
101
                markersize=markersize,
102
                alpha=alpha,
103
            )
104
            axes[idx_ax, 0].plot(
×
105
                np.ma.array(
106
                    dataOM[key],
107
                    mask=~(
108
                        feas_val * np.ones(
109
                            (
110
                                1,
111
                                np.array(dataOM[key]).shape[1]
112
                                if len(np.array(dataOM[key]).shape) > 1
113
                                else 1
114
                            ),
115
                            dtype=bool,
116
                        )
117
                    )
118
                ),
119
                markerstyle,
120
                label="".join(["_", method, "_"]),
121
                color=pt0[-1].get_color(),
122
                alpha=alpha,
123
                fillstyle="full",
124
                markersize=markersize,
125
            )
126
            axes[idx_ax, 0].plot(
×
127
                np.ma.array(
128
                    dataOM[key],
129
                    mask=(
130
                        feas_val * np.ones(
131
                            (
132
                                1,
133
                                np.array(dataOM[key]).shape[1]
134
                                if len(np.array(dataOM[key]).shape) > 1
135
                                else 1
136
                            ),
137
                            dtype=bool,
138
                        )
139
                    )
140
                ),
141
                markerstyle,
142
                label="".join(["_", method, "_"]),
143
                color=pt0[-1].get_color(),
144
                alpha=alpha,
145
                fillstyle="none",
146
                markersize=markersize,
147
            )
148
            if has_ref_vals:
×
149
                cval = key_val_map[key]
×
NEW
150
                if (cval[0] is not None) and (np.log10(np.abs(cval[0])) < 18):
×
151
                    axes[idx_ax, 0].plot([0, len(dataOM[key])], [cval[0], cval[0]], "b:", label="_lower bound_")
×
NEW
152
                if (cval[1] is not None) and (np.log10(np.abs(cval[1])) < 18):
×
153
                    axes[idx_ax, 0].plot([0, len(dataOM[key])], [cval[1], cval[1]], "r:", label="_upper bound_")
×
154
            axes[idx_ax, 0].set_title(key)
×
155

156
    if has_ref_vals:
×
157
        axes[0, 0].plot([], [], "b:", label="lower bound")
×
158
        axes[0, 0].plot([], [], "r:", label="upper bound")
×
159
    axes[0, 0].legend()
×
160
    fig.tight_layout()
×
161

162
    return fig, axes
×
163

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc