Extract GPI data from JLS file

Hello,

I have a recording in which GPI signals are used. Opening the JLS file in Joulescope UI works just fine, I see the correct INx signals.

But how do I extract INx from the JLS file? (with python)

Any help is appreciated.

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?

Hi @mliberty, thank you for the rapid response.

I tested the script for JLS v1 and it does exactly what I need it to do.
Appreciate the inclusion of both JLS v1 and v2 - this will be useful in the future.

thank you for the solutions!

1 Like