Belle II Software development
Plot2DRefiner Class Reference
Inheritance diagram for Plot2DRefiner:
Refiner SaveProfilesRefiner SaveScatterRefiner

Public Member Functions

 __init__ (self, y, x=None, name=None, title=None, contact=None, description=None, check=None, stackby=None, y_unit=None, y_binary=None, y_log=None, lower_bound=None, upper_bound=None, bins=None, outlier_z_score=None, fit=None, fit_z_score=None, skip_single_valued=False, allow_discrete=False)
 
 refine (self, harvesting_module, crops, tdirectory=None, groupby_part_name=None, groupby_value=None, **kwds)
 
 __get__ (self, harvesting_module, cls=None)
 
 __call__ (self, harvesting_module, crops=None, *args, **kwds)
 

Static Public Member Functions

 has_more_than_one_value (xs)
 

Public Attributes

 name = name
 cached user-defined name for this profile histogram / scatterplot
 
 title = title
 cached user-defined title for this profile histogram / scatterplot
 
 description = description
 cached user-defined description for this profile histogram / scatterplot
 
 check = check
 cached user-defined user-check action for this profile histogram / scatterplot
 
 contact = contact
 cached user-defined contact person for this profile histogram / scatterplot
 
 x = x
 cached value of abscissa
 
 y = y
 cached value of ordinate
 
 stackby = stackby
 cached stacking selection for this profile histogram / scatterplot
 
 y_unit = y_unit
 cached measurement unit for ordinate
 
 lower_bound = lower_bound
 cached lower bound for this profile histogram / scatterplot
 
 upper_bound = upper_bound
 cached upper bound for this profile histogram / scatterplot
 
 bins = bins
 cached number of bins for this profile histogram / scatterplot
 
 y_binary = y_binary
 cached flag for probability y axis (range 0.0 .
 
 y_log = y_log
 cached flag for logarithmic y axis for this profile histogram / scatterplot
 
 outlier_z_score = outlier_z_score
 cached Z-score (for outlier detection) for this profile histogram / scatterplot
 
 allow_discrete = allow_discrete
 cached flag to allow discrete values for this profile histogram / scatterplot
 
 fit = fit
 cached fit for this profile histogram / scatterplot
 
 fit_z_score = fit_z_score
 cached fit Z-score (for outlier detection) for this profile histogram / scatterplot
 
 skip_single_valued = skip_single_valued
 cached flag to skip single-valued bins for this profile histogram / scatterplot
 
 refiner_function = refiner_function
 cached copy of the instance's refiner function
 

Static Public Attributes

str plot_kind = "profile"
 by default, this refiner is for profile histograms
 

Detailed Description

Refiner for profile histograms and 2D scatterplots

Definition at line 312 of file refiners.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ ( self,
y,
x = None,
name = None,
title = None,
contact = None,
description = None,
check = None,
stackby = None,
y_unit = None,
y_binary = None,
y_log = None,
lower_bound = None,
upper_bound = None,
bins = None,
outlier_z_score = None,
fit = None,
fit_z_score = None,
skip_single_valued = False,
allow_discrete = False )
Constructor for this refiner

Definition at line 317 of file refiners.py.

336 allow_discrete=False):
337 """Constructor for this refiner"""
338
339 super().__init__()
340
341 ## cached user-defined name for this profile histogram / scatterplot
342 self.name = name
343 ## cached user-defined title for this profile histogram / scatterplot
344 self.title = title
345
346 ## cached user-defined description for this profile histogram / scatterplot
347 self.description = description
348 ## cached user-defined user-check action for this profile histogram / scatterplot
349 self.check = check
350 ## cached user-defined contact person for this profile histogram / scatterplot
351 self.contact = contact
352
353 ## cached value of abscissa
354 self.x = x
355 ## cached value of ordinate
356 self.y = y
357 ## cached stacking selection for this profile histogram / scatterplot
358 self.stackby = stackby
359 ## cached measurement unit for ordinate
360 self.y_unit = y_unit
361
362 ## cached lower bound for this profile histogram / scatterplot
363 self.lower_bound = lower_bound
364 ## cached upper bound for this profile histogram / scatterplot
365 self.upper_bound = upper_bound
366 ## cached number of bins for this profile histogram / scatterplot
367 self.bins = bins
368 ## cached flag for probability y axis (range 0.0 .. 1.05) for this profile histogram / scatterplot
369 self.y_binary = y_binary
370 ## cached flag for logarithmic y axis for this profile histogram / scatterplot
371 self.y_log = y_log
372
373 ## cached Z-score (for outlier detection) for this profile histogram / scatterplot
374 self.outlier_z_score = outlier_z_score
375 ## cached flag to allow discrete values for this profile histogram / scatterplot
376 self.allow_discrete = allow_discrete
377
378 ## cached fit for this profile histogram / scatterplot
379 self.fit = fit
380 ## cached fit Z-score (for outlier detection) for this profile histogram / scatterplot
381 self.fit_z_score = fit_z_score
382
383 ## cached flag to skip single-valued bins for this profile histogram / scatterplot
384 self.skip_single_valued = skip_single_valued
385

