def plot_thick_vs_eff_meta(self): """plots the efficiency function for a set of thicknesses, Args: sigma: Full sigma calculation fo the detector ranges: Ranges calculation blades: detector blades result: Efficiency figure: figure to plot in Returns: plotted figure reference: figure 3.12 On Francesco's Thesis """ sigma = self.calculate_sigma() sigmalist = [] c = 0 for s in sigma: sigmalist.append([s, self.wavelength[c][1]]) c += 1 ranges = self.calculate_ranges() blades = self.blades result = self.calculate_eff() if self.single: thickVsEff = efftools.metadata_samethick_vs_thickandnb_single(sigmalist, ranges, len(blades)) else: thickVsEff = efftools.metadata_samethick_vs_thickandnb(sigmalist, ranges, len(blades)) self.metadata.update({'thickVsEff': thickVsEff})
def plot_thick_vs_eff_meta(self, sigma, ranges, blades, result, figure): """plots the efficiency function for a set of thicknesses, Args: sigma: Full sigma calculation fo the detector ranges: Ranges calculation blades: detector blades result: Efficiency figure: figure to plot in Returns: plotted figure reference: figure 3.12 On Francesco's Thesis """ bx = figure.add_subplot(111) sigmalist = [] c = 0 for s in sigma: sigmalist.append([s, self.wavelength[c][1]]) c += 1 if self.single: #TODO Poli sigma thickVsEff = efftools.metadata_samethick_vs_thickandnb_single(sigmalist, ranges, len(blades)) bx.plot(thickVsEff[0], np.array(thickVsEff[1]), label=" Backscatering") bx.plot(thickVsEff[0], np.array(thickVsEff[2]), label=" Transmission") bx.legend(numpoints=1) bx.grid(True) bx.set_xlabel('Converter thickness ($\mu$m)') bx.set_ylabel('Detector efficiency (%)') # line = bx.plot([self.blades[0].backscatter, self.blades[0].backscatter], # [0, result[1][0] * 100], '--') # plt.setp(line, 'color', 'k', 'linewidth', 0.5) else: thickVsEff = efftools.metadata_samethick_vs_thickandnb(sigmalist, ranges, len(blades)) self.metadata.update({'thickVsEff': thickVsEff}) bx.plot(thickVsEff[0],np.array(thickVsEff[1])) bx.grid(True) bx.set_xlabel('Converter thickness ($\mu$m)') bx.set_ylabel('Detector efficiency (%)') line = bx.plot([self.blades[0].backscatter, self.blades[0].backscatter], [0, result[1]], '--') plt.setp(line, 'color', 'r', 'linewidth', 0.5) if self.single: line2 = bx.plot([0, self.blades[0].backscatter], [result[1][0], result[1][0]], '--') line3 = bx.plot([0, self.blades[0].backscatter], [result[0][0], result[0][0]], '--') line4 = bx.plot([self.blades[0].backscatter, self.blades[0].backscatter], [result[0][0], 0], '--') line5 = bx.plot([self.blades[0].backscatter, self.blades[0].backscatter], [result[1][0], 0], '--') plt.setp(line3, 'color', 'r', 'linewidth', 0.5) plt.setp(line4, 'color', 'r', 'linewidth', 0.5) plt.setp(line5, 'color', 'r', 'linewidth', 0.5) else: line2 = bx.plot([0, np.array(self.blades[0].backscatter)], [result[1], result[1]], '--') plt.setp(line2, 'color', 'r', 'linewidth', 0.5) # ticks = bx.get_yticks() * 100 # bx.set_yticklabels(ticks) return bx
def plot_thick_vs_eff2(self): """plots the efficiency function for a set of thicknesses, Args: sigma: Full sigma calculation fo the detector ranges: Ranges calculation blades: detector blades result: Efficiency figure: figure to plot in Returns: plotted figure reference: figure 3.12 On Francesco's Thesis """ sigma = self.calculate_sigma() sigmalist = [] c = 0 for s in sigma: sigmalist.append([s, self.wavelength[c][1]]) c += 1 ranges = self.calculate_ranges() blades = self.blades result = self.calculate_eff() bx = plt.figure(1) plt.subplot(111) if self.single: thickVsEff = efftools.metadata_samethick_vs_thickandnb_single(sigmalist, ranges, len(blades)) plt.plot(thickVsEff[0], np.array(thickVsEff[1]), label=" Backscattering") plt.plot(thickVsEff[0], np.array(thickVsEff[2]), label=" Transmission") plt.plot(thickVsEff[0], np.array(thickVsEff[3]), label=" Total") self.metadata.update({'thickVsEffBack': [thickVsEff[0], np.array(thickVsEff[1])]}) self.metadata.update({'thickVsEffTrans': [thickVsEff[0], np.array(thickVsEff[2])]}) plt.legend(numpoints=1) plt.grid(True) meta = self.metadata.get('thickVsEffBack') meta2 = self.metadata.get('thickVsEffTrans') data = np.array([meta[0], meta[1]]) data2 = np.array([meta2[0], meta2[1]]) ''' datafile_id = open('/Users/alvarocbasanez/backscattering', 'w+') datafile_id2 = open('/Users/alvarocbasanez/transmission', 'w+') for a, am in zip(data[0], data[1]): datafile_id.write("{}\t{}\n".format(a, am)) for a, am in zip(data2[0], data2[1]): datafile_id2.write("{}\t{}\n".format(a, am)) datafile_id.close() datafile_id2.close() ''' plt.xlabel(r'Converter thickness ($\mu$m)') plt.ylabel('Detector efficiency (%)') line = plt.plot([self.blades[0].backscatter, self.blades[0].backscatter],[0, result[1] ], '--') plt.setp(line, 'color', 'k', 'linewidth', 0.5) else: thickVsEff = efftools.metadata_samethick_vs_thickandnb(sigmalist, ranges, len(blades)) self.metadata.update({'thickVsEff': thickVsEff}) plt.plot(thickVsEff[0], np.array(thickVsEff[1])) plt.grid(True) plt.xlabel(r'Converter thickness ($\mu$m)') plt.ylabel('Detector efficiency (%)') line = plt.plot([self.blades[0].backscatter, self.blades[0].backscatter], [0, np.array(result[1])],'--') plt.setp(line, 'color', 'k', 'linewidth', 0.5) if self.single: print() #line2 = plt.plot([0, self.blades[0].backscatter], [result[0][1], result[0][1]], '--') else: line2 = plt.plot([0, self.blades[0].backscatter], [np.array(result[1]), np.array(result[1])], '--') plt.setp(line2, 'color', 'k', 'linewidth', 0.5) return bx