Browse Source

New plots

Caleb Fangmeier 6 years ago
parent
commit
6f281ef37a
3 changed files with 24 additions and 17 deletions
  1. 18 13
      analysis/plots.py
  2. 5 3
      analysis/templates/dashboard.htm
  3. 1 1
      filval

+ 18 - 13
analysis/plots.py

@@ -57,7 +57,7 @@ def plot_residuals_v_ladder(rs, var, layer):
     fmt_var = {'phi': r'\phi',
                'z': 'z',
                }[var]
-    scale = {'phi': 10**6,
+    scale = {'phi': 10**3,
              'z': 10**4,
              }[var]
     xlabel = {'phi': r'$\Delta \phi_1$(rad)',
@@ -80,7 +80,6 @@ def plot_residuals_v_ladder(rs, var, layer):
 @decl_plot
 def sc_extrapolation_first(rs, var, layer, hit, even_odd, log=False, norm=None, cut=None):
     ''' Raphael's plots '''
-    errors = True
 
     # def preproc(h):
     #     return hist_slice(hist(h.ProjectionY()), (-0.07, 0.07))
@@ -118,7 +117,7 @@ def sc_extrapolation_first(rs, var, layer, hit, even_odd, log=False, norm=None,
          ('z', 'B2', 2, 'odd'): rs.sc_second_hits_in_B2_dz_odd,
          ('z', 'B3', 2, 'odd'): rs.sc_second_hits_in_B3_dz_odd,
          }[(var, layer, hit, even_odd)]
-    scale = {'phi': 10**6,
+    scale = {'phi': 10**3,
              'z': 10**4,
              }[var]
     varlabel = {('z', 1): r"$\Delta z_1(\mu \mathrm{m})$",
@@ -144,8 +143,12 @@ def generate_dashboard(plots):
 
     env = Environment(
         loader=PackageLoader('plots', 'templates'),
-        autoescape=select_autoescape(['htm', 'html', 'xml'])
+        autoescape=select_autoescape(['htm', 'html', 'xml']),
     )
+    env.globals.update({'quote': quote,
+                        'enumerate': enumerate,
+                        'zip': zip,
+                        })
 
     def render_to_file(template_name, **kwargs):
         with open(join('output', template_name), 'w') as tempout:
@@ -159,9 +162,7 @@ def generate_dashboard(plots):
             l = l[n:]
 
     render_to_file('dashboard.htm', plots=get_by_n(plots, 3),
-                   outdir="figures/",
-                   quote=quote,
-                   enumerate=enumerate)
+                   outdir="figures/")
 
 
 if __name__ == '__main__':
@@ -205,18 +206,19 @@ if __name__ == '__main__':
     dz1_v_ladder_B1 = (plot_residuals_v_ladder, (rs, 'z', 'B1'), {})
     dz1_v_ladder_B2 = (plot_residuals_v_ladder, (rs, 'z', 'B2'), {})
 
-    dphi1_sc_ex_B1 = (sc_extrapolation_first, (rs, 'phi', 'B1', 1, 'either'), {'log': True, 'norm': 1.0})
-    dphi1_sc_ex_B2 = (sc_extrapolation_first, (rs, 'phi', 'B2', 1, 'either'), {'log': True, 'norm': 1.0})
+    opts = {'log': False, 'norm': 1.0, 'cut': 25}
+    dphi1_sc_ex_B1 = (sc_extrapolation_first, (rs, 'phi', 'B1', 1, 'either'), opts )
+    dphi1_sc_ex_B2 = (sc_extrapolation_first, (rs, 'phi', 'B2', 1, 'either'), opts)
     dz1_sc_ex_B1 = (sc_extrapolation_first, (rs, 'z', 'B1', 1, 'either'), {'norm': 1.0})
     dz1_sc_ex_B2 = (sc_extrapolation_first, (rs, 'z', 'B2', 1, 'either'), {'norm': 1.0})
 
-    dphi1_sc_ex_B1_even = (sc_extrapolation_first, (rs, 'phi', 'B1', 1, 'even'), {'log': True, 'norm': 1.0})
-    dphi1_sc_ex_B2_even = (sc_extrapolation_first, (rs, 'phi', 'B2', 1, 'even'), {'log': True, 'norm': 1.0})
+    dphi1_sc_ex_B1_even = (sc_extrapolation_first, (rs, 'phi', 'B1', 1, 'even'), opts)
+    dphi1_sc_ex_B2_even = (sc_extrapolation_first, (rs, 'phi', 'B2', 1, 'even'), opts)
     dz1_sc_ex_B1_even = (sc_extrapolation_first, (rs, 'z', 'B1', 1, 'even'), {'norm': 1.0})
     dz1_sc_ex_B2_even = (sc_extrapolation_first, (rs, 'z', 'B2', 1, 'even'), {'norm': 1.0})
 
-    dphi1_sc_ex_B1_odd = (sc_extrapolation_first, (rs, 'phi', 'B1', 1, 'odd'), {'log': True, 'norm': 1.0})
-    dphi1_sc_ex_B2_odd = (sc_extrapolation_first, (rs, 'phi', 'B2', 1, 'odd'), {'log': True, 'norm': 1.0})
+    dphi1_sc_ex_B1_odd = (sc_extrapolation_first, (rs, 'phi', 'B1', 1, 'odd'), opts)
+    dphi1_sc_ex_B2_odd = (sc_extrapolation_first, (rs, 'phi', 'B2', 1, 'odd'), opts)
     dz1_sc_ex_B1_odd = (sc_extrapolation_first, (rs, 'z', 'B1', 1, 'odd'), {'norm': 1.0})
     dz1_sc_ex_B2_odd = (sc_extrapolation_first, (rs, 'z', 'B2', 1, 'odd'), {'norm': 1.0})
 
@@ -248,6 +250,9 @@ if __name__ == '__main__':
              Plot([[dphi1_sc_ex_B1_odd, dphi1_sc_ex_B2_odd],
                    [dz1_sc_ex_B1_odd, dz1_sc_ex_B2_odd]],
                   'sc_ex_1_odd'),
+             Plot([[[dphi1_sc_ex_B1_odd, dphi1_sc_ex_B1_even], "FL"],
+                   [dz1_sc_ex_B1_odd, dz1_sc_ex_B1_even]],
+                  'sc_ex_1_odd_v_even'),
              ]
 
     # Finally, render and save the plots and generate the html+bootstrap

+ 5 - 3
analysis/templates/dashboard.htm

@@ -31,7 +31,7 @@ MathJax.Hub.Config({
         <div class="caption">
           <p class="text-center"> {{ plot.name }} </p>
           <div class="panel-group" id="accordion">
-    {% for id, ((i,j), doc) in enumerate(plot.docs.items()) %}
+    {% for id, (i,j) in enumerate(plot.docs.keys()) %}
             <div class="panel-heading">
               <h4 class="panel-title">
                 <button data-toggle="collapse" data-parent="#accordion" class="btn btn-info" href="#collapse{{r}}-{{c}}-{{id}}">
@@ -40,18 +40,20 @@ MathJax.Hub.Config({
             </div>
             <div id="collapse{{r}}-{{c}}-{{id}}" class="panel-collapse collapse">
               <div class="panel-body">
+      {% for doc, argdict in zip(plot.docs[(i,j)], plot.argdicts[(i,j)]) %}
                 <p class="text-left">{{ doc|safe }}</p>
                 <hr>
                 <p class="text-left"><strong>Plot Arguments</strong></p>
                 <table class="table table-hover">
                   <tbody>
-      {% for key, val in plot.argdict[(i,j)].items() %}
+        {% for key, val in argdict.items() %}
                     <tr>
                       <td>{{ key }}</td> <td>{{ val }}</td>
                     </tr>
-      {% endfor %}
+        {% endfor %}
                   </tbody>
                 </table>
+      {% endfor %}
               </div>
             </div>
     {% endfor %}

+ 1 - 1
filval

@@ -1 +1 @@
-Subproject commit beb797bd8c0e9052921923841a9a8f2756338c95
+Subproject commit 1b5a7600f1f45686e20683e0d032e08288218bad