updated README, changed the save data files to state voltage V instead of magnetic field strength T
This commit is contained in:
parent
dd69caa42d
commit
87e23e01c0
@ -217,7 +217,23 @@ def polar_to_cartesian(radius, start_angle, end_angle, step_size, clockwise=True
|
|||||||
def LCR_scan_func(handle:int, init_voltage:float, final_voltage:float,
|
def LCR_scan_func(handle:int, init_voltage:float, final_voltage:float,
|
||||||
res:float, base_file_name='', folder_name='',
|
res:float, base_file_name='', folder_name='',
|
||||||
reversescan_bool=False, zerowhenfin_bool=True, loopscan_bool=False)->None:
|
reversescan_bool=False, zerowhenfin_bool=True, loopscan_bool=False)->None:
|
||||||
# TODO: docstring
|
"""This code is implemented to rotate the Liquid Crystal Retarder, using Thorlabs' KLC101 K-Cube control box. For each
|
||||||
|
voltage (^= angle in the Liquid Crystal Retarder), a measurement of the spectrum via the LightField spectrometer is made.
|
||||||
|
Data
|
||||||
|
|
||||||
|
|
||||||
|
Args:
|
||||||
|
handle (int): the handle of the KLC101 device
|
||||||
|
init_voltage (float): starting voltage (V)
|
||||||
|
final_voltage (float): end voltage (V)
|
||||||
|
res (float): voltage step size (V)
|
||||||
|
base_file_name (str, optional): Name of measurement file. Defaults to ''.
|
||||||
|
folder_name (str, optional): Name of folder, where the measurements are saved to. Defaults to ''.
|
||||||
|
reversescan_bool (bool, optional): Toggles to perform measurements in the reverse direction. Defaults to False.
|
||||||
|
zerowhenfin_bool (bool, optional): Turns off the output of the control box, at the end of the measurement series. Defaults to True.
|
||||||
|
loopscan_bool (bool, optional): Toggles the option to perform the following scan:
|
||||||
|
starting voltage -> final voltage -> starting voltage. Defaults to False.
|
||||||
|
"""
|
||||||
def pyramid_list(lst) -> Union[list, np.ndarray]:
|
def pyramid_list(lst) -> Union[list, np.ndarray]:
|
||||||
"""reverses the list and removes the first element of reversed list. Then, this is appended to
|
"""reverses the list and removes the first element of reversed list. Then, this is appended to
|
||||||
the end of the original list and returned as the 'pyramid' list.
|
the end of the original list and returned as the 'pyramid' list.
|
||||||
@ -285,18 +301,18 @@ def LCR_scan_func(handle:int, init_voltage:float, final_voltage:float,
|
|||||||
print(f'Actual output voltage: {actual_voltage_val[0]} V,', f'Target output voltage: {voltage_val} V')
|
print(f'Actual output voltage: {actual_voltage_val[0]} V,', f'Target output voltage: {voltage_val} V')
|
||||||
|
|
||||||
#scanning loop
|
#scanning loop
|
||||||
for i, bval in enumerate(voltage_lst):
|
for i, voltageval in enumerate(voltage_lst):
|
||||||
if not loopscan_bool:
|
if not loopscan_bool:
|
||||||
helper_scan_func(i, bval)
|
helper_scan_func(i, voltageval)
|
||||||
else:
|
else:
|
||||||
if i <= middle_index_voltage_lst:
|
if i <= middle_index_voltage_lst:
|
||||||
helper_scan_func(i, bval)
|
helper_scan_func(i, voltageval)
|
||||||
else:
|
else:
|
||||||
helper_scan_func(i, bval)
|
helper_scan_func(i, voltageval)
|
||||||
|
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
# we acquire with the LF
|
# we acquire with the LF
|
||||||
acquire_name_spe = f'{base_file_name}_{bval}T'
|
acquire_name_spe = f'{base_file_name}_{voltageval}V'
|
||||||
AcquireAndLock(acquire_name_spe) #this creates a .spe file with the scan name.
|
AcquireAndLock(acquire_name_spe) #this creates a .spe file with the scan name.
|
||||||
|
|
||||||
# read the .spe file and get the data as loaded_files
|
# read the .spe file and get the data as loaded_files
|
||||||
@ -342,6 +358,9 @@ def LCR_scan_func(handle:int, init_voltage:float, final_voltage:float,
|
|||||||
|
|
||||||
wl = np.array(loaded_files.wavelength)
|
wl = np.array(loaded_files.wavelength)
|
||||||
np.savetxt("Wavelength.txt", wl)
|
np.savetxt("Wavelength.txt", wl)
|
||||||
|
# TODO: save the list of voltages to a separate .csv or .txt data in the same folder directory.
|
||||||
|
# PERFORM TEST TO SEE IF THIS WORKS!!!
|
||||||
|
np.savetxt("Voltage.txt", voltage_lst)
|
||||||
|
|
||||||
################################################################# END OF FUNCTION DEFS ###########################################################################################
|
################################################################# END OF FUNCTION DEFS ###########################################################################################
|
||||||
|
|
||||||
@ -373,7 +392,7 @@ try:
|
|||||||
serialnumber = klc[0]
|
serialnumber = klc[0]
|
||||||
|
|
||||||
# Connect device
|
# Connect device
|
||||||
KLC_handle = klcOpen(serialnumber, 115200, 3) # baud rate and timeout(in s)
|
KLC_handle = klcOpen(serialnumber, 115200, 3) # serial-nr., baud rate and timeout(in s)
|
||||||
if(KLC_handle<0):
|
if(KLC_handle<0):
|
||||||
print("open ", serialnumber, " failed")
|
print("open ", serialnumber, " failed")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
@ -403,8 +422,9 @@ try:
|
|||||||
# InitializerFilenameParams()
|
# InitializerFilenameParams()
|
||||||
# TODO: find out what these two lines of code do, leave commented as of (31.10.2024)
|
# TODO: find out what these two lines of code do, leave commented as of (31.10.2024)
|
||||||
|
|
||||||
LCR_scan_func(handle=KLC_handle, init_voltage=start_voltage, final_voltage=end_voltage, res=voltage_stepsize,
|
LCR_scan_func(handle=KLC_handle, init_voltage=start_voltage, final_voltage=end_voltage, res=voltage_stepsize,
|
||||||
base_file_name=experiment_name, folder_name=experiment_folder_name)
|
base_file_name=experiment_name, folder_name=experiment_folder_name,
|
||||||
|
reversescan_bool=False, zerowhenfin_bool=True, loopscan_bool=False)
|
||||||
|
|
||||||
except Exception() as e:
|
except Exception() as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
from ctypes import *
|
from ctypes import *
|
||||||
import os,sys
|
import os,sys
|
||||||
|
|
||||||
|
# TODO: change the file path below for the offline computer, maybe direct to the KLC programm
|
||||||
|
# folder path (under C++)
|
||||||
#region import dll functions; NOTE: ENTER ABSOLUTE PATH BELOW
|
#region import dll functions; NOTE: ENTER ABSOLUTE PATH BELOW
|
||||||
klcLib=cdll.LoadLibrary(r"C:\Users\rtan\Documents\RyanWork2024\Dasha-LCR_Code\Thorlabs_KLC_PythonSDK\"KLCCommandLib_x64.dll")
|
klcLib=cdll.LoadLibrary(r"C:\Users\rtan\Documents\RyanWork2024\Dasha-LCR_Code\Thorlabs_KLC_PythonSDK\"KLCCommandLib_x64.dll")
|
||||||
|
|
||||||
|
17
README.md
17
README.md
@ -4,9 +4,15 @@ This code is implemented to rotate the Liquid Crystal Retarder.
|
|||||||
|
|
||||||
## How to use the script
|
## How to use the script
|
||||||
|
|
||||||
The user of the script must enter the given start- and end voltages, as well as the voltage resolution (controller voltage resolution is 1 mV!), which are located at the bottom of the script. TODO: CONTINUE EXPLANATION
|
The user of the script must enter the given start- and end voltages, as well as the voltage resolution (controller voltage resolution is 1 mV!), which are located at the bottom of the script. The variable names are:
|
||||||
|
|
||||||
## Notes
|
- `start_voltage`
|
||||||
|
- `end_voltage`
|
||||||
|
- `voltage_stepsize`
|
||||||
|
|
||||||
|
In the next step, enter the name of the file, under the variable `experiment_settings`. The main functionality to perform the rotation script is located in the `LCR_scan_func`, for which there are additional input parameters to modify measurement: `reversescan_bool` allows the user to perform the rotation in the opposite direction, and is set to `False` on default. `zerowhenfin_bool` sets the voltage of preset 1 (V1, as called in the SDK from Thorlabs) to 0 V **and** disables the output of the device, and is set to `True` per defaut. `loopscan_bool` allows for a measurement series starting voltage -> final voltage -> starting voltage loop, and is set to `False` per default. These parameters and editable in the function head, right at th bottom of the script.
|
||||||
|
|
||||||
|
## Notes/ Possible Issues
|
||||||
|
|
||||||
1. For the code to work, change the directory to load the KLCCommandLib_x64.dll file, located in 'KLCCommandLib64.py', line 5, to your specific directory, in which the .dll file is stored.
|
1. For the code to work, change the directory to load the KLCCommandLib_x64.dll file, located in 'KLCCommandLib64.py', line 5, to your specific directory, in which the .dll file is stored.
|
||||||
The line of code is as follows:
|
The line of code is as follows:
|
||||||
@ -16,5 +22,12 @@ The line of code is as follows:
|
|||||||
2. Another issue is then importing the other needed folders, probably have to have all the required files in the same scan
|
2. Another issue is then importing the other needed folders, probably have to have all the required files in the same scan
|
||||||
script folder on the offline computer. (This is probably resolved in the newer version of the code.)
|
script folder on the offline computer. (This is probably resolved in the newer version of the code.)
|
||||||
|
|
||||||
|
3. Input of negative voltage values could cause a problem => TODO: Test with Dasha!!!
|
||||||
|
|
||||||
## Standing Issues/Planned Updates
|
## Standing Issues/Planned Updates
|
||||||
|
|
||||||
|
- Possibly will change the file path for `KLCCommandLib_x64.dll` in `KLCCommandLib64.py` to that of the file in the programm files, under the C++ SDK folder.
|
||||||
|
- Older version of code saved the files the name `VOLTAGE_VALUE + T`, changed T -> V for voltage.
|
||||||
|
- (Optional) might modify the folder path argument of `LCR_scan_func` to include the absolute path of the saving folder directory **and** temporary dump folder path, this is to be discussed with Dasha later on.
|
||||||
|
- Further modification/ implementation with the Ophir powermeter, TBD.
|
||||||
|
- Added functionality: saved list of voltages to a separate `.txt` data in the same folder directory. TODO: TEST IF IT WORKS AS INTENDED
|
Loading…
Reference in New Issue
Block a user