|
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 |
@@ -241,10 +242,11 @@ def plot_ref_sld( |
241 | 242 | """ |
242 | 243 | data = PlotEventData() |
243 | 244 |
|
| 245 | + # We need to take a copy of results and SLD in case the data to plot is modified later |
244 | 246 | data.modelType = project.model |
245 | | - data.reflectivity = results.reflectivity |
| 247 | + data.reflectivity = copy.deepcopy(results.reflectivity) |
246 | 248 | data.shiftedData = results.shiftedData |
247 | | - data.sldProfiles = results.sldProfiles |
| 249 | + data.sldProfiles = copy.deepcopy(results.sldProfiles) |
248 | 250 | data.resampledLayers = results.resampledLayers |
249 | 251 | data.dataPresent = RATapi.inputs.make_data_present(project) |
250 | 252 | data.subRoughs = results.contrastParams.subRoughs |
@@ -275,6 +277,12 @@ def plot_ref_sld( |
275 | 277 | for sld in results.predictionIntervals.sld |
276 | 278 | ], |
277 | 279 | } |
| 280 | + # For a shaded plot, use the mean values from predictionIntervals |
| 281 | + for reflectivity, mean_reflectivity in zip(data.reflectivity, results.predictionIntervals.reflectivity): |
| 282 | + reflectivity[:, 1] = mean_reflectivity[2] |
| 283 | + for sldProfile, mean_sld_profile in zip(data.sldProfiles, results.predictionIntervals.sld): |
| 284 | + for sld, mean_sld in zip(sldProfile, mean_sld_profile): |
| 285 | + sld[:, 1] = mean_sld[2] |
278 | 286 | else: |
279 | 287 | raise ValueError( |
280 | 288 | "Shaded confidence intervals are only available for the results of Bayesian analysis (NS or DREAM)" |
|
0 commit comments