Skip to content

Commit

Permalink
Bugfix delayed descriptors (#137)
Browse files Browse the repository at this point in the history
* Bump version number

* Back to dev

* bug fix - short and extended replication factors set in as_bufr.

* flake8.
  • Loading branch information
david-i-berry authored Oct 16, 2024
1 parent 0552901 commit 5c551fa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ nosetests.xml
logs

# pycharm
.idea
.idea

# scratch directory
scratch
21 changes: 20 additions & 1 deletion csv2bufr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#
###############################################################################

__version__ = '0.8.2'
__version__ = '0.8.dev3'

import csv
from datetime import timezone, datetime
Expand Down Expand Up @@ -512,6 +512,15 @@ def as_bufr(self, use_cached: bool = False) -> bytes:
bufr_msg = codes_bufr_new_from_samples("BUFR4")
# set delayed replications, this is needed again as we only used it the
# first time to set the keys
if len(self.short_delayed_replications) > 0:
try:
codes_set_array(bufr_msg,
"inputShortDelayedDescriptorReplicationFactor",
self.short_delayed_replications)
except Exception as e:
msg = f"Error ({e}) setting inputShortDelayedDescriptorReplicationFactor" # noqa
raise RuntimeError(msg)

if len(self.delayed_replications) > 0:
try:
codes_set_array(bufr_msg,
Expand All @@ -520,6 +529,16 @@ def as_bufr(self, use_cached: bool = False) -> bytes:
except Exception as e:
msg = f"Error ({e}) setting inputDelayedDescriptorReplicationFactor" # noqa
raise RuntimeError(msg)

if len(self.extended_delayed_replications) > 0:
try:
codes_set_array(bufr_msg,
"inputExtendedDelayedDescriptorReplicationFactor", # noqa
self.extended_delayed_replications)
except Exception as e:
msg = f"Error ({e}) setting inputExtendedDelayedDescriptorReplicationFactor" # noqa
raise RuntimeError(msg)

# ============================
# iterate over keys and encode
# ============================
Expand Down

0 comments on commit 5c551fa

Please sign in to comment.