pygama package#
pygama init file. it might be better to declare more of the public functions here if it makes sphinx auto-generated documentation easier.
There’s a nice discussion about what to include in this file here: https://www.reddit.com/r/Python/comments/1bbbwk/whats_your_opinion_on_what_to_include_in_init_py/
Clint’s fav answer:
I like importing key functions and classes. Flat is better than nested, so as a user of a library, I prefer from library import ThingIWant or import library and then using library.ThingIWant rather than from library.things.thing_i_want import ThingIWant.
- More specifically, I would often have the contents of __init__.py be:
“Docstring explaining package” (use triple quotes though) from thispackage.module_or_subpackage import * from thispackage.module_thats_next_alphabetically import * …
And then have each module use __all__ to specify which names constitute its public API that should be exposed by the package.
For something you are distributing publicly, I don’t think your __init__.py should ever by “blank” as specified by option 1: you should at least include a docstring explaining what the package does. This will help users poking around in ipython, etc.
Subpackages#
- pygama.analysis package
- pygama.dsp package
- Subpackages
- pygama.dsp._processors package
- Submodules
- pygama.dsp._processors.Wiener_filter module
- pygama.dsp._processors.bl_subtract module
- pygama.dsp._processors.convolutions module
- pygama.dsp._processors.fftw module
- pygama.dsp._processors.fixed_time_pickoff module
- pygama.dsp._processors.gaussian_filter1d module
- pygama.dsp._processors.get_multi_local_extrema module
- pygama.dsp._processors.linear_slope_fit module
- pygama.dsp._processors.log_check module
- pygama.dsp._processors.min_max module
- pygama.dsp._processors.moving_windows module
- pygama.dsp._processors.multi_a_filter module
- pygama.dsp._processors.multi_t_filter module
- pygama.dsp._processors.optimize module
- pygama.dsp._processors.param_lookup module
- pygama.dsp._processors.pole_zero module
- pygama.dsp._processors.presum module
- pygama.dsp._processors.pulse_injector module
- pygama.dsp._processors.saturation module
- pygama.dsp._processors.soft_pileup_corr module
- pygama.dsp._processors.template module
- pygama.dsp._processors.time_point_thresh module
- pygama.dsp._processors.trap_filters module
- pygama.dsp._processors.upsampler module
- pygama.dsp._processors.windower module
- pygama.dsp._processors package
- Submodules
- pygama.dsp.ProcessingChain module
ProcessingChain
ProcessingChain.__add_io_buffer()
ProcessingChain.__add_var()
ProcessingChain.__execute_procs()
ProcessingChain.__parse_expr()
ProcessingChain.__print()
ProcessingChain.add_input_buffer()
ProcessingChain.add_output_buffer()
ProcessingChain.add_processor()
ProcessingChain.add_scalar()
ProcessingChain.add_waveform()
ProcessingChain.execute()
ProcessingChain.execute_block()
ProcessingChain.get_input_buffer()
ProcessingChain.get_output_buffer()
ProcessingChain.get_variable()
- pygama.dsp.WaveformBrowser module
- pygama.dsp.build_processing_chain module
- pygama.dsp.dsp_optimize module
- pygama.dsp.errors module
- pygama.dsp.processors module
- pygama.dsp.units module
- Subpackages
- pygama.io package
- Submodules
- pygama.io.MGDODecoder module
- pygama.io.ch_group module
- pygama.io.compassdaq module
- pygama.io.daq_to_raw module
- pygama.io.fcdaq module
- pygama.io.hit_to_evt module
- pygama.io.io_base module
- pygama.io.lh5 module
- pygama.io.llamadaq module
- pygama.io.orca_digitizers module
- pygama.io.orca_flashcam module
- pygama.io.orcadaq module
- pygama.io.pollers module
- pygama.io.raw_to_dsp module
- pygama.io.wfcompress module
- pygama.lh5 package
- pygama.sandbox package
- Submodules
- pygama.sandbox.base module
- pygama.sandbox.base_calculators module
- pygama.sandbox.base_transforms module
- pygama.sandbox.compass_header module
- pygama.sandbox.compass_wfs module
- pygama.sandbox.database module
- pygama.sandbox.databases module
- pygama.sandbox.h5parser module
- pygama.sandbox.multirun module
- pygama.sandbox.test module
- pygama.sandbox.test_3302 module
- pygama.sandbox.test_lh5_buffered_read module
- pygama.sandbox.test_pygama module
- pygama.sandbox.test_tier_0 module
- pygama.sandbox.test_tier_1 module
- pygama.sandbox.test_wfc module
- pygama.sandbox.tier1_base module
- pygama.sandbox.tier1_vector module
- pygama.sandbox.uproot_mjd module
- pygama.sandbox.uproot_test module
- pygama.sandbox.vec1 module
- pygama.sandbox.vector module
Submodules#
pygama.git module#
pygama.utils module#
pygama convenience functions.
- class pygama.utils.SafeDict#
Bases:
dict
used in handling LEGEND file format strings. when a key is missing, return the string value of that key.
- pygama.utils.fit_simple_scaling(x, y, var=1)#
Fast computation of weighted linear least squares fit to a simple scaling
I.e. y = scale * x. Returns the best fit scale parameter and its variance.
- Parameters:
x (array like) – x values for the fit
y (array like) – y values for the fit
var (array like (optional)) – The variances for each y-value
- Returns:
scale, scale_var – The scale parameter and its variance
- Return type:
tuple (float, float)
- pygama.utils.get_dataset_from_cmdline(args, run_db, cal_db)#
- make it easier to call this from argparse:
arg(“-ds”, nargs=’*’, action=”store”, help=”load runs for a DS”) arg(“-r”, “–run”, nargs=1, help=”load a single run”)
- pygama.utils.get_formatted_stats(mean, sigma, ndigs=2)#
convenience function for formatting mean +/- sigma to the right number of significant figures.
- pygama.utils.get_par_names(func)#
Return a list containing the names of the arguments of “func” other than the first argument. In pygamaland, those are the function’s “parameters.”
- pygama.utils.linear_fit_by_sums(x, y, var=1)#
Fast computation of weighted linear least squares fit to a linear model
Note: doesn’t compute covariances. If you want covariances, just use polyfit
- Parameters:
x (array like) – x values for the fit
y (array like) – y values for the fit
var (array like (optional)) – The variances for each y-value
- Returns:
(m, b) – The slope (m) and y-intercept (b) of the best fit (in the least-squares sense) of the data to y = mx + b
- Return type:
tuple (float, float)
- pygama.utils.peakdet(v, delta, x=None)#
Converted from MATLAB script at: http://billauer.co.il/peakdet.html Returns two arrays: [maxtab, mintab] = peakdet(v, delta, x) An updated (vectorized) version is in pygama.dsp.transforms.peakdet
- pygama.utils.plot_func(func, pars, range=None, npx=None, **kwargs)#
plot a function. take care of the x-axis points automatically, or user can specify via range and npx arguments.
- pygama.utils.print_fit_results(pars, cov, func=None, title=None, pad=True)#
convenience function for scipy.optimize.curve_fit results
- pygama.utils.set_plot_style(style)#
Choose a pygama plot style. Current options: ‘clint’, ‘root’ Or add your own [label].mpl file in the pygama directory!
- pygama.utils.sh(cmd, sh=False)#
input a shell command as you would type it on the command line.
- pygama.utils.sizeof_fmt(num, suffix='B')#
given a file size in bytes, output a human-readable form.
- pygama.utils.tqdm_range(start, stop, step=1, verbose=False, text=None, bar_length=20, unit=None)#
Uses tqdm.trange which wraps around the python range and also has the option to display a progress
Example:
- for start_row in range(0, tot_n_rows, buffer_len):
…
Can be converted to the following
- for start_row in tqdm_range(0, tot_n_rows, buffer_len, verbose):
…
- Parameters:
start (int) – starting iteration value
stop (int) – ending iteration value
step (int) – step size inbetween each iteration
verbose (int) – verbose = 0 hides progress bar verbose > 0 displays progress bar
text (str) – text to display in front of the progress bar
bar_length (str) – horizontal length of the bar in cursor spaces
- Returns:
iterable – object that can be iterated over in a for loop
- Return type:
tqdm.trange
- pygama.utils.tree_draw(tree, vars, tcut)#
if you have to debase yourself and use ROOT, this is an easy convenience function for quickly extracting data from TTrees. TTree::Draw can only handle groups of 4 variables at a time, but here we can put in as many as we want, and return a list of numpy.ndarrays for each one
- pygama.utils.update_progress(tqdm_bar, progress)#