notscared / notscared2-main / benchmarking / NxM_demo.ipynb
NxM_demo.ipynb
Raw

NxM Tiled Dataset Demo


Initialization


# Import necessary libraries
import sys
import os

from notscared import snr
from notscared.data import trace_handler_advanced as trace_handler
from notscared import cpa
import time
import matplotlib.pyplot as plt
import numpy as np
import itertools
# Establish file name make sure that the file you wish to choose is in the same directory as your script
db_file = '15x8x20000_r1_singlerail5_sr_ise.zarr'
proj_root = os.getcwd()
file_name = os.path.join(proj_root, db_file)
print(file_name)


# Get all of the (x, y) pairs to include in your computation, here we just extract from the file name
tile_size = db_file.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

print("Tile coordinates: " , tile_coordinates)
c:\Dev\OSUCS\notscared2\notscared2\benchmarking\15x8x20000_r1_singlerail5_sr_ise.zarr
[(0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7), (8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (8, 6), (8, 7), (9, 0), (9, 1), (9, 2), (9, 3), (9, 4), (9, 5), (9, 6), (9, 7), (10, 0), (10, 1), (10, 2), (10, 3), (10, 4), (10, 5), (10, 6), (10, 7), (11, 0), (11, 1), (11, 2), (11, 3), (11, 4), (11, 5), (11, 6), (11, 7), (12, 0), (12, 1), (12, 2), (12, 3), (12, 4), (12, 5), (12, 6), (12, 7), (13, 0), (13, 1), (13, 2), (13, 3), (13, 4), (13, 5), (13, 6), (13, 7), (14, 0), (14, 1), (14, 2), (14, 3), (14, 4), (14, 5), (14, 6), (14, 7)]

General SNR


print("File name is ", file_name)

#Declare trace_handler object configuring what file you would like to open (listed above) preferred batch size (recommended 5k) and what trace you would like to start on (0 for this dataset)
handler = trace_handler.TraceHandler(fileName = file_name,
                                     batchSize = 5000,
                                     batchStart = 0,
                                     tiles_coordinates = tile_coordinates)

#Declare SNR object passing in the trace handler the byte positions (0-15) you would like to compute
algorithm = snr.SNR(Tracehandler = handler,
                    Bytes = [0])

#Call .run() on the algorithm to start the computation
algorithm.run()

#If using pyplot to plot results declare your figure
fig, ax = plt.subplots(figsize=(8, 4))

#Plot the results of running your computation
ax.plot(algorithm.results[0], 'blue')

#Label Your axes
plt.ylabel("SNR")
plt.xlabel("Samples")

#Display the plot
plt.show()
---------------------------------------------------------------------------

PathNotFoundError                         Traceback (most recent call last)

Cell In[5], line 2
      1 #Declare trace_handler object configuring what file you would like to open (listed above) preferred batch size (recommended 5k) and what trace you would like to start on (0 for this dataset)
----> 2 handler = trace_handler.TraceHandler(fileName = file_name,
      3                                      batchSize = 5000,
      4                                      batchStart = 0,
      5                                      tiles_coordinates = tile_coordinates)
      7 #Declare SNR object passing in the trace handler the byte positions (0-15) you would like to compute
      8 algorithm = snr.SNR(Tracehandler = handler,
      9                     Bytes = [0])


File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\notscared\data\trace_handler_advanced.py:23, in TraceHandler.__init__(self, fileName, batchSize, batchStart, tiles_coordinates, time_slice, trace_step)
     21 self.data_length = None
     22 self.current_tile = '0/0'  # Default tile
---> 23 self.data = zarr.open(fileName, mode='r')
     24 print("opened zarr file ", fileName)
     25 self.step = trace_step


File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\zarr\convenience.py:122, in open(store, mode, zarr_version, path, **kwargs)
    120     return open_group(_store, mode=mode, **kwargs)
    121 else:
--> 122     raise PathNotFoundError(path)


PathNotFoundError: nothing found at path ''