pH Calculation Tools¶
Module to calculate pH for devices from Pyroscience.
The following functions are only valid for devices with Firmware >= 4.10 (released 2023).
- pyrotoolbox.pH.calculate_pH(R, temperature, salinity, top, bottom, pka, slope, pka_t, bottom_t, top_t, slope_t, pka_is1, pka_is2, offset, **kwargs)¶
Calculate pH from R, temperature, salinity and sensor constants. See also function calculate_pH_from_calibration.
- Parameters:
R – R-value from the sensor
temperature – temperature of the sample in °C
salinity – salinity of the sample in g/L
top – material constant
bottom – material constant
pka – material constant
slope – material constant
pka_t – material constant
bottom_t – material constant
top_t – material constant
slope_t – material constant
pka_is1 – material constant
pka_is2 – material constant
offset – offset in pH-units (from 3rd calibration point)
kwargs – kwargs are ignored
- Returns:
- pyrotoolbox.pH.calculate_pH_from_calibration(R, temperature, salinity, calibration: dict, **kwargs)¶
apply a pH calibration to measurement data for FW >= 410
The calibration parameters can be passed from the calibration metadata.
Example usage: apply_pH_calibration(data[‘R’], data[‘temp’], data[‘salinity’], m[‘calibration’])
- Parameters:
R – R-value from the sensor
temperature – temperature of the sample in °C
salinity – salinity of the sample in g/L
calibration – calibration dictionary as created by the parsers
kwargs – kwargs are inserted into the calibration and override the values
- Returns:
calculated pH values
- pyrotoolbox.pH.calculate_pH_from_interpolated_calibration(R, temperature, salinity, calibrations, return_fits=False)¶
Apply an interpolated pH calibration to measurement data
The top and bottom value is calculated for every passed calibration and fitted linear over time. For every measurement point an individual value of top and bottom is calculated.
- Parameters:
R – data for “R”
temperature – overrides temp values from df. Single value or iterable with same length as df is required
salinity – Single value or iterable with same length as df is required
calibrations – dict in format {timestring: calib_data} e.g. {‘2019-05-05 13:10:00’: {pH1: 4, temp1: 22.08, …}}, or a list of calibration-dicts
R – overrides R values from df. Single value or iterable with same length as df is required
return_fits – return the fits of top, bottom and offset instead
- Returns:
calculated pH-values
- pyrotoolbox.pH.calculate_pH_with_prospective_drift_compensation(R, temperature, salinity, calibration: dict, d0: float, d1: float, d2: float, d3: float, start_timestamp=None)¶
apply prospective pH drift compensation to a pH measurement.
- currently we have identified two main sources of drift for the pH sensor materials:
dye hydrolysis or leaching in water (strongly temperature dependent)
photo-bleaching during a measurement
The effect on the sensors is assumed to be only a decrease in Top (due to reduced dye content)
- Parameters:
R – R-values
temperature – temperature data
salinity – salinity data
calibration – calibration dictionary as created by the parser functions
start_timestamp – optional, time of the calibration. By default, the date_calibration_acid value is used
d0 – first coefficient of the temperature dependent drift
d1 – second coefficient of the temperature dependent drift
d2 – third coefficient of the temperature dependent drift
d3 – fourth coefficient of the temperature dependent drift
start_timestamp – optional, start of the drift. If omitted the date of the last acid calibration is used
- Returns:
array of pH values