Repository: PIC-IRIS/PH5 (language: python)

Issue:
[BUG] unsimpleton has error after #451
**Describe the bug**
After segdreader has been changed for segdtoph5 work  with SmartSolo segd (#451), error happens when running unsimpleton:
```
Traceback (most recent call last):
  File "/Users/ldam/opt/anaconda3/envs/ph5/bin/unsimpleton", line 11, in <module>
    load_entry_point('ph5', 'console_scripts', 'unsimpleton')()
  File "/Users/ldam/Documents/GIT/PH5/ph5/utilities/unsimpleton.py", line 144, in main
    line_number = sd.reel_headers.extended_header_3['line_number']
AttributeError: 'ReelHeaders' object has no attribute 'extended_header_3'
```

**Environment (please complete the following information):**
 - OS: [e.g. Ubuntu 16.04]
 - Program Version [unsimpleton 2018.268]

**To Reproduce**
Run unsimpleton to a list of fcnt files to convert them to rg16 files
unsimpleton –f <fcnt_list_file> –d <converted_data_folder>

**Expected behavior**
There should be no error and converted data files should be created in converted_data_folder



Discussion / hints:

Fix patch:
diff --git a/ph5/utilities/unsimpleton.py b/ph5/utilities/unsimpleton.py
index c4f7a560..e2f9dc54 100644
--- a/ph5/utilities/unsimpleton.py
+++ b/ph5/utilities/unsimpleton.py
@@ -15,7 +15,7 @@
 import logging
 from ph5.core import segdreader
 
-PROG_VERSION = '2018.268'
+PROG_VERSION = '2021.208'
 LOGGER = logging.getLogger(__name__)
 
 
@@ -141,11 +141,11 @@ def main():
             extended_headers(sd)
             external_header(sd)
 
-            line_number = sd.reel_headers.extended_header_3['line_number']
-            receiver_point = sd.reel_headers.extended_header_3[
+            line_number = sd.reel_headers.extended_headers[2]['line_number']
+            receiver_point = sd.reel_headers.extended_headers[2][
                 'receiver_point']
-            sd.reel_headers.general_header_block_2['file_version_number']
-            id_number = sd.reel_headers.extended_header_1['id_number']
+            sd.reel_headers.general_header_blocks[1]['file_version_number']
+            id_number = sd.reel_headers.extended_headers[0]['id_number']
             outfile = "PIC_{0}_{1}_{3}.0.0.rg{2}".format(
                 line_number, receiver_point, 16, id_number)
             linkname = os.path.join(outpath, outfile)


Test patch:
diff --git a/ph5/utilities/tests/test_unsimpleton.py b/ph5/utilities/tests/test_unsimpleton.py
new file mode 100644
index 00000000..56ee5e1d
--- /dev/null
+++ b/ph5/utilities/tests/test_unsimpleton.py
@@ -0,0 +1,43 @@
+'''
+Tests for unsimpleton
+'''
+import os
+import sys
+import unittest
+
+from mock import patch
+from testfixtures import OutputCapture
+
+from ph5.utilities import unsimpleton
+from ph5.core.tests.test_base import TempDirTestCase
+
+
+class TestUnsimpleton_main(TempDirTestCase):
+    def test_main(self):
+        # add fcnt data of the same das in the same array but with different
+        # deploytime
+        fcnt_dir = os.path.join(self.home, "ph5/test_data/segd/fairfield/")
+        # create list file
+        list_file = open('fcnt_list', "w")
+        fcnt_fileList = os.listdir(fcnt_dir)
+        s = ""
+        for f in fcnt_fileList:
+            if f.endswith(".fcnt") and f.startswith("1111"):
+                s += fcnt_dir + f + "\n"
+        list_file.write(s)
+        list_file.close()
+
+        # run unsimpleton => 3 rg16 files created with appropriate names
+        testargs = ['unsimpleton', '-f', 'fcnt_list', '-d', 'rg16data']
+        with patch.object(sys, 'argv', testargs):
+            with OutputCapture():
+                unsimpleton.main()
+        rg16_dir = os.path.join(self.tmpdir, "rg16data")
+        rg16_fileList = sorted(os.listdir(rg16_dir))
+        self.assertEqual(rg16_fileList, ['PIC_1_1111_4886.0.0.rg16',
+                                         'PIC_1_1111_4892.0.0.rg16',
+                                         'PIC_1_1111_5118.0.0.rg16'])
+
+
+if __name__ == "__main__":
+    unittest.main()