Export time, current and dig0 from .jls

Hi there,

using the nice example jls_plot.py (pyjoulescope_examples/bin/jls_plot.py at main · jetperch/pyjoulescope_examples · GitHub) I managed to, nicely, export time and current from a jls where I had captured only current.

Now, I have a capture that also has dig0 channel as well and I need that also the be exported.

Can you assist me on this? Don’t know how to read the file in order to access the digital channel as well.

Many thanks
Thanos

Hi @thanos_vgenis - The Python pyjls package that support JLS v2 includes a plot entry point that may work for you. Try something like this:

python -m pyjls plot  --signals current,gpi[0] --show {path/to/your.jls}

Be sure to replace {path/to/your.jls} with the actual path to the JLS file you want to display.

If you want to know what signals are in your jls file, use python -m pyjls info {path/to/your.jls}

Does this do what you want?

Hi there,

so many thanks for the instant reply!

tried the plot thing and got:

python -m pyjls plot --signals current --show test2.jls
usage: main.py [-h] {annotate,export,info,help} …
main.py: error: argument subparser_name: invalid choice: ‘plot’ (choose from ‘annotate’, ‘export’, ‘info’, ‘help’)

I am also facing issues with " python -m pyjls info {path/to/your.jls}" as well, I’ll come back on that.

BR,
Thanos

Hi again, regarding python -m pyjls info {path/to/your.jls}

I have two files, test2.jls with only current capture and test3.jls with current and dig0.

Running the info command I am getting:

python -m pyjls info test2.jls
Sources:
0: global_annotation_source
1: JS220-000582
Signals:
0: global_annotation_signal
1: current (3055752 samples at 1000000 Hz)
User Data:
0:

