Changeset 6da860a in sasview for src/sas/qtgui/Perspectives/Inversion/InversionLogic.py
- Timestamp:
- May 1, 2018 11:51:06 AM (7 years ago)
- Branches:
- ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- 72ecbdf2
- Parents:
- 6bd0d81
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Inversion/InversionLogic.py
r318b353e r6da860a 1 1 import math 2 import pylab2 import logging 3 3 import numpy as np 4 4 … … 12 12 GROUP_ID_IQ_DATA = r"$I_{obs}(q)$" 13 13 GROUP_ID_PR_FIT = r"$P_{fit}(r)$" 14 PR_PLOT_PTS = 51 15 16 logger = logging.getLogger(__name__) 14 17 15 18 … … 19 22 No QStandardModelIndex here. 20 23 """ 21 22 # TODO: Add way to change this value23 _pr_n_pts = 5124 24 25 25 def __init__(self, data=None): … … 63 63 maxq = pr.q_max 64 64 65 x = pylab.arange(minq, maxq, maxq / 301.0)65 x = np.arange(minq, maxq, maxq / 301.0) 66 66 y = np.zeros(len(x)) 67 67 err = np.zeros(len(x)) … … 73 73 except: 74 74 err[i] = 1.0 75 print(("Error getting error", value, x[i]))75 logger.log(("Error getting error", value, x[i])) 76 76 77 77 new_plot = Data1D(x, y) … … 89 89 # If we have used slit smearing, plot the smeared I(q) too 90 90 if pr.slit_width > 0 or pr.slit_height > 0: 91 x = pylab.arange(minq, maxq, maxq / 301.0)91 x = np.arange(minq, maxq, maxq / 301.0) 92 92 y = np.zeros(len(x)) 93 93 err = np.zeros(len(x)) … … 99 99 except: 100 100 err[i] = 1.0 101 print(("Error getting error", value, x[i]))101 logger.log(("Error getting error", value, x[i])) 102 102 103 103 new_plot = Data1D(x, y) … … 113 113 return new_plot 114 114 115 def update1DPlot(self, plot, out, pr, q=None):116 """117 Create a new 1D data instance based on fitting results118 """119 120 qtemp = pr.x121 if q is not None:122 qtemp = q123 124 # Make a plot125 maxq = max(qtemp)126 127 minq = min(qtemp)128 129 # Check for user min/max130 if pr.q_min is not None and maxq >= pr.q_min >= minq:131 minq = pr.q_min132 if pr.q_max is not None and maxq >= pr.q_max >= minq:133 maxq = pr.q_max134 135 x = pylab.arange(minq, maxq, maxq / 301.0)136 y = np.zeros(len(x))137 err = np.zeros(len(x))138 for i in range(len(x)):139 value = pr.iq(out, x[i])140 y[i] = value141 try:142 err[i] = math.sqrt(math.fabs(value))143 except:144 err[i] = 1.0145 print(("Error getting error", value, x[i]))146 147 plot.x = x148 plot.y = y149 150 # If we have used slit smearing, plot the smeared I(q) too151 if pr.slit_width > 0 or pr.slit_height > 0:152 x = pylab.arange(minq, maxq, maxq / 301.0)153 y = np.zeros(len(x))154 err = np.zeros(len(x))155 for i in range(len(x)):156 value = pr.iq_smeared(pr.out, x[i])157 y[i] = value158 try:159 err[i] = math.sqrt(math.fabs(value))160 except:161 err[i] = 1.0162 print(("Error getting error", value, x[i]))163 164 plot.x = x165 plot.y = y166 167 return plot168 169 115 def newPRPlot(self, out, pr, cov=None): 170 116 """ 171 117 """ 172 118 # Show P(r) 173 x = pylab.arange(0.0, pr.d_max, pr.d_max / self._pr_n_pts)119 x = np.arange(0.0, pr.d_max, pr.d_max / PR_PLOT_PTS) 174 120 175 121 y = np.zeros(len(x)) … … 193 139 y[i] = value 194 140 195 # if self._normalize_output == True:196 # y = y / total197 # dy = dy / total198 # elif self._scale_output_unity == True:199 # y = y / pmax200 # dy = dy / pmax201 202 141 if cov2 is None: 203 142 new_plot = Data1D(x, y) … … 213 152 214 153 return new_plot 215 216 def updatePRPlot(self, plot, out, pr, cov=None):217 x = pylab.arange(0.0, pr.d_max, pr.d_max / self._pr_n_pts)218 219 y = np.zeros(len(x))220 dy = np.zeros(len(x))221 222 total = 0.0223 pmax = 0.0224 cov2 = np.ascontiguousarray(cov)225 226 for i in range(len(x)):227 if cov2 is None:228 value = pr.pr(out, x[i])229 else:230 (value, dy[i]) = pr.pr_err(out, cov2, x[i])231 total += value * pr.d_max / len(x)232 233 # keep track of the maximum P(r) value234 if value > pmax:235 pmax = value236 237 y[i] = value238 239 # if self._normalize_output == True:240 # y = y / total241 # dy = dy / total242 # elif self._scale_output_unity == True:243 # y = y / pmax244 # dy = dy / pmax245 plot.x = x246 plot.y = y247 248 if cov2 is not None:249 plot.dy = dy250 251 return plot252 154 253 155 def computeDataRange(self):
Note: See TracChangeset
for help on using the changeset viewer.