Changes in / [dff8988:29bf25a] in ammosreader


Ignore:
Files:
21 added
29 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • ammosreader/AmmosGlobalFrameHeader.py

    rdff8988 r29bf25a  
    11"""I provide an AMMOS global frame header."""
    22import struct
    3 from ammosreader import logger
     3import logging
     4
     5logging.basicConfig(filename='ammos.log', level=logging.DEBUG)
     6
    47
    58class AmmosGlobalFrameHeader:
     
    1821        magic_word = elements[0].hex()
    1922
    20         logger.debug("Header created")
    2123        if magic_word != cls.MAGIC_WORD:
    2224            return None
     
    3840        """I return a new instance of myself initialized with above parameters."""
    3941        if magic_word != type(self).MAGIC_WORD:
    40             logger.error("Wrong magic word found")
     42            logging.error("Wrong magic word found")
    4143            self.magic_word = magic_word
    4244        else:
  • ammosreader/PDW.py

    rdff8988 r29bf25a  
    44import math
    55import numpy as np
    6 from ammosreader import logger
     6
    77
    88class PDW():
     
    2424        :rtype: PDW
    2525        """
    26 
    27         logger.info("from bytes")
    28         if (len(byte_string) != 32):
    29             logger.error("Byte count invalid")
    30             raise TypeError("Byte count invalid")
     26        assert(len(byte_string) == 32)
    3127
    3228        parts = struct.unpack('<Q4s4s4s4s4s4s', byte_string)
    33 
    3429        nanoseconds = (parts[0])
    35         unix_time = np.datetime64('now', 'ns').astype(int)
    36         if nanoseconds >= unix_time:
    37             raise OverflowError("Timestamp invalid")
    3830        time_of_arrival = np.datetime64(nanoseconds, 'ns')
    3931
     
    6961        modulations = {0: 'Unknown', 1: 'Unmodulated', 2: 'FM', 3: 'LFM', 4: 'PSK-2', 5: 'PSK-3', 6: 'PSK-4',
    7062                       7: 'PSK-m', 8: 'NLFM', 9: 'SFM', 10: 'TFM', 11: 'Pulse too short'}
    71         modulation = modulations.get(int(sixth_entry_bit_string[7:12], 2), 0)
     63        modulation = modulations[int(sixth_entry_bit_string[7:12], 2)]
    7264        sector = int(sixth_entry_bit_string[28:32], 2)
    7365
  • ammosreader/__init__.py

    rdff8988 r29bf25a  
    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.