Skip to content

Commit

Permalink
extract focus-plane metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
bunnie committed Jan 16, 2024
1 parent 9c32adb commit 4fe279c
Showing 1 changed file with 37 additions and 11 deletions.
48 changes: 37 additions & 11 deletions stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,24 @@
import logging
import json
import statistics
import matplotlib.pyplot as plt

PIEZO_UM_PER_LSB = 0.007425

def meta_from_fname(fname):
metadata = {}
items = fname.split('_')
for i in items:
metadata[i[0]] = float(i[1:])
return metadata

def main():
parser = argparse.ArgumentParser(description="Extract stitching stats")
parser.add_argument(
"--loglevel", required=False, help="set logging level (INFO/DEBUG/WARNING/ERROR)", type=str, default="INFO",
)
parser.add_argument(
"--name", required=False, help="database file name", default='db.json'
"--name", required=False, help="database file name", default='raw/marvell-10x/db.json'
)
args = parser.parse_args()
numeric_level = getattr(logging, args.loglevel.upper(), None)
Expand All @@ -19,16 +29,32 @@ def main():

with open(args.name, 'r') as config:
schema = json.loads(config.read())
offset_x = []
offset_y = []
for layer, tile in schema['tiles'].items():
(x, y) = tile['offset']
offset_x += [x]
offset_y += [y]

logging.info(f"Mean offset: {statistics.mean(offset_x):0.3f}, {statistics.mean(offset_y):0.3f}")
logging.info(f"Stddev: {statistics.stdev(offset_x):0.3f}, {statistics.stdev(offset_y):0.3f}")
logging.info(f"Max: {max([abs(max(offset_x)), abs(min(offset_x))]):0.3f}, {max([abs(max(offset_y)), abs(min(offset_y))]):0.3f}")

if False:
offset_x = []
offset_y = []
for layer, tile in schema['tiles'].items():
(x, y) = tile['offset']
offset_x += [x]
offset_y += [y]

logging.info(f"Mean offset: {statistics.mean(offset_x):0.3f}, {statistics.mean(offset_y):0.3f}")
logging.info(f"Stddev: {statistics.stdev(offset_x):0.3f}, {statistics.stdev(offset_y):0.3f}")
logging.info(f"Max: {max([abs(max(offset_x)), abs(min(offset_x))]):0.3f}, {max([abs(max(offset_y)), abs(min(offset_y))]):0.3f}")
else:
x = []
y = []
z = []
for layer, tile in schema['tiles'].items():
meta = meta_from_fname(tile['file_name'])
x += [meta['x']]
y += [meta['y']]
z += [meta['z'] - meta['p'] * PIEZO_UM_PER_LSB / 1000.0]

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(x, y, z)
plt.show()

if __name__ == "__main__":
main()

0 comments on commit 4fe279c

Please sign in to comment.