When I use the python Driver class provided by the pypi library, I can only seem to set the sampling frequency of the current measurement (driver.publish(“h/fs”, fs) which is undocumented it seems). but it doesn’t affect the GPI readings which happen with full resolution (2MS/s). As a results, I have mismatching data (from a 0.5s recording):
u/js220/002627.current: 0.06291326085940004 A | 500000 samples
u/js220/002627.gpi[0]: 0.199584 | 1000000 samples
u/js220/002627.gpi[1]: 0.163816 | 1000000 samples
u/js220/002627.gpi[2]: 0.163817 | 1000000 samples
I am trying to align data in a pandas dataframe using all kinds of metadata (sample_id_range, sample_rate, utc_range) but nothing seems to be in place. It actually looks like the sampling rate in wrongly reported for the GPIs.
What is the best practice to do that?
I am using a jupyter notebook / WSL / Win11 stack, which might cause problems, but the current readings are actually looking very good and I seldomly get sample dropouts.
Hi @MLehmann and welcome to the Joulescope forum!
Yes, the h/fs
topic only changes the output sample frequency for current
, voltage
, and power
. The current_range and the general purpose inputs always update at 2 Msps.
However, it is easy to correlate data from a single JS220. Simply use the sample_id
field, which always updates at the instrument’s 2 Msps rate. You will notice that the read_by_pyjoulescope_driver.py
example always divides by decimate_factor
which adjusts sample_id to be single incrementing based on the h/fs
value.
We have not done a great job independently documenting the available topics. However, the topics and their metadata are available:
python -m pyjoulescope_driver info -v *
I don’t know if the latest commit in the read_by_js_driver.py
fixed something, but the alignment now works by using sample_id_range
.
BTW: in a linux shell, the command for getting topics and metadata must be:
python -m pyjoulescope_driver info -v "*"
The sample_id
used in sample_id_range
in the example is already divided by the decimate factor:
sample_id = value['sample_id'] // decimate_factor
Using this value will align correctly for signals with the same decimate factor. However, this will not help align current with a GPI0, for example. You can modify the code to also store the original sample_id values, like this:
signal_state['sample_id_raw_range'] = [value['sample_id'], value['sample_id']]
...
signal_state['sample_id_raw_range'][-1] = value['sample_id'] + sample_count * decimate_factor