Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
0cd32ae
Added clustering and mode tracking
Oct 21, 2025
1f711db
Added clustering and mode tracking
Oct 21, 2025
d34018c
Merge branch 'main' of https://github.com/au650680/example-shm
Oct 21, 2025
a487753
Merge branch 'main' into clustering_and_mode_tracking
Oct 21, 2025
62bddcd
Edits to last pull
Oct 28, 2025
aedc878
Bug fix and small change to plot_cluster
Oct 31, 2025
802139e
Small changes
Nov 5, 2025
9d145fd
Small changes
Nov 5, 2025
ee4f49a
Model update module and other changes
Nov 11, 2025
1e08818
Update README.md
Nov 11, 2025
c8ba534
Changed the typing of some arguments in some functions
Nov 11, 2025
e7e0926
Merge branch 'clustering_and_mode_tracking' into fix_clustering_and_m…
Nov 12, 2025
708df2c
Delete init file
Nov 12, 2025
8e8858a
Multiple changes and fixes
Nov 18, 2025
dedbf22
Simplifications to commit
Nov 21, 2025
23e1f4d
TopicsToPublish placeholder names
Nov 21, 2025
47da3c7
New record and replay data
Nov 21, 2025
bbdc720
Minor changes to comments
Nov 21, 2025
bbf56aa
Updated record and replay functions
Nov 24, 2025
d83cc29
Update model_update.py
Nov 24, 2025
0600840
Minor changes
Nov 25, 2025
afd27e1
Fixes and looping replay function
Nov 25, 2025
f9b3e39
Revert back to "sysid" key in configurations
Nov 25, 2025
8acef14
YAFEM model function is added to constants.py
Nov 27, 2025
67ac538
Refactor MQTT record/replay and change to model update information
Nov 27, 2025
e887bd4
Change recording topic to match with subscribe topic.
Nov 27, 2025
0875f7b
New topic names and origon added to replay config
Nov 28, 2025
32f667a
Hotfix for model update functions
Nov 28, 2025
ad7a8fc
Updated poetry.lock
Nov 28, 2025
c8b7599
Updated USERGUIDE
Nov 28, 2025
ca522ac
Added record and replay guide
Nov 28, 2025
89f3239
Small improvements
Feb 25, 2026
2e5c96b
Replay function edit and beam experiment data added
Mar 5, 2026
d348023
Changes to replay function
Mar 5, 2026
0b8a54e
Merge remote-tracking branch 'upstream/main' into fix_clustering_and_…
Mar 9, 2026
f6b2e21
Updated plot_sysid.py
Mar 9, 2026
0900daa
Added readme file, reference results for beam experiment, bug fixes
Mar 11, 2026
7c34e4e
Update beam import
Mar 11, 2026
14f6c16
replay functionality added as example
Mar 11, 2026
90e5d7a
Included record folder to project
Mar 11, 2026
4fe7578
Change to file path in replay.py
Mar 11, 2026
7962ed8
Removed os library
Mar 11, 2026
270dc7b
Removed os pathing from MU
Mar 11, 2026
6d6bf07
Fixed test
Mar 12, 2026
f20646b
More test fixes
Mar 12, 2026
626c12f
Merge branch 'main' into fix_clustering_and_model_update
au650680 Mar 12, 2026
ad5594d
removing sysid reference
Mar 12, 2026
fb74c97
Merge remote-tracking branch 'upstream/main' into fix_clustering_and_…
Mar 12, 2026
02d024c
Merge branch 'fix_clustering_and_model_update' of https://github.com/…
Mar 12, 2026
24d2213
Increased covariance threshold in sysid test
Mar 16, 2026
c40834d
Increased covariance threshold even more
Mar 16, 2026
e5d3f9d
Revert threshold changes
Mar 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/test.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"MQTT": {
"host": "mqtt.eclipseprojects.io",
"host": "public.mqttserver.eu",
"port": 1883,
"userId": "",
"password": "",
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[pytest]
minversion = 8.3
pythonpath = src src/data src/methods tests
pythonpath = src src/data src/methods tests models
testpaths =
tests
addopts = --cov=src --ignore=src/examples --cov-report=term-missing --cov-report=html
Expand Down
4 changes: 2 additions & 2 deletions src/pt_mock/publish_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ def main(config_path: str = "config/R-PI.json",
offset_path: str = "config/offset.json",
run_once: bool = False) -> None:
config = load_config(config_path)
mqtt_config = config["sysid"]
mqtt_client, _, _ = setup_mqtt_client(mqtt_config)
mqtt_config = config["MQTT"]
mqtt_client = setup_mqtt_client(mqtt_config,mqtt_config["TopicsToSubscribe"][0])

mqtt_client.connect(mqtt_config["host"], mqtt_config["port"], 60)
mqtt_client.loop_start()
Expand Down
6 changes: 4 additions & 2 deletions tests/integration/data/accel/hbk/test_accelerometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ def mqtt_client():
mqtt_config["ClientID"] = f"test_{uuid.uuid4().hex[:6]}"

topic_index = 0
client, selected_topic = setup_mqtt_client(mqtt_config, topic_index)
client = setup_mqtt_client(mqtt_config, topic_index)

client.connect(mqtt_config["host"], mqtt_config["port"], 60)
client.loop_start()
connect_delay = float(os.environ.get("MQTT_CONNECT_DELAY"))
time.sleep(connect_delay)

yield client, selected_topic
topic = mqtt_config["TopicsToSubscribe"][0]

yield client, topic
client.loop_stop()
client.disconnect()

Expand Down
4 changes: 2 additions & 2 deletions tests/integration/data/accel/hbk/test_aligner.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def mqtt_client_and_config():
mqtt_config = config["MQTT"].copy()
mqtt_config["ClientID"] = f"test_{uuid.uuid4().hex[:6]}"

client, _ = setup_mqtt_client(mqtt_config, topic_index=0)
client = setup_mqtt_client(mqtt_config, mqtt_config["TopicsToSubscribe"][0])
client.connect(mqtt_config["host"], mqtt_config["port"], 60)
client.loop_start()
time.sleep(connect_delay)
Expand All @@ -37,7 +37,7 @@ def mqtt_setup():
mqtt_config["ClientID"] = f"test_{uuid.uuid4().hex[:6]}"

# Setup MQTT client once
client, _ = setup_mqtt_client(mqtt_config, 0)
client = setup_mqtt_client(mqtt_config, mqtt_config["TopicsToSubscribe"][0])
client.connect(mqtt_config["host"], mqtt_config["port"], 60)
client.loop_start()
time.sleep(connect_delay)
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/data/comm/test_mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def test_setup_mqtt_client_invalid_index():
"port": 1883
}

