def execute_config(conf, output_dir, db): import pandas as pd import smpdflib.core as lib import logging resultset = [] for group in conf.actiongroups: pdfsets, observables = group['pdfsets'], group['observables'] resources = group.copy() resources.pop('actions') # perform convolution #TODO Do this better if any(requires_result(act) for act in group['actions']): results = lib.produce_results(pdfsets, observables, db) resultset.append(results) data_table = lib.results_table(results) summed_table = lib.summed_results_table(results) total = pd.concat((data_table, summed_table), ignore_index = True) if logging.getLogger().isEnabledFor(logging.DEBUG): ... #print_results(results) resources.update({'results':results, 'data_table':data_table, 'total':total, 'summed_table':summed_table}) if any(requires_correlations(act) for act in group['actions']): pdfcorrlist = lib.correlations(data_table, db=db) resources.update({'pdfcorrlist':pdfcorrlist}) prefix = group['prefix'] resources.update({ 'output_dir':output_dir, 'prefix':prefix, 'pdfsets': pdfsets, 'db': db}) for action, res in do_actions(group['actions'], resources): logging.info("Finalized action '%s'." % action) return resultset
from smpdflib.plots import plot_bindist #Db folder should exist... db = shelve.open('db/db') to_plot = {make_observable('data/applgrid/CMSWCHARM-WpCb-eta4.root', order=1) : 4, make_observable('data/applgrid/APPLgrid-LHCb-Z0-ee_arXiv1212.4260-eta34.root', order=1) : 8, } pdfs = [PDF('MC900_nnlo', label="legendtext"), PDF('CMC100_nnlo', label="other"), PDF('MCH_nnlo_100', label="another") ] if __name__ == '__main__': for obs, bin in to_plot.items(): results = produce_results(pdfs, [obs], db=db) obs_table = results_table(results) for (obs,b), fig in plot_bindist(obs_table, bin, base_pdf = pdfs[0]): ax = fig.axes[0] ax.set_xlabel("My X label") ax.set_ylabel("MY Y label") ax.set_title("My title") path = "%s_bin_%s.pdf" % (obs, b+1) fig.savefig(path) plt.close(fig)