Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* MNT: Update telemetry generator to iterate over all packet definitions

- Add a polynomial calibrator for analog conversions

- Add logic for variable length BYTES

Some instruments don't provide the apId column, so we can calculate
it ourselves. We do need the integer apid for the XTCE file.
  • Loading branch information
greglucas committed Jul 22, 2024
1 parent ac3bc02 commit 2ba60f1
Show file tree
Hide file tree
Showing 18 changed files with 505 additions and 1,052 deletions.
433 changes: 433 additions & 0 deletions imap_processing/ccsds/excel_to_xtce.py

Large diffs are not rendered by default.

60 changes: 60 additions & 0 deletions imap_processing/tests/ccsds/test_excel_to_xtce.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
"""Testing for xtce generator template."""

import sys
from pathlib import Path
from unittest import mock

import pytest

from imap_processing.ccsds import excel_to_xtce

pytest.importorskip("openpyxl")


@pytest.fixture()
def filepath(tmpdir):
p = Path(tmpdir / "test_file.xlsx").resolve()
p.touch()
return p


# General test
@mock.patch("imap_processing.ccsds.excel_to_xtce.XTCEGenerator")
def test_main_general(mock_input, filepath):
"""Testing base main function."""
test_args = [
"test_script",
"--output",
"swe.xml",
f"{filepath}",
]
with mock.patch.object(sys, "argv", test_args):
excel_to_xtce.main()
mock_input.assert_called_once()


# Testing without required arguments
def test_main_inval_arg():
"""Testing with invalid instrument."""
test_args = [
"test_script",
"--output",
"glows.xml",
]
with mock.patch.object(sys, "argv", test_args):
with pytest.raises(SystemExit):
excel_to_xtce.main()


# File does not exist
def test_main_inval_file():
"""Testing with invalid file."""
test_args = [
"test_script",
"--instrument",
"glows",
"not-a-valid-file.txt",
]
with mock.patch.object(sys, "argv", test_args):
with pytest.raises(SystemExit):
excel_to_xtce.main()
11 changes: 11 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,13 @@ lint.ignore = ["D104", "PLR2004", "RUF200", "S311"]
# S603 unchecked input in subprocess call is fine in our tests
# PT006 Wrong type passed to first argument of @pytest.mark.parametrize
"*/tests/*" = ["D", "S101", "S603", "PT006"]
"tools/xtce*" = ["D"]

[tool.ruff.lint.pydocstyle]
convention = "numpy"

[tool.poetry.scripts]
imap_cli = 'imap_processing.cli:main'
imap_xtce = 'tools.xtce_generation.xtce_generator_template:main'
imap_xtce = 'imap_processing.ccsds.excel_to_xtce:main'

[tool.codespell]
ignore-words-list = "livetime"
Expand Down
86 changes: 0 additions & 86 deletions tools/tests/test_xtce_generator_template.py

This file was deleted.

Binary file removed tools/xtce_generation/26850.02-TLMDEF-04.xlsx
Binary file not shown.
Binary file removed tools/xtce_generation/TLM_SWP_20231006-121021.xlsx
Binary file not shown.
54 changes: 0 additions & 54 deletions tools/xtce_generation/ccsds_header_xtce_generator.py

This file was deleted.

Loading

0 comments on commit 2ba60f1

Please sign in to comment.