MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / process_readings

Function process_readings

examples/NI DAQmx/daqbridge.py:118–149  ·  view source on GitHub ↗

Process raw voltage readings and return values for CSV output. Args: raw_data: numpy array of shape (num_channels, num_samples) with raw voltage readings channel_config: list of channel configuration dictionaries Returns: numpy array of shape (num_channels, num

(raw_data: np.ndarray, channel_config: list)

Source from the content-addressed store, hash-verified

116
117
118def process_readings(raw_data: np.ndarray, channel_config: list) -> np.ndarray:
119 """
120 Process raw voltage readings and return values for CSV output.
121
122 Args:
123 raw_data: numpy array of shape (num_channels, num_samples) with raw voltage readings
124 channel_config: list of channel configuration dictionaries
125
126 Returns:
127 numpy array of shape (num_channels, num_samples) with processed values
128
129 Default behavior:
130 - Voltage channels: pass through as-is
131 - Current channels: convert voltage to current using shunt resistor (I = V / R)
132
133 Modify this function to add your custom processing logic.
134 """
135 output = raw_data.copy()
136
137 for ch_idx, ch_cfg in enumerate(channel_config):
138 if ch_cfg.get("type") == "current":
139 shunt = ch_cfg.get("shunt_resistor", 1.0)
140 output[ch_idx, :] = raw_data[ch_idx, :] / shunt # I = V / R
141
142 # -----------------------------------------------------
143 # ADD YOUR CUSTOM PROCESSING HERE
144 # Example:
145 # output[0, :] = raw_data[0, :] * 2.0 # Scale channel 0
146 # output[1, :] = np.clip(raw_data[1, :], -5, 5) # Clamp channel 1
147 # -----------------------------------------------------
148
149 return output
150
151
152# =============================================================================

Callers 1

runMethod · 0.85

Calls 2

copyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected