diff --git a/config.py b/config.py index 00589d3e8bcf436685117837bf0ca1e9e5936c2a..c0ee048cce3410946cea8ccfe7007c5d3c0e0623 100644 --- a/config.py +++ b/config.py @@ -24,7 +24,7 @@ CONTROL_CONFIG = { # Execution logging configuration EXEC_LOGGING_CONFIG = { 'logging_level': logging.DEBUG, - 'logging_to_console': False, + 'logging_to_console': True, 'file_name': 'ohmpi_log', 'max_bytes': 262144, 'backup_count': 30, @@ -37,7 +37,6 @@ DATA_LOGGING_CONFIG = { 'logging_level': logging.INFO, 'logging_to_console': True, 'file_name': 'data_log', - 'logging_to_console': False, 'max_bytes': 16777216, 'backup_count': 1024, 'when': 'd', diff --git a/ohmpi.py b/ohmpi.py index dd652fb169a709866a79fafdaba64f840894d5f0..d4eed9ad580030132ff30115924f9d77d17c1146 100644 --- a/ohmpi.py +++ b/ohmpi.py @@ -83,21 +83,22 @@ class OhmPi(object): # default acquisition settings self.settings = { 'injection_duration': 0.2, - 'nbr_meas': 100, + 'nbr_meas': 1, 'sequence_delay': 1, 'nb_stack': 1, 'export_path': 'data/measurement.csv' } - + print(self.settings) # read in acquisition settings if settings is not None: self._update_acquisition_settings(settings) - self.exec_logger.debug('Initialized with configuration:' + str(self.settings)) + print(self.settings) + self.exec_logger.debug('Initialized with settings:' + str(self.settings)) # read quadrupole sequence if sequence is None: - self.sequence = np.array([[1, 2, 3, 4]]) + self.sequence = np.array([[1, 2, 3, 4]], dtype=np.int32) else: self.read_quad(sequence) @@ -232,7 +233,7 @@ class OhmPi(object): sequence : numpy.array Array of shape (number quadrupoles * 4). """ - sequence = np.loadtxt(filename, delimiter=" ", dtype=int) # load quadrupole file + sequence = np.loadtxt(filename, delimiter=" ", dtype=np.int32) # load quadrupole file if sequence is not None: self.exec_logger.debug('Sequence of {:d} quadrupoles read.'.format(sequence.shape[0])) @@ -496,8 +497,7 @@ class OhmPi(object): } else: # for testing, generate random data d = {'time': datetime.now().isoformat(), 'A': quad[0], 'B': quad[1], 'M': quad[2], 'N': quad[3], - 'R [ohm]': np.abs(np.random.randn(1)) - } + 'R [ohm]': np.abs(np.random.randn(1)).tolist()} # round number to two decimal for nicer string output output = [f'{k}\t' for k in d.keys()] @@ -510,7 +510,14 @@ class OhmPi(object): output += f'{val}\t' output = output[:-1] self.exec_logger.debug(output) - self.data_logger.info(json.loads(d)) + dd = d.copy() + dd.update({'A': str(dd['A'])}) + dd.update({'B': str(dd['B'])}) + dd.update({'M': str(dd['M'])}) + dd.update({'N': str(dd['N'])}) + print(np.dtype(d['A'])) + print(json.dumps(dd)) + self.data_logger.info(json.dumps(dd)) time.sleep(1) # NOTE: why this? return d @@ -798,4 +805,4 @@ print(current_time.strftime("%Y-%m-%d %H:%M:%S")) # for testing if __name__ == "__main__": - ohmpi = OhmPi(settings='ohmpi_param.json') \ No newline at end of file + ohmpi = OhmPi(settings='ohmpi_settings.json') diff --git a/ohmpi_param.json b/ohmpi_settings.json similarity index 100% rename from ohmpi_param.json rename to ohmpi_settings.json