Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/pyttadoc/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ Functions
.. autofunction:: pytta.plot_bars
.. autofunction:: pytta.plot_spectrogram
.. autofunction:: pytta.plot_waterfall

.. autofunction:: pytta.multiple_sweep_excitation
.. autofunction:: pytta.multiple_sweep_irs
.. autofunction:: pytta.triggered_average
6 changes: 5 additions & 1 deletion pytta/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@
list_devices, print_devices, get_device_from_user,\
fft_convolve, find_delay, corr_coef, resample,\
peak_time, save, load, plot_time, plot_time_dB, plot_freq,\
plot_bars, plot_spectrogram, plot_waterfall, SPL
plot_bars, plot_spectrogram, plot_waterfall, SPL,\
multiple_sweep_excitation, multiple_sweep_irs, triggered_average

# Must go on v0.1.0 (DEPRECATED)
from .functions import fft_degree
Expand Down Expand Up @@ -146,6 +147,9 @@
'resample',
'corr_coef',
'peak_time',
'multiple_sweep_excitation',
'multiple_sweep_irs',
'triggered_average',
'save',
'load',
'weighting',
Expand Down
2 changes: 1 addition & 1 deletion pytta/_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ def waterfall(sigObjs, step=2 ** 9, n=2 ** 13, fmin=None, fmax=None, pmin=None,
# Apply rolling window
sliced = np.asarray(list(more_itertools.windowed(ht, n=n, step=step, fillvalue=0)))
window = np.asarray(
[ss.tukey(n, alpha=winAlpha) for s in sliced]) # Tukey window (alpha=0 is a rectangular window)
[ss.windows.tukey(n, alpha=winAlpha) for s in sliced]) # Tukey window (alpha=0 is a rectangular window)
windowed = sliced * window # Apply window
windowedFFT = abs(2 / n * fft(windowed)) # Apply FFT
windowedFFT = windowedFFT[:, idx_min_FFT - fpad: idx_max_FFT + 1 + fpad] # Crop the FFT
Expand Down
98 changes: 7 additions & 91 deletions pytta/apps/roomir.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
from os import getcwd, listdir, mkdir
from os.path import isfile, join, exists
import copy as cp
import traceback
from pytta.classes._instanceinfo import caller_name

# Dict with the measurementKinds
# TO DO FUTURE: add 'inchcalibration', 'outchcalibration'
Expand Down Expand Up @@ -2236,21 +2236,7 @@ def RT(self, roomirsGetDict, decay=20, IREndManualCut=None):
each source-receiver configuration, which is a key;

"""
# Code snippet to guarantee that generated object name is
# the declared at global scope
# for frame, line in traceback.walk_stack(None):
for framenline in traceback.walk_stack(None):
# varnames = frame.f_code.co_varnames
varnames = framenline[0].f_code.co_varnames
if varnames == ():
break
# creation_file, creation_line, creation_function, \
# creation_text = \
extracted_text = \
traceback.extract_stack(framenline[0], 1)[0]
# traceback.extract_stack(frame, 1)[0]
# creation_name = creation_text.split("=")[0].strip()
creation_name = extracted_text[3].split("=")[0].strip()
creation_name = caller_name()

# TR in all positions and averagßes
# TR_avgs = {'S1R1': [Analysis_avg1, An_avg2, ..., An_avgn]}
Expand Down Expand Up @@ -2320,21 +2306,7 @@ def G_Lps(self, recalibirsGetDict):
level;

"""
# Code snippet to guarantee that generated object name is
# the declared at global scope
# for frame, line in traceback.walk_stack(None):
for framenline in traceback.walk_stack(None):
# varnames = frame.f_code.co_varnames
varnames = framenline[0].f_code.co_varnames
if varnames == ():
break
# creation_file, creation_line, creation_function, \
# creation_text = \
extracted_text = \
traceback.extract_stack(framenline[0], 1)[0]
# traceback.extract_stack(frame, 1)[0]
# creation_name = creation_text.split("=")[0].strip()
creation_name = extracted_text[3].split("=")[0].strip()
creation_name = caller_name()

recalibirs = recalibirsGetDict
# Calculating Lps for each recalibir MeasuredThing
Expand Down Expand Up @@ -2401,21 +2373,7 @@ def G_Lpe_inSitu(self, roomirsGetDict, IREndManualCut=None):
key;

