diff options
author | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2020-04-20 13:37:13 +0200 |
---|---|---|
committer | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2020-04-20 13:37:13 +0200 |
commit | ba4cad888865cd19e14cde42c03cc50f2a0745ab (patch) | |
tree | b1a75ee2cdfb1b6228a975690381cc4e5783fc0e /controller/fw/tools/dsss_demod_test_runner.py | |
parent | 87ae7dfcb35d9a55950eecc2116d13d73b2b9ece (diff) | |
download | master-thesis-ba4cad888865cd19e14cde42c03cc50f2a0745ab.tar.gz master-thesis-ba4cad888865cd19e14cde42c03cc50f2a0745ab.tar.bz2 master-thesis-ba4cad888865cd19e14cde42c03cc50f2a0745ab.zip |
Add fw simulator
Diffstat (limited to 'controller/fw/tools/dsss_demod_test_runner.py')
-rw-r--r-- | controller/fw/tools/dsss_demod_test_runner.py | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/controller/fw/tools/dsss_demod_test_runner.py b/controller/fw/tools/dsss_demod_test_runner.py index e31a686..a7acccd 100644 --- a/controller/fw/tools/dsss_demod_test_runner.py +++ b/controller/fw/tools/dsss_demod_test_runner.py @@ -83,15 +83,18 @@ def run_test(seed, amplitude_spec, background, nbits, decimation, symbols, thfs, signal = np.repeat(dsss_modulate(test_data, nbits) * 2.0 - 1, decimation) # We're re-using the seed here. This is not a problem. noise = noise_gen(seed, len(signal), *noise_params) + # DEBUG + # Map lsb to sign to match test program + # test_data = (test_data>>1) * (2*(test_data&1) - 1) amplitudes = amplitude_spec[0] * 10 ** np.linspace(0, amplitude_spec[1], amplitude_spec[2]) output = [] for amp in amplitudes: with tempfile.NamedTemporaryFile(dir=cachedir) as f: waveform = signal*amp + noise - f.write(waveform.astype('float').tobytes()) + f.write(waveform.astype('float32').tobytes()) f.flush() - + for thf in thfs: cmdline = [lookup_binary(nbits, thf, decimation, symbols), f.name] proc = subprocess.Popen(cmdline, stdout=subprocess.PIPE, text=True) @@ -107,10 +110,10 @@ def run_test(seed, amplitude_spec, background, nbits, decimation, symbols, thfs, ser = min(sequence_matcher(test_data, match) for match in matched) if matched else None rpars = ResultParams(nbits, thf, decimation, symbols, seed, amp, background) output.append((rpars, ser)) - print(f'ran {rpars} {ser=} {" ".join(cmdline)}') return output -def parallel_generator(db, table, columns, builder, param_list, desc, context={}, params_mapper=lambda *args: args): +def parallel_generator(db, table, columns, builder, param_list, desc, context={}, params_mapper=lambda *args: args, + disable_cache=False): with multiprocessing.Pool(multiprocessing.cpu_count()) as pool: with db as conn: jobs = [] @@ -119,7 +122,7 @@ def parallel_generator(db, table, columns, builder, param_list, desc, context={} f'SELECT result FROM {table} WHERE ({",".join(columns)}) = ({",".join("?"*len(columns))})', params_mapper(*params)).fetchone() - if found_res: + if found_res and not disable_cache: yield params, json.loads(*found_res) else: @@ -142,13 +145,18 @@ if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('-d', '--dump', help='Write results to JSON file') parser.add_argument('-c', '--cachedir', default='dsss_test_cache', help='Directory to store build output and data in') + parser.add_argument('-n', '--no-cache', action='store_true', help='Disable result cache') args = parser.parse_args() DecoderParams = namedtuple('DecoderParams', ['nbits', 'thf', 'decimation', 'symbols']) - dec_paramses = [ DecoderParams(nbits=nbits, thf=thf, decimation=decimation, symbols=20) +# dec_paramses = [ DecoderParams(nbits=nbits, thf=thf, decimation=decimation, symbols=20) +# for nbits in [5, 6] +# for thf in [4.5, 4.0, 5.0] +# for decimation in [10, 5, 22] ] + dec_paramses = [ DecoderParams(nbits=nbits, thf=thf, decimation=decimation, symbols=100) for nbits in [5, 6] - for thf in [4.5, 4.0, 5.0] - for decimation in [10, 5, 22] ] + for thf in [3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 9.5, 10.0] + for decimation in [1, 2, 3, 4, 5, 6, 9, 10, 11, 12, 16, 22, 30, 40, 50] ] # dec_paramses = [ DecoderParams(nbits=nbits, thf=thf, decimation=decimation, symbols=100) # for nbits in [5, 6, 7, 8] # for thf in [1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 9.5, 10.0] @@ -171,8 +179,11 @@ if __name__ == '__main__': GeneratorParams = namedtuple('GeneratorParams', ['seed', 'amplitude_spec', 'background']) gen_params = [ GeneratorParams(rep, (5e-3, 1, 5), background) #GeneratorParams(rep, (0.05e-3, 3.5, 50), background) - for rep in range(30) + for rep in range(50) for background in ['meas://fmeas_export_ocxo_2day.bin', 'synth://grid_freq_psd_spl_108pt.json'] ] +# gen_params = [ GeneratorParams(rep, (5e-3, 1, 5), background) +# for rep in range(1) +# for background in ['meas://fmeas_export_ocxo_2day.bin'] ] data_db = sqlite3.connect(path.join(args.cachedir, 'data_db.sqlite3')) data_db.execute('CREATE TABLE IF NOT EXISTS waveforms' @@ -198,7 +209,8 @@ if __name__ == '__main__': params_mapper=params_mapper, builder=run_test, param_list=waveform_params, desc='Generating waveforms', - context=dict(cachedir=data_cache_dir, lookup_binary=lookup_binary)): + context=dict(cachedir=data_cache_dir, lookup_binary=lookup_binary), + disable_cache=args.no_cache): results += chunk if args.dump: |