Skip to content

Commit

Permalink
Fixed plot entry point to time align signals.
Browse files Browse the repository at this point in the history
  • Loading branch information
mliberty1 committed Jul 25, 2024
1 parent 20283a6 commit e15e68a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
This file contains the list of changes made to the JLS project.


## 0.9.7

2024 Jul 24

* Fixed plot entry point to time align signals.


## 0.9.6

2024 Jun 28
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ cmake_minimum_required (VERSION 3.10)
set(PARENT_PROJECT_DIR ${PROJECT_SOURCE_DIR})
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE) # universal2
project(JLS
VERSION 0.9.6
VERSION 0.9.7
LANGUAGES C)
SET(PROJECT_PREFIX JLS)
SET(VERSION_STRING "${PROJECT_VERSION}")
Expand Down
2 changes: 1 addition & 1 deletion include/jls/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ JLS_CPP_GUARD_START
// Use version_update.py to update.
#define JLS_VERSION_MAJOR 0
#define JLS_VERSION_MINOR 9
#define JLS_VERSION_PATCH 6
#define JLS_VERSION_PATCH 7

/**
* \brief Macro to encode version to uint32_t.
Expand Down
16 changes: 13 additions & 3 deletions pyjls/entry_points/plot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021-2022 Jetperch LLC
# Copyright 2021-2024 Jetperch LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from pyjls import Reader, SignalType, SummaryFSR
from pyjls import Reader, SignalType, SummaryFSR, time64
import logging
import numpy as np
import sys
Expand Down Expand Up @@ -57,6 +57,10 @@ def on_cmd(args):
signals = [s for s in r.signals.values()]
signals = [s for s in signals if s.signal_type == SignalType.FSR]
ax1, ax = None, None

# find the earliest starting time for any signal (time64)
t_plot_start = min([r.sample_id_to_timestamp(signal.signal_id, 0) for signal in signals])

for idx, signal in enumerate(signals):
ax = f.add_subplot(len(signals), 1, idx + 1, sharex=ax1)
if ax1 is None:
Expand All @@ -67,7 +71,13 @@ def on_cmd(args):
incr = signal.length // args.sample_count
length = signal.length // incr
data = r.fsr_statistics(signal.signal_id, 0, incr, length)
x = np.arange(0, length, dtype=np.float64) * (incr / signal.sample_rate)

# compute each sample's time relative to t_plot_start (float seconds)
t_start = (r.sample_id_to_timestamp(signal.signal_id, 0) - t_plot_start) / time64.SECOND
s_end = (length - 1) * incr
t_end = (r.sample_id_to_timestamp(signal.signal_id, s_end) - t_plot_start) / time64.SECOND
x = np.linspace(t_start, t_end, length, dtype=np.float64)

if not args.hide_min_max:
ax.fill_between(x, data[:, SummaryFSR.MAX], data[:, SummaryFSR.MIN], alpha=0.2)
ax.plot(x, data[:, SummaryFSR.MEAN])
Expand Down
2 changes: 1 addition & 1 deletion pyjls/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.


__version__ = "0.9.6"
__version__ = "0.9.7"

__title__ = "pyjls"
__description__ = 'Joulescope™ file format'
Expand Down

0 comments on commit e15e68a

Please sign in to comment.