Member Function Documentation

◆ __call__()

__call__ ( self,
harvesting_module,
crops = None,
* args,
** kwds )
inherited
implementation of the function-call of the Refiner instance r = Refiner() r(harvester) # decoration r(harvester, crops, args, keywords) # refinement

Definition at line 55 of file refiners.py.

55 def __call__(self, harvesting_module, crops=None, *args, **kwds):
56 """implementation of the function-call of the Refiner instance
57 r = Refiner()
58 r(harvester) # decoration
59 r(harvester, crops, args, keywords) # refinement
60 """
61 if crops is None:
62 # Decoration mode
63 harvesting_module.refiners.append(self)
64 return harvesting_module
65 else:
66 # Refining mode
67 return self.refine(harvesting_module, crops, *args, **kwds)
68

◆ __get__()

__get__ ( self,
harvesting_module,
cls = None )
inherited
Getter of the Refiner instance

Definition at line 42 of file refiners.py.

42 def __get__(self, harvesting_module, cls=None):
43 """Getter of the Refiner instance"""
44 if harvesting_module is None:
45 # Class access
46 return self
47 else:
48 # Instance access
49 refine = self.refine
50
51 def bound_call(*args, **kwds):
52 return refine(harvesting_module, *args, **kwds)
53 return bound_call
54

◆ has_more_than_one_value()

has_more_than_one_value ( xs)
static
check if a list has at least two unique values

Definition at line 505 of file refiners.py.

505 def has_more_than_one_value(xs):
506 """check if a list has at least two unique values"""
507 first_x = xs[0]
508 for x in xs:
509 if x != first_x:
510 return True
511 else:
512 return False
513
514

◆ refine()

refine ( self,
harvesting_module,
crops,
tdirectory = None,
groupby_part_name = None,
groupby_value = None,
** kwds )
Process the profile histogram / scatterplot

Reimplemented from Refiner.

Definition at line 386 of file refiners.py.

392 **kwds):
393 """Process the profile histogram / scatterplot"""
394
395 stackby = self.stackby
396 if stackby:
397 stackby_parts = crops[stackby]
398 else:
399 stackby_parts = None
400
401 replacement_dict = dict(
402 refiner=self,
403 module=harvesting_module,
404 stackby_key=' stacked by ' + stackby if stackby else "",
405 groupby_key=' in group ' + groupby_part_name + groupby_value if groupby_part_name else "",
406 )
407
408 contact = self.contact or self.default_contact
409 contact = formatter.format(contact, **replacement_dict)
410
411 y_crops = select_crop_parts(crops, select=self.y)
412 x_crops = select_crop_parts(crops, select=self.x, exclude=self.y)
413
414 for y_part_name, y_parts in iter_items_sorted_for_key(y_crops):
415 for x_part_name, x_parts in iter_items_sorted_for_key(x_crops):
416
417 if self.skip_single_valued and not self.has_more_than_one_value(x_parts):
418 get_logger().info('Skipping "%s" by "%s" profile because x has only a single value "%s"',
419 y_part_name,
420 x_part_name,
421 x_parts[0])
422 continue
423
424 if self.skip_single_valued and not self.has_more_than_one_value(y_parts):
425 get_logger().info('Skipping "%s" by "%s" profile because y has only a single value "%s"',
426 y_part_name,
427 x_part_name,
428 y_parts[0])
429 continue
430
431 name = self.name or self.default_name
432 title = self.title or self.default_title
433 description = self.description or self.default_description
434 check = self.check or self.default_check
435
436 name = formatter.format(name,
437 x_part_name=x_part_name,
438 y_part_name=y_part_name,
439 **replacement_dict)
440
441 title = formatter.format(title,
442 x_part_name=x_part_name,
443 y_part_name=y_part_name,
444 **replacement_dict)
445
446 description = formatter.format(description,
447 x_part_name=x_part_name,
448 y_part_name=y_part_name,
449 **replacement_dict)
450
451 check = formatter.format(check,
452 x_part_name=x_part_name,
453 y_part_name=y_part_name,
454 **replacement_dict)
455
456 profile_plot = ValidationPlot(name)
457
458 plot_kind = self.plot_kind
459 if plot_kind == "profile":
460 profile_plot.profile(x_parts,
461 y_parts,
462 lower_bound=self.lower_bound,
463 upper_bound=self.upper_bound,
464 bins=self.bins,
465 y_binary=self.y_binary,
466 y_log=self.y_log,
467 outlier_z_score=self.outlier_z_score,
468 allow_discrete=self.allow_discrete,
469 stackby=stackby_parts)
470
471 if self.fit:
472 if self.fit_z_score is None:
473 kwds = dict()
474 else:
475 kwds = dict(z_score=self.fit_z_score)
476
477 fit_method_name = 'fit_' + str(self.fit)
478 try:
479 fit_method = getattr(profile_plot, fit_method_name)
480 except BaseException:
481 profile_plot.fit(str(self.fit), **kwds)
482 else:
483 fit_method(**kwds)
484
485 elif plot_kind == "scatter":
486 profile_plot.scatter(x_parts,
487 y_parts,
488 lower_bound=self.lower_bound,
489 upper_bound=self.upper_bound,
490 outlier_z_score=self.outlier_z_score,
491 stackby=stackby_parts)
492
493 profile_plot.title = title
494 profile_plot.contact = contact
495 profile_plot.description = description
496 profile_plot.check = check
497
498 profile_plot.xlabel = compose_axis_label(x_part_name)
499 profile_plot.ylabel = compose_axis_label(y_part_name, self.y_unit)
500
501 if tdirectory:
502 profile_plot.write(tdirectory)
503

