AnalyzeTools package

Submodules

AnalyzeTools.AnalyzeManager module

class AnalyzeTools.AnalyzeManager.AnalyzeManager(snare, analysesFullPaths)

Bases: PyQt5.QtCore.QObject

AnalyzeManager handles the main analyze methods like adding and deleting a widget. It contains the active widgets in an 2D dictionary depending on the channel. As well as a channel depending boolean dictionary with the activated reports. All widget information which is dynamically imported at startup (“Info.txt”) is also stored in this class.

addWidget(analysis, channel, selNo)

Adds Analyze to Analyze mapping.

Parameters:
  • analysis (QWidget) – Analyze
  • channel (Object) – unique Channelobject
  • selNo (str) – String of selection label
deleteWidget(channel, selNo)

Delete Analyze from Analyze mapping.

Parameters:
  • channel (object) – unique Channelobject
  • selNo (str) – String of selection label
getStatusBarString()

Returns a string for the Status Bar with analyse depending information. :return: string with AnalyzeWidget information :rtype: str

listAnalyzeTypes()

List all imported Analyses as a list.

Returns:List of all AnalyzeWidgets
Return type:list
readWidgetInfo(path)

Read the Widget information and parameters from Info.txt.

Parameters:path (str) – path to Widget Info.txt
Returns:DataFrame with the imported Widget information
Return type:panda DataFrame
removeAnalysis

AnalyzeTools.AnalyzeWidget module

class AnalyzeTools.AnalyzeWidget.AnalyzeWidget(snare, channel, selNo, timeWeight, fqWeight)

Bases: PyQt5.QtWidgets.QWidget

AnalyzeWidget is the base class for every Analyze Widget. It contains the figurePlot, navigation menu and the labels. The whole layout is set in self.layout. The figurePlot is stored in self.figurePlot, the navigation in self.nav and the labels in self.titleLabel as well as self.infoLabel.

delete()

Trigger the delete widget signal.

pan()

Trigger the pan signal for the figure toolbar.

report
reset()

Trigger the reset signal for the figure toolbar.

sendReportState(state)

Forward report information to ReportManager; with togglestate and channel/selNo as parameters. :param state: Togglestate of “Report” checkbox. :type state: bool

setupLayout(layout)

Set up the default layout of a AnalyzeWidget. :param layout: transmit the layout :type layout: layout

zoom()

Trigger the zoom signal for the figure toolbar.

zoomPlot(event)

Zoom in and out by ctrl + scroll wheel. :param event: Mouse event :type event: matplotlib.backend_bases.MouseEvent

AnalyzeTools.AnalyzeWidgetSelect module

class AnalyzeTools.AnalyzeWidgetSelect.AnalyzeWidgetSelect(snare, channel, selNo, type)

Bases: PyQt5.QtWidgets.QWidget

AnalyzeWidgetSelect encapsulates the selected Analyze Widget and initialize it dynamically depending on user choice. The replot methods handlle the signals for replot/refresh. A method for clearing a layout is also implemented.

clearLayout(layout)

Removes all Widgets that are on given layout.

Parameters:layout (QLayout) – Layout to clear.
dynamicClassImport(classstr)

A helper method to import just the needed widget class dynamically depending on current user choice.

Returns:Corresponding class to selected Analyze Widget.
Return type:QWidget
initParm()

Initialize widget parameter given in Info.txt as constructor variables. If not given initialize with default values.

refresh()

General refresh method.

refreshNav(timeWeight=None, fqWeight=None, parm1=None, parm2=None, parm3=None)

Refresh method triggered from “Analyzer” Navigation Menu.

Parameters:
  • timeWeight (str) – Time weight slow, fast or impulse
  • fqWeight (str) – Frequency weight A, B, C or Z
  • parm1 (str or int) – optional parameter
  • parm2 (str or int) – optional parameter
  • parm3 (str or int) – optional parameter
replotSel(channel=None, selNo=None, type='FFT')

Replot method triggered by “Editor” Analyze Button. Reimport widgetInfo because analyze type could have changed. Also initialize the new widget parameters, then refresh.

Parameters:
  • channel (object) – unique Channelobject
  • selNo (str) – String of selection label
  • type (str) – Short analyze widget name (f.e. FFT, Hist. ...)
setWidget()

AnalyzeTools.Calculation module

class AnalyzeTools.Calculation.Calculation(snare, calib, timeWeight, fqWeight)

Bases: PyQt5.QtCore.QThread

Pool for common calculation methods which is inherited for every calculation class of a analyze widget. The class contain all necessary nominal data adopted from IEC 61672:1 2013 Standard. More precisely this involves band indices, nominal frequencies and weighting values. Frequency weighting is preformed in time domain with an implementation of the difference equation in direct form II with the correct coefficients. ::seealso fqWeighting Time weighting is done by integrate the sound pressure using exponential integration. This is realized by applying a low-pass filter with one real pole at :math:’-1/tau’.

db(a, rms=False)

Returns dB sound pressure level or dB fullscale peakvalues depending if a calibration is set. warning:: Values in array ‘a’ need to be energetic values (pressure squared).

Parameters:
  • a (array) – Input values
  • rms (bool) – Optional to handle root mean square
Returns:

dBSPL or dBFS values

