nectarchain.makers.component.spe.spe_algorithm.SPEnominalalgorithm#
- class SPEnominalalgorithm(*args: t.Any, **kwargs: t.Any)[source]#
Bases:
SPEalgorithmSPE fitting algorithm at nominal voltage.
Runs a multi-pixel SPE fit using
iminuitwithppandnas free parameters. Supports both single-process and multi-process execution.Initializes the FlatFieldSingleHHVSPEMaker object.
- Parameters:
- chargenp.ma.masked_array or array-like
The charge data.
- countsnp.ma.masked_array or array-like
The counts data.
- ``*args``
Additional positional arguments.
- ``**kwargs``
Additional keyword arguments.
Methods
add_traitsDynamically add trait attributes to the HasTraits instance.
class_config_rst_docGenerate rST documentation for this class' config options.
class_config_sectionGet the config section for this class.
class_get_helpGet the help string for this class in ReST format.
class_get_trait_helpGet the helptext string for a single trait.
class_own_trait_eventsGet a dict of all event handlers defined on this class, not a parent.
class_own_traitsGet a dict of all the traitlets defined on this class, not a parent.
class_print_helpGet the help string for a single trait and print it.
class_trait_namesGet a list of all the names of this class' traits.
class_traitsGet a
dictof all the traits of this class.Creates an instance of FlatFieldSingleHHVSPEMaker using charge and counts data from a ChargesContainer object.
Display and save the plot for each specified pixel ID.
from_nameObtain an instance of a subclass via its name
get_current_configreturn the current configuration as a dict (e.g. the values of all traits, even if they were not set during configuration).
has_traitReturns True if the object has a trait with the specified name.
hold_trait_notificationsContext manager for bundling trait change notifications and cross validation.
non_abstract_subclassesGet a dict of all non-abstract subclasses of this class.
notify_changeNotify observers of a change event
observeSetup a handler to be called when a trait changes.
on_trait_changeDEPRECATED: Setup a handler to be called when a trait changes.
Generate a plot of the data and a model fit for a specific pixel.
Plot the SPE fit result for a single pixel using pyqtgraph.
read_param_from_yamlReads parameters from a YAML file and updates the internal parameters of the FlatFieldSPEMaker class.
Run the SPE fit for the specified (or all) pixels.
Perform a fit on a specific pixel using the Minuit package.
section_namesreturn section names as a list
set_traitForcibly sets trait attribute, including read-only attributes.
setup_instancetrait_defaultsReturn a trait's default value or a dictionary of them
trait_eventsGet a
dictof all the event handlers of this class.trait_has_valueReturns True if the specified trait has a value.
trait_metadataGet metadata values for trait by key.
trait_namesGet a list of all the names of this class' traits.
trait_valuesA
dictof trait names and their values.traitsGet a
dictof all the traits of this class.unobserveRemove a trait change handler.
unobserve_allRemove trait change handlers of any type for the specified name.
update_configUpdate config and load the new values
Attributes
Returns a deep copy of the
__chargeattribute.The chunk size for multi-processing
configA trait whose value must be an instance of a specified class.
Returns a deep copy of the
__countsattribute.cross_validation_lockA contextmanager for running a block with our cross validation lock set to True.
display_toggleEnable/disable display of SPE fit results
flag to active multi-processing
npixelsReturns the total number of pixels.
The Number of cpu used for SPE fit
orderThe order of the polynome used in the savgol filter algorithm
parametersReturns a deep copy of the internal
Parametersobject.The name of the SPE fit parameters file
parentA trait whose value must be an instance of a specified class.
pixels_idReturns a deep copy of the pixel ID array.
resultsReturns a deep copy of the
SPEfitContainerresult table.The tolerance used for minuit
window_lengthThe windows leght used for the savgol filter algorithm
- property charge#
Returns a deep copy of the
__chargeattribute.
- chunksize#
The chunk size for multi-processing
- property counts#
Returns a deep copy of the
__countsattribute.
- classmethod create_from_chargesContainer(signal: ChargesContainer, config=None, parent=None, **kwargs)[source]#
Creates an instance of FlatFieldSingleHHVSPEMaker using charge and counts data from a ChargesContainer object.
- Parameters:
- signalChargesContainer
The ChargesContainer object.
- ``**kwargs``
Additional keyword arguments.
- Returns:
- FlatFieldSingleHHVSPEMaker
An instance of FlatFieldSingleHHVSPEMaker.
- display(pixels_id: ndarray, package='pyqtgraph', **kwargs) None[source]#
Display and save the plot for each specified pixel ID.
- Parameters:
- pixels_id: np.ndarray
An array of pixel IDs.
- package: str
the package used to plot, can be matplotlib or pyqtgraph. Default to pyqtgraph
- kwargs
Additional keyword arguments. figpath : str The path to save the generated plot figures. Defaults to
/tmp/NectarGain_pid{os.getpid()}.
- multiproc#
flag to active multi-processing
- nproc#
The Number of cpu used for SPE fit
- parameters_file#
The name of the SPE fit parameters file
- plot_single_matplotlib(charge: ndarray, counts: ndarray, pp: float, resolution: float, gain: float, gain_error: float, n: float, pedestal: float, pedestalWidth: float, luminosity: float, likelihood: float, **kwargs) tuple[source]#
Generate a plot of the data and a model fit for a specific pixel. The different parameters are explained in Caroff et al. (2019).
- Parameters:
- pixel_id: int
The ID of the pixel for which the plot is generated.
- charge: np.ndarray
An array of charge values.
- counts: np.ndarray
An array of event counts corresponding to the charge values.
- pp: float
The value of the
ppparameter.- resolution: float
The value of the
resolutionparameter.- gain: float
The value of the
gainparameter.- gain_error: float
The value of the
gain_errorparameter.- n: float
The value of the
nparameter.- pedestal: float
The value of the
pedestalparameter.- pedestalWidth: float
The value of the
pedestalWidthparameter.- luminosity: float
The value of the
luminosityparameter.- likelihood: float
The value of the
likelihoodparameter.
- Returns:
- : tuple
A tuple containing the generated plot figure and the axes of the plot.
- plot_single_pyqtgraph(charge: ndarray, counts: ndarray, pp: float, resolution: float, gain: float, gain_error: float, n: float, pedestal: float, pedestalWidth: float, luminosity: float, likelihood: float) tuple[source]#
Plot the SPE fit result for a single pixel using pyqtgraph.
- Parameters:
- pixel_idint
The pixel ID.
- chargenp.ndarray
Charge bin centres.
- countsnp.ndarray
Event counts per charge bin.
- ppfloat
The pp parameter.
- resolutionfloat
The resolution parameter.
- gainfloat
The SPE gain.
- gain_errorfloat
The error on the SPE gain.
- nfloat
The n parameter.
- pedestalfloat
The pedestal value.
- pedestalWidthfloat
The pedestal width.
- luminosityfloat
The luminosity parameter.
- likelihoodfloat
The fit likelihood value.
- Returns:
- pyqtgraph.GraphicsLayoutWidget
The generated pyqtgraph window containing the plot.
- run(pixels_id: ndarray = None, **kwargs) ndarray[source]#
Run the SPE fit for the specified (or all) pixels.
- Parameters:
- pixels_idnp.ndarray, optional
Array of pixel IDs to fit. If None, all pixels are fitted.
- ``**kwargs``
Additional keyword arguments passed to the fit machinery. Accepted keys include
tol(Minuit tolerance),nproc(number of processes), andchunksize.
- Returns:
- np.ndarray
Array of fit status objects for each fitted pixel.
- static run_fit(i: int, tol: float) dict[source]#
Perform a fit on a specific pixel using the Minuit package.
- Parameters:
- iint
The index of the pixel to perform the fit on.
- Returns:
- : dict
A dictionary containing the fit values and errors for the specified pixel. The keys are
values_ianderrors_i, whereiis the index of the pixel.
- tol#
The tolerance used for minuit