Extract GPI data from JLS file

Hi @edgarkipans, and welcome to the Joulescope forum! For Joulescope UI 1.0 alpha, we switched the JLS v2 file format. All prior versions used the JLS v1 format.

Here is an example for how you can extract the GPI signals for JLS v1:

# Copyright 2023 Jetperch LLC
# Licensed under the Apache License, Version 2.0

from joulescope.data_recorder import DataReader

filename = r'C:\tmp\js110_v1.jls'

r = DataReader().open(filename)
try:
    sample_now, sample_end = r.sample_id_range
    block_size = int(r.sampling_frequency)  # fetch in 1 second blocks
    while True:
        if sample_now >= sample_end:
            break
        sample_next = min(sample_end, sample_now + block_size)
        data = r.samples_get(sample_now, sample_next, units='samples')
        # use current_lsb for in0, voltage_lsb for in1
        block = data['signals']['current_lsb']['value']
        print(block[:10])  # do something here
        sample_now = sample_next
finally:
    r.close()

JLS v2 is a more flexible file format that can store any signal you would like. For JLS v2 files recorded with Joulescope UI 1.0, here is how you can extract gpi[0]:

# Copyright 2023 Jetperch LLC
# Licensed under the Apache License, Version 2.0

from pyjls import Reader

filename = r'C:\tmp\js220_v2.jls'

with Reader(filename) as r:
    signals_filt = [s for s in r.signals.values() if s.name == 'gpi[0]']
    assert(len(signals_filt) == 1)
    signal = signals_filt[0]
    sample_now, sample_end = 0, signal.length
    block_size = int(signal.sample_rate)  # fetch in 1 second blocks
    while True:
        if sample_now >= sample_end:
            break
        sample_next = min(sample_end, sample_now + block_size)
        data = r.fsr(signal.signal_id, sample_now, sample_next - sample_now)
        print(data[:10])  # do something here
        sample_now = sample_next

Does this answer your question and help you get the INx data you want?