CMS 3D CMS Logo

Functions | Variables
create_public_peakpu_plots Namespace Reference

Functions

def CacheFilePath (cache_file_dir, day=None)
 
def GetXLocator (ax)
 
def PlotPeakPUAllYears (lumi_data_by_fill_per_year)
 
def processdata (years)
 
def TweakPlot (fig, ax, time_range, add_extra_head_room=False)
 

Variables

 accel_mode
 
 action
 
 amodetag_bug_workaround
 
 arg_parser
 
 args
 
 beam_energy
 
 beam_energy_defaults
 
 beam_energy_from_cfg
 
 beam_energy_tmp
 
 beam_fluctuation
 
 beam_fluctuation_defaults
 
 beam_fluctuation_from_cfg
 
 beam_fluctuation_tmp
 
 cache_file_dir
 
 cfg_defaults
 
 cfg_parser
 
 color_scheme_names
 
 color_scheme_names_tmp
 
 config_file_name
 
 date_begin
 
 date_end
 
 DATE_FMT_STR_AXES
 
 DATE_FMT_STR_CFG
 
 DATE_FMT_STR_LUMICALC
 
 DATE_FMT_STR_LUMICALC_DAY
 
 DATE_FMT_STR_OUT
 
 desc_str
 
 description
 
 file
 
 help
 
 hist
 
 ignore_cache
 
 KNOWN_ACCEL_MODES
 
 LEAD_SCALE_FACTOR
 
 lumi_data_by_fill_per_year
 
 lumicalc_flags_from_cfg
 
 lumicalc_script
 
 NUM_SEC_IN_LS
 
 options
 
 oracle_connection_string
 
 particle_type_str
 
 particle_type_strings
 
 path_name
 
 tmp
 
 today
 
 use_oracle
 
 verbose
 
 year_begin
 
 year_end
 
 years
 

Function Documentation

def create_public_peakpu_plots.CacheFilePath (   cache_file_dir,
  day = None 
)

Definition at line 110 of file create_public_peakpu_plots.py.

110 def CacheFilePath(cache_file_dir, day=None):
111  cache_file_path = os.path.abspath(cache_file_dir)
112  if day:
113  cache_file_name = "lumicalc_cache_%s.csv" % day.isoformat()
114  cache_file_path = os.path.join(cache_file_path, cache_file_name)
115  return cache_file_path
116 
117 
def CacheFilePath(cache_file_dir, day=None)
def create_public_peakpu_plots.GetXLocator (   ax)
Pick a DateLocator based on the range of the x-axis.

Definition at line 118 of file create_public_peakpu_plots.py.

References min(), and TweakPlot().

Referenced by TweakPlot().

118 def GetXLocator(ax):
119  """Pick a DateLocator based on the range of the x-axis."""
120  (x_lo, x_hi) = ax.get_xlim()
121  num_days = x_hi - x_lo
122  min_num_ticks = min(num_days, 5)
123  locator = matplotlib.dates.AutoDateLocator(minticks=min_num_ticks,
124  maxticks=None)
125  # End of GetLocator().
126  return locator
127 
T min(T a, T b)
Definition: MathUtil.h:58
def create_public_peakpu_plots.PlotPeakPUAllYears (   lumi_data_by_fill_per_year)
Mode 1: years side-by-side

Definition at line 405 of file create_public_peakpu_plots.py.

References public_plots_tools.AddLogo(), indexGen.date, edm.print(), public_plots_tools.SavePlot(), and TweakPlot().

