From 27a55d79d6c8c47bc4ebe305d1de5647ff08be1b Mon Sep 17 00:00:00 2001
From: Patrick Godwin <patrick.godwin@ligo.org>
Date: Tue, 23 Jul 2019 07:52:14 -0700
Subject: [PATCH] utils.py: when saving features, only store time-based columns
 as double-precision, rest as single-precision

---
 gstlal-burst/python/fxtools/utils.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/gstlal-burst/python/fxtools/utils.py b/gstlal-burst/python/fxtools/utils.py
index 64d219164c..606acecf87 100644
--- a/gstlal-burst/python/fxtools/utils.py
+++ b/gstlal-burst/python/fxtools/utils.py
@@ -103,6 +103,14 @@ def create_new_dataset(path, base, data, name = 'data', group = None, tmp = Fals
 
 	return fname
 
+def feature_dtype(columns):
+	"""
+	given a set of columns, returns back numpy dtypes associated with those
+	columns. All time-based columns are double-precision, others are stored
+	in single-precision.
+	"""
+	return [(column, numpy.float64) if 'time' in column else (column, numpy.float32) for column in columns]
+
 #----------------------------------
 ### gps time utilities
 
@@ -273,7 +281,7 @@ class HDF5TimeseriesFeatureData(FeatureData):
 		self.sample_rate = kwargs['sample_rate']
 		self.waveform = kwargs['waveform']
 		self.metadata = dict(**kwargs)
-		self.dtype = [(column, 'float') for column in self.columns]
+		self.dtype = feature_dtype(self.columns)
 		self.feature_data = {key: numpy.empty((self.cadence * self.sample_rate,), dtype = self.dtype) for key in keys}
 		self.last_save_time = 0
 		self.clear()
@@ -322,7 +330,7 @@ class HDF5ETGFeatureData(FeatureData):
 		self.cadence = kwargs['cadence']
 		self.waveform = kwargs['waveform']
 		self.metadata = dict(**kwargs)
-		self.dtype = [(column, 'float') for column in self.columns]
+		self.dtype = feature_dtype(self.columns)
 		self.feature_data = {key: [] for key in keys}
 		self.clear()
 
-- 
GitLab