Changes in / [29bf25a:dff8988] in ammosreader
- Files:
-
- 29 added
- 21 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
ammosreader/AmmosGlobalFrameHeader.py
r29bf25a rdff8988 1 1 """I provide an AMMOS global frame header.""" 2 2 import struct 3 import logging 4 5 logging.basicConfig(filename='ammos.log', level=logging.DEBUG) 6 3 from ammosreader import logger 7 4 8 5 class AmmosGlobalFrameHeader: … … 21 18 magic_word = elements[0].hex() 22 19 20 logger.debug("Header created") 23 21 if magic_word != cls.MAGIC_WORD: 24 22 return None … … 40 38 """I return a new instance of myself initialized with above parameters.""" 41 39 if magic_word != type(self).MAGIC_WORD: 42 logg ing.error("Wrong magic word found")40 logger.error("Wrong magic word found") 43 41 self.magic_word = magic_word 44 42 else: -
ammosreader/PDW.py
r29bf25a rdff8988 4 4 import math 5 5 import numpy as np 6 6 from ammosreader import logger 7 7 8 8 class PDW(): … … 24 24 :rtype: PDW 25 25 """ 26 assert(len(byte_string) == 32) 26 27 logger.info("from bytes") 28 if (len(byte_string) != 32): 29 logger.error("Byte count invalid") 30 raise TypeError("Byte count invalid") 27 31 28 32 parts = struct.unpack('<Q4s4s4s4s4s4s', byte_string) 33 29 34 nanoseconds = (parts[0]) 35 unix_time = np.datetime64('now', 'ns').astype(int) 36 if nanoseconds >= unix_time: 37 raise OverflowError("Timestamp invalid") 30 38 time_of_arrival = np.datetime64(nanoseconds, 'ns') 31 39 … … 61 69 modulations = {0: 'Unknown', 1: 'Unmodulated', 2: 'FM', 3: 'LFM', 4: 'PSK-2', 5: 'PSK-3', 6: 'PSK-4', 62 70 7: 'PSK-m', 8: 'NLFM', 9: 'SFM', 10: 'TFM', 11: 'Pulse too short'} 63 modulation = modulations [int(sixth_entry_bit_string[7:12], 2)]71 modulation = modulations.get(int(sixth_entry_bit_string[7:12], 2), 0) 64 72 sector = int(sixth_entry_bit_string[28:32], 2) 65 73 -
ammosreader/__init__.py
r29bf25a rdff8988 1 import logging 2 import logging.config 3 import os 4 from pathlib import Path 5 6 # change the default log path to /var/log/ammos/ammos.log when system configuration created this dir 7 # with the appropriate rights 8 9 log_dir = Path(os.environ.get('AMMOS_LOG_DIR', '/tmp/')) 10 11 log_path = log_dir / 'ammos.log' 12 13 if not log_path.exists(): 14 # print(log_path, "does not exist") 15 try: 16 # print("Trying to create logfile", str(log_path)) 17 log_path.touch() 18 except PermissionError: 19 # print("Logging to file disabled") 20 conf_file = Path(__file__).parent / 'ammos_logging.conf' 21 print("Conf file", conf_file) 22 logging.config.fileConfig(conf_file) 23 else: 24 # print("Logging to", str(log_path)) 25 logging.basicConfig(filename=str(log_path), encoding='utf-8', level=logging.DEBUG) 26 27 logger = logging.getLogger(__name__) 28 29 logger.warning("Text")
Note:
See TracChangeset
for help on using the changeset viewer.