From a566dda4b031af42c9e3f396950c2df49f0917bb Mon Sep 17 00:00:00 2001 From: rtan Date: Tue, 23 Jul 2024 09:45:21 +0200 Subject: [PATCH] path_save=None default changed --- 20240709SerdarModScript.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/20240709SerdarModScript.py b/20240709SerdarModScript.py index 292a589..4d53971 100644 --- a/20240709SerdarModScript.py +++ b/20240709SerdarModScript.py @@ -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 # 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, - 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: # 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, @@ -382,6 +382,7 @@ def sweep_b_val(instr:pyvisa.resources.Resource, min_bval:float, max_bval:float, ValueError: when Bx limit is exceeded. ConnectionError: when no device is connected. """ '''''' + def pyramid_list(lst) -> Union[list, np.ndarray]: """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. @@ -400,6 +401,9 @@ def sweep_b_val(instr:pyvisa.resources.Resource, min_bval:float, max_bval:float, else: 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 =='': 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_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: bval_lst = pyramid_list(bval_lst)