diff --git a/ion_functions/data/co2_functions.py b/ion_functions/data/co2_functions.py index 020523d..6bf8c2d 100644 --- a/ion_functions/data/co2_functions.py +++ b/ion_functions/data/co2_functions.py @@ -166,6 +166,39 @@ def pco2_thermistor(traw, sami_bits): return therm +def pco2_battery(braw, sami_bits): + """ + Description: + + Convert the battery voltage data from counts to volts from the + pCO2 instrument. + + Implemented by: + + 2023-02-23: Mark Steiner. Initial code. + + Usage: + + volts = pco2_battery_voltage(vraw, sami_bits) + + where + + volts = converted battery voltage [degC] + braw = raw battery voltage [counts] + sami_bits = number of bits on the SAMI hardware + """ + # reset inputs to arrays + braw = np.atleast_1d(braw) + sami_bits = np.atleast_1d(sami_bits) + + # convert raw battery readings from counts to Volts + if sami_bits[0] == 14: + volts = ne.evaluate('braw * 3. / 4000.') + else: + volts = ne.evaluate('braw * 15. / 4096.') + return volts + + def pco2_pco2wat(mtype, light, therm, ea434, eb434, ea620, eb620, calt, cala, calb, calc, a434blank, a620blank): """ diff --git a/ion_functions/data/ph_functions.py b/ion_functions/data/ph_functions.py index cfc27ea..ef075f9 100644 --- a/ion_functions/data/ph_functions.py +++ b/ion_functions/data/ph_functions.py @@ -61,13 +61,19 @@ def ph_thermistor(traw, sami_bits): return therm -def ph_battery(braw): +def ph_battery(braw, sami_bits): """ - Function to convert the battery voltage from counts to Volts from the pH - instrument. + Function to convert the battery voltage from counts to Volts from the pH instrument. """ + # reset inputs to arrays + braw = np.atleast_1d(braw) + sami_bits = np.atleast_1d(sami_bits) + # convert raw battery readings from counts to Volts - volts = ne.evaluate('braw * 15. / 4096.') + if sami_bits[0] == 14: + volts = ne.evaluate('braw * 3. / 4000.') + else: + volts = ne.evaluate('braw * 15. / 4096.') return volts