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
 
 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 109 of file create_public_peakpu_plots.py.

109 def CacheFilePath(cache_file_dir, day=None):
110  cache_file_path = os.path.abspath(cache_file_dir)
111  if day:
112  cache_file_name = "lumicalc_cache_%s.csv" % day.isoformat()
113  cache_file_path = os.path.join(cache_file_path, cache_file_name)
114  return cache_file_path
115 
116 
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 117 of file create_public_peakpu_plots.py.

References min(), and TweakPlot().

Referenced by TweakPlot().

117 def GetXLocator(ax):
118  """Pick a DateLocator based on the range of the x-axis."""
119  (x_lo, x_hi) = ax.get_xlim()
120  num_days = x_hi - x_lo
121  min_num_ticks = min(num_days, 5)
122  locator = matplotlib.dates.AutoDateLocator(minticks=min_num_ticks,
123  maxticks=None)
124  # End of GetLocator().
125  return locator
126 
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 409 of file create_public_peakpu_plots.py.

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

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

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

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

Definition at line 130 of file create_public_peakpu_plots.py.

References GetXLocator().

Referenced by GetXLocator(), and PlotPeakPUAllYears().

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

Variable Documentation

create_public_peakpu_plots.accel_mode

Definition at line 226 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.action

Definition at line 187 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.amodetag_bug_workaround

Definition at line 234 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.arg_parser

Definition at line 186 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.args

Definition at line 191 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_energy

Definition at line 243 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_energy_defaults

Definition at line 306 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_energy_from_cfg

Definition at line 244 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_energy_tmp

Definition at line 240 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_fluctuation

Definition at line 256 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_fluctuation_defaults

Definition at line 315 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_fluctuation_from_cfg

Definition at line 257 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_fluctuation_tmp

Definition at line 253 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.cache_file_dir

Definition at line 219 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 217 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.color_scheme_names_tmp

Definition at line 216 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 268 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.date_end

Definition at line 270 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.DATE_FMT_STR_AXES

Definition at line 60 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.DATE_FMT_STR_CFG

Definition at line 61 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.DATE_FMT_STR_LUMICALC

Definition at line 57 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.DATE_FMT_STR_LUMICALC_DAY

Definition at line 58 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.DATE_FMT_STR_OUT

Definition at line 59 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.desc_str

Definition at line 184 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.description

Definition at line 186 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.help

Definition at line 188 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.hist

Definition at line 34 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 64 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.LEAD_SCALE_FACTOR

Definition at line 66 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.lumi_data_by_fill_per_year

Definition at line 382 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.lumicalc_flags_from_cfg

Definition at line 225 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.lumicalc_script

Definition at line 224 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.NUM_SEC_IN_LS

Definition at line 62 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.options

Definition at line 191 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.oracle_connection_string

Definition at line 292 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.particle_type_str

Definition at line 304 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.particle_type_strings

Definition at line 299 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.path_name

Definition at line 366 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.tmp

Definition at line 267 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.today

Definition at line 274 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.use_oracle

Definition at line 293 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.verbose

Definition at line 221 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.year_begin

Definition at line 394 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.year_end

Definition at line 395 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.years

Definition at line 380 of file create_public_peakpu_plots.py.