def setUp(): Klims = [-0.5, 120] Kticks = [0, 50, 100] Laplims = [-1, 60] Lapticks = [0, 10, 20, 30, 40, 50] Hlims = None Hticks = None ELBOlims = None ELBOticks = None # Size of state seq plots ZW = 12 ZH = 4.5 # Dont shrink this. Text gets cut off! PlotUtil.setUp( dataName, getStateSeqColorMap(), getLineColorMap(), getLineStyleMap(), Klims, Kticks, Laplims, Lapticks, Hlims, Hticks, ELBOlims, ELBOticks, ZW, ZH, ) return makeKeyPathMap()
def __recursive_display_Tree(self, node, pos, parent_pos): node_text = str(node) node_type = PlotUtil.nodestyle_leaf if node.isLeaf( ) else PlotUtil.nodestyle_internal _w_p, _ = node.calc_Treesize() # draw left child if node.get_Left() is not None: node_left = node.get_Left() _w_l, _ = node_left.calc_Treesize() x_l = pos[0] - _w_p * PlotUtil.pos_xoffset / 2.0 pos_child = ((x_l + _w_l * PlotUtil.pos_xoffset / 2.0), pos[1] - PlotUtil.pos_yoffset) self.__recursive_display_Tree(node_left, pos_child, parent_pos=pos) if node.get_Right() is not None: node_right = node.get_Right() _w_r, _ = node_right.calc_Treesize() x_r = pos[0] + _w_p * PlotUtil.pos_xoffset / 2.0 pos_child = ((x_r - _w_r * PlotUtil.pos_xoffset / 2.0), pos[1] - PlotUtil.pos_yoffset) self.__recursive_display_Tree(node_right, pos_child, parent_pos=pos) # draw myself PlotUtil.draw_Node(node_text, pos, parent_pos, node_type)
def setUp(lineStyleByKey='K'): Klims = [-0.5, 105] Kticks = [8, 20, 40, 60, 80] Laplims = [0, 5000] Lapticks = [1, 10, 100, 1000] Hlims = [-0.03, 0.85] Hticks = [0, 0.2, 0.4, 0.6, 0.8] ELBOlims = [-1.65, -1.395] ELBOticks = [-1.6, -1.5, -1.4] # Size of state seq plots ZW = 8 ZH = 4.5 # Dont shrink this. Text gets cut off! if lineStyleByKey.count('K'): StyleMap = getLineStyleMap_ByKValue() else: StyleMap = getLineStyleMap_ByStickyValue() PlotUtil.setUp(dataName, getStateSeqColorMap(), getLineColorMap(), StyleMap, Klims, Kticks, Laplims, Lapticks, Hlims, Hticks, ELBOlims, ELBOticks, ZW, ZH) J = makePathMap() J.update(makePathMap_ForBirths()) return J
def run(): """ <Description> Args: param1: This is the first param. Returns: This is a description of what is returned. """ base_dir = RetinalUtil._landscape_base() step = Pipeline.Step.POLISH in_dir = Pipeline._cache_dir(base=base_dir, enum=Pipeline.Step.REDUCED) out_dir = Pipeline._cache_dir(base=base_dir, enum=step) force = True limit = None functor = lambda: generate_landscape(in_dir) energy_obj = CheckpointUtilities.\ getCheckpoint(filePath=out_dir + "energy.pkl", orCall=functor,force=force) data = CheckpointUtilities.lazy_multi_load(in_dir) # also load all the data fig = PlotUtilities.figure((3, 6)) PlotUtil.plot_landscapes(data, energy_obj) PlotUtilities.savefig(fig, out_dir + "out_G.png") pass
def setUp(): Klims = [0, 105] Kticks = [25, 50, 75, 100] Laplims = [0, 120] Lapticks = [2, 10, 100] Hlims = None Hticks = None ELBOlims = None ELBOticks = None # Size of state seq plots ZW = 12 ZH = 3.5 PlotUtil.setUp( dataName, getStateSeqColorMap(), getColorMap(), getStyleMap(), Klims, Kticks, Laplims, Lapticks, Hlims, Hticks, ELBOlims, ELBOticks, ZW, ZH, )
def setUp(): Klims = [0, 100] Kticks = [8, 25, 50, 75, 100] Laplims = [-2, 200] Lapticks = [1, 10, 100] Hlims = [-0.025, 0.8] Hticks = [0, 0.2, 0.4, 0.6] ELBOlims = [-1.65, -1.4] ELBOticks = [-1.65, -1.6, -1.55, -1.5, -1.45] # Size of state seq plots ZW = 12 ZH = 3.5 PlotUtil.setUp( dataName, getColorMap(), getStyleMap(), Klims, Kticks, Laplims, Lapticks, Hlims, Hticks, ELBOlims, ELBOticks, ZW, ZH, )
def setUp(): Klims = [-0.5, 65] Kticks = [0, 20, 40, 60] Laplims = [0, 2100] Lapticks = [1, 10, 100, 1000] Hlims = [-0.03, 0.8] Hticks = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7] ELBOlims = None # [-2.2, -2.07] ELBOticks = None # [-2.2, -2.15, -2.1] # Size of state seq plots ZW = 12 ZH = 4.5 PlotUtil.setUp( dataName, getStateSeqColorMap(), getLineColorMap(), getLineStyleMap(), Klims, Kticks, Laplims, Lapticks, Hlims, Hticks, ELBOlims, ELBOticks, ZW, ZH, ) return makeKeyPathMap()
def setUp(): Klims = [-0.5, 65] Kticks = [0, 20, 40, 60] Laplims = [0, 2100] Lapticks = [1, 10, 100, 1000] Hlims = [-0.03, 0.85] Hticks = [0, 0.2, 0.4, 0.6, 0.8] ELBOlims = [-2.85, -2.0] ELBOticks = [-2.8, -2.6, -2.4, -2.2] # Size of state seq plots ZW = 8 ZH = 4.5 # Dont shrink this. Text gets cut off! PlotUtil.setUp(dataName, getStateSeqColorMap(), getLineColorMap(), getLineStyleMap(), Klims, Kticks, Laplims, Lapticks, Hlims, Hticks, ELBOlims, ELBOticks, ZW, ZH) J = makePathMap() J.update(makePathMap_ForBirths()) return J
def setUp(): Klims = [-0.5, 120] Kticks = [0, 25, 50, 75, 100] Laplims = [0, 105] Lapticks = [1, 10, 100] Hlims = None Hticks = None ELBOlims = [-0.0365, -0.033] ELBOticks = [-0.036, -0.035, -0.034] # Size of state seq plots ZW = 8 ZH = 4.5 # Dont shrink this. Text gets cut off! PlotUtil.setUp(dataName, getStateSeqColorMap(), getLineColorMap(), getLineStyleMap(), Klims, Kticks, Laplims, Lapticks, Hlims, Hticks, ELBOlims, ELBOticks, ZW, ZH) J = OrderedDict() J.update(makePathMap_ForStoch()) J.update(makePathMap()) J.update(makePathMap_ForBirths()) return J
def setUp(): Klims = [-0.5, 27] Kticks = [0, 5, 10, 15, 20, 25] Laplims = [0, 2100] Lapticks = [1, 10, 100, 1000] Hlims = [-0.03, 0.85] Hticks = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8] ELBOlims = None # [-1.65, -1.4] ELBOticks = None # [-1.6, -1.55, -1.5, -1.45] # Size of state seq plots ZW = 12 ZH = 4.5 PlotUtil.setUp( dataName, getStateSeqColorMap(), getLineColorMap(), getLineStyleMap(), Klims, Kticks, Laplims, Lapticks, Hlims, Hticks, ELBOlims, ELBOticks, ZW, ZH, ) return makeKeyPathMap()
def setUp(): Klims = [0, 208] Kticks = [50, 100, 150, 200] Laplims = [0, 1000] Lapticks = [2, 10, 100, 500] Hlims = [-0.05, 0.75] Hticks = [0, 0.2, 0.4, 0.6] # Size of state seq plots ZW = 12 ZH = 4.5 PlotUtil.setUp(dataName, getColorMap(), getStyleMap(), Klims, Kticks, Laplims, Lapticks, Hlims, Hticks, ZW, ZH)
def makeLegendInOwnFigure( Jdict, names = ['stoch', 'sampler', 'memo', 'delete,merge', 'birth,delete,merge', 'Sticky=0', 'Sticky=50'], ): ''' Create legend for trace plots, in separate matplotlib figure. ''' # Split up each name into original name (key in Jdict) and legend name origNames = list() legendNames = list() for name in names: if name.count(":") > 0: fields = name.split(":") origNames.append(fields[0]) legendNames.append(fields[1]) else: origNames.append(name) legendNames.append(name) # Build job dict with one entry for each of the specified names J2 = OrderedDict() for name in origNames: Jmatch = getSubsetByName(Jdict, name, keepName=1) if len(Jmatch.keys()) == 0: raise ValueError("Cannot find key %s in provided job path dict" % ( name)) firstkey = Jmatch.keys()[0] Jsingle = dict() Jsingle[name + firstkey] = Jmatch[firstkey] J2.update(Jsingle) # Make trace plot with these jobs only PlotUtil.plotHammingDist(J2, loc=None, xscale='log') # Grab current axes of this trace plot axH = PlotUtil.pylab.gca(); # Set all line handles to wide, solid lines lineHandles, lineLabels = axH.get_legend_handles_labels() for ii in range(len(lineHandles)): lineHandles[ii].set_linewidth(6) lineHandles[ii].set_linestyle('-') if names[ii].count('Sticky'): lineHandles[ii].set_color('k') lineHandles[ii].set_linewidth(3) if names[ii].count('Sticky=0'): lineHandles[ii].set_linestyle('--') # Remove lines from the plot entirely, so its just the legend axH.axis('off') for ii in range(len(axH.lines)): axH.lines.pop() # Show the legend axH.legend(lineHandles, legendNames)
def setUp(): Klims = [0, 68] Kticks = [20, 40, 60] Laplims = [0, 1400] Lapticks = [2, 10, 100, 1000] Hlims = [0.1, 0.8] Hticks = [0.2, 0.4, 0.6] # Size of state seq plots ZW = 12 ZH = 4.5 PlotUtil.setUp(dataName, getColorMap(), getStyleMap(), Klims, Kticks, Laplims, Lapticks, Hlims, Hticks, ZW, ZH)
def _energy_plot(energy_list, out_dir): # interpolate all the energies to the same grid energies_plot = [e._iwt_obj for e in energy_list] q_interp, splines = RetinalUtil.interpolating_G0(energies_plot) # get an average/stdev of energy fig = PlotUtilities.figure((7, 7)) ax = plt.subplot(1, 1, 1) PlotUtil.plot_mean_landscape(q_interp, splines, ax=ax) min_x_show_nm = int(np.floor(min(q_interp) - 2)) max_x_show_nm = min_x_show_nm + 20 plt.xlim([min_x_show_nm, max_x_show_nm]) plt.xticks([i for i in range(min_x_show_nm, max_x_show_nm)]) ax.xaxis.set_ticks_position('both') ax.grid(True) PlotUtilities.savefig(fig, out_dir + "avg.png")
def setUp(): Klims = [0, 105] Kticks = [25, 50, 75, 100] Laplims = [0, 2100] Lapticks = [2, 10, 100, 1000] Hlims = [-0.025, 0.5] Hticks = [0, 0.1, 0.2, 0.3, 0.4] # Size of state seq plots ZW = 12 ZH = 3.5 PlotUtil.setUp(dataName, getColorMap(), getStyleMap(), Klims, Kticks, Laplims, Lapticks, Hlims, Hticks, ZW, ZH)
def _mean_f(f,energy_list_arr,q_interp): means = [] for i, energy_list in enumerate(energy_list_arr): _, splines = RetinalUtil.interpolating_G0(energy_list, f=f) mean, _ = PlotUtil._mean_and_stdev_landcapes(splines, q_interp) means.append(mean) return means
def data_plot(fecs, energies, gs1=None, xlim=[None, None]): n_cols = len(energies) n_rows = 2 all_ax = [] if gs1 is None: gs1 = gridspec.GridSpec(n_rows + 1, n_cols) for i, (data, e) in enumerate(zip(fecs, energies)): axs_tmp = [plt.subplot(gs1[j, i]) for j in range(n_rows)] ax1, ax2 = axs_tmp PlotUtil.plot_landscapes(data, e, ax1=ax1, ax2=ax2) # every axis after the first gets more of the decoaration chopped... all_ax.append(axs_tmp) # XXX should really put this into the meta class... plt.sca(ax1) tmp_str = e.file_name match = re.search( r""" ([\w+-]+Retinal)/([\d\w]+)/([\d\w]+)/ """, tmp_str, re.IGNORECASE | re.VERBOSE) assert match is not None groups = match.groups() BR, velocity, title = groups vel_label = velocity.replace("nms", "") title_label = title.replace("FEC", "") title = "{:s}, v={:s}\n {:s}".format(BR, vel_label, title_label) PlotUtilities.title(title, fontsize=5) for a in axs_tmp: a.set_xlim(xlim) fix_axes(all_ax) xlim = all_ax[0][0].get_xlim() # just get the IWT energies_plot = [e._iwt_obj for e in energies] q_interp, splines = RetinalUtil.interpolating_G0(energies_plot) # get an average/stdev of energy ax = plt.subplot(gs1[-1, 0]) mean_energy, std_energy = PlotUtil.plot_mean_landscape(q_interp, splines, ax=ax) max_q_nm = RetinalUtil.q_GF_nm_plot() q_at_max_energy,_,_ = \ PlotUtil.plot_delta_GF(q_interp,mean_energy,std_energy, max_q_nm=max_q_nm) plt.axvspan(q_at_max_energy, max(xlim), color='k', alpha=0.3) ax.set_xlim(xlim)
def setUp(): Klims = [0, 67] Kticks = [8, 16, 32, 64] Laplims = [0, 2100] Lapticks = [2, 10, 100, 1000] #Laplims = [0, 1000] #Lapticks = [2, 10, 100, 400] Hlims = [-.025, 0.8] Hticks = [0, 0.2, 0.4, 0.6] # Size of state seq plots ZW = 12 ZH = 3.5 PlotUtil.setUp(dataName, getColorMap(), getStyleMap(), Klims, Kticks, Laplims, Lapticks, Hlims, Hticks, ZW, ZH)
def setUp(): Klims = [0, 68] Kticks = [20, 40, 60] Laplims = [0, 1400] Lapticks = [2, 10, 100, 1000] Hlims = [0.1, 0.8] Hticks = [0.2, 0.4, 0.6] ELBOlims = None ELBOticks = None # Size of state seq plots ZW = 12 ZH = 4.5 PlotUtil.setUp(dataName, getStateSeqColorMap(), getLineColorMap(), getLineStyleMap(), Klims, Kticks, Laplims, Lapticks, Hlims, Hticks, ELBOlims, ELBOticks, ZW, ZH) return makePPListMapFromJPattern(PlotUtil.MakePath('findhypers'))
def setUp(): Klims = [-0.5, 80] Kticks = [0, 10, 20, 30, 40, 50] Laplims = [0, 120] Lapticks = [1, 10, 100] Hlims = [-0.03, 0.6] Hticks = [0, 0.1, 0.2, 0.3, 0.4, 0.5] ELBOlims = None ELBOticks = None # Size of state seq plots ZW = 12 ZH = 4.5 PlotUtil.setUp(dataName, getStateSeqColorMap(), getLineColorMap(), getLineStyleMap(), Klims, Kticks, Laplims, Lapticks, Hlims, Hticks, ELBOlims, ELBOticks, ZW, ZH) return makeKeyPathMap()
def setUp(): Klims = [-0.5, 105] Kticks = [8, 20, 40, 60, 80, 100] Laplims = [0, 2500] Lapticks = [1, 10, 100, 1000] Hlims = [-0.03, 0.85] Hticks = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8] ELBOlims = [-1.65, -1.4] ELBOticks = [-1.6, -1.55, -1.5, -1.45] # Size of state seq plots ZW = 12 ZH = 4.5 # Dont shrink this. Text gets cut off! PlotUtil.setUp(dataName, getStateSeqColorMap(), getLineColorMap(), getLineStyleMap(), Klims, Kticks, Laplims, Lapticks, Hlims, Hticks, ELBOlims, ELBOticks, ZW, ZH) return makeKeyPathMap()
def setUp(): Klims = [-0.5, 205] Kticks = [0, 50, 100, 150, 200] Laplims = [0, 2100] Lapticks = [1, 10, 100, 1000] Hlims = [-0.03, 0.8] Hticks = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7] ELBOlims = [-2.8, -2.38] ELBOticks = [-2.7, -2.6, -2.5, -2.4] # Size of state seq plots ZW = 12 ZH = 4.5 PlotUtil.setUp(dataName, getStateSeqColorMap(), getLineColorMap(), getLineStyleMap(), Klims, Kticks, Laplims, Lapticks, Hlims, Hticks, ELBOlims, ELBOticks, ZW, ZH) return makeKeyPathMap()
def _get_error_landscapes(q_interp, energy_list_arr, **kw): landscpes_with_error = [] for i, energy_list in enumerate(energy_list_arr): _, splines = RetinalUtil.interpolating_G0(energy_list) beta = energy_list[0].beta mean, stdev = PlotUtil._mean_and_stdev_landcapes(splines, q_interp) mean -= min(mean) l = LandscapeWithError(q_nm=q_interp, G_kcal=mean, G_err_kcal=stdev, beta=beta) landscpes_with_error.append(l) return landscpes_with_error
def run(): """ <Description> Args: param1: This is the first param. Returns: This is a description of what is returned. """ default_base = "../../../Data/170321FEC/" base_dir = Pipeline._base_dir_from_cmd(default=default_base) step = Pipeline.Step.SANITIZED in_dir = Pipeline._cache_dir(base=base_dir, enum=Pipeline.Step.CORRECTED) out_dir = Pipeline._cache_dir(base=base_dir,enum=step) force = True max_n_pool = 6 n_pool = max_n_pool kw_feather = RetinalUtil._def_kw_FEATHER() data = align_data(in_dir,out_dir,force=force,n_pool=n_pool, **kw_feather) # plot all of the FEATHER information plot_subdir = Pipeline._plot_subdir(base_dir, step) PlotUtil._feather_plot(data,plot_subdir)
if c == '1': print("\t\t STEP1: Load dataset...") xx, yy = ds.load(True, r'.\dataset.dat') xx = ds.discrete_vec(xx, K=DS.DATAUtil.g_SuperParam['K']) y_c = yy[:, 1] xx_t, y_t = ds.load(True, r'.\testds.dat') x_t = ds.discrete_vec(xx_t, K=DS.DATAUtil.g_SuperParam['K']) y_t_c = y_t[:, 1] print("\t\t STEP2: Build CART Tree...") model = DecisionTree.CART(c_r=True) model.train(xx, y_c) print("\t\t STEP3: Display CART Tree...") PlotUtil.init_Plot("CART Decision Tree - (C)") model.display_Tree() PlotUtil.show_Plot() print("\t\t STEP4: Predict by CART Tree...") y_p = model.predict(x_t) y_p = y_p.flatten() if y_p.shape[0] > 0: eval_y = np.zeros_like(y_p, dtype=int) eval_y = np.where((y_p == y_t_c), 1, 0) y_p = ds.y_int2str(y_p) y_p = np.reshape(y_p, (-1, 1)) print("The predict result is:") print(y_p) print("The predict precision is {:.2%}".format(eval_y.sum() / eval_y.shape[0]))
parser.add_argument('files', nargs='+', help="""Root Files Containing Histograms to Merge""") parser.add_argument( '--method', default="sum", help="""Method of merging. Default is summing all distributions""") parser.add_argument('--output', '-o', default="combined.root", help="""Output file name""") parser.add_argument( '--hname', default="combined", help="""Name of histogram stored in the output root file""") args = parser.parse_args() if args.method == "sum": PlotUtil.AddTH1DFromRoot(args.files, fout_name=args.output, hout_name=args.hname) elif (args.method == "dif"): if (len(args.files) == 2): PlotUtil.SubtractTH1DFromRoot(args.files[0], args.files[1], fout_name=args.output, hout_name=args.hname) else: raise Exception( "Exactly two histograms should be provided for taking difference. {0} provided." .format(len(args.files)))
SPE: Gain = %7.2f I (muA) = %7.2f, V (mV) = %7.2f, ADC = %d """ % (self.pmt_gain, self.A / units.muA, self.V / units.mV, self.nADC) return s if __name__ == '__main__': import PlotUtil as putil import matplotlib.pyplot as plt signal_start = 2000 * units.ns signal_length = 200 * units.mus daq_window = 1 * units.ms spe = SPE() print spe signal_end = signal_start + signal_length signal_t, signal_PE = spe.SpePulseTrain(signal_start, signal_end, daq_window) putil.plot_signal(signal_t / units.ns, signal_PE / units.muA, title='Input Signal: PE Train', signal_start=0 * units.ns, signal_end=len(signal_t) / units.ns, units='muA') plt.show()
l = {i: listdir(join(args.path, i)) for i in l} for discrim in l: L = [i for i in l[discrim] if ".root" in i] f_in = zip(sorted([i for i in L if "Asimov" in i]), sorted([i for i in L if "Observed" in i])) for asi, obs in f_in: if 'khvv' in asi: higgs = 'H' coup = 'Hvv' elif 'kavv' in asi: higgs = 'A' coup = 'Avv' elif 'kagg' in asi: higgs = 'A' coup = 'Agg' if "fix" in asi: fix = "fix" else: fix = "floating" Utilities.try_makedir(join(args.outpath, discrim)) PlotUtil.LLScanPlot(join(args.path, discrim, asi), join(args.path, discrim, obs), "SM Expected", "Observed", xtitle="#kappa_{" + coup + "}", ytitle="-2ln(#lambda)", SMfix=("fix" in asi), higgs=higgs, output=join(args.outpath, discrim, "{0}_{1}.pdf".format(coup, fix)))
plot_factor = config['CONSTANTS']['PLOT_FACTOR'] bc = (0, 0) if cell_count%2 != 0: print('Please use even number of cells') sys.exit() ic = np.zeros([2, 5]) ic[0][0] = 1 ic[0][1] = cell_count/2 ic[0][2] = IC_l['DENS'] ic[0][3] = IC_l['VELO'] ic[0][4] = IC_l['PRES'] ic[1][0] = cell_count/2+1 ic[1][1] = cell_count ic[1][2] = IC_r['DENS'] ic[1][3] = IC_r['VELO'] ic[1][4] = IC_r['PRES'] if __name__ == '__main__': cells = fv.run(domain_length, cell_count, ic, bc, time_eval) x, d, u, p = tr.test(domain_length, cell_count*plot_factor, IC_l, IC_r, time_eval) pu.plot(cells, domain_length/cell_count, plot_factor, x, d, u, p)
import FiniteVolume as fv import PlotUtil as pu # Extracting configuration properties with open('config.json', 'r') as f: config = json.load(f) test_inputs = config['MAIN'] domain_length = test_inputs['DOMAIN_LENGTH'] cell_count = test_inputs['CELL_COUNT'] bc = (config['MAIN']['BC']['LEFT'], config['MAIN']['BC']['RIGHT']) ic = np.zeros([np.size(config['MAIN']['IC']), 5]) for i in range(0, np.size(config['MAIN']['IC'])): ic[i][0] = config['MAIN']['IC'][i]['START'] ic[i][1] = config['MAIN']['IC'][i]['END'] ic[i][2] = config['MAIN']['IC'][i]['DENS'] ic[i][3] = config['MAIN']['IC'][i]['VELO'] ic[i][4] = config['MAIN']['IC'][i]['PRES'] time_eval = config['MAIN']['TIME_EVAL'] plot_factor = config['CONSTANTS']['PLOT_FACTOR'] cells = fv.run(domain_length, cell_count, ic, bc, time_eval) pu.plot(cells, domain_length / cell_count, plot_factor)
'word': 'soccer' }, { 'database': 'limitdb2', 'table_name': 'coord_tweets', 'quality_function': 'PH', 'word': 'soccer' }] x_label = 'K Percentage (%)' y_label = 'Quality' title = 'K-Q curves of "soccer" on different data size' # 2. Get the curves from corresponding database db = None curves = [] for targetCurve in targetCurves: database = targetCurve['database'] if db is None: db = DatabaseFactory.getDatabase(dbtype, database) elif db.getDatabase() != database: db.close() db = DatabaseFactory.getDatabase(dbtype, database) curve = db.queryCurve(targetCurve['table_name'], targetCurve['quality_function'], targetCurve['word']) curves.append(curve) print curves # 3. plot the curves PlotUtil.plotCurves(pdfBasePath + '/' + fileName, labels, x, curves, x_label, y_label, title)
# (1) Plot T-(r, k) curves of different keywords i_fileName = i_fileName_head + '_t-r-k_' + order_suffix i_labels = keyword_labels print 'i_labels:' print i_labels i_x = r_labels i_curves = [] print 'keywords:' for keyword in keywords: print keyword[0] i_curves.append(times[keyword[0]]) i_x_label = '(r, k) pair for r' i_y_label = 'Execution Time(s)' # i_title = 'F=[' + str(min(frequencies)) + '-' + str(max(frequencies)) + '] Q=' + str(quality) + ' - T-(r,k) curves' i_title = 'F=[' + str( keywords[0][1]) + '] Q=' + str(quality) + ' - T-(r,k) curves' print 'Plotting', i_title PlotUtil.plotCurves(i_fileName, i_labels, i_x, i_curves, i_x_label, i_y_label, i_title) end = time.time() print '=================================================' print ' ' + dbType + ' Experiment - Time over quality ' print '- Hybrid approach' print '=================================================' print 'table:', tableName print 'keywords:', keywords print 'r_percentage:', r_labels print '-------------------------------------------------' print 'Finished!', end - start, 'seconds spent.'
######################################################################## reweight_type = MiniTree.Property.reweight_type if "REWEIGHT" in Work[ "SETTING"] else None h = MiniTrees.weighted_histograms(MiniTree.Tree, param["NAME"], Work["WEIGHT"], param["NBIN"], param["MIN"], param["MAX"], category=CATEGORY, lumiscale=Work["LUMISCALE"], reweight_type=reweight_type) if proc not in histograms: histograms[proc] = h else: histograms[proc] = PlotUtil.merge_two_hist_by_keys( histograms[proc], h) if ("DATADRIVEN" in Work["SETTING"]) and (MiniTree.Property.IsDataDriven): if 'data driven bkg' not in histograms: histograms['data driven bkg'] = h else: histograms[ 'data driven bkg'] = PlotUtil.merge_two_hist_by_keys( histograms[proc], h) elif len(proc) > 1: raise Exception("Not Mutually Exclusive MiniTrees: {0}".format( param["MINITREES"])) if "ORDERED" in Work["SETTING"]: histograms = OrderedDict([[i, histograms[i]] for i in sorted(histograms.iterkeys())])
join(newdir, element.output.format(category)), element.hname + "_" + args.discriminant)) print "Finish combining {0}".format(element.name) os.system( "python MergeHistFromRootFiles.py {0} {1} -o={2} --hname={3} --method=dif" .format(join(newdir, CombineMC[0].format(category)), join(newdir, CombineMC[1].format(category)), join(newdir, CombineMC[0].format(category)), 'MC_REDU_BKG' + "_" + args.discriminant)) print "Finish combining MC Reducible Background" PlotUtil.NormalizeHistFromRoot( join(newdir, 'output_category_{0}_MC_REDU_BKG_nominal.root'.format(category)), H4lAnalysis.Minitree_H4l.Data_Driven_Count[category], fout_name=join( newdir, 'output_category_{0}_Redu_Bkg_nominal.root'.format(category)), hout_name='Redu_Bkg_{0}'.format(args.discriminant)) print "Finish producing data driven backgroun samples" Util.try_remove( join( newdir, 'output_category_{0}_data_run_2_Asimov_nominal.root'.format( category))) os.system( "python MergeHistFromRootFiles.py {0} -o={1} --hname={2} ".format( " ".join([ join( newdir,
s = """ SPE: Gain = %7.2f I (muA) = %7.2f, V (mV) = %7.2f, ADC = %d """ % (self.pmt_gain, self.A/units.muA, self.V/units.mV, self.nADC) return s if __name__ == '__main__': import PlotUtil as putil import matplotlib.pyplot as plt signal_start = 2000 * units.ns signal_length = 200 * units.mus daq_window = 1 * units.ms spe = SPE() print spe signal_end = signal_start + signal_length signal_t, signal_PE = spe.SpePulseTrain(signal_start, signal_end, daq_window) putil.plot_signal(signal_t/units.ns, signal_PE/units.muA, title='Input Signal: PE Train', signal_start=0 * units.ns, signal_end=len(signal_t)/units.ns, units='muA') plt.show()