Skip to content

Reading and preparing data

All functions of the package use the same two arrays for a spectrum:

  • f: the frequencies in hertz.
  • Z: the complex impedance in ohms. Z.real is \(Z'\) and Z.imag is \(Z''\).

The readers do not change the sign of the imaginary part in the file. For a capacitive sample, \(Z''\) is negative. The plot functions show \(-Z''\), which is the usual form of Nyquist and Bode plots.

Find the files

from EISFitpython import data_extraction as data

files = data.get_eis_files("EIS_Data", subfolder="Example-3-4")

get_eis_files returns all files in the folder in the order of their names, and prints the list. Make sure that the order of the files agrees with the order of your temperatures. The function compares the names as text. Thus s-100deg comes before s-90deg.

Read a file

Function File format Header lines Column separator
readNEISYS Text export of the NEISYS spectrometer The reader ignores them Tab
readTXT Text file with three columns The reader ignores lines with words such as freq, Hz, real, imag or Z Tab, comma or spaces
readCSV CSV file with three columns Not allowed Comma or semicolon

The three columns are frequency, real part and imaginary part of the impedance:

frequency    Z'    Z''

Each reader returns (f, Z). The readers ignore a row with the frequency zero.

f, Z = data.readTXT("measurement.txt")

Select a frequency range

trim_data keeps the points from fmin to fmax. The two limits are part of the range:

f_fit, Z_fit = data.trim_data(f, Z, fmin=1.0, fmax=1e6)

Use None for a limit you do not need. The order of the points does not change.

Stack several spectra

The global-local fit uses all spectra of a series as one long array. The stack functions connect the files in the order of the list:

f_all, Z_all, lengths = data.stack_NEISYS_files(files, return_lengths=True)

With return_lengths=True the function also returns the number of points of each file. stack_TXT_files and stack_CSV_files do the same for the other formats and return (f_all, Z_all).

Split stacked spectra

split_array divides a stacked array into its spectra again. The safest procedure is to give the point counts:

f_sets, Z_sets = data.split_array(f_all, Z_all, lengths=lengths)

Without lengths, the function finds the points where one frequency sweep ends and the next sweep starts. For sweeps from high frequency to low frequency, a new sweep starts where the frequency increases again. This procedure is correct if each spectrum is one sweep in one direction. A spectrum must not contain points in the wrong order.

The result is a list of arrays. This is also true for one spectrum. If you do not give Z, the second list in the result is empty.

The global-local fit finds the spectra by their sweeps. Thus stack the files in the order of the measurement, and do not sort the stacked array.