@@ -0,0 +1,1996 @@
+import logging, argparse, os, sys, re%0Aimport numpy as np%0Afrom fnmatch import fnmatch%0Afrom collections import OrderedDict%0Afrom .utils import getWorkDirs, checkSymLink%0Afrom ..ccsgp.ccsgp import make_plot%0Afrom ..ccsgp.utils import getOpts%0Afrom ..ccsgp.config import default_colors%0A%0Adef gp_rdiff(version):%0A  %22%22%22example for ratio or difference plots using QM12 data (see gp_panel)%0A%0A  :param version: plot version / input subdir name%0A  :type version: str%0A  %22%22%22%0A  inDir, outDir = getWorkDirs()%0A  inDir = os.path.join(inDir, version)%0A  data, cocktail = OrderedDict(), OrderedDict()%0A  for file in os.listdir(inDir):%0A    energy = re.compile('%5Cd+').search(file).group()%0A    data_type = re.sub('%25s%5C.dat' %25 energy, '', file)%0A    file_url = os.path.join(inDir, file)%0A    data_import = np.loadtxt(open(file_url, 'rb'))%0A    data_import = data_import%5Bdata_import%5B:,0%5D %3C 1.3%5D%0A    if fnmatch(file, 'data*'): data%5Benergy%5D = data_import%0A    else: cocktail%5Benergy%5D = data_import%0A  # TODO: rebin cocktail to data%0A  # TODO: implement difference%0A  # TODO: implement ratio!%0A  dataOrdered = OrderedDict(%0A    (' '.join(%5Bk, 'GeV'%5D), '''data%5Bk%5D - cocktailRebin%5Bk%5D''')%0A    for k in sorted(data, key=int)%0A  )%0A  nSets = len(dataOrdered)%0A  make_plot(%0A    data = dataOrdered.values(),%0A    properties = %5B%0A      'lt 1 lw 4 ps 1.5 lc %25s pt 18' %25 default_colors%5Bi%5D for i in xrange(nSets)%0A    %5D,%0A    titles = dataOrdered.keys(),%0A    # TODO: adjust name and ylabel for ratio%0A    name = os.path.join(outDir, 'diff%25s' %25 version), ylabel = 'diff',%0A    xlabel = 'dielectron mass (GeV/c%5E%7B2%7D)',%0A  )%0A  return 'done'%0A%0Aif __name__ == '__main__':%0A  checkSymLink()%0A  parser = argparse.ArgumentParser()%0A  parser.add_argument(%22version%22, help=%22version = subdir name of input dir%22)%0A  parser.add_argument(%22--log%22, help=%22show log output%22, action=%22store_true%22)%0A  args = parser.parse_args()%0A  loglevel = 'DEBUG' if args.log else 'WARNING'%0A  logging.basicConfig(%0A    format='%25(message)s', level=getattr(logging, loglevel)%0A  )%0A  print gp_stack(args.version)%0A

add gp_rdiff