with pytest.raises(ValueError):
setup_mqtt_client(dummy_config, topic_index=5)
with pytest.raises(IndexError):
setup_mqtt_client(dummy_config, dummy_config["TopicsToSubscribe"][5])


def test_on_connect_callback_failure():
Expand Down Expand Up @@ -118,7 +118,7 @@ def test_setup_mqtt_client():
"port": 1883
}
# Unpack the returned tuple
client, selected_topic = setup_mqtt_client(dummy_config)
client = setup_mqtt_client(dummy_config, dummy_config["TopicsToSubscribe"][0])

# Check that the client has the correct client_id.
client_id = client._client_id.decode() if isinstance(client._client_id, bytes) else client._client_id
Expand Down
5 changes: 2 additions & 3 deletions tests/integration/methods/test_sys_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def test_sysid():
stored_cov_damping = stored_data['cov_damping']
stored_mode_shapes = stored_data['mode_shapes']


tolerance = 0.4
assert np.allclose(frequencies, stored_frequencies, atol=tolerance, equal_nan=True), "Frequencies do not match!"
assert np.allclose(cov_freq, stored_cov_freq, atol=tolerance, equal_nan=True), "Covariance frequencies do not match!"
Expand Down Expand Up @@ -90,11 +89,11 @@ def test_get_oma_results_integration(mocker):

