Plotting Library#
- csm.tools.plot.plot_mass_cost_comparison(base_kwargs, parameterization, component, parameter_label, reference_turbines=None, background_data=None, mass_units='tonnes', cost_basis='millions', save_name=None, fig_kwargs=None, legend_kwargs=None, reference_scatter_kwargs=None, background_scatter_kwargs=None, plot_kwargs=None, axis_label_kwargs=None, model_plot_settings=None, turbine_scatter_settings=None, mass_xlim=None, mass_ylim=None, cost_xlim=None, cost_ylim=None, *, return_fig_ax=False)#
Plots a 2-column figure of a focal parameter vs
componentmass andcomponentmass vscomponentcost for a set of cost and scaling model(s). Additional reference turbine scatter points and empirical/background scatter points can be added to be shown against the models' scaling curves.- Parameters:
base_kwargs (dict[str, dict]) -- Base configuration for each of the models in the form of model names as keys and configuration dictionary as values. See
csm.get_model()for more details on model naming possibilities. The keys will be used for the figure legend.parameterization (dict[str, list]) --
The parameterization input to
CSMBase.parameterize_subset(). Note that only the first parameter will be used if multiple are provided.Dictionary of independent variables with an iterable value consisting of an explicit set of values or range of values generated by
np.linspace. For both cases, the first value must be one of "inputs" or "range". Subsequent values should specified according to the case:- "inputs": all subsequent values will be used as inputs, e.g.,
{"tower_length": ("inputs", 90, 100)} will run 2 iterations, one with a 90m tower length and one with a 100 meter tower length.
- "range": subsequent values must be start, stop, num where stop is inclusive,
e.g., {"efficiency_max": ("range", 0.8, 1.0, 5)} will run 5 iterations of the model varying
efficiency_maxwith values 0.8, 0.85, 0.9, 0.95, and 1.0.
component (str) -- The name of the turbine component to calculate its respective mass and cost. For available options, see
CSMBase.output_names()parameter_label (str) -- Axis label for the parameter values, e.g., "Blade Mass (kg)".
reference_turbines (dict[str, dict] | None, optional) -- Dictionary of turbine names as keys and model compliant configuration dictionaries that will be used to display each turbine's output on the models' scaling curves. The dictionary keys will be used as the legend labels. Defaults to None.
background_data (pd.DataFrame | None, optional) --
pandas.DataFrameof empirical data points with rows representing turbines and column names matching the naming scheme from the model, i.e., use "rotor_diameter", not "Rotor Diameter" or "rated_power_kw", not "MW". Additionally, ensure the units match the models' units, i.e., kW, kg, USD, etc. Defaults to None.mass_units (str, optional) -- One of "kg" or "tonnes" (metric tonnes) to automatically scale mass units. Defaults to "tonnes".
cost_basis (str, optional) -- One of "dollars", "thousands", or "millions" to automatically scale the cost-basis. Defaults to "millions".
save_name (str | Path | None, optional) -- If provided, the figure will be saved to the file location. Defaults to None.
fig_kwargs (dict | None, optional) -- Keyword arguments passed to
plt.figure(). Defaults to None.legend_kwargs (dict | None, optional) -- Keyword arguments passed to
Figure.legend(). Defaults to None.reference_scatter_kwargs (dict | None, optional) -- Keyword arguments passed to
Axes.scatter()when plotting the reference turbine data. Defaults to None.background_scatter_kwargs (dict | None, optional) -- Keyword arguments passed to
Axes.scatter()when plotting the empirical/background data points. Defaults to None.plot_kwargs (dict | None, optional) -- Keyword arguments passed to
Axes.plot()when plotting the model scaling curves. Defaults to None.axis_label_kwargs (dict | None, optional) -- Keyword arguments passed to each
Axes.set_xlabel()andAxes.set_ylabel(). Defaults to None.model_plot_settings (dict[str, str] | None, optional) -- Keyword arguments passed to
Axes.plot()when plotting the individual model scaling curves. Use this to control model-specific plotting elements with keys matchingbase_kwargs. Defaults to None.turbine_scatter_settings (dict[str, str] | None, optional) -- Keyword arguments passed to
Axes.scatter()when plotting the reference turbines. Use this to control turbine-specific plotting elements with keys matchingreference_turbines. Defaults to None.mass_xlim (tuple[float, float] | None, optional) -- X-axis limits for the parameter vs mass figure. Defaults to None.
mass_ylim (tuple[float, float] | None, optional) -- Y-axis limits for the parameter vs mass figure. Defaults to None.
cost_xlim (tuple[float, float] | None, optional) -- X-axis limits for the mass vs cost figure. Defaults to None.
cost_ylim (tuple[float, float] | None, optional) -- Y-axis limits for the mass vs cost figure. Defaults to None.
return_fig_ax (bool, optional) -- If True, return the figure and axes objects as
(fig, (ax1, ax2)). Defaults to False.
- Raises:
ValueError -- Raised if an invalid input is provided to
mass_units.ValueError -- Raised if an invalid input is provided to
cost_basis.
- Returns:
None | tuple[plt.Figure, tuple[plt.Axes, plt.Axes]] --
FigureandAxesobjectsreturned if
return_fig_axis True, otherwise None.
- Return type:
None | tuple[Figure, tuple[Axes, Axes]]