"""
# Code snippet to guarantee that generated object name is
# the declared at global scope
# for frame, line in traceback.walk_stack(None):
for framenline in traceback.walk_stack(None):
# varnames = frame.f_code.co_varnames
varnames = framenline[0].f_code.co_varnames
if varnames == ():
break
# creation_file, creation_line, creation_function, \
# creation_text = \
extracted_text = \
traceback.extract_stack(framenline[0], 1)[0]
# traceback.extract_stack(frame, 1)[0]
# creation_name = creation_text.split("=")[0].strip()
creation_name = extracted_text[3].split("=")[0].strip()
creation_name = caller_name()

# Lpe in all positions and averagßes
# Lpe_avgs = {'S1R1': [Analysis_avg1, An_avg2, ..., An_avgn]}
Expand Down Expand Up @@ -2461,21 +2419,7 @@ def G_Lpe_revCh(self, roomirsGetDict, IREndManualCut=None):
all the reverberation chamber's impulsive responses;

"""
# Code snippet to guarantee that generated object name is
# the declared at global scope
# for frame, line in traceback.walk_stack(None):
for framenline in traceback.walk_stack(None):
# varnames = frame.f_code.co_varnames
varnames = framenline[0].f_code.co_varnames
if varnames == ():
break
# creation_file, creation_line, creation_function, \
# creation_text = \
extracted_text = \
traceback.extract_stack(framenline[0], 1)[0]
# traceback.extract_stack(frame, 1)[0]
# creation_name = creation_text.split("=")[0].strip()
creation_name = extracted_text[3].split("=")[0].strip()
creation_name = caller_name()

SigObjs = []
if isinstance(roomirsGetDict, dict):
Expand Down Expand Up @@ -2548,21 +2492,7 @@ def G(self, Lpe_avgs, Lpe_revCh, V_revCh, T_revCh, Lps_revCh, Lps_inSitu):
source-receiver configuration, which is a key;

"""
# Code snippet to guarantee that generated object name is
# the declared at global scope
# for frame, line in traceback.walk_stack(None):
for framenline in traceback.walk_stack(None):
# varnames = frame.f_code.co_varnames
varnames = framenline[0].f_code.co_varnames
if varnames == ():
break
# creation_file, creation_line, creation_function, \
# creation_text = \
extracted_text = \
traceback.extract_stack(framenline[0], 1)[0]
# traceback.extract_stack(frame, 1)[0]
# creation_name = creation_text.split("=")[0].strip()
creation_name = extracted_text[3].split("=")[0].strip()
creation_name = caller_name()

# G (omfg) calculation
# G averages in all positions
Expand Down Expand Up @@ -2627,21 +2557,7 @@ def G_T_revCh(self, roomirsGetDict, IREndManualCut=None, T=20):
all the reverberation chamber's impulsive responses;

"""
# Code snippet to guarantee that generated object name is
# the declared at global scope
# for frame, line in traceback.walk_stack(None):
for framenline in traceback.walk_stack(None):
# varnames = frame.f_code.co_varnames
varnames = framenline[0].f_code.co_varnames
if varnames == ():
break
# creation_file, creation_line, creation_function, \
# creation_text = \
extracted_text = \
traceback.extract_stack(framenline[0], 1)[0]
# traceback.extract_stack(frame, 1)[0]
# creation_name = creation_text.split("=")[0].strip()
creation_name = extracted_text[3].split("=")[0].strip()
creation_name = caller_name()

roomirs = roomirsGetDict
RTs = []
Expand Down
6 changes: 5 additions & 1 deletion pytta/classes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* RecMeasure
* PlayRecMeasure
* FRFMeasure
* SimulatedPlayRecMeasure and SimulatedFRFMeasure, without a sound card
* Streaming
* Monitor
* OctFilter
Expand All @@ -38,7 +39,8 @@

from .signal import SignalObj, ImpulsiveResponse
#from .signal import plot_SignalObjs
from .measurement import Measurement, RecMeasure, PlayRecMeasure, FRFMeasure
from .measurement import Measurement, RecMeasure, PlayRecMeasure, FRFMeasure, \
SimulatedPlayRecMeasure, SimulatedFRFMeasure
from .streaming import Streaming, Monitor
from .filter import OctFilter, weighting
from .analysis import Analysis, RoomAnalysis
Expand All @@ -51,6 +53,8 @@
'RecMeasure',
'PlayRecMeasure',
'FRFMeasure',
'SimulatedPlayRecMeasure',
'SimulatedFRFMeasure',
'Streaming',
'Monitor',
'OctFilter',
Expand Down
14 changes: 14 additions & 0 deletions pytta/classes/_instanceinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,25 @@
"""


import sys
import time
import traceback
import threading


def caller_name():
"""
Name assigned on the module-level line that led to the current call:
'x' for ``x = pytta.generate.sweep()``. The text before '=' (the whole
line if there is none), or '' when the source line is not available.
"""
frame = sys._getframe(2) # the caller of the function asking
while frame.f_code.co_varnames and frame.f_back is not None:
frame = frame.f_back
line = traceback.extract_stack(frame, 1)[0].line or ''
return line.split('=')[0].strip()


class InstanceCreationError(Exception):
pass

Expand Down
Loading