python -m pyjls info test3.jls
WARNING:2024-07-24 16:54:29,053:raw.c:351:pyjls.c:seek to 0
Traceback (most recent call last):
File “C:.…\AppData\Local\Programs\Python\Python38\lib\runpy.py”, line 194, in _run_module_as_main
return run_code(code, main_globals, None,
File “C:.…\AppData\Local\Programs\Python\Python38\lib\runpy.py”, line 87, in run_code
exec(code, run_globals)
File "C:.…\AppData\Local\Programs\Python\Python38\lib\site-packages\pyjls_main
.py", line 82, in
sys.exit(run())
File "C:.…\AppData\Local\Programs\Python\Python38\lib\site-packages\pyjls_main
.py", line 78, in run
return args.func(args)
File “C:.…\AppData\Local\Programs\Python\Python38\lib\site-packages\pyjls\entry_points\info.py”, line 44, in on_cmd
with Reader(args.filename) as r:
File “pyjls\binding.pyx”, line 498, in pyjls.binding.Reader.init
File “pyjls\binding.pyx”, line 251, in pyjls.binding._handle_rc
RuntimeError: rd_fsr_length IO[4]: Input/output error

This is consistent, I just can’t access a .jls file if there is a digital signal in the capture :frowning:
Please help, thanks in advance.

BR,
Thanos

Hi @thanos_vgenis,

I think that you may be running an old version of pyjls. To check:

pip show pyjls

You should see:

Name: pyjls
Version: 0.9.6
Summary: Joulescope™ file format
Home-page: https://joulescope.readthedocs.io
Author: Jetperch LLC
Author-email: joulescope-dev@jetperch.com
License: Apache 2.0
Location: C:\bin\Python3_12_4\Lib\site-packages
Requires: numpy, pywin32
Required-by: joulescope

If not, you should update:

pip install -U pyjls

The error on test3.jls looks like it was not closed correctly. The latest version of pyjls performs error recovery and should hopefully be able to open it. If not, you can recover it by replaying it to a new file. You use it like this:

python -m pyjls copy {src.jls} {dst.jls}

Does this help? Can you plot your JLS file?

Hi mliberty,

many thanks for this, I think we’re getting somewhere.

Sadly I am running python 3.0.8 due to matlab-python compatibility issues. So, for my python I am getting:

pip show pyjls
Name: pyjls
Version: 0.7.0
Summary: Joulescope™ file format
Home-page: https://joulescope.readthedocs.io
Author: Jetperch LLC
Author-email: joulescope-dev@jetperch.com
License: Apache 2.0
Location: c:.…\appdata\local\programs\python\python38\lib\site-packages
Requires: pywin32, numpy
Required-by: joulescope

Since you are the one maintaining pyjls as far as I can tell, may I ask if there is any way to use pyjls 0.9.6 on python 3.0.8? If not, I’ll find a way around this somehow.

BR,
Thanos

Do you really mean Python 3.0.8 from 2008 or 3.8 from 2019?

Although we don’t officially support either, 3.8 has a chance of being possible, but would likely require work on your side. We still support 3.9, and we dropped 3.8 support for some reason that I don’t recall. We don’t normally drop support unless something breaks.

We definitely do not support 3.0.8, and I suspect that it is not even possible.

Is Matlab compatibility really an issue? Why not install Python 3.12 separately for just this case? If you are on Windows, they work together just fine. You can download Python from python.org. You can install without modifying paths and then simply use the full path for all operations. I recommend installing Python 3.12.4 into C:\bin\Python3_12_4, and then you can do this:

C:\bin\Python3_12_4\python -m pip install pyjls
C:\bin\Python3_12_4\python -m plot --signals current,gpi[0] --show {path/to/your.jls}

Yeap, sorry, 3.8 of course.

Well, let me see what I can do, you’re right about it all.

I really need to export data to matlab and I need to do this with a manageable file size. Exporting jls to csv is not an option, I’ll try to find an alternative way.

Many thanks
Thanos

Can you update Matlab?

this is also one of the alternatives

Seems that 3.9 works with pyjls and is compatible to my Matlab version, hope it all works.

So many thanks, will keep you posted

BR,
Thanos

1 Like

Here I am again,

managed to do most of the stuff I needed, yet there are, still, some issue.

E.g., I have this capture:

python -m pyjls info test3.jls
Sources:
0: global_annotation_source
1: JS220-000582
Signals:
0: 0.global_annotation_signal
1: 1.current (7834428 samples at 1000000 Hz)
2: 1.gpi[0] (15724544 samples at 2000000 Hz)
User Data:
0:

do you have any idea why gpi[0] samples are not twice as many as current? Are the two signals not synchronized?

If I plot in matlab my current and dig[0] they look off compared to the Joulescope capture, they are shifted in time.
Is there a reference I need to pay attention to?

Many thanks
Thanos

Hi @thanos_vgenis ,

The JS220 samples everything at 2 Msps, but then it downsamples current, voltage, and power to 1 Msps. It needs to do this to fit all the information over USB HS. Although it needs to sample at 2 Msps for accurate 300 kHz analog bandwidth with a SAR ADC, it can downsample to 1 MHz digitally without affecting the 300 kHz bandwidth. The sample rates you see are as expected.

Each signal is recorded independently. Although samples from a single Joulescope are sampled synchronously, the JLS file usually does not necessarily contain the same starting sample for each signal. The JS220 sends each signal type independently. The packing between the float32 current, voltage and power are different than the 1-bit general-purpose inputs, so they arrive differently.

I see that pyjls plot does not time align the signals. I fixed this and released pyjls 0.9.7. Please update using:

python -m pip install -U pyjls

The plot entry point now has the time alignment code on lines 61-62 and 75-79.

In general, you can use the pyjls Reader methods sample_id_to_timestamp and timestamp_to_sample_id to convert between sample IDs and UTC timestamp in the time64 format. As you see in the plot entry point, we simply divide by time64.SECOND to compute the relative offset in seconds.

You can also extract a snippet across signals that is time aligned. See the extract pyjls entry point for an example.

Does this make sense and answer your question?

Yeap, I synced the signals and now I am, smoothly, running my post-processing.

Thank you so much for your instant and to the point support, highly impressed!

BR,
Thanos

1 Like