From ac2bc330549a16f95bf755079c644427b1162b0f Mon Sep 17 00:00:00 2001
From: Michael McWilliam <mimc@dtu.dk>
Date: Fri, 19 Oct 2018 11:58:26 +0200
Subject: [PATCH] Some minor bug fixes

---
 wetb/hawc2/hawc2_simulation.py | 2 ++
 wetb/hawc2/st_file.py          | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/wetb/hawc2/hawc2_simulation.py b/wetb/hawc2/hawc2_simulation.py
index f3096d0..244ea68 100644
--- a/wetb/hawc2/hawc2_simulation.py
+++ b/wetb/hawc2/hawc2_simulation.py
@@ -153,6 +153,8 @@ class Hawc2_Simulation(object):
         old_home = os.getcwd()
 
         # Change to the htc directory
+        if not os.path.isdir(self.write_directory):
+            os.mkdir(self.write_directory)
         os.chdir(self.write_directory)
 
         # scale sensors for writing
diff --git a/wetb/hawc2/st_file.py b/wetb/hawc2/st_file.py
index 03f9440..ae29fb8 100644
--- a/wetb/hawc2/st_file.py
+++ b/wetb/hawc2/st_file.py
@@ -176,6 +176,7 @@ class StBaseData(object):
         else:
             raise IndexError('The keys cannot have more than 3 terms')
         if len(sub_set_data)!=len(val):
+            print('The size of the data is %d and the size of the value is %d'%(len(sub_set_data), len(val)))
             raise IndexError('The value is not the same size as the data')
         if data_id in key_str:
             col_id = key_str.index(data_id)
@@ -277,6 +278,9 @@ class StBaseData(object):
             if not is_int(header_words[0]):
                 raise Exception('First term in the header of an ST file must be the number of main sets')
             no_maindata_sets = int(header_words[0])
+            if no_maindata_sets != txt.count("#"):
+                print('About to throw an error because the file "%s" does not have the correct number of # characters'%(filename)) 
+                print('The number of sets in the header is %d and the number of sets in the file is %d'%(no_maindata_sets,txt.count("#"))) 
             assert no_maindata_sets == txt.count("#")
         self.main_data_sets = {}
         for mset in main_sets[1:]:
-- 
GitLab