405  def PlotPeakPUAllYears(lumi_data_by_fill_per_year):
406  """Mode 1: years side-by-side"""
407 
408  # Loop over all color schemes and plot.
409  for color_scheme_name in color_scheme_names:
410  print(" color scheme '%s'" % color_scheme_name)
411  color_scheme = ColorScheme(color_scheme_name)
412  color_by_year = color_scheme.color_by_year
413  logo_name = color_scheme.logo_name
414  file_suffix = color_scheme.file_suffix
415 
416  for type in ["lin", "log"]:
417  is_log = (type == "log")
418  aspect_ratio = matplotlib.figure.figaspect(1. / 2.5)
419  fig = plt.figure(figsize=aspect_ratio)
420  ax = fig.add_subplot(111)
421 
422  time_begin_ultimate = datetime.datetime.strptime(lumi_data_by_fill_per_year[years[0]][0][0],DATE_FMT_STR_LUMICALC).date()
423  str_begin_ultimate = time_begin_ultimate.strftime(DATE_FMT_STR_OUT)
424  for (year_index, year) in enumerate(years):
425 
426  lumi_data = lumi_data_by_fill_per_year[year]
427  times_tmp = [datetime.datetime.strptime(tmp,DATE_FMT_STR_LUMICALC).date() for tmp in lumi_data[0]]
428  times = [matplotlib.dates.date2num(i) for i in times_tmp] #x_axis
429  maxpus = lumi_data[1] # y_axis
430 
431  # NOTE: Special case for 2010.
432  label = None
433  if year == 2010 or year == 2011 :
434  label = r"%d, %s" % \
435  (year,r'7TeV $\sigma$=71.5mb')
436  else:
437  label = r"%d, %s" % \
438  (year,r'8TeV $\sigma$=73mb')
439  ax.plot(times,maxpus,
440  color=color_by_year[year],
441 # marker="none", linestyle="solid",
442  marker="o", linestyle='none',
443  linewidth=4,
444  label=label)
445  if is_log:
446  ax.set_yscale("log")
447 
448  time_begin = datetime.datetime(years[0], 1, 1, 0, 0, 0)
449  time_end = datetime.datetime(years[-1], 12, 16, 20, 50,9)
450  str_begin = time_begin.strftime(DATE_FMT_STR_OUT)
451  str_end = time_end.strftime(DATE_FMT_STR_OUT)
452 
453  num_cols = None
454  num_cols = len(years)
455  tmp_x = 0.095
456  tmp_y = .95
457 
458  leg = ax.legend(loc="upper left", bbox_to_anchor=(tmp_x, 0., 1., tmp_y),
459  frameon=False, ncol=num_cols)
460  for t in leg.get_texts():
461  t.set_font_properties(FONT_PROPS_TICK_LABEL)
462 
463  # Set titles and labels.
464  fig.suptitle(r"CMS peak interactions per crossing, %s" % particle_type_str,
465  fontproperties=FONT_PROPS_SUPTITLE)
466  ax.set_title("Data included from %s to %s UTC \n" % \
467  (str_begin_ultimate, str_end),
468  fontproperties=FONT_PROPS_TITLE)
469  ax.set_xlabel(r"Date (UTC)", fontproperties=FONT_PROPS_AX_TITLE)
470  ax.set_ylabel(r"Peak interactions per crossing",\
471  fontproperties=FONT_PROPS_AX_TITLE)
472 
473  # Add the logo.
474  #zoom = 1.7
475  zoom = .95
476  AddLogo(logo_name, ax, zoom=zoom)
477  extra_head_room = 0
478  if is_log:
479  #if mode == 1:
480  extra_head_room = 1
481  #elif mode == 2:
482  # extra_head_room = 2
483  TweakPlot(fig, ax, (time_begin, time_end),
484 # TweakPlot(fig, ax, (time_begin_ultimate, time_end),
485  add_extra_head_room=True)
486 
487  log_suffix = ""
488  if is_log:
489  log_suffix = "_log"
490  SavePlot(fig, "peak_pu_%s_%s%s" % \
491  (particle_type_str.lower(),
492  log_suffix, file_suffix))
def TweakPlot(fig, ax, time_range, add_extra_head_room=False)
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def AddLogo(logo_name, ax, zoom=1.2)
def PlotPeakPUAllYears(lumi_data_by_fill_per_year)
def SavePlot(fig, file_name_base)
def create_public_peakpu_plots.processdata (   years)

Definition at line 69 of file create_public_peakpu_plots.py.

References mps_setup.append, spr.find(), objects.autophobj.float, createfilelist.int, genParticles_cff.map, edm.print(), split, and str.

69 def processdata(years):
70  results={}#{year:[[str,str],[pu,pu]]}
71  for y in years:
72  fills=[]#[fillnum]
73  maxputimelist=[]
74  maxpulist=[]
75  results[y]=[maxputimelist,maxpulist]
76  f=None
77  try:
78  lumifilename=str(y)+'lumibyls.csv'
79  f=open(lumifilename,'rb')
80  except IOError:
81  print('failed to open file ',lumifilename)
82  return result
83  freader=csv.reader(f,delimiter=',')
84  idx=0
85  for row in freader:
86  if idx==0:
87  idx=1
88  continue
89  if row[0].find('#')==1:
90  continue
91  [runnum,fillnum]=map(lambda i:int(i),row[0].split(':'))
92  avgpu=float(row[7])
93  if avgpu>50: continue
94  putime=row[2]
95  max_avgpu=avgpu
96  max_putime=putime
97  if fillnum not in fills:#new fill
98  fills.append(fillnum)
99  results[y][0].append(max_putime)
100  results[y][1].append(max_avgpu)
101  if avgpu>max_avgpu:
102  results[y][0][-1]=max_putime
103  results[y][1][-1]=max_avgpu
104  print(results)
105  return results
106 
107 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
#define str(s)
double split
Definition: MVATrainer.cc:139
def create_public_peakpu_plots.TweakPlot (   fig,
  ax,
  time_range,
  add_extra_head_room = False 
)

