Skip to content

Commit

Permalink
bug fix - short and extended replication factors set in as_bufr.
Browse files Browse the repository at this point in the history
  • Loading branch information
david-i-berry committed Oct 16, 2024
1 parent 7dfb16b commit b8d762a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
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
20 changes: 20 additions & 0 deletions csv2bufr/__init__.py
Original file line number Diff line number Diff line change
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,17 @@ 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",
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 b8d762a

Please sign in to comment.