Return type:

array

dbSplToPascal(db)

Converts dBSPL to Pascal. :param db: Array with dB values :return: array

fft(a, fftSize=10000)

Calculates the fast fourier transform of the input array.

Parameters:
  • a (array) – Input array
  • fftSize – FFT Size; optional parameter
Returns:

FFT values

Return type:

array

fqWeighting(values, fqWeight)

Apply A, B, C or Z frequency-weighting. First the needed nominal weighting coefficients a and b are imported. The filtering is implementated in lfilter with Direct Form II using standard difference equation.

Parameters:
  • a (array) – Input values
  • fqWeight (str) – Frequency-weight A, B, C or Z
Returns:

Frequency-weighted values

Return type:

array

indexOfNearestVal(a, value)

Returns the index of an array which is nearest to the given value. Finds an index of nearest value in sorted array compared to given value. Its fast for large arrays. warning:: array needs to be sorted! :param a: Input values :type a: array :param value: Nearest value :type value: int :return: Index of nearest value :rtype: int

resourcePath(relativePath)

Returns absolute path to relative path given file as parameter. :param relativePath: relative path :return: absolute path

rms(a)

Returns the root mean square of all the elements of a.

Parameters:a (array) – Input array
Returns:RMS of a
Return type:array
timeWeighting(a, timeWeight)
Apply slow, fast or impulse time-weighting.
Time weighting is done by integrate the sound pressure using exponential integration.
Parameters:
  • a (array) – Input values
  • timeWeight (str) – Time-weight slow, fast or impulse
Returns:

Time-weighted values

Return type:

array

AnalyzeTools.CalibrationWidget module

class AnalyzeTools.CalibrationWidget.CalibrationWidget(snare, channel, selNo)

Bases: PyQt5.QtWidgets.QWidget

Stores the calibration value of current selection (self.selNo) in SNARE’s channel dependent ‘calibrations’ variable.

calculate()

AnalyzeTools.NavMenu module

class AnalyzeTools.NavMenu.NavMenu

Bases: PyQt5.QtWidgets.QWidget

Nav Menu is the base class for the navigation and can be modified if not the standard navigation “NavMenuStandard” with delete, timeweighting, frequency weighting, and plot functions (pan, zoom, reset) isn’t enoguh. This is E.g. the case for the FFT widget, which includes the nth octave dropdown.

delete
deselectReport()

Deactivate widget report checkbox.

getFrame(bottomwidget, topwidget=None)
pan
replot
reportState
reset
selectReport()

Activate widget report checkbox.

sendReplot()

Emit replot signal.

sendReportState(status)

Emit report signal.

Parameters:status (bool) – bool state if report is activated
zoom
class AnalyzeTools.NavMenu.NavMenuStandard(timeWeighting=True, fqWeighting=True)

Bases: AnalyzeTools.NavMenu.NavMenu

Use this standard navigation class to provide your Analyse Widget with a regular, fixed Navigation bar: Frequency Weighting (Dropdown), Time Weighting (Dropdown), Reset, Zoom, Pan, Report (Checkbox) and Delete. Optional parameters ‘timeWeighting’ and ‘fqWeighting’ offers the possibility to hide the selection.

For extendend more buttons, create your Widget own Nav* Script and inherit from WidgetNav Base Class.

replot

AnalyzeTools.NominalData module

class AnalyzeTools.NominalData.NominalData(csvFile)

Bases: object

Pool for common nominal data. Handles the read from NominalData CSV file in which the FFT band indices, corresponding nominal frequencies and time weighting coefficients for the difference equation are stored. All nominal data are adopted after standard IEC 61672:1 2013: A standard for sound level meters.

nominalFrequencies(nthOctave, bandNo, onlyNth=1)

Returns the nominal frequencies. Parameter nthOctave specifies for witch nth Octave the nominal frequencies are needed.

Parameters:
  • nthOctave (int) – Nth Octave
  • bandNo (int) – Band indices
  • onlyNth (int) – defines if every nominal frequency or just every nth frequency is returned
Returns:

nominal frequencies

Return type:

array

weighting(weight)

AnalyzeTools.Plot module

class AnalyzeTools.Plot.Plot

Bases: PyQt5.QtCore.QThread

Base class for every plot class.

AnalyzeTools.PlotBar module

class AnalyzeTools.PlotBar.PlotBar(xAxis, bars, calib, xLabelCalibrated, xLabelUncalibrated, yLabel, xLim, barWidth=0.1)

Bases: AnalyzeTools.Plot.Plot

Common used plot class for bar plots.

getPlot()
class AnalyzeTools.PlotBar.PlotBarToolTip(values, xAxis, ax, calib=True, xDataComplete=None, xTol=None, xUnit='Hz', yUnit='dB')

Bases: PyQt5.QtCore.QThread

callback for matplotlib to display a tooltip when frequencybars are clicked. parm: calib boolean if plot is calibration dependent (dbFS and dBSPL on y axis) xDataComplete is used for FFT Plots, where more FQ Bars exist as the axis got for discrete values.

changeColor(event)

Deal with pick events and changes the color..

distance(x1, x2, y1, y2)

return the distance between two points.

drawTooltip(ax, x, y, dbval, idx)

Draw the bar text on the plot.

Module contents