Bläddra i källkod

Merge branch 'master' of git.fangmeier.tech:caleb/filval

Caleb Fangmeier 7 år sedan
förälder
incheckning
933573447d
3 ändrade filer med 11 tillägg och 8 borttagningar
  1. 5 4
      filval/histogram_utils.py
  2. 6 2
      filval/plotter.py
  3. 0 2
      setup.py

+ 5 - 4
filval/histogram_utils.py

@@ -42,6 +42,7 @@ def hist2d(th2, rescale_x=1.0, rescale_y=1.0, rescale_z=1.0):
     """
     """
     nbins_x = th2.GetNbinsX()
     nbins_x = th2.GetNbinsX()
     nbins_y = th2.GetNbinsY()
     nbins_y = th2.GetNbinsY()
+    print(nbins_x, nbins_y)
     xs = np.zeros((nbins_y+1, nbins_x+1), np.float32)
     xs = np.zeros((nbins_y+1, nbins_x+1), np.float32)
     ys = np.zeros((nbins_y+1, nbins_x+1), np.float32)
     ys = np.zeros((nbins_y+1, nbins_x+1), np.float32)
     values = np.zeros((nbins_y, nbins_x), np.float32)
     values = np.zeros((nbins_y, nbins_x), np.float32)
@@ -52,11 +53,11 @@ def hist2d(th2, rescale_x=1.0, rescale_y=1.0, rescale_z=1.0):
             ys[j][i] = th2.GetYaxis().GetBinLowEdge(j+1)
             ys[j][i] = th2.GetYaxis().GetBinLowEdge(j+1)
             values[j][i] = th2.GetBinContent(i+1, j+1)
             values[j][i] = th2.GetBinContent(i+1, j+1)
             errors[j][i] = th2.GetBinError(i+1, j+1)
             errors[j][i] = th2.GetBinError(i+1, j+1)
-        xs[nbins_y][i] = th2.GetXaxis().GetBinUpEdge(i+1)
-        ys[nbins_y][i] = th2.GetYaxis().GetBinUpEdge(nbins_y+1)
+        xs[nbins_y][i] = th2.GetXaxis().GetBinUpEdge(i)
+        ys[nbins_y][i] = th2.GetYaxis().GetBinUpEdge(nbins_y)
     for j in range(nbins_y+1):
     for j in range(nbins_y+1):
-        xs[j][nbins_x] = th2.GetXaxis().GetBinUpEdge(nbins_x+1)
-        ys[j][nbins_x] = th2.GetYaxis().GetBinUpEdge(j+1)
+        xs[j][nbins_x] = th2.GetXaxis().GetBinUpEdge(nbins_x)
+        ys[j][nbins_x] = th2.GetYaxis().GetBinUpEdge(j)
 
 
     xs *= rescale_x
     xs *= rescale_x
     ys *= rescale_y
     ys *= rescale_y

+ 6 - 2
filval/plotter.py

@@ -87,7 +87,8 @@ def decl_plot(fn):
 
 
 def generate_dashboard(plots, title, output='dashboard.html', template='dashboard.j2', source_file=None, ana_source=None):
 def generate_dashboard(plots, title, output='dashboard.html', template='dashboard.j2', source_file=None, ana_source=None):
     from jinja2 import Environment, PackageLoader, select_autoescape
     from jinja2 import Environment, PackageLoader, select_autoescape
-    from os.path import join
+    from os.path import join, isdir
+    from os import mkdir
     from urllib.parse import quote
     from urllib.parse import quote
 
 
     env = Environment(
     env = Environment(
@@ -111,6 +112,9 @@ def generate_dashboard(plots, title, output='dashboard.html', template='dashboar
     else:
     else:
         source = "# Not supplied!!"
         source = "# Not supplied!!"
 
 
+    if not isdir('output'):
+        mkdir('output')
+
     with open(join('output', output), 'w') as tempout:
     with open(join('output', output), 'w') as tempout:
         templ = env.get_template(template)
         templ = env.get_template(template)
         tempout.write(templ.render(
         tempout.write(templ.render(
@@ -212,7 +216,7 @@ def render_plots(plots, exts=('png',), scale=1.0, to_disk=True):
         print(f'Building plot {plot.name}')
         print(f'Building plot {plot.name}')
         plot.data = None
         plot.data = None
         if to_disk:
         if to_disk:
-            with lp.figure(plot.name, directory='output/figures',
+            with lp.figure(plot.name.replace(' ', '_'), directory='output/figures',
                            exts=exts,
                            exts=exts,
                            size=(scale * 10, scale * 10)):
                            size=(scale * 10, scale * 10)):
                 argdicts, docs, txts = grid_plot(plot.subplots)
                 argdicts, docs, txts = grid_plot(plot.subplots)

+ 0 - 2
setup.py

@@ -3,8 +3,6 @@ from setuptools import setup
 with open('requirements.txt') as req:
 with open('requirements.txt') as req:
     install_requires = [l.strip() for l in req.readlines()]
     install_requires = [l.strip() for l in req.readlines()]
 
 
-print(install_requires)
-
 setup(
 setup(
     name='filval',
     name='filval',
     version='0.1',
     version='0.1',