Changeset 654
 Timestamp:
 Mar 30, 2010 7:12:31 PM (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

sans/utils/bt5/bt5plot2/BT5DataSet.py
r653 r654 158 158 xdata.append(mval) 159 159 ydata.append(data[mval][1] + data[mval][2] + data[mval][4] + data[mval][5] + data[mval][6]) 160 yerror.append(math.sqrt(ydata[len(ydata)1])) 160 if (ydata[len(ydata)1] == 0): 161 yerror.append(0) 162 else: 163 yerror.append(math.sqrt(ydata[len(ydata)1])) 161 164 162 165 axes.set_ylabel("Counts") … … 164 167 self.plot = axes.errorbar(xdata,ydata,yerror,None,'bo', picker=5) 165 168 else: 166 self.plot = axes. plot(xdata,ydata,'bo',picker=5)169 self.plot = axes.errorbar(xdata,ydata,None,None,'bo', picker=5) 167 170 168 171 elif plottype == 'rate': … … 182 185 for mval in mvals: 183 186 ydata.append((data[mval][1] + data[mval][2] + data[mval][4] + data[mval][5] + data[mval][6]) / cnttime) 184 yerror.append(math.sqrt(ydata[len(ydata)1])/math.sqrt(cnttime)) 187 if (ydata[len(ydata)1] == 0): 188 yerror.append(0) 189 else: 190 yerror.append(math.sqrt(ydata[len(ydata)1])/math.sqrt(cnttime)) 185 191 axes.set_ylabel("Counts/second") 186 192 else: … … 189 195 for mval in mvals: 190 196 ydata.append((data[mval][1] + data[mval][2] + data[mval][4] + data[mval][5] + data[mval][6]) / cnttime) 191 yerror.append(math.sqrt(ydata[len(ydata)1])/math.sqrt(cnttime)) 197 if (ydata[len(ydata)1] == 0): 198 yerror.append(0) 199 else: 200 yerror.append(math.sqrt(ydata[len(ydata)1])/math.sqrt(cnttime)) 192 201 axes.set_ylabel("Counts/Monitor Count") 193 202 … … 195 204 self.plot = axes.errorbar(xdata,ydata,yerror,None,'bo', picker=5) 196 205 else: 197 self.plot = axes.plot(xdata,ydata,'bo',picker=5) 206 self.plot = axes.errorbar(xdata,ydata,None,None,'bo', picker=5) 207 208 print xdata 209 print ydata 210 print yerror 198 211 199 212 elif plottype == 'trans': … … 207 220 xdata.append(mval) 208 221 ydata.append(data[mval][3]) 209 yerror.append(math.sqrt(ydata[len(ydata)1])) 222 if (ydata[len(ydata)1] == 0): 223 yerror.append(0) 224 else: 225 yerror.append(math.sqrt(ydata[len(ydata)1])) 210 226 211 227 axes.set_ylabel("Transmission Detector Counts") … … 213 229 self.plot = axes.errorbar(xdata,ydata,yerror,None,'bo', picker=5) 214 230 else: 215 self.plot = axes. plot(xdata,ydata,'bo',picker=5)231 self.plot = axes.errorbar(xdata,ydata,None,None,'bo', picker=5) 216 232 217 233 … … 232 248 self.plot = axes.errorbar(xdata,ydata,yerror,None,'bo', picker=5) 233 249 else: 234 self.plot = axes. plot(xdata,ydata,'bo',picker=5)250 self.plot = axes.errorbar(xdata,ydata,None,None,'bo', picker=5) 235 251 236 252 elif plottype == 'split': … … 270 286 axes.errorbar(xdata,ydata5,yerror5,None, 'o')) 271 287 else: 272 self.plot = axes.plot(xdata,ydata1, 'o',273 xdata,ydata2, 'o',274 xdata,ydata3, 'o',275 xdata,ydata4, 'o',276 xdata,ydata5, 'o')288 self.plot = (axes.errorbar(xdata,ydata1,None,None, 'o'), 289 axes.errorbar(xdata,ydata2,None,None, 'o'), 290 axes.errorbar(xdata,ydata3,None,None, 'o'), 291 axes.errorbar(xdata,ydata4,None,None, 'o'), 292 axes.errorbar(xdata,ydata5,None,None, 'o')) 277 293 278 294 elif plottype == 'nrate': … … 291 307 for mval in mvals: 292 308 ydata.append((data[mval][1] + data[mval][2] + data[mval][4] + data[mval][5] + data[mval][6]) / (data[mval][0]/1e6)) 293 yerror.append(math.sqrt(ydata[len(ydata)1])/math.sqrt(data[mval][0]/1e6)) 309 if (ydata[len(ydata)1] == 0): 310 yerror.append(0) 311 else: 312 yerror.append(math.sqrt(ydata[len(ydata)1])/math.sqrt(data[mval][0]/1e6)) 294 313 295 314 axes.set_ylabel("Counts / (10^6 Monitor Counts)") … … 297 316 self.plot = axes.errorbar(xdata,ydata,yerror,None,'bo', picker=5) 298 317 else: 299 self.plot = axes. plot(xdata,ydata,'bo',picker=5)318 self.plot = axes.errorbar(xdata,ydata,None,None,'bo', picker=5) 300 319 301 320 … … 304 323 def remove_plot(self): 305 324 306 #AJJ 10/26/09 307 #This is frankly hideous. Surely there is a better way for me 308 #to iterate through the contents of self.plot 309 #print self.plot 310 #print type(self.plot[0]).__name__ 311 #Is it a plot with errorbars? 325 #Is it a plot with errorbars? 312 326 if type(self.plot[0]) is tuple: 313 # print "Split plot with errorbars"327 #split plot 314 328 for splot in self.plot: 315 329 splot[0].remove() … … 318 332 for linec in splot[2]: 319 333 linec.remove() 320 elif type(self.plot[0]).__name__ == 'Line2D' and type(self.plot[1]).__name__ == 'Line2D': 321 #print "Split plot without errorbars" 322 for splot in self.plot: 323 splot.remove() 324 elif type(self.plot[0]).__name__ == 'Line2D': 325 #print "Plot with errorbars" 334 else: 335 #normal plot 326 336 for line in self.plot[0:1]: 327 337 axes = line.get_axes() … … 331 341 for linec in self.plot[2]: 332 342 linec.remove() 333 else:334 for line in self.plot:335 axes = line.get_axes()336 axes.lines.remove(line)
Note: See TracChangeset
for help on using the changeset viewer.