Functions
allpot.plots Namespace Reference

Functions

def make_allpot_plot (is_ana, is_fhc, is_rhc, fhc, rhc, fhc_cum, rhc_cum, total, style, subplots_kwargs={'figsize':(24, 10)}, tight_layout_kwargs={'pad':6.5})
 

Detailed Description

Module containing plotting functions for POT plots

Function Documentation

def allpot.plots.make_allpot_plot (   is_ana,
  is_fhc,
  is_rhc,
  fhc,
  rhc,
  fhc_cum,
  rhc_cum,
  total,
  style,
  subplots_kwargs = {'figsize': (24, 10)},
  tight_layout_kwargs = {'pad': 6.5} 
)
Makes the all/historical POT plot

Args
----
    is_ana (Series): Boolean timeseries identifying whether each
        POT record is contained within the dataset for the given
        analysis.
    is_fhc (Series): Boolean timeseries identifying whether each
        POT record is forward horn current (FHC).
    is_rhc (Series): Boolean timeseries identifying whether each
        POT record is reverse horn current (RHC).

    fhc (Series): Timeseries containing all the FHC POT records.
    rhc (Series): Timeseries containing all the RHC POT records.

    fhc_cum (Series): Cumulative timeseries for all FHC records.
    rhc_cum (Series): Cumulative timeseries for all RHC records.
    total (Series): Cumulative timeseries for all POT records.

    style (dict): Dictionary containing all style arguments for each
        series to plot.

    subplots_kwargs (dict): Args to pass to `plt.subplots`.
    tight_layout_kwargs (dict): Args to pass to `plt.tight_layout`.

    ana_text (str): Analysis name/label to highlight the POT records
        corresponding to a particular analysis dataset.
    end_date (str): Date at which timeseries ends. If making the plot
        to end "today" (i.e. the most recent POT records available),
        leave this as a blank string.
    binning (str): Description of how the plot should be binned.
        Usually either 'daily' or 'weekly'.

Definition at line 20 of file plots.py.

20 ):
21  '''Makes the all/historical POT plot
22 
23  Args
24  ----
25  is_ana (Series): Boolean timeseries identifying whether each
26  POT record is contained within the dataset for the given
27  analysis.
28  is_fhc (Series): Boolean timeseries identifying whether each
29  POT record is forward horn current (FHC).
30  is_rhc (Series): Boolean timeseries identifying whether each
31  POT record is reverse horn current (RHC).
32 
33  fhc (Series): Timeseries containing all the FHC POT records.
34  rhc (Series): Timeseries containing all the RHC POT records.
35 
36  fhc_cum (Series): Cumulative timeseries for all FHC records.
37  rhc_cum (Series): Cumulative timeseries for all RHC records.
38  total (Series): Cumulative timeseries for all POT records.
39 
40  style (dict): Dictionary containing all style arguments for each
41  series to plot.
42 
43  subplots_kwargs (dict): Args to pass to `plt.subplots`.
44  tight_layout_kwargs (dict): Args to pass to `plt.tight_layout`.
45 
46  ana_text (str): Analysis name/label to highlight the POT records
47  corresponding to a particular analysis dataset.
48  end_date (str): Date at which timeseries ends. If making the plot
49  to end "today" (i.e. the most recent POT records available),
50  leave this as a blank string.
51  binning (str): Description of how the plot should be binned.
52  Usually either 'daily' or 'weekly'.
53 
54  '''
55 
56  plt.style.use('seaborn-poster')
57 
58  # Make figure and axis
59  fig, ax1 = plt.subplots(**subplots_kwargs)
60  plt.tight_layout(**tight_layout_kwargs) # Make margins tighter
61 
62  # Draw shaded period for neutrino/antineutrino beam and analysis
63  if ana_text and not end_date:
64  ax1 = is_ana.plot(kind='area', color='LightSlateGray',
65  alpha=style['ana_alpha']*1.5, label='_nolegend_', linewidth=0.)
66  if binning == 'weekly':
67  width = 1.0
68  alpha = 0.
69  else:
70  width = 0.85
71  alpha = style['area_alpha']
72  ax1 = isfhc.plot(kind='area', color=style['colors']['fhc'], alpha=alpha, label='_nolegend_', linewidth=0.)
73  ax1 = isrhc.plot(kind='area', color=style['colors']['rhc'], alpha=alpha, label='_nolegend_', linewidth=0.)
74  if binning == 'weekly':
75  ax1.bar(isfhc.index, isfhc, width=width, color=style['colors']['fhc'],
76  alpha=style['area_alpha'], label='_nolegend_', linewidth=0.)
77  ax1.bar(isrhc.index, isrhc, width=width, color=style['colors']['rhc'],
78  alpha=style['area_alpha'], label='_nolegend_', linewidth=0.)
79  plt.tick_params(axis='both', which='major', labelsize=style['ax_label_size'])
80 
81  # Draw main lines and scatter
82  ax2 = total.plot(secondary_y=True, color=style['colors']['all'], label=total_label)
83  ax2 = fhc_cum.plot(secondary_y=True, color=style['colors']['fhc'], label=fhc_cum_label)
84  s1 = ax1.scatter(fhc.index, fhc, marker="o", alpha=style['pot_alpha'], color=fhc_light, label=fhc_label)
85  ax2 = rhc_cum.plot(secondary_y=True, color=style['colors']['rhc'], label=rhc_cum_label)
86  s2 = ax1.scatter(rhc.index, rhc, marker="o", alpha=style['pot_alpha'], color=rhc_light, label=rhc_label)
87 
88  # Legend
89  h1, l1 = ax1.get_legend_handles_labels()
90  h2, l2 = ax2.get_legend_handles_labels()
91  plt.legend(h1+h2, l1+l2, loc='upper left',
92  fontsize=style['leg_font_size'],
93  fancybox=True, framealpha=style['text_alpha'])
94 
95  # Set limit on y-axis
96  ax1.set_ylim(0, max_y1)
97  ax2.set_ylim(0, max_y2)
98 
99  # Set axis titles
100  ax1.set_xlabel('Date', fontsize=style['ax_title_size'])
101  if binning == 'weekly':
102  ax1.set_ylabel('Weekly exposure ($10^{18}$ POT)', fontsize=style['ax_title_size'])
103  else:
104  ax1.set_ylabel('Daily exposure ($10^{18}$ POT)', fontsize=style['ax_title_size'])
105  ax2.set_ylabel('Cumulative exposure ($10^{20}$ POT)', fontsize=style['ax_title_size'])
106  plt.tick_params(axis='both', which='major', labelsize=style['ax_label_size'])
107 
108  # Add text
109  if numi_text:
110  plt.figtext(0.54, 0.83, numi_text, fontsize=28,
111  bbox=dict(boxstyle="round", color='white', alpha=style['text_alpha']))
112  if ana_text and not end_date:
113  plt.figtext(0.69, 0.76, ana_text, fontsize=24, color='LightSlateGray',
114  bbox=dict(boxstyle="round", color='white', alpha=style['text_alpha']))
115 
116  plt.show()
117 
118  for ext in exts:
119  fig.savefig(plot_name + ext)
120