Tutorial: ixdat readers

To “load a file” with ixdat, we use a Reader. The easiest way to do this is by using Measurement.read() and Spectrum.read().

Ixdat’s pluggable design means that once data is read in, it is equally useful wherever it is read in from. I.e., if you do the same electrochemistry experiment on two different potentiostats with different file formats, the only part of your code that needs to change is the specification of the reader.

You can also read from a url, using Measurement.read_url() or read and append multiple data files using Measurement.read_set().

Measurements

In ixdat, a “Measurement” involves data resolved in time (even if you’re not used to thinking of it that way - for example cyclic voltammetry data is often thought of as current vs potential, but can also be considered current and potential both as functions of time).

The full list of measurement readers available can be viewed as follows:

[1]:
from ixdat.readers import READER_CLASSES

for reader_name, Reader in READER_CLASSES.items():
    print(reader_name + ":\t\t" + str(Reader))
importing ixdat v0.2.7.dev1 from C:\Users\Søren\git\ixdat\src\ixdat\__init__.py
ixdat:          <class 'ixdat.readers.ixdat_csv.IxdatCSVReader'>
ixdat_spectrum:         <class 'ixdat.readers.ixdat_csv.IxdatSpectrumReader'>
biologic:               <class 'ixdat.readers.biologic.BiologicMPTReader'>
avantage:               <class 'ixdat.readers.avantage.AvantageAVGReader'>
autolab:                <class 'ixdat.readers.autolab.NovaASCIIReader'>
ivium:          <class 'ixdat.readers.ivium.IviumDatasetReader'>
chi:            <class 'ixdat.readers.chi.CHInstrumentsTXTReader'>
pfeiffer:               <class 'ixdat.readers.pfeiffer.PVMassSpecReader'>
rgasoft:                <class 'ixdat.readers.rgasoft.StanfordRGASoftReader'>
cinfdata:               <class 'ixdat.readers.cinfdata.CinfdataTXTReader'>
cinfdata_db:            <class 'ixdat.readers.cinfdata_db.CinfdataDBReader'>
zilien:         <class 'ixdat.readers.zilien.ZilienTSVReader'>
zilien_tmp:             <class 'ixdat.readers.zilien.ZilienTMPReader'>
zilien_spec:            <class 'ixdat.readers.zilien.ZilienSpectrumReader'>
EC_MS:          <class 'ixdat.readers.ec_ms_pkl.EC_MS_CONVERTER'>
msrh_sec:               <class 'ixdat.readers.msrh_sec.MsrhSECReader'>
msrh_sec_decay:         <class 'ixdat.readers.msrh_sec.MsrhSECDecayReader'>
xrdml:          <class 'ixdat.readers.xrdml.XRDMLReader'>
qexafs:         <class 'ixdat.readers.qexafs.QexafsDATReader'>

The above readers can all be used via Measurement.read, with the name give as the reader argument. For example:

from ixdat import Measurement

ec = Measurement.read("my_biologic_data.mpt", reader=".mpt")
ec.plot()   # everything in ixdat comes in ready-to-plot :)

using Path

The first argument to read is the file specification. It is the path to the data file including the suffix. If the data is in the same folder, the file name with suffix suffices, but if it is a different folder, the full path or relative path needs to be specified. It can be a string or a Path object of the pathlib package. We recommend the use of pathlib. For example:

from pathlib import Path()
from ixdat import Measurement

data_dir = Path.home() / "Documents/project/experiment"
ec = Measurement.read(data_dir / "my_biologic_data.mpt", reader=".mpt")
ec.plot()

spectra

Before ixdat version 0.2.7, the readers of Spectrum data (such as “xrdml”) are grouped together with the readers of Measurement data. As of ixdat 0.2.7, the readers of Spectrum data are listed separately, in SPECTRUM_READER_CLASSES:

[2]:
try:
    from ixdat.readers import SPECTRUM_READER_CLASSES
except ImportError:
    print("Upgrade to ixdat 0.2.7 or higher (when available)")
else:
    for reader_name, Reader in SPECTRUM_READER_CLASSES.items():
        print(reader_name + ":\t\t" + str(Reader))
Upgrade to ixdat 0.2.7 or higher (when available)

Either way, spectra can be read in using Spectrum.read with the reader specified the same way as for measurements. For example:

from ixdat import Spectrum

xrd = Spectrum.read(my_xrd_data.xrdml, reader="xrdml")
xrd.plot()

Advanced

If you need to make the use of the reader class itself, you can also import and initiate it explicitly. For example:

from ixdat.readers.biologic import BiologicMPTReader

my_reader = BiologicMPTReader()
ec = my_reader.read("my_biologic_data.mpt")

We plan to demonstrate details and quirks of each reader in jupyter notebook tutorials in the near future. For now, you can see each reader demonstrated in a .py file in the main ixdat github repository here:

https://github.com/ixdat/ixdat/tree/main/development_scripts/reader_demonstrators