def gp_ptspec():
fenergies = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', ]<EOL>nen = len(fenergies)<EOL>mee_keys = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>mee_dict = OrderedDict((k,'<STR_LIT>') for k in mee_keys)<EOL>yscale = { '<STR_LIT>': '<STR_LIT>', '<STR_LIT>': '<STR_LIT>', '<STR_LIT>': '<STR_LIT>', '<STR_LIT>': '<STR_LIT>', '<STR_LIT>': '<STR_LIT>' }<EOL>inDir, outDir = getWorkDirs()<EOL>data, data_avpt, dpt_dict = {}, {}, {}<EOL>yvals, yvalsPt = [], []<EOL>scale = {<EOL>'<STR_LIT>': <NUM_LIT>, '<STR_LIT>': <NUM_LIT:1.0>, '<STR_LIT>': <NUM_LIT>,<EOL>'<STR_LIT>': <NUM_LIT>, '<STR_LIT>': <NUM_LIT><EOL>}<EOL>lmr_label = None<EOL>for filename in os.listdir(inDir):<EOL><INDENT>file_url = os.path.join(inDir, filename)<EOL>filebase = os.path.splitext(filename)[<NUM_LIT:0>] <EOL>energy, mee_name, mee_range, data_type = splitFileName(filebase)<EOL>if mee_name == '<STR_LIT>':<EOL><INDENT>mee_range_split = list(map(float, mee_range.split('<STR_LIT:->')))<EOL>lmr_label = '<STR_LIT>' % (<EOL>mee_range_split[<NUM_LIT:0>], mee_range_split[<NUM_LIT:1>]<EOL>)<EOL><DEDENT>if energy == '<STR_LIT>': continue<EOL>if mee_name not in mee_keys: continue<EOL>mee_dict[mee_name] = mee_range<EOL>data[filebase] = np.loadtxt(open(file_url, '<STR_LIT:rb>'))<EOL>if data_type == '<STR_LIT:data>':<EOL><INDENT>data[filebase] = data[filebase][:-<NUM_LIT:1>] <EOL><DEDENT>if energy == '<STR_LIT>': data[filebase][:,(<NUM_LIT:1>,<NUM_LIT:3>,<NUM_LIT:4>)] /= <NUM_LIT:0.5><EOL>mask = (data[filebase][:,<NUM_LIT:0>] > <NUM_LIT>) & (data[filebase][:,<NUM_LIT:0>] < <NUM_LIT>)<EOL>avpt_data = data[filebase][mask]<EOL>pTs = avpt_data[:,<NUM_LIT:0>]<EOL>wghts = avpt_data[:,<NUM_LIT:1>]<EOL>probs = unp.uarray(avpt_data[:,<NUM_LIT:1>], avpt_data[:,<NUM_LIT:3>]) <EOL>probs /= umath.fsum(probs) <EOL>avpt = umath.fsum(pTs*probs)<EOL>logging.info(('<STR_LIT>' % (<EOL>filebase, np.average(pTs, weights = wghts)<EOL>)).format(avpt)) <EOL>dp = [ float(getEnergy4Key(energy)), avpt.nominal_value, <NUM_LIT:0.>, avpt.std_dev, <NUM_LIT:0.> ]<EOL>avpt_key = mee_name<EOL>if data_type == '<STR_LIT>': avpt_key += '<STR_LIT>'<EOL>if data_type == '<STR_LIT>': avpt_key += '<STR_LIT>'<EOL>if data_type == '<STR_LIT>': avpt_key += '<STR_LIT>'<EOL>if data_type == '<STR_LIT>': avpt_key += '<STR_LIT>'<EOL>if avpt_key in data_avpt: data_avpt[avpt_key].append(dp)<EOL>else: data_avpt[avpt_key] = [ dp ]<EOL>yvalsPt.append(avpt.nominal_value)<EOL>if data_type != '<STR_LIT:data>':<EOL><INDENT>data[filebase][:,(<NUM_LIT:1>,<NUM_LIT:3>,<NUM_LIT:4>)] /= scale[energy]<EOL><DEDENT>data[filebase][:,(<NUM_LIT:1>,<NUM_LIT:3>,<NUM_LIT:4>)] *= float(yscale[energy])<EOL>if data_type == '<STR_LIT>' or fnmatch(data_type, '<STR_LIT>'):<EOL><INDENT>data[filebase][:,<NUM_LIT:2>:] = <NUM_LIT:0.><EOL><DEDENT>yvals += [v for v in data[filebase][:,<NUM_LIT:1>] if v > <NUM_LIT:0>]<EOL>dpt_dict_key = getSubplotTitle(mee_name, mee_range)<EOL>if dpt_dict_key not in dpt_dict:<EOL><INDENT>ndsets = nen*<NUM_LIT:2><EOL>if mee_name == '<STR_LIT>': ndsets += <NUM_LIT:4>*<NUM_LIT:3><EOL>dpt_dict[dpt_dict_key] = [ [None]*ndsets, [None]*ndsets, [None]*ndsets ]<EOL><DEDENT>enidx = fenergies.index(energy)<EOL>dsidx = enidx<EOL>if fnmatch(data_type, '<STR_LIT>'):<EOL><INDENT>dsidx = (energy=='<STR_LIT>')*<NUM_LIT:0> + (energy=='<STR_LIT>')*<NUM_LIT:3> + (energy=='<STR_LIT>')*<NUM_LIT:6> + (energy=='<STR_LIT>')*<NUM_LIT:9><EOL>dsidx += (data_type=='<STR_LIT>')*<NUM_LIT:0> + (data_type=='<STR_LIT>')*<NUM_LIT:1><EOL>dsidx += (data_type=='<STR_LIT>')*<NUM_LIT:2><EOL><DEDENT>else:<EOL><INDENT>dsidx += int(mee_name == '<STR_LIT>') * <NUM_LIT:4> * <NUM_LIT:3> <EOL><DEDENT>dsidx += int(data_type == '<STR_LIT:data>') * len(fenergies)<EOL>dpt_dict[dpt_dict_key][<NUM_LIT:0>][dsidx] = data[filebase] <EOL>if data_type == '<STR_LIT:data>': <EOL><INDENT>dpt_dict[dpt_dict_key][<NUM_LIT:1>][dsidx] = '<STR_LIT>' % default_colors[enidx]<EOL><DEDENT>elif data_type == '<STR_LIT>':<EOL><INDENT>dpt_dict[dpt_dict_key][<NUM_LIT:1>][dsidx] = '<STR_LIT>' % default_colors[enidx]<EOL><DEDENT>else:<EOL><INDENT>dpt_dict[dpt_dict_key][<NUM_LIT:1>][dsidx] = '<STR_LIT>' % (<EOL><NUM_LIT:2>+(data_type=='<STR_LIT>')+(data_type=='<STR_LIT>')*<NUM_LIT:2>, default_colors[enidx]<EOL>)<EOL><DEDENT>dpt_dict[dpt_dict_key][<NUM_LIT:2>][dsidx] = '<STR_LIT:U+0020>'.join([ <EOL>getEnergy4Key(energy), '<STR_LIT>', '<STR_LIT>' % (<EOL>Decimal(yscale[energy])<EOL>)<EOL>]) if data_type == '<STR_LIT:data>' else '<STR_LIT>'<EOL><DEDENT>plot_key_order = list(dpt_dict.keys())<EOL>plot_key_order.sort(key=lambda x: float(x.split('<STR_LIT::>')[<NUM_LIT:1>].split('<STR_LIT:->')[<NUM_LIT:0>]))<EOL>for k in data_avpt: data_avpt[k].sort(key=lambda x: x[<NUM_LIT:0>])<EOL>energies = [ dp[<NUM_LIT:0>] for dp in data_avpt[mee_keys[<NUM_LIT:0>]] ]<EOL>energies.append(<NUM_LIT>) <EOL>linsp = {}<EOL>for start,stop in zip(energies[:-<NUM_LIT:1>],energies[<NUM_LIT:1>:]):<EOL><INDENT>linsp[start] = np.linspace(start, stop, num = <NUM_LIT:4>*len(mee_keys))<EOL><DEDENT>for k in data_avpt:<EOL><INDENT>key = k.split('<STR_LIT:_>')[<NUM_LIT:0>]<EOL>for i in range(len(data_avpt[k])):<EOL><INDENT>data_avpt[k][i][<NUM_LIT:0>] = linsp[energies[i]][mee_keys.index(key)]<EOL><DEDENT><DEDENT>yMin, yMax = <NUM_LIT:0.5>*min(yvals), <NUM_LIT:3>*max(yvals)<EOL>make_panel(<EOL>dpt_dict = OrderedDict((k,dpt_dict[k]) for k in plot_key_order),<EOL>name = os.path.join(outDir, '<STR_LIT>'),<EOL>ylabel = '<STR_LIT>',<EOL>xlabel = '<STR_LIT>',<EOL>ylog = True, xr = [<NUM_LIT:0>, <NUM_LIT>], yr = [<NUM_LIT>, <NUM_LIT>],<EOL>key = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'],<EOL>arrow_bar = <NUM_LIT>, layout = '<STR_LIT>', size = '<STR_LIT>'<EOL>)<EOL>return '<STR_LIT>'<EOL>
example for a 2D-panel plot etc.