def pushButton_4_clicked(self): ''' Slot for pushButton_4. Scatter plot. ''' # just plot the rays from the selected sources qindices = self.listWidget.selectedIndexes() rays = [] for qi in qindices: source = self.sources[qi.row()] for ray in self.detector.rays: if ray.tag is source: rays.append(ray) # color bounce option colorBounces = self.checkBox_3.isChecked() # create window window = QWidget() window.setWindowTitle('Scatter Plot') l = QVBoxLayout(window) canv = MplCanvas(window, width=5, height=5, dpi=100) scatterHist(rays, figure=canv.figure, colorBounces=colorBounces) l.addWidget(canv) window.show() self.figures.append(window)
module = Module(radii=[5.151, 3.799], seglen=30.0, base=[0, 0, 0], focal=200, angles=None, conic=False) detector = Detector(width=0.96, height=0.96, normal=[0, 0, 1], center=[0, 0, 200.0 + 30.0], reso=[128, 128]) source_distance = -2187.5 offaxis_angle_arcmin = 1.0 source = Source( type='point', center=[ source_distance * np.sin(np.deg2rad(offaxis_angle_arcmin / 60.0)), 0.0, source_distance ], color=[0, 1, 1]) rays = source.generateRays(module.targetFront, 2000) module.passRays(rays, robust=True) detector.catchRays(rays) plot(detector) scatterHist(rays) plt.show()
from foxsisim.plotting import plot import matplotlib.pyplot as plt if __name__ == '__main__': # create module/detector/source objects using defaults module = Module() detector = Detector() source = Source() # generate 1000 rays at source rays = source.generateRays(module.targetFront, 1000) # pass rays through module module.passRays(rays, robust=True) # catch rays at detector detector.catchRays(rays) # plot detector pixels plot(detector) # create scatter plot detectorRays = detector.rays fig2 = plt.figure(figsize=(5,5)) scatterHist(detectorRays,fig2) # show plt.show()
from foxsisim.plotting import plot import matplotlib.pyplot as plt if __name__ == '__main__': # create module/detector/source objects using defaults module = Module() detector = Detector() source = Source() # generate 1000 rays at source rays = source.generateRays(module.targetFront, 1000) # pass rays through module module.passRays(rays, robust=True) # catch rays at detector detector.catchRays(rays) # plot detector pixels plot(detector) # create scatter plot detectorRays = detector.rays fig2 = plt.figure(figsize=(5, 5)) scatterHist(detectorRays, fig2) # show plt.show()
# In[4]: rays = source.generateRays(module.targetFront, 10) module.passRays(rays, robust=True) detector.catchRays(rays) # In[5]: plot(detector) # In[6]: scatterHist(rays) # In[7]: for ray in rays: print("x=%f, y=%f, bounce=%i, dead=%i" % (ray.des[0], ray.des[1], ray.bounces, ray.dead)) # In[8]: np.sum([ray.dead for ray in rays]) # In[9]:
from foxsisim.plotting import plot import numpy as np if __name__ == '__main__': # create module of 7 shells module = Module(radii=[5.151, 3.799], seglen=30.0, base=[0,0,0], focal=200, angles=None, conic=False) detector = Detector(width=0.96, height=0.96, normal=[0,0,1], center=[0,0,200.0+30.0], reso =[128,128]) source_distance = -2187.5 offaxis_angle_arcmin = 1.0 source = Source(type='point', center=[ source_distance * np.sin(np.deg2rad(offaxis_angle_arcmin/60.0)) , 0.0 , source_distance ], color=[0,1,1]) rays = source.generateRays(module.targetFront, 2000) module.passRays(rays, robust=True) detector.catchRays(rays) plot(detector) scatterHist(rays)
from datetime import datetime tstart = datetime.now() print('pasing rays') # pass rays through module module.passRays(rays, robust=True) # catch rays at detector detector.catchRays(rays) rays_on_detector = len(detector.rays) print('Number of rays on Detector ' + str(rays_on_detector)) print('Time total: ' + str((datetime.now() - tstart).seconds) + ' seconds') print('Time per ray (s): ' + str(rays_on_detector / float((datetime.now() - tstart).seconds))) drays = [ray for ray in rays if ray.des[2] == 230.0] scatterHist(drays) #plt.show() plt.savefig('photons_on_detec.png') plt.figure() plt.hist([ray.energy for ray in detector.rays], normed=True, label='rays on detector', color='r') plt.xlabel('Energy [keV]') plt.title('Histogram caught rays on detector') plt.legend() plt.show() plt.savefig('output_spect_on_detec.png')