Member Data Documentation

◆ allow_discrete

allow_discrete = allow_discrete

cached flag to allow discrete values for this profile histogram / scatterplot

Definition at line 376 of file refiners.py.

◆ bins

bins = bins

cached number of bins for this profile histogram / scatterplot

Definition at line 367 of file refiners.py.

◆ check

check = check

cached user-defined user-check action for this profile histogram / scatterplot

Definition at line 349 of file refiners.py.

◆ contact

contact = contact

cached user-defined contact person for this profile histogram / scatterplot

Definition at line 351 of file refiners.py.

◆ description

description = description

cached user-defined description for this profile histogram / scatterplot

Definition at line 347 of file refiners.py.

◆ fit

fit = fit

cached fit for this profile histogram / scatterplot

Definition at line 379 of file refiners.py.

◆ fit_z_score

fit_z_score = fit_z_score

cached fit Z-score (for outlier detection) for this profile histogram / scatterplot

Definition at line 381 of file refiners.py.

◆ lower_bound

lower_bound = lower_bound

cached lower bound for this profile histogram / scatterplot

Definition at line 363 of file refiners.py.

◆ name

name = name

cached user-defined name for this profile histogram / scatterplot

Definition at line 342 of file refiners.py.

◆ outlier_z_score

outlier_z_score = outlier_z_score

cached Z-score (for outlier detection) for this profile histogram / scatterplot

Definition at line 374 of file refiners.py.

◆ plot_kind

str plot_kind = "profile"
static

by default, this refiner is for profile histograms

Definition at line 315 of file refiners.py.

◆ refiner_function

refiner_function = refiner_function
inherited

cached copy of the instance's refiner function

Definition at line 40 of file refiners.py.

◆ skip_single_valued

skip_single_valued = skip_single_valued

cached flag to skip single-valued bins for this profile histogram / scatterplot

Definition at line 384 of file refiners.py.

◆ stackby

stackby = stackby

cached stacking selection for this profile histogram / scatterplot

Definition at line 358 of file refiners.py.

◆ title

title = title

cached user-defined title for this profile histogram / scatterplot

Definition at line 344 of file refiners.py.

◆ upper_bound

upper_bound = upper_bound

cached upper bound for this profile histogram / scatterplot

Definition at line 365 of file refiners.py.

◆ x

x = x

cached value of abscissa

Definition at line 354 of file refiners.py.

◆ y

y = y

cached value of ordinate

Definition at line 356 of file refiners.py.

◆ y_binary

y_binary = y_binary

cached flag for probability y axis (range 0.0 .

. 1.05) for this profile histogram / scatterplot

Definition at line 369 of file refiners.py.

◆ y_log

y_log = y_log

cached flag for logarithmic y axis for this profile histogram / scatterplot

Definition at line 371 of file refiners.py.

◆ y_unit

y_unit = y_unit

cached measurement unit for ordinate

Definition at line 360 of file refiners.py.


The documentation for this class was generated from the following file: