Importing titration data
Titration data needs to be in the format described in Variables and conventions in order to work with Calkulate functions. The
io module contains a function to import text files generated by the widespread VINDTA instrument in a suitable format, or to load titration datasets that were simulated and reported by D81.
Import VINDTA-style .dat files
io.datfile function is useful if titration data is in a text file (e.g. the format typically generated by a VINDTA instrument). This format is easy to replicate with any other sort of data that you may have.
volAcid, emf, tempK = calk.io.datfile(datFile, delimiter='\t', skip_header=2, **kwargs)
datFile is a string containing the .dat file's name (and path). The other optional inputs, including
**kwargs, get passed to NumPy's
genfromtxt function to assist in opening the file correctly.
What format is that?
A text file with the extension '.dat' for each titration that looks something like this (with extra rows in place of the
bottle CRM-144-0435-4 0 0 0 0 0.00 0.00 35.000 4.000 0.00 0.0 24.857 35.000 0.000 0.000 0.000 187.600 24.857 0.150 209.350 24.855 0.300 236.800 24.857 ... ... ... 3.750 483.800 24.862 3.900 486.350 24.865 4.050 488.650 24.862
The first two lines contain various bits of user-inputted information about the sample. Other than skipping past them to the titration data, these lines are totally ignored by Calkulate.
The rest of the file has a row for each acid addition step in the titration. The space- or tab-separated columns are:
- Volume of acid added in ml;
- Measured EMF of the sample + acid mixture in mV;
- Temperature of the sample + acid mixture in °C.
Creating .dat files
If you have imported or simulated titration data in the format expected by Calkulate, you can export it in this .dat file format using the
calk.io.writeDat(datFile, volAcid, emf, tempK, line0='', line1='')
Be careful - if the specified
datFile already exists then it will be overwritten without warning!
line1 inputs allow you to add anything to the first two lines of the .dat file; these lines are ignored by the Calkulate import function.
Titration data simulated by D81 and reported in his Tables 1 (without phosphate) and 4 (with phosphate) are available within Calkulate. They can be imported as follows:
(massAcid, pH, tempK, massSample, concAcid, pSal, alk, concTotals, eqConstants) = calk.io.Dickson1981(withPhosphate=True)