|
1 | 1 | """Plots using the matplotlib library""" |
2 | 2 |
|
| 3 | +import copy |
3 | 4 | from functools import partial, wraps |
4 | 5 | from math import ceil, floor, sqrt |
5 | 6 | from statistics import stdev |
@@ -119,7 +120,7 @@ def plot_ref_sld_helper( |
119 | 120 | if confidence_intervals is not None: |
120 | 121 | ref_min, ref_max = confidence_intervals["reflectivity"][i] |
121 | 122 | mult = (1 if not q4 else r[:, 0] ** 4) / div |
122 | | - ref_plot.fill_between(r[:, 0], ref_min / div, ref_max / div, alpha=0.6, color="grey") |
| 123 | + ref_plot.fill_between(r[:, 0], ref_min * mult, ref_max * mult, alpha=0.6, color="grey") |
123 | 124 |
|
124 | 125 | if data.dataPresent[i]: |
125 | 126 | sd_x = sd[:, 0] |
@@ -241,10 +242,13 @@ def plot_ref_sld( |
241 | 242 | """ |
242 | 243 | data = PlotEventData() |
243 | 244 |
|
| 245 | + # We need to take a copy of reflectivity and SLD in case we are plotting a |
| 246 | + # shaded plot and will therefore change the plotted data to that from the |
| 247 | + # centre of the Bayesian distribution |
244 | 248 | data.modelType = project.model |
245 | | - data.reflectivity = results.reflectivity |
| 249 | + data.reflectivity = copy.deepcopy(results.reflectivity) |
246 | 250 | data.shiftedData = results.shiftedData |
247 | | - data.sldProfiles = results.sldProfiles |
| 251 | + data.sldProfiles = copy.deepcopy(results.sldProfiles) |
248 | 252 | data.resampledLayers = results.resampledLayers |
249 | 253 | data.dataPresent = RATapi.inputs.make_data_present(project) |
250 | 254 | data.subRoughs = results.contrastParams.subRoughs |
@@ -275,6 +279,12 @@ def plot_ref_sld( |
275 | 279 | for sld in results.predictionIntervals.sld |
276 | 280 | ], |
277 | 281 | } |
| 282 | + # For a shaded plot, use the mean values from predictionIntervals |
| 283 | + for reflectivity, mean_reflectivity in zip(data.reflectivity, results.predictionIntervals.reflectivity): |
| 284 | + reflectivity[:, 1] = mean_reflectivity[2] |
| 285 | + for sldProfile, mean_sld_profile in zip(data.sldProfiles, results.predictionIntervals.sld): |
| 286 | + for sld, mean_sld in zip(sldProfile, mean_sld_profile): |
| 287 | + sld[:, 1] = mean_sld[2] |
278 | 288 | else: |
279 | 289 | raise ValueError( |
280 | 290 | "Shaded confidence intervals are only available for the results of Bayesian analysis (NS or DREAM)" |
|
0 commit comments