Definition at line 131 of file create_public_peakpu_plots.py.

References GetXLocator().

Referenced by GetXLocator(), and PlotPeakPUAllYears().

131  add_extra_head_room=False):
132 
133  # Fiddle with axes ranges etc.
134  (time_begin, time_end) = time_range
135  ax.relim()
136  ax.autoscale_view(False, True, True)
137  for label in ax.get_xticklabels():
138  label.set_ha("right")
139  label.set_rotation(30.)
140 
141  # Bit of magic here: increase vertical scale by one tick to make
142  # room for the legend.
143  if add_extra_head_room:
144  y_ticks = ax.get_yticks()
145  (y_min, y_max) = ax.get_ylim()
146  is_log = (ax.get_yscale() == "log")
147  y_max_new = y_max
148  if is_log:
149  tmp = y_ticks[-1] / y_ticks[-2]
150  y_max_new = y_max * math.pow(tmp, add_extra_head_room)
151  else:
152  tmp = y_ticks[-1] - y_ticks[-2]
153  y_max_new = y_max + add_extra_head_room * tmp
154  ax.set_ylim(y_min, y_max_new)
155 
156  # Add a second vertical axis on the right-hand side.
157  ax_sec = ax.twinx()
158  ax_sec.set_ylim(ax.get_ylim())
159  ax_sec.set_yscale(ax.get_yscale())
160 
161  for ax_tmp in fig.axes:
162  for sub_ax in [ax_tmp.xaxis, ax_tmp.yaxis]:
163  for label in sub_ax.get_ticklabels():
164  label.set_font_properties(FONT_PROPS_TICK_LABEL)
165 
166  ax.set_xlim(time_begin, time_end)
167 
168  locator = GetXLocator(ax)
169  minorXlocator=matplotlib.ticker.AutoMinorLocator()
170  #ax.yaxis.set_major_locator(matplotlib.ticker.MultipleLocator(5))
171  #ax.yaxis.set_minor_locator(matplotlib.ticker.MultipleLocator(5))
172  ax.xaxis.set_major_locator(locator)
173  ax.xaxis.set_minor_locator(minorXlocator)
174 
175  formatter = matplotlib.dates.DateFormatter(DATE_FMT_STR_AXES)
176  ax.xaxis.set_major_formatter(formatter)
177 
178  fig.subplots_adjust(top=.85, bottom=.14, left=.13, right=.91)
179  # End of TweakPlot().
180 

Variable Documentation

create_public_peakpu_plots.accel_mode

Definition at line 225 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.action

Definition at line 188 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.amodetag_bug_workaround

Definition at line 232 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.arg_parser

Definition at line 187 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.args

Definition at line 192 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_energy

Definition at line 241 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_energy_defaults

Definition at line 303 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_energy_from_cfg

Definition at line 242 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_energy_tmp

Definition at line 238 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_fluctuation

Definition at line 254 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_fluctuation_defaults

Definition at line 312 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_fluctuation_from_cfg

Definition at line 255 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_fluctuation_tmp

Definition at line 251 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.cache_file_dir

Definition at line 218 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.cfg_defaults

Definition at line 199 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.cfg_parser

Definition at line 208 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.color_scheme_names

Definition at line 216 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.color_scheme_names_tmp

Definition at line 215 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.config_file_name

Definition at line 196 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.date_begin

Definition at line 266 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.date_end

Definition at line 268 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.DATE_FMT_STR_AXES

Definition at line 61 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.DATE_FMT_STR_CFG

Definition at line 62 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.DATE_FMT_STR_LUMICALC

Definition at line 58 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.DATE_FMT_STR_LUMICALC_DAY

Definition at line 59 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.DATE_FMT_STR_OUT

Definition at line 60 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.desc_str

Definition at line 185 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.description

Definition at line 187 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.file

Definition at line 33 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.help

Definition at line 189 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.hist

Definition at line 35 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.ignore_cache

Definition at line 197 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.KNOWN_ACCEL_MODES

Definition at line 65 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.LEAD_SCALE_FACTOR

Definition at line 67 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.lumi_data_by_fill_per_year

Definition at line 378 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.lumicalc_flags_from_cfg

Definition at line 224 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.lumicalc_script

Definition at line 223 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.NUM_SEC_IN_LS

Definition at line 63 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.options

Definition at line 192 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.oracle_connection_string

Definition at line 289 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.particle_type_str

Definition at line 301 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.particle_type_strings

Definition at line 296 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.path_name

Definition at line 363 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.tmp

Definition at line 265 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.today

Definition at line 272 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.use_oracle

Definition at line 290 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.verbose

Definition at line 220 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.year_begin

Definition at line 390 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.year_end

Definition at line 391 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.years

Definition at line 376 of file create_public_peakpu_plots.py.