A lock-in amplifier can be used to measure the electrical impedance of a device. Before you begin, read the description of Stanford Research Systems 830 Lock-in Amplifier and the section on Frequency dependent impedance measurements.
The following Python script uses the SR830 to output an AC voltage across a device and then measures the amplitude and phase of current that passes through the device. This information can be used to calculate the impedance. The script performs this measurement for a range of frequencies.