Skip to content

Commit

Permalink
remove log statements in methods run by Ray workers
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanielloNTIA committed Apr 25, 2023
1 parent 5e6b3c7 commit dee3c5d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 29 deletions.
23 changes: 8 additions & 15 deletions scos_actions/signal_processing/apd.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,26 @@ def get_apd(
ne.evaluate("20*log10(all_amps)", out=all_amps)

if bin_size_dB is None or bin_size_dB == 0:
# No downsampling
if min_bin is not None or max_bin is not None:
logger.warning(
f"APD bin edge specified but no downsampling is being performed"
)
# No downsampling. min_bin and max_bin ignored.
a = np.sort(all_amps)
p = 1 - ((np.arange(len(a)) + 1) / len(a))
# Replace peak amplitude 0 count with NaN
p[-1] = np.nan
else:
# Dynamically get bin edges if necessary
if min_bin is None:
logger.debug("Setting APD minimum bin edge to minimum recorded amplitude")
min_bin = np.nanmin(all_amps)
if max_bin is None:
logger.debug("Setting APD maximum bin edge to maximum recorded amplitude")
max_bin = np.nanmax(all_amps)
if min_bin >= max_bin:
logger.error(
raise ValueError(
f"Minimum APD bin {min_bin} is not less than maximum {max_bin}"
)
# Check that downsampling range is evenly spanned by bins
if not ((max_bin - min_bin) / bin_size_dB).is_integer():
raise ValueError(
"APD downsampling range is not evenly spanned by configured bin size."
)
# Scale bin edges to the correct units if necessary
if impedance_ohms is not None:
min_bin, max_bin = (
Expand All @@ -88,11 +87,7 @@ def get_apd(
assert np.isclose(
a[1] - a[0], bin_size_dB
) # Checks against undesired arange behavior
if not ((max_bin - min_bin) / bin_size_dB).is_integer():
logger.debug(
"APD downsampling range is not evenly spanned by configured bin size.\n"
+ f"Check that the following amplitude bin edges are correct: {a}"
)

# Get counts of amplitudes exceeding each bin value
p = sample_ccdf(all_amps, a)
# Replace any 0 probabilities with NaN
Expand All @@ -102,8 +97,6 @@ def get_apd(
if impedance_ohms is not None:
ne.evaluate("a-(10*log10(impedance_ohms))", out=a)

logger.debug(f"APD result length: {len(a)} samples.")

return p, a


Expand Down
16 changes: 3 additions & 13 deletions scos_actions/signal_processing/fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def get_fft(
:return: The transformed input, scaled based on the specified
normalization mode.
"""
logger.debug("Computing FFTs")
# Make sure num_ffts and fft_size are integers
if isinstance(fft_size, int) and isinstance(num_ffts, int):
pass
Expand All @@ -79,25 +78,16 @@ def get_fft(

# Get num_ffts for default case: as many as possible
if num_ffts <= 0:
logger.info("Number of FFTs not specified. Using as many as possible.")
num_ffts = int(len(time_data) // fft_size)
logger.info(
f"Number of FFTs set to {num_ffts} based on specified FFT size {fft_size}"
)

# Determine if truncation will occur and raise a warning if so
if len(time_data) != fft_size * num_ffts:
thrown_away_samples = len(time_data) - (fft_size * num_ffts)
msg = "Time domain data length is not divisible by num_ffts.\nTime"
msg += "domain data will be truncated; Throwing away last "
msg += f"{thrown_away_samples} sample(s)."
logger.warning(msg)
msg = "Time domain data length is not divisible by num_ffts * fft_size.\n"
msg += "Try zero-padding the input or adjusting FFT parameters."
raise ValueError(msg)

# Resize time data for FFTs
time_data = np.reshape(time_data[: num_ffts * fft_size], (num_ffts, fft_size))
logger.debug(
f"Num. FFTs: {num_ffts}, FFT Size: {fft_size}, Data shape: {time_data.shape}"
)

# Apply the FFT window if provided
if fft_window is not None:
Expand Down
1 change: 0 additions & 1 deletion scos_actions/signal_processing/power_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ def apply_power_detector(
detector_functions = [np.min, np.max, np.mean, np.median]

# Get functions based on specified detector
logger.debug(f"Applying power detectors: {detectors}")
applied_detectors = []
if "min" in detectors:
applied_detectors.append(detector_functions[0])
Expand Down

0 comments on commit dee3c5d

Please sign in to comment.