nectarchain.makers.component.spe.spe_algorithm.SPEnominalalgorithm#

class SPEnominalalgorithm(pixels_id, charge, counts, config=None, parent=None, **kwargs)[source]#

Bases: SPEalgorithm

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_traits

Dynamically add trait attributes to the HasTraits instance.

class_config_rst_doc

Generate rST documentation for this class' config options.

class_config_section

Get the config section for this class.

class_get_help

Get the help string for this class in ReST format.

class_get_trait_help

Get the helptext string for a single trait.

class_own_trait_events

Get a dict of all event handlers defined on this class, not a parent.

class_own_traits

Get a dict of all the traitlets defined on this class, not a parent.

class_print_help

Get the help string for a single trait and print it.

class_trait_names

Get a list of all the names of this class' traits.

class_traits

Get a dict of all the traits of this class.

create_from_chargesContainer

Creates an instance of FlatFieldSingleHHVSPEMaker using charge and counts data from a ChargesContainer object.

display

Display and save the plot for each specified pixel ID.

from_name

Obtain an instance of a subclass via its name

get_current_config

return the current configuration as a dict (e.g. the values of all traits, even if they were not set during configuration).

has_trait

Returns True if the object has a trait with the specified name.

hold_trait_notifications

Context manager for bundling trait change notifications and cross validation.

non_abstract_subclasses

Get a dict of all non-abstract subclasses of this class.

notify_change

Notify observers of a change event

observe

Setup a handler to be called when a trait changes.

on_trait_change

DEPRECATED: Setup a handler to be called when a trait changes.

plot_single_matplotlib

Generate a plot of the data and a model fit for a specific pixel.

plot_single_pyqtgraph

read_param_from_yaml

Reads parameters from a YAML file and updates the internal parameters of the FlatFieldSPEMaker class.

run

run_fit

Perform a fit on a specific pixel using the Minuit package.

section_names

return section names as a list

set_trait

Forcibly sets trait attribute, including read-only attributes.

setup_instance

trait_defaults

Return a trait's default value or a dictionary of them

trait_events

Get a dict of all the event handlers of this class.

trait_has_value

Returns True if the specified trait has a value.

trait_metadata

Get metadata values for trait by key.

trait_names

Get a list of all the names of this class' traits.

trait_values

A dict of trait names and their values.

traits

Get a dict of all the traits of this class.

unobserve

Remove a trait change handler.

unobserve_all

Remove trait change handlers of any type for the specified name.

update_config

Update config and load the new values

Attributes

charge

Returns a deep copy of the __charge attribute.

chunksize

The chunk size for multi-processing

config

A trait whose value must be an instance of a specified class.

counts

Returns a deep copy of the __counts attribute.

cross_validation_lock

A contextmanager for running a block with our cross validation lock set to True.

multiproc

flag to active multi-processing

npixels

nproc

The Number of cpu used for SPE fit

order

The order of the polynome used in the savgol filter algorithm

parameters

parameters_file

The name of the SPE fit parameters file

parent

A trait whose value must be an instance of a specified class.

pixels_id

results

tol

The tolerance used for minuit

window_length

The windows leght used for the savgol filter algorithm

property charge#

Returns a deep copy of the __charge attribute.

chunksize#

The chunk size for multi-processing

property counts#

Returns a deep copy of the __counts attribute.

classmethod create_from_chargesContainer(signal, 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, package='pyqtgraph', **kwargs)[source]#

Display and save the plot for each specified pixel ID.

Return type:

None

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, counts, pp, resolution, gain, gain_error, n, pedestal, pedestalWidth, luminosity, likelihood, **kwargs)[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 pp parameter.

resolution: float

The value of the resolution parameter.

gain: float

The value of the gain parameter.

gain_error: float

The value of the gain_error parameter.

n: float

The value of the n parameter.

pedestal: float

The value of the pedestal parameter.

pedestalWidth: float

The value of the pedestalWidth parameter.

luminosity: float

The value of the luminosity parameter.

likelihood: float

The value of the likelihood parameter.

Returns:
: tuple

A tuple containing the generated plot figure and the axes of the plot.

rtype:

tuple ..

static run_fit(i, tol)[source]#

Perform a fit on a specific pixel using the Minuit package.

Return type:

dict

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_i and errors_i, where i is the index of the pixel.

tol#

The tolerance used for minuit