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

Public Member Functions

def __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)
 
def refine (self, harvesting_module, crops, tdirectory=None, groupby_part_name=None, groupby_value=None, **kwds)
 

Static Public Member Functions

def has_more_than_one_value (xs)
 

Public Attributes

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

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__()

def __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

Reimplemented from Refiner.

Definition at line 317 of file refiners.py.

336 allow_discrete=False):
337 """Constructor for this refiner"""
338
339 super().__init__()
340
341
342 self.name = name
343
344 self.title = title
345
346
347 self.description = description
348
349 self.check = check
350
351 self.contact = contact
352
353
354 self.x = x
355
356 self.y = y
357
358 self.stackby = stackby
359
360 self.y_unit = y_unit
361
362
363 self.lower_bound = lower_bound
364
365 self.upper_bound = upper_bound
366
367 self.bins = bins
368
369 self.y_binary = y_binary
370
371 self.y_log = y_log
372
373
374 self.outlier_z_score = outlier_z_score
375
376 self.allow_discrete = allow_discrete
377
378
379 self.fit = fit
380
381 self.fit_z_score = fit_z_score
382
383
384 self.skip_single_valued = skip_single_valued
385

Member Function Documentation

◆ has_more_than_one_value()

def 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()

def 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

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

Definition at line 376 of file refiners.py.

◆ bins

bins

cached number of bins for this profile histogram / scatterplot

Definition at line 367 of file refiners.py.

◆ check

check

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

Definition at line 349 of file refiners.py.

◆ contact

contact

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

Definition at line 351 of file refiners.py.

◆ description

description

cached user-defined description for this profile histogram / scatterplot

Definition at line 347 of file refiners.py.

◆ fit

fit

cached fit for this profile histogram / scatterplot

Definition at line 379 of file refiners.py.

◆ 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

cached lower bound for this profile histogram / scatterplot

Definition at line 363 of file refiners.py.

◆ 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

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.

◆ 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

cached stacking selection for this profile histogram / scatterplot

Definition at line 358 of file refiners.py.

◆ title

title

cached user-defined title for this profile histogram / scatterplot

Definition at line 344 of file refiners.py.

◆ upper_bound

upper_bound

cached upper bound for this profile histogram / scatterplot

Definition at line 365 of file refiners.py.

◆ x

x

cached value of abscissa

Definition at line 354 of file refiners.py.

◆ y

y

cached value of ordinate

Definition at line 356 of file refiners.py.

◆ 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

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

Definition at line 371 of file refiners.py.

◆ 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: