Source code for wni.system_config

"""System configuration settings"""


import os

import wni.config as config


[docs]class SystemConfig(object): """ Contains (certain) highlevel system configuration, including options for where data gets sent and radar calibration details. """ def __init__(self): self.ch1_ref_cal = 0 self.ch2_ref_cal = 0 self.dump_to_disk = False self.data_dump_directory = os.path.expanduser('~/data') self.filter_cpu = True self.do_range_correction = True # push data to the UI. self.processing_in_gui = True # if the processor is active, this is how frequently it will actually # process data. It will only process data every multiple of this # number. self.processing_interval = 1 # whether to calculate reflectivity in pulse processor. self.calc_reflectivity = True # whether to calculate velocity in pulse processor. self.calc_velocity = True # calculate the magnitude of lag 1 autocorrelation self.calc_mag_R1 = False # whether to output all I/Q data from pulse processor. self.output_iq = False # whether to calculate the products using Doppler processing. # Doppler processing is much more expensive. self.doppler_processing = False # Output the power spectral density self.output_psd = False # factor by which to decimate. # A value of 1 means no decimation. This setting only takes effect if # scan_settings.fir_enable == False, because that is the condition # in which filtering is done on a CPU instead of the FPGA. self.decimation = 1 # what should be plotted self.plot_power = True self.plot_velocity = True self.plot_frequency = False self.plot_phase = False # grab the main config file, so we can find configuration options from # our C code. self.flip_velocity_sign = config.FLIP_VELOCITY_SIGN
[docs] def settings_as_dict(self): """ Return current settings as a dict. """ attrs = ( 'ch1_ref_cal', 'ch2_ref_cal', 'dump_to_disk', 'data_dump_directory', 'filter_cpu', 'do_range_correction', 'processing_in_gui', 'processing_interval', 'calc_reflectivity', 'calc_velocity', 'calc_mag_R1', 'output_iq', 'doppler_processing', 'output_psd', 'decimation', 'plot_power', 'plot_velocity', 'plot_frequency', 'plot_phase', 'flip_velocity_sign', ) settings = {attr: getattr(self, attr) for attr in attrs} return settings
[docs] def apply_dict_config(self, config): """ Apply configuration specified in a dict. Keys are attribute names, and values are the values that will be assigned. """ config = config.copy() for attr in config: if not hasattr(self, attr): msg = 'Bad setting for SystemConfig: No setting named "{}".' msg = msg.format(attr) raise ValueError(msg) for attr, value in config.items(): setattr(self, attr, value)