-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpotsize
More file actions
38 lines (29 loc) · 1.26 KB
/
Copy pathSpotsize
File metadata and controls
38 lines (29 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 19 16:29:39 2023
@author: batman
"""
import numpy as np
import matplotlib.pyplot as plt
from scipy import ndimage
# Load an example image
image = plt.imread('laser_beam.png') # replace with the path to your image file
image = image[:,:,0] # use only one color channel (assuming grayscale)
# Define the pixel size of the image (in meters)
pixel_size = 5e-6 # 5 microns
# Define the focal length of the lens at each point in the system (in meters)
focal_lengths = np.array([0.05, 0.1, 0.2, 0.3, 0.4, 0.5])
# Measure the spot size at each point in the system
spot_sizes = np.zeros(len(focal_lengths))
for i, focal_length in enumerate(focal_lengths):
# Calculate the physical size of the image (in meters)
image_size = image.shape[0] * pixel_size
# Calculate the physical size of the laser beam (in meters)
beam_size = image_size / ndimage.measurements.find_objects(image)[0][0].size
# Calculate the spot size (in meters) using the lens equation
spot_sizes[i] = beam_size * (focal_length / (focal_length - image_size))
# Print the results
print("Spot sizes at each optic:")
for i, focal_length in enumerate(focal_lengths):
print(f"Optic {i+1}: {spot_sizes[i]*1e6} microns")