openscm_calibration.scipy_plotting.scmdata#
Support for plotting during scipy optimisation with [scmdata][scmdata]
Functions:
| Name | Description |
|---|---|
convert_target_to_model_output_units_scmrun |
Convert the target data to the model output's units |
get_timeseries_scmrun |
Get timeseries for plotting from an [ |
plot_timeseries_scmrun |
Plot timeseries |
Attributes:
| Name | Type | Description |
|---|---|---|
DEFAULT_PLOT_TIMESERIES_BACKGROUND_TS_KWARGS |
dict[str, Any]
|
Default value for |
DEFAULT_PLOT_TIMESERIES_BEST_TS_KWARGS |
dict[str, Any]
|
Default value for |
DEFAULT_PLOT_TIMESERIES_TARGET_TS_KWARGS |
dict[str, Any]
|
Default value for |
DEFAULT_PLOT_TIMESERIES_BACKGROUND_TS_KWARGS
module-attribute
#
DEFAULT_PLOT_TIMESERIES_BACKGROUND_TS_KWARGS: dict[
str, Any
] = {
"legend": False,
"linewidth": 0.5,
"alpha": 0.3,
"color": "tab:gray",
"zorder": 1.5,
}
Default value for background_ts_kwargs used by plot_timeseries_scmrun
Provided to give the user an easy to modify these defaults if they wish or a starting point.
DEFAULT_PLOT_TIMESERIES_BEST_TS_KWARGS
module-attribute
#
DEFAULT_PLOT_TIMESERIES_BEST_TS_KWARGS: dict[str, Any] = {
"legend": False,
"linewidth": 2,
"alpha": 0.8,
"color": "tab:orange",
"zorder": 2.5,
}
Default value for best_ts_kwargs used by plot_timeseries_scmrun
Provided to give the user an easy to modify these defaults if they wish or a starting point.
DEFAULT_PLOT_TIMESERIES_TARGET_TS_KWARGS
module-attribute
#
DEFAULT_PLOT_TIMESERIES_TARGET_TS_KWARGS: dict[str, Any] = {
"legend": False,
"linewidth": 2,
"alpha": 0.8,
"color": "tab:blue",
"zorder": 2,
}
Default value for target_ts_kwargs used by plot_timeseries_scmrun
Provided to give the user an easy to modify these defaults if they wish or a starting point.
convert_target_to_model_output_units_scmrun #
convert_target_to_model_output_units_scmrun(
*,
target: BaseScmRun,
model_output: BaseScmRun,
convert_results_to_plot_dict: ResultsToDictConverter[
BaseScmRun
],
) -> BaseScmRun
Convert the target data to the model output's units
This is a helper function that allows the data to be lined up before setting up plotting etc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
BaseScmRun
|
Target data to convert |
required |
model_output
|
BaseScmRun
|
A sample of the model's output |
required |
convert_results_to_plot_dict
|
ResultsToDictConverter[BaseScmRun]
|
The function that will be used to convert
[ |
required |
Returns:
| Type | Description |
|---|---|
BaseScmRun
|
Target data with units that match the model output |
Source code in src/openscm_calibration/scipy_plotting/scmdata.py
get_timeseries_scmrun #
get_timeseries_scmrun(
inp: BaseScmRun, time_axis: str = "year-month"
) -> DataFrame
Get timeseries for plotting from an [scmdata.run.BaseScmRun][scmdata.run.BaseScmRun]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inp
|
BaseScmRun
|
Object to convert |
required |
time_axis
|
str
|
Passed to [ |
'year-month'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Data with the time axis as rows, ready for simplified plotting using panda's plotting methods. |
Source code in src/openscm_calibration/scipy_plotting/scmdata.py
plot_timeseries_scmrun #
plot_timeseries_scmrun(
best_run: BaseScmRun,
others_to_plot: tuple[BaseScmRun, ...],
target: BaseScmRun,
convert_results_to_plot_dict: ResultsToDictConverter[
BaseScmRun
],
timeseries_keys: Iterable[str],
axes: dict[str, Axes],
get_timeseries: Callable[[BaseScmRun], DataFrame],
background_ts_kwargs: dict[str, Any] | None = None,
target_ts_kwargs: dict[str, Any] | None = None,
best_ts_kwargs: dict[str, Any] | None = None,
ylabel_kwargs: dict[str, Any] | None = None,
) -> None
Plot timeseries
This plots the target, the best result so far and other results
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
best_run
|
BaseScmRun
|
Best run from iterations |
required |
others_to_plot
|
tuple[BaseScmRun, ...]
|
Other results to plot from iterations |
required |
target
|
BaseScmRun
|
Target timeseries |
required |
convert_results_to_plot_dict
|
ResultsToDictConverter[BaseScmRun]
|
Callable which converts [ |
required |
timeseries_keys
|
Iterable[str]
|
Keys of the timeseries to plot |
required |
axes
|
dict[str, Axes]
|
Axes on which to plot |
required |
get_timeseries
|
Callable[[BaseScmRun], DataFrame]
|
Function which converts [ |
required |
background_ts_kwargs
|
dict[str, Any] | None
|
Passed to |
None
|
target_ts_kwargs
|
dict[str, Any] | None
|
Passed to |
None
|
best_ts_kwargs
|
dict[str, Any] | None
|
Passed to |
None
|
ylabel_kwargs
|
dict[str, Any] | None
|
Passed to |
None
|
Source code in src/openscm_calibration/scipy_plotting/scmdata.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |