From 24e7da9ef0d42713c1c2c0ea6562cb95ec21729d Mon Sep 17 00:00:00 2001
From: Destiny Kuehn <destiny.kuehn@student.nmt.edu>
Date: Thu, 14 Nov 2024 15:25:32 -0700
Subject: [PATCH] Fix channel comment bug

---
 nexus/nexus.py         | 4 ++--
 nexus/obspyImproved.py | 5 +++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/nexus/nexus.py b/nexus/nexus.py
index cf4a4ae2..5447962d 100755
--- a/nexus/nexus.py
+++ b/nexus/nexus.py
@@ -16,6 +16,7 @@ from PySide6.QtCore import Qt
  
 from obspy import read_inventory
 from obspy.core.inventory import Network, Station, Equipment
+from obspy.core.inventory.util import Comment
 
 from .NRLWizard import NRLWizard, DATALOGGER, SENSOR
 from . import obspyImproved
@@ -525,8 +526,7 @@ class ChannelNode(InventoryNode):
         try:
             self._inv_obj.comments[0].value = value
         except:
-            self._inv_obj.comments = [obspyImproved.Comment(
-                value=value)]
+            self._inv_obj.comments.append(Comment(value))
         return True
     channel_comment = property(get_comment, set_comment)
     FM.append(channel_comment)
diff --git a/nexus/obspyImproved.py b/nexus/obspyImproved.py
index 5336c075..f1c6bd62 100644
--- a/nexus/obspyImproved.py
+++ b/nexus/obspyImproved.py
@@ -12,6 +12,7 @@ from obspy import Inventory
 from obspy import UTCDateTime
 from obspy.core.inventory import (Network, Station, Channel,
                                   Site, Equipment)
+from obspy.core.inventory.util import Comment
 from obspy.io.mseed.core import _is_mseed
 from obspy.io.mseed import util
 
@@ -228,6 +229,10 @@ class InventoryIm(Inventory):
             if self.extend_epoch(inv_cha, start, end):
                 inv_cha._new = new
 
+        # add Comment object to Channel
+        comment = Comment('')
+        inv_cha.comments.append(comment)
+
     def extend_epoch(self, inv, start, end):
         ret = False
         if inv.start_date > start:
-- 
GitLab