Skip to content

Commit

Permalink
Update tables v38, v39. Bump version
Browse files Browse the repository at this point in the history
Also update talbespreparer to accomodate latest WMO tables format
changes
  • Loading branch information
ywangd committed Feb 18, 2023
1 parent 16d5873 commit 14ba4f5
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pybufrkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
UnknownDescriptor,
PyBufrKitError)

__version__ = '0.2.19'
__version__ = '0.2.20'
__author__ = '[email protected]'

LOGGER = logging.getLogger('PyBufrKit')
Expand Down
2 changes: 1 addition & 1 deletion pybufrkit/tables/0/0_0/38/TableB.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pybufrkit/tables/0/0_0/38/TableD.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pybufrkit/tables/0/0_0/38/code_and_flag.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pybufrkit/tables/0/0_0/39/TableB.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pybufrkit/tables/0/0_0/39/TableD.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pybufrkit/tables/0/0_0/39/code_and_flag.json

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions pybufrkit/tablespreparer.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def convert_tables_from_zip(version, data):
table_code_and_flag = {}
for fileinfo in zf.infolist():
if fileinfo.filename.startswith('BUFR4-{}{}BUFRCREX_TableB_en_'.format(version, os.path.sep)):
print('Table B: ' + fileinfo.filename)
table_b.update(process_table_b(zf.read(fileinfo).decode('utf-8')))
elif fileinfo.filename.startswith('BUFR4-{}{}BUFR_TableD_en_'.format(version, os.path.sep)):
table_d.update(process_table_d(zf.read(fileinfo).decode('utf-8')))
Expand Down Expand Up @@ -69,11 +70,13 @@ def write_tables(version, tables, output_dir):
def process_table_b(content):
lines = csv.reader(io.StringIO(content), quoting=csv.QUOTE_MINIMAL)
next(lines) # skip header
# WMO output is inconsistent and can have extra comma after 3rd column (name)
offset = 0
d = {}
for line in lines:
crex_scale = 0 if line[10] == '' else int(line[10])
crex_data_width = 0 if line[11] == '' else int(line[11])
d[line[2]] = [line[3], line[5], int(line[6]), int(line[7]), int(line[8]), line[9], crex_scale, crex_data_width]
crex_scale = 0 if line[9 + offset] == '' else int(line[9 + offset])
crex_data_width = 0 if line[10 + offset] == '' else int(line[10 + offset])
d[line[2]] = [line[3], line[4 + offset], int(line[5 + offset]), int(line[6 + offset]), int(line[7 + offset]), line[8 + offset], crex_scale, crex_data_width]
return d


Expand Down

0 comments on commit 14ba4f5

Please sign in to comment.