-
Notifications
You must be signed in to change notification settings - Fork 30
Fix header for BUFR version 2 #43
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
Conversation
021f0b8 to
67cb0e2
Compare
|
Do you mind providing a sample file and add a test for it? |
|
I was creating the test here and found the following weird thing: This passes: from pybufrkit.decoder import Decoder
from pybufrkit.encoder import Encoder
data = [
[
b'BUFR',
0, # file length (will be calculated)
2
],
[0, # section length (will be calculated)
0, # master table
0, # centre
0, # sequence number
False, # has section 2 (no)
'0000000', # flag bits
6, # data category
0, # data local subcategory
11, # master table version
10, # local table version
25, # year
3, # month
25, # day
13, # hour
45, # min
b'test1', # Extra bytes
],
[0, # section length (will be calculated)
'00000000', # reserved bits
1, # subsets
True, # is observation
False, # is compressed
'000000', # flag bits
# Definition follows
[]
],
[
0, # section length (will be calculated)
'00000000', # flag bits
[
[
] # flat data
]
],
[b'7777']
]
def test_optional_parameter_v2():
encoder = Encoder()
bufr_message = encoder.process(data)
assert bufr_message.sections[1].section_length.value == 22
assert bufr_message.local_bytes.value == b'test1'
decoder = Decoder()
decoded = decoder.process(bufr_message.serialized_bytes)
assert decoded.sections[1].section_length.value == 22
assert decoded.local_bytes.value == b'test1'This fails: from pybufrkit.decoder import Decoder
from pybufrkit.encoder import Encoder
data = [
[
b'BUFR',
0, # file length (will be calculated)
2
],
[0, # section length (will be calculated)
0, # master table
0, # centre
0, # sequence number
False, # has section 2 (no)
'0000000', # flag bits
6, # data category
0, # data local subcategory
11, # master table version
10, # local table version
25, # year
3, # month
25, # day
13, # hour
45, # min
b'test', # Extra bytes
],
[0, # section length (will be calculated)
'00000000', # reserved bits
1, # subsets
True, # is observation
False, # is compressed
'000000', # flag bits
# Definition follows
[]
],
[
0, # section length (will be calculated)
'00000000', # flag bits
[
[
] # flat data
]
],
[b'7777']
]
def test_optional_parameter_v2():
encoder = Encoder()
bufr_message = encoder.process(data)
assert bufr_message.sections[1].section_length.value == 21
assert bufr_message.local_bytes.value == b'test'
decoder = Decoder()
decoded = decoder.process(bufr_message.serialized_bytes)
assert decoded.sections[1].section_length.value == 21
assert decoded.local_bytes.value == b'test' |
|
This is expected. See this code comment pybufrkit/pybufrkit/encoder.py Lines 169 to 170 in 5128e2e
In the same doc that you were referring to, it says the following in 2.2
|
|
Thank you! I can almost read a technical document ;) I will finish the test cases and update the commit. |
According to: FM94-BUFR Encoding and Decoding Software User Guidelines Version 1.6 For BUFR Software Version 3.1 The header for BUFR version 2 doesn't have second field. Extra bytes are allowed for local use
67cb0e2 to
425d4a5
Compare
|
Thanks for the update |
According to:
FM94-BUFR Encoding and Decoding Software
User Guidelines
Version 1.6
For BUFR Software Version 3.1
The header for BUFR version 2 doesn't have second field. Extra bytes are allowed for local use