mock_aligner.extract.return_value = (mock_data, mock_timestamp)

sysid_output, timestamp = sysid.get_sysid_results(number_of_minutes, mock_aligner, fs)
sysid_output, timestamp = sysid.get_sysid_output(number_of_minutes, mock_aligner, fs)

assert isinstance(sysid_output, dict)
assert "Fn_poles" in sysid_output
assert timestamp == mock_timestamp
assert timestamp == mock_timestamp.isoformat()


def test_oma_raises_on_empty_data():
Expand Down
7 changes: 3 additions & 4 deletions tests/integration/mock_pt_test/test_publish_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@
@pytest.fixture(scope="function")
def mqtt_client():
config = load_config("config/test.json")
mqtt_config = config["sysid"].copy()
mqtt_config = config["MQTT"].copy()
mqtt_config["ClientID"] = f"test_{uuid.uuid4().hex[:6]}"
client = setup_mqtt_client(mqtt_config)
client = setup_mqtt_client(mqtt_config,mqtt_config["TopicsToSubscribe"][0])
client.connect(mqtt_config["host"], mqtt_config["port"], 60)
client.loop_start()
time.sleep(1.0)
yield client
client.loop_stop()
client.disconnect()


def test_send_batch_actual_publish(mqtt_client):
samples = [0.1 * i for i in range(SAMPLES_PER_MESSAGE)]
batch = Batch(
Expand Down Expand Up @@ -81,7 +80,7 @@ def test_main_falls_back_when_offset_config_is_corrupt(mock_file):
}
}
mock_sensor.return_value = MagicMock()
mock_mqtt.return_value = (MagicMock(), "topic")
mock_mqtt.return_value = (MagicMock())
with patch("pt_mock.publish_samples.time.sleep", return_value=None):
main(run_once=True)
assert mock_send.call_count == 2
Expand Down
8 changes: 5 additions & 3 deletions tests/unit/methods/test_sys_id_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def test_publish_oma_results_retries_and_publishes_once(mocker):
aligner = MagicMock()
aligner.client = MagicMock()

publish_sysid_output(0.1, aligner, mock_client, "test/topic", fs)
# publish_sysid_output(0.1, aligner, mock_client, "test/topic", fs)
publish_sysid_output(mock_client, ["test/topic"], 0.1, fs)

assert mock_client.publish.called
assert mock_client.publish.call_count == 1
Expand All @@ -129,15 +130,16 @@ def test_setup_client_with_multiple_topics(mocker):
mqtt_config = {
"host": "localhost",
"port": 1883,
"topics": ["topic1", "topic2"]
"TopicsToSubscribe": ["topic1", "topic2"]
}

extract_mock = mocker.patch("methods.sysid.extract_fs_from_metadata", return_value=123.0)

mock_mqtt_client = MagicMock()
mocker.patch("methods.sysid.setup_mqtt_client", return_value=(mock_mqtt_client, None))
mocker.patch("methods.sysid.setup_mqtt_client", return_value=(mock_mqtt_client))

client, fs = setup_client(mqtt_config)
client.loop_stop()

extract_mock.assert_called_once_with(mqtt_config)
client.connect.assert_called_once_with("localhost", 1883, 60)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/mock_pt_test/test_publish_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def test_main_executes_sensor_loop_once(self, _, mock_adxl,
mock_load_config.return_value = {
"MQTT": {
"ClientID": "test-client",
"host": "mqtt.eclipseprojects.io",
"host": "public.mqttserver.eu",
"port": 1883,
"userId": "",
"password": "",
Expand Down
Loading