notscared / notscared2-main / benchmarking / snr_verification.py
snr_verification.py
Raw
import os
import sys
import notscared.snr as snr
import notscared.data.trace_handler as trace_handler
import itertools


def main():

    # python snr_verification <db_name> False

    if len(sys.argv) != 3:
        print("Usage: python snr_verification.py <zarr_file> <useTiled?>")
        sys.exit(1)

    db_name = sys.argv[1]
    useTiledExample = sys.argv[2]

    if (useTiledExample):

        tile_size = db_name.split("_")[0].split("x")[:2]  # Extract tile size from file name
        tile_size = [int(x) for x in tile_size]  # Convert tile size to integers
        tile_coordinates = list(itertools.product(range(tile_size[0]), range(tile_size[1])))  # Generate all (x, y) pairs
        batchStart = 0

    else:
        tile_coordinates = []
        batchStart = 75001

    proj_root = os.getcwd()
    filename = os.path.join(proj_root, db_name)

    th = trace_handler.TraceHandler(fileName=filename, 
                                    batchSize=5000, 
                                    batchStart=batchStart, 
                                    tiles_coordinates=tile_coordinates)
    
    snrresults = snr.SNR(Tracehandler=th, Bytes=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15], bytes_to_graph=[(0, 'grey'), (1, 'red')])
    snrresults.run()
    snrresults.publish()


if __name__ == '__main__':
    main()