From 256f26025e96f9500a046c207064e1ca319c5393 Mon Sep 17 00:00:00 2001
From: am0ebe <am0ebe@gmx.de>
Date: Sun, 7 Feb 2021 20:00:33 +0100
Subject: [PATCH]  change isHabitat to habitat in (0,1,2,3,4), where 0 is
 noHabitat and 1 is upperleft corner and so on

---
 dataFilter.py | 12 ++----------
 dataSync.py   | 25 +++++++++++++++++--------
 2 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/dataFilter.py b/dataFilter.py
index fe2705a..d03ac25 100755
--- a/dataFilter.py
+++ b/dataFilter.py
@@ -137,14 +137,6 @@ def add_cols( data ):
 			if pxe:
 				npxe+=1
 
-			# if(pxe):
-			# 	print(f"{l[4:10]}")
-			# 	print(f"{l[col_habitat:col_habitat+4]}")
-			# 	print(f"tag: {tag}")
-			# 	print(f"sxe:{sxe}, last_pos:{last_pos}, this_pos:{this_pos}")
-			# 	print(f"pxe:{pxe}, last_habitat:{last_habitat}, this_habitat:{this_habitat}")
-			# 	input()
-
 			l.insert(col_lastdetect,lastdetect)
 			l.insert(col_sxe, sxe)
 			l.insert(col_pxe, pxe)
@@ -197,8 +189,8 @@ def write(outFile, data):
 		f.writelines(header)
 		f.writelines(data)
 
-	cmd_compress=f"tar -zcvf {outFile}.tgz {outFile}" # ">/dev/null 2>/dev/null"
-	os.system(cmd_compress)
+		cmd_compress=f"tar -zcvf {outFile}.tgz {outFile}" # ">/dev/null 2>/dev/null"
+		os.system(cmd_compress)
 
 def main(filename):
 
diff --git a/dataSync.py b/dataSync.py
index fa738ab..1ef4a35 100755
--- a/dataSync.py
+++ b/dataSync.py
@@ -1,8 +1,9 @@
 #!/usr/bin/python3
 # clean, sort, merge raw data
-# output should be one huge table with all necessary fields for further processing/vizualization
 #
-# files are 'skyglow.log','tags' and trackfiles (containing 'unit-x' in name, where x is a number
+# output one huge table with all necessary fields for further processing/vizualization
+#
+# files are 'skyglow.log','tags' and trackfiles (containing 'unit-x' in name, where x is a number)
 #
 ############################
 # TODO
@@ -102,8 +103,6 @@ def initFileStructure():
 		A_DELIM=';'
 		A_MINLEN = 39
 		A_MAXLEN = 44
-		# A_MINLEN = 35
-		# A_MAXLEN = 49
 		A_NCOLS = 7 #/w comments
 		A_COL_SPECIES=1
 		A_COL_SPECIES_IND=0
@@ -245,7 +244,7 @@ class Data:
 			lines = self.clean(lines, T_MINLEN, T_MAXLEN, T_NCOLS, T_DELIM, self.getTrackTime)
 
 			if not lines:
-				pp("-> empty or non-usable data!")
+				pp("-> empty // non-usable")
 				return []
 
 		uid=getUID(fileName)
@@ -265,10 +264,20 @@ class Data:
 
 			x = int(cols[T_COL_X])
 			y = int(cols[T_COL_Y])
-			isHabitat = not ( x==3 or x==4 or y==3 or y==4 )
 
-			# add columns (date,time,uid,isHabitat)
-			line = line[:idx_after_ms] + DELIM + date + DELIM + time + DELIM + str(uid) + DELIM + str(isHabitat) + line[idx_after_ms:]
+			if x in (1,2) and y in (1,2):
+				habitat=1
+			elif x in (5,6) and y in (1,2):
+				habitat=2
+			elif x in (1,2) and y in (5,6):
+				habitat=3
+			elif x in (5,6) and y in (5,6):
+				habitat=4
+			else:
+				habitat=0
+
+			# add columns (date,time,uid,habitat)
+			line = line[:idx_after_ms] + DELIM + date + DELIM + time + DELIM + str(uid) + DELIM + str(habitat) + line[idx_after_ms:]
 
 			if PROJ == "ecolux":
 				line = line[:line.rindex(DELIM)] # remove signalstrength column
-- 
GitLab