-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MNT/ENH: Add FLOAT and FILL options for spreadsheet dataType #701
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<xtce:SpaceSystem xmlns:xtce="http://www.omg.org/space/xtce" name="Test Instrument"> | ||
<xtce:Header date="2024-07-26 00:00:00" version="v1.2" author="IMAP SDC" /> | ||
<xtce:TelemetryMetaData> | ||
<xtce:ParameterTypeSet> | ||
<xtce:IntegerParameterType name="VERSION" signed="false"> | ||
<xtce:IntegerDataEncoding sizeInBits="3" encoding="unsigned" /> | ||
</xtce:IntegerParameterType> | ||
<xtce:IntegerParameterType name="TYPE" signed="false"> | ||
<xtce:IntegerDataEncoding sizeInBits="1" encoding="unsigned" /> | ||
</xtce:IntegerParameterType> | ||
<xtce:IntegerParameterType name="SEC_HDR_FLG" signed="false"> | ||
<xtce:IntegerDataEncoding sizeInBits="1" encoding="unsigned" /> | ||
</xtce:IntegerParameterType> | ||
<xtce:IntegerParameterType name="PKT_APID" signed="false"> | ||
<xtce:IntegerDataEncoding sizeInBits="11" encoding="unsigned" /> | ||
</xtce:IntegerParameterType> | ||
<xtce:IntegerParameterType name="SEQ_FLGS" signed="false"> | ||
<xtce:IntegerDataEncoding sizeInBits="2" encoding="unsigned" /> | ||
</xtce:IntegerParameterType> | ||
<xtce:IntegerParameterType name="SRC_SEQ_CTR" signed="false"> | ||
<xtce:IntegerDataEncoding sizeInBits="14" encoding="unsigned" /> | ||
</xtce:IntegerParameterType> | ||
<xtce:IntegerParameterType name="PKT_LEN" signed="false"> | ||
<xtce:IntegerDataEncoding sizeInBits="16" encoding="unsigned" /> | ||
</xtce:IntegerParameterType> | ||
<xtce:IntegerParameterType name="TEST_PACKET_SHCOARSE" signed="false"> | ||
<xtce:IntegerDataEncoding sizeInBits="32" encoding="unsigned" /> | ||
</xtce:IntegerParameterType> | ||
<xtce:IntegerParameterType name="TEST_PACKET_VAR_UINT" signed="false"> | ||
<xtce:IntegerDataEncoding sizeInBits="2" encoding="unsigned"> | ||
<xtce:DefaultCalibrator> | ||
<xtce:PolynomialCalibrator> | ||
<xtce:Term coefficient="1.5" exponent="0" /> | ||
<xtce:Term coefficient="2.5" exponent="1" /> | ||
</xtce:PolynomialCalibrator> | ||
</xtce:DefaultCalibrator> | ||
</xtce:IntegerDataEncoding> | ||
</xtce:IntegerParameterType> | ||
<xtce:IntegerParameterType name="TEST_PACKET_VAR_INT" signed="true"> | ||
<xtce:IntegerDataEncoding sizeInBits="4" encoding="signed" /> | ||
</xtce:IntegerParameterType> | ||
<xtce:IntegerParameterType name="TEST_PACKET_VAR_SINT" signed="true"> | ||
<xtce:IntegerDataEncoding sizeInBits="5" encoding="signed" /> | ||
</xtce:IntegerParameterType> | ||
<xtce:BinaryParameterType name="TEST_PACKET_VAR_BYTE"> | ||
<xtce:BinaryDataEncoding bitOrder="mostSignificantBitFirst"> | ||
<xtce:SizeInBits> | ||
<xtce:DynamicValue> | ||
<xtce:ParameterInstanceRef parameterRef="PKT_LEN" /> | ||
<xtce:LinearAdjustment slope="8" intercept="-70" /> | ||
</xtce:DynamicValue> | ||
</xtce:SizeInBits> | ||
</xtce:BinaryDataEncoding> | ||
</xtce:BinaryParameterType> | ||
<xtce:IntegerParameterType name="TEST_PACKET_VAR_FILL" signed="false"> | ||
<xtce:IntegerDataEncoding sizeInBits="3" encoding="unsigned" /> | ||
</xtce:IntegerParameterType> | ||
<xtce:FloatParameterType name="TEST_PACKET_VAR_FLOAT"> | ||
<xtce:FloatDataEncoding sizeInBits="32" encoding="IEEE-754" /> | ||
</xtce:FloatParameterType> | ||
<xtce:IntegerParameterType name="TEST_PACKET2_SHCOARSE" signed="false"> | ||
<xtce:IntegerDataEncoding sizeInBits="32" encoding="unsigned" /> | ||
</xtce:IntegerParameterType> | ||
<xtce:IntegerParameterType name="TEST_PACKET2_VAR1" signed="false"> | ||
<xtce:IntegerDataEncoding sizeInBits="2" encoding="unsigned" /> | ||
</xtce:IntegerParameterType> | ||
</xtce:ParameterTypeSet> | ||
<xtce:ParameterSet> | ||
<xtce:Parameter name="VERSION" parameterTypeRef="VERSION"> | ||
<xtce:LongDescription>CCSDS Packet Version Number (always 0)</xtce:LongDescription> | ||
</xtce:Parameter> | ||
<xtce:Parameter name="TYPE" parameterTypeRef="TYPE"> | ||
<xtce:LongDescription>CCSDS Packet Type Indicator (0=telemetry)</xtce:LongDescription> | ||
</xtce:Parameter> | ||
<xtce:Parameter name="SEC_HDR_FLG" parameterTypeRef="SEC_HDR_FLG"> | ||
<xtce:LongDescription>CCSDS Packet Secondary Header Flag (always 1)</xtce:LongDescription> | ||
</xtce:Parameter> | ||
<xtce:Parameter name="PKT_APID" parameterTypeRef="PKT_APID"> | ||
<xtce:LongDescription>CCSDS Packet Application Process ID</xtce:LongDescription> | ||
</xtce:Parameter> | ||
<xtce:Parameter name="SEQ_FLGS" parameterTypeRef="SEQ_FLGS"> | ||
<xtce:LongDescription>CCSDS Packet Grouping Flags (3=not part of group)</xtce:LongDescription> | ||
</xtce:Parameter> | ||
<xtce:Parameter name="SRC_SEQ_CTR" parameterTypeRef="SRC_SEQ_CTR"> | ||
<xtce:LongDescription>CCSDS Packet Sequence Count (increments with each new packet)</xtce:LongDescription> | ||
</xtce:Parameter> | ||
<xtce:Parameter name="PKT_LEN" parameterTypeRef="PKT_LEN"> | ||
<xtce:LongDescription>CCSDS Packet Length (number of bytes after Packet length minus 1)</xtce:LongDescription> | ||
</xtce:Parameter> | ||
<xtce:Parameter name="TEST_PACKET_SHCOARSE" parameterTypeRef="TEST_PACKET_SHCOARSE"> | ||
<xtce:LongDescription>Mission elapsed time</xtce:LongDescription> | ||
</xtce:Parameter> | ||
<xtce:Parameter name="TEST_PACKET_VAR_UINT" parameterTypeRef="TEST_PACKET_VAR_UINT"> | ||
<xtce:LongDescription>Unsgned integer data with conversion</xtce:LongDescription> | ||
</xtce:Parameter> | ||
<xtce:Parameter name="TEST_PACKET_VAR_INT" parameterTypeRef="TEST_PACKET_VAR_INT"> | ||
<xtce:LongDescription>Integer data</xtce:LongDescription> | ||
</xtce:Parameter> | ||
<xtce:Parameter name="TEST_PACKET_VAR_SINT" parameterTypeRef="TEST_PACKET_VAR_SINT"> | ||
<xtce:LongDescription>Signed integer data</xtce:LongDescription> | ||
</xtce:Parameter> | ||
<xtce:Parameter name="TEST_PACKET_VAR_BYTE" parameterTypeRef="TEST_PACKET_VAR_BYTE"> | ||
<xtce:LongDescription>Binary data - variable length</xtce:LongDescription> | ||
</xtce:Parameter> | ||
<xtce:Parameter name="TEST_PACKET_VAR_FILL" parameterTypeRef="TEST_PACKET_VAR_FILL"> | ||
<xtce:LongDescription>Fill data</xtce:LongDescription> | ||
</xtce:Parameter> | ||
<xtce:Parameter name="TEST_PACKET_VAR_FLOAT" parameterTypeRef="TEST_PACKET_VAR_FLOAT"> | ||
<xtce:LongDescription>Float data</xtce:LongDescription> | ||
</xtce:Parameter> | ||
<xtce:Parameter name="TEST_PACKET2_SHCOARSE" parameterTypeRef="TEST_PACKET2_SHCOARSE"> | ||
<xtce:LongDescription>Mission elapsed time</xtce:LongDescription> | ||
</xtce:Parameter> | ||
<xtce:Parameter name="TEST_PACKET2_VAR1" parameterTypeRef="TEST_PACKET2_VAR1" shortDescription="Variable 1 short desc"> | ||
<xtce:LongDescription>Variable 1 - long desc</xtce:LongDescription> | ||
</xtce:Parameter> | ||
</xtce:ParameterSet> | ||
<xtce:ContainerSet> | ||
<xtce:SequenceContainer name="CCSDSPacket" abstract="true"> | ||
<xtce:EntryList> | ||
<xtce:ParameterRefEntry parameterRef="VERSION" /> | ||
<xtce:ParameterRefEntry parameterRef="TYPE" /> | ||
<xtce:ParameterRefEntry parameterRef="SEC_HDR_FLG" /> | ||
<xtce:ParameterRefEntry parameterRef="PKT_APID" /> | ||
<xtce:ParameterRefEntry parameterRef="SEQ_FLGS" /> | ||
<xtce:ParameterRefEntry parameterRef="SRC_SEQ_CTR" /> | ||
<xtce:ParameterRefEntry parameterRef="PKT_LEN" /> | ||
</xtce:EntryList> | ||
</xtce:SequenceContainer> | ||
<xtce:SequenceContainer name="TEST_PACKET"> | ||
<xtce:BaseContainer containerRef="CCSDSPacket"> | ||
<xtce:RestrictionCriteria> | ||
<xtce:Comparison parameterRef="PKT_APID" value="1" useCalibratedValue="false" /> | ||
</xtce:RestrictionCriteria> | ||
</xtce:BaseContainer> | ||
<xtce:EntryList> | ||
<xtce:ParameterRefEntry parameterRef="TEST_PACKET_SHCOARSE" /> | ||
<xtce:ParameterRefEntry parameterRef="TEST_PACKET_VAR_UINT" /> | ||
<xtce:ParameterRefEntry parameterRef="TEST_PACKET_VAR_INT" /> | ||
<xtce:ParameterRefEntry parameterRef="TEST_PACKET_VAR_SINT" /> | ||
<xtce:ParameterRefEntry parameterRef="TEST_PACKET_VAR_BYTE" /> | ||
<xtce:ParameterRefEntry parameterRef="TEST_PACKET_VAR_FILL" /> | ||
<xtce:ParameterRefEntry parameterRef="TEST_PACKET_VAR_FLOAT" /> | ||
</xtce:EntryList> | ||
</xtce:SequenceContainer> | ||
<xtce:SequenceContainer name="TEST_PACKET2"> | ||
<xtce:BaseContainer containerRef="CCSDSPacket"> | ||
<xtce:RestrictionCriteria> | ||
<xtce:Comparison parameterRef="PKT_APID" value="15" useCalibratedValue="false" /> | ||
</xtce:RestrictionCriteria> | ||
</xtce:BaseContainer> | ||
<xtce:EntryList> | ||
<xtce:ParameterRefEntry parameterRef="TEST_PACKET2_SHCOARSE" /> | ||
<xtce:ParameterRefEntry parameterRef="TEST_PACKET2_VAR1" /> | ||
</xtce:EntryList> | ||
</xtce:SequenceContainer> | ||
</xtce:ContainerSet> | ||
</xtce:TelemetryMetaData> | ||
</xtce:SpaceSystem> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,21 +12,36 @@ | |
|
||
|
||
@pytest.fixture() | ||
def filepath(tmpdir): | ||
p = Path(tmpdir / "test_file.xlsx").resolve() | ||
p.touch() | ||
def excel_file(): | ||
p = Path(__file__).parent / "test_data" / "excel_to_xtce_test_file.xlsx" | ||
return p | ||
|
||
|
||
def test_generated_xml(excel_file, tmp_path): | ||
"""Make sure we are producing the expected contents within the XML file. | ||
|
||
To produce a new expected output file the following command can be used. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good to know! This makes me wonder, do we have readme for this cli tool? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have an issue to make this better! On my list... |
||
imap_xtce imap_processing/tests/ccsds/test_data/excel_to_xtce_test_file.xlsx | ||
--output imap_processing/tests/ccsds/test_data/expected_output.xml | ||
""" | ||
generator = excel_to_xtce.XTCEGenerator(excel_file) | ||
output_file = tmp_path / "output.xml" | ||
generator.to_xml(output_file) | ||
|
||
expected_file = excel_file.parent / "expected_output.xml" | ||
with open(output_file) as f, open(expected_file) as f_expected: | ||
assert f.read() == f_expected.read() | ||
|
||
|
||
# General test | ||
@mock.patch("imap_processing.ccsds.excel_to_xtce.XTCEGenerator") | ||
def test_main_general(mock_input, filepath): | ||
def test_main_general(mock_input, excel_file): | ||
"""Testing base main function.""" | ||
test_args = [ | ||
"test_script", | ||
"--output", | ||
"swe.xml", | ||
f"{filepath}", | ||
f"{excel_file}", | ||
] | ||
with mock.patch.object(sys, "argv", test_args): | ||
excel_to_xtce.main() | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went down the road of mocking/creating this spreadsheet in code, but it ended up being a lot more confusing in my opinion to follow what was being changed/updated. So this seemed reasonable to add a small-ish binary file for testing this routine for clarity's sake.