From 5e05bdb764a584e8855ff712847710734640092f Mon Sep 17 00:00:00 2001
From: Jacques Grelet <jacques.grelet@gmail.cpm>
Date: Sun, 17 Apr 2022 16:24:09 -0300
Subject: [PATCH] variables_1D is class attribute now

---
 file_extractor.py | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/file_extractor.py b/file_extractor.py
index 1757a9e..eecaf8f 100644
--- a/file_extractor.py
+++ b/file_extractor.py
@@ -61,6 +61,7 @@ class FileExtractor:
     keys: list of physical parameter to extract
     separator : str, column separator, default None (blank)
     '''
+    variables_1D = ['PROFILE', 'TIME', 'LATITUDE', 'LONGITUDE','BATH']
 
     # constructor with values by defaul
     def __init__(self, fname, roscop, keys, dbname=":memory:", separator=None):
@@ -96,6 +97,11 @@ class FileExtractor:
         ''' overload string representation '''
         return 'Class FileExtractor, file: %s, size = %d x %d' % (self.fname, self.n, self.m)
 
+    # get the keys list from __data
+    def getlist(self):
+        ''' return keys '''
+        return self.__data.keys()
+
     def disp(self):
         # for key in keys:
         #     print("{}:".format(key))
@@ -138,10 +144,7 @@ class FileExtractor:
         #m = int(max_size[0][f"COUNT({self.keys[0]})"])
         print(f"get sizes: {n} x {m}")
 
-        # hdr is a list of dict, add station ?
-        variables_1D = ['PROFILE', 'TIME', 'LATITUDE', 'LONGITUDE','BATH']
-
-        for k in variables_1D:
+        for k in self.variables_1D:
             #print(self.roscop[k])
             if '_FillValue' in self.roscop[k]:
                     self.__data[k] = np.full(n, self.roscop[k]['_FillValue']) 
@@ -408,6 +411,7 @@ if __name__ == "__main__":
     fe.read_files(cfg, args.instrument)
     # print(f"Indices: {fe.n} x {fe.m}\nkeys: {fe.keys}")
     # # debug
-    print(fe['PRES'])
-    print(fe['TEMP'])
+    #print(fe['PRES'])
+    print(fe['TEMP'][0][1])
+    print(fe.getlist())
     # print(fe['PSAL'])
-- 
GitLab