path_save=None default changed

This commit is contained in:
Ryan Tan 2024-07-23 09:45:21 +02:00
parent 87b8908a99
commit a566dda4b0

View File

@ -355,9 +355,9 @@ def write_no_echo(instr:pyvisa.resources.Resource, command:str, sleeptime=0.01)-
# receive values in units of T, rescale in kg to talk with the power supplyy. 1T = 10kG # receive values in units of T, rescale in kg to talk with the power supplyy. 1T = 10kG
# NOTE: removed singlepowersupply_bool, reading serial-nr. of the device instead. # NOTE: removed singlepowersupply_bool, reading serial-nr. of the device instead.
# TODO: add a param to allow the # old save folder: "C:/Users/localadmin/Desktop/Users/Lukas/2024_02_08_Map_test"
def sweep_b_val(instr:pyvisa.resources.Resource, min_bval:float, max_bval:float, def sweep_b_val(instr:pyvisa.resources.Resource, min_bval:float, max_bval:float,
res:float, magnet_coil:str, Settings:str, base_file_name='', path_save="C:/Users/localadmin/Desktop/Users/Lukas/2024_02_08_Map_test", res:float, magnet_coil:str, Settings:str, base_file_name='', path_save=None,
reversescan_bool=False, zerowhenfin_bool=False, loopscan_bool=False)->None: reversescan_bool=False, zerowhenfin_bool=False, loopscan_bool=False)->None:
# TODO: update docs in the end # TODO: update docs in the end
""" this function performs a sweep of the B field of the chosen magnet coil. It creates a list o B values from the given min and max values, """ this function performs a sweep of the B field of the chosen magnet coil. It creates a list o B values from the given min and max values,
@ -382,6 +382,7 @@ def sweep_b_val(instr:pyvisa.resources.Resource, min_bval:float, max_bval:float,
ValueError: when Bx limit is exceeded. ValueError: when Bx limit is exceeded.
ConnectionError: when no device is connected. ConnectionError: when no device is connected.
""" '''''' """ ''''''
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.
@ -400,6 +401,9 @@ def sweep_b_val(instr:pyvisa.resources.Resource, min_bval:float, max_bval:float,
else: else:
raise TypeError('Please input a list!') raise TypeError('Please input a list!')
if path_save is None:
path_save = datetime.datetime.now().strftime("%Y_%m_%d_%H%M_hrs_")
if base_file_name =='': if base_file_name =='':
base_file_name = datetime.datetime.now().strftime('%Y_%m_%d_%H.%M') base_file_name = datetime.datetime.now().strftime('%Y_%m_%d_%H.%M')
@ -460,6 +464,7 @@ def sweep_b_val(instr:pyvisa.resources.Resource, min_bval:float, max_bval:float,
init_lim, subsequent_lim = subsequent_lim, init_lim init_lim, subsequent_lim = subsequent_lim, init_lim
init_sweep, subsequent_sweep = subsequent_sweep, init_sweep init_sweep, subsequent_sweep = subsequent_sweep, init_sweep
# creates the pyramid list of B vals if one were to perform a hysteresis measurement
if loopscan_bool: if loopscan_bool:
bval_lst = pyramid_list(bval_lst) bval_lst = pyramid_list(bval_lst)