Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added volts2demod() function to units #218

Merged
merged 1 commit into from
May 28, 2024
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

### Added
- octave_tools - Added the possibility to pass the AutoCalibrationParams to ``get_correction_for_each_LO_and_IF()`` to customize the calibration parameters (IF_amplitude for instance).
- unit - ``volts2demod()`` function that does the inverse operation of ``demod2volts()``

## [0.17.4] - 2024-05-07
### Fixed
Expand Down
18 changes: 18 additions & 0 deletions qualang_tools/units/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,24 @@ def demod2volts(
else:
return 4096 * data * self.V / duration

def volts2demod(
self,
value_in_volts: Union[float, ndarray],
duration: Union[float, int],
single_demod: bool = False,
) -> Union[float, ndarray]:
"""Converts the volts to demodulated data units.

:param value_in_volts: some value in volts. Must be a python variable or array.
:param duration: demodulation duration in ns.
:param single_demod: Flag to add the additional factor of 2 needed for single demod.
:return: the same value in demodulated data units.
"""
if single_demod:
return (value_in_volts * duration) / (2 * 4096 * self.V)
else:
return (value_in_volts * duration) / (4096 * self.V)

def raw2volts(self, data: Union[float, ndarray]) -> Union[float, ndarray]:
"""Converts the raw data to volts.

Expand Down
Loading