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

Public Member Functions

 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 default_name = "{module.id}_{y_part_name}_by_{x_part_name}_scatter{groupby_key}{stackby_key}"
 default name for this scatterplot
 
str default_title = "Scatter of {y_part_name} by {x_part_name} from {module.title}"
 default title for this scatterplot
 
str default_contact = "{module.contact}"
 default contact person for this scatterplot
 
str default_description = "This is a scatter of {y_part_name} over {x_part_name}."
 default description for this scatterplot
 
str default_check = "Check if the distributions is reasonable."
 default user-check action for this scatterplot
 
str plot_kind = "profile"
 by default, this refiner is for profile histograms
 

Detailed Description

Refiner for 2D scatterplots

Definition at line 532 of file refiners.py.

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)
staticinherited
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 )
inherited
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
inherited

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

Definition at line 376 of file refiners.py.

◆ bins

bins = bins
inherited

cached number of bins for this profile histogram / scatterplot

Definition at line 367 of file refiners.py.

◆ check

check = check
inherited

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

Definition at line 349 of file refiners.py.

◆ contact

contact = contact
inherited

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

Definition at line 351 of file refiners.py.

◆ default_check

str default_check = "Check if the distributions is reasonable."
static

default user-check action for this scatterplot

Definition at line 543 of file refiners.py.

◆ default_contact

str default_contact = "{module.contact}"
static

default contact person for this scatterplot

Definition at line 539 of file refiners.py.

◆ default_description

str default_description = "This is a scatter of {y_part_name} over {x_part_name}."
static

default description for this scatterplot

Definition at line 541 of file refiners.py.

◆ default_name

str default_name = "{module.id}_{y_part_name}_by_{x_part_name}_scatter{groupby_key}{stackby_key}"
static

default name for this scatterplot

Definition at line 535 of file refiners.py.

◆ default_title

str default_title = "Scatter of {y_part_name} by {x_part_name} from {module.title}"
static

default title for this scatterplot

Definition at line 537 of file refiners.py.

◆ description

description = description
inherited

cached user-defined description for this profile histogram / scatterplot

Definition at line 347 of file refiners.py.

◆ fit

fit = fit
inherited

cached fit for this profile histogram / scatterplot

Definition at line 379 of file refiners.py.

◆ fit_z_score

fit_z_score = fit_z_score
inherited

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
inherited

cached lower bound for this profile histogram / scatterplot

Definition at line 363 of file refiners.py.

◆ name

name = name
inherited

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
inherited

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"
staticinherited

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
inherited

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

Definition at line 384 of file refiners.py.

◆ stackby

stackby = stackby
inherited

cached stacking selection for this profile histogram / scatterplot

Definition at line 358 of file refiners.py.

◆ title

title = title
inherited

cached user-defined title for this profile histogram / scatterplot

Definition at line 344 of file refiners.py.

◆ upper_bound

upper_bound = upper_bound
inherited

cached upper bound for this profile histogram / scatterplot

Definition at line 365 of file refiners.py.

◆ x

x = x
inherited

cached value of abscissa

Definition at line 354 of file refiners.py.

◆ y

y = y
inherited

cached value of ordinate

Definition at line 356 of file refiners.py.

◆ y_binary

y_binary = y_binary
inherited

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
inherited

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
inherited

cached measurement unit for ordinate

Definition at line 360 of file refiners.py.


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