Skip to content

[FEATURE] add SignalObj.uncalibrate - #62

Open
aguirreSL wants to merge 1 commit into
PyTTaMaster:developmentfrom
aguirreSL:dev-uncalibrate
Open

aguirreSL wants to merge 1 commit into
PyTTaMaster:developmentfrom
aguirreSL:dev-uncalibrate

Conversation

@aguirreSL

@aguirreSL aguirreSL commented Oct 31, 2026 •

Copy link
Copy Markdown

Adds SignalObj.uncalibrate(chIndex=None), asked for in #14. It undoes calib_pressure and calib_voltage for one channel, or for every calibrated channel when chIndex is None: the samples are divided by the correction factor and the channel goes back to full scale (CF = 1, unit 'FS', dB reference 1). Channels that were not calibrated are left as they are.

While writing the tests I found that calib_voltage failed with a correct calibrator. Both calib_volt and calib_press check the calibrator frequency with np.argmax(freqSignal). On a complex spectrum argmax compares real parts, and the spectrum of a sine is mostly imaginary, so the check found a wrong frequency and printed its warning. In calib_volt the warning then raised ValueError: Precision not allowed in integer format specifier, because it formats an integer refFreq with '{:.2}'. The check now takes the argmax of the magnitude, and the warning formats both frequencies with '{}'.

The tests in tests/test_uncalibrate.py calibrate one channel in pressure and another in voltage, then check that uncalibrate() gives back the original samples and full scale on both, and that uncalibrate(0) leaves the second channel calibrated.

Checked with Python 3.12, numpy 1.26 and scipy 1.17. The existing tests behave as on development: the 7 failures there (3 in test_h5io.py, 4 in test_pyttasave.py) are the same with and without this change.

Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com

uncalibrate undoes calib_pressure and calib_voltage for one channel or
for all of them: the samples are divided by the correction factor and
the channel goes back to full scale (CF = 1, unit 'FS').

The check of the calibrator frequency took the argmax of the complex
spectrum, which compares real parts and misses a sine, so it warned for
a correct calibrator. In calib_volt the warning then failed, since it
formatted an integer refFreq with a precision. The check now uses the
magnitude of the spectrum.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant