-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add spp.create_packet_list function #160
Open
medley56
wants to merge
2
commits into
main
Choose a base branch
from
add-list-packets-function
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,33 @@ | ||
"""Tests for main space_packet_parser.__init__ module""" | ||
import space_packet_parser | ||
import space_packet_parser as spp | ||
from space_packet_parser.xtce import definitions | ||
|
||
|
||
def test_load_xtce(jpss_test_data_dir, tmp_path): | ||
"""Test high level function for loading an XTCE definition file""" | ||
xtcedef = space_packet_parser.load_xtce(jpss_test_data_dir / "jpss1_geolocation_xtce_v1.xml") | ||
xtcedef = spp.load_xtce(jpss_test_data_dir / "jpss1_geolocation_xtce_v1.xml") | ||
assert isinstance(xtcedef, definitions.XtcePacketDefinition) | ||
|
||
outpath = tmp_path / "test_output.xml" | ||
xtcedef.write_xml(outpath) | ||
assert outpath.exists() | ||
|
||
assert space_packet_parser.load_xtce(outpath) == xtcedef | ||
assert spp.load_xtce(outpath) == xtcedef | ||
|
||
|
||
def test_create_packet_list(jpss_test_data_dir): | ||
"""Test directly creating a list of Packets from a data file and a definition""" | ||
jpss_packets = jpss_test_data_dir / "J01_G011_LZ_2021-04-09T00-00-00Z_V01.DAT1" | ||
jpss_xtce = jpss_test_data_dir / "jpss1_geolocation_xtce_v1.xml" | ||
|
||
# Single file | ||
packet_list = spp.create_packet_list(jpss_packets, jpss_xtce) | ||
assert len(packet_list) == 7200 | ||
assert packet_list[0]["PKT_APID"] == 11 | ||
assert packet_list[-1]["PKT_APID"] == 11 | ||
|
||
# Multiple files | ||
packet_list = spp.create_packet_list([jpss_packets, jpss_packets], jpss_xtce) | ||
assert len(packet_list) == 14400 | ||
assert packet_list[0]["PKT_APID"] == 11 | ||
assert packet_list[-1]["PKT_APID"] == 11 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we want to add this option if we are thinking about getting rid of the generator on the definition? I'm wondering if we want to accept a generator instead here, or call this method
create_ccsds_packet_list
or something like that?I'm still torn on how this should all behave and how to make it simple and general at the same time.
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.
If we accept a custom generator function then I think we want to allow the user to pass kwargs to it. We certainly need it for the
ccsds_generator
, right? One option could be to disallow additional kwarg passing and tell the user they have to pass the generator as afunctools.partial
with options already set. I'm not sure what is easier for people.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.
Thinking broader about what it means to be generic to any packet type with XTCE parsing. We probably shouldn't provide a generator like I mentioned, instead the XTCE parsing would yield the packets that it produces during its parsing. This would also mean removing the ccsds_generator from the
definition.packet_generator()
routine.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.
Linking to #140.
I'm still not understanding how we would decide how many bytes to read from the source before we instantiate a
Packet
for parsing without letting users define that logic for themselves. For CCSDS it's obvious but it's not obvious to me how we would do it without a CCSDS header to tell us how many bytes are in the packet. e.g. How many bytes should go in thebinary_data
attribute of a newPacket
object?