def setup_xarray(scan_list,scan_list2,scan_range,scan_range2,log,log2,precis,precis2,scan_type):
if scan_type=='1d':
#for scanning a predefined list of numbers
if scan_list!=[]:
#interpolate to prescribed length
l1_spl=US(range(len(scan_list)),scan_list)
XARRAY=l1_spl(np.linspace(0,len(scan_list)-1,precis))
X2ARRAY=None
#for having a second simultaneously varying variable
if scan_list2!=[]:
#interpolate to prescribed length
l2_spl=US(scan_list,scan_list2)
X2ARRAY=l2_spl(XARRAY)
#log- or linearly spaced 1d scan
if (scan_list==[] and scan_list2==[]):
X2ARRAY=None #np.empty(1,dtype=np.float)
if log:
XARRAY=np.logspace(np.log10(scan_range[0]),np.log10(scan_range[1]),precis)
else:
XARRAY=np.linspace(scan_range[0],scan_range[1],precis)
elif scan_type=='2d':
#for scanning a predefined list of numbers
if scan_list!=[]:
#interpolate to prescribed length
l1_spl=US(range(len(scan_list)),scan_list)
XARRAY=np.tile(l1_spl(np.linspace(0,len(scan_list)-1,precis)),precis).flatten()
#for having a second simultaneously varying variable
if scan_list2!=[]:
#interpolate to prescribed length
l2_spl=US(scan_list,scan_list2)
X2ARRAY=np.repeat(l2_spl(XARRAY),precis)
else:
exit('Error: need to specify two scan_lists for 2d scan!')
#log- or linearly spaced 2d scan
if (scan_list==[] and scan_list2==[]):
if log:
XARRAY=np.tile(np.logspace(np.log10(scan_range[0]),np.log10(scan_range[1]),precis),precis2).flatten()
else:
XARRAY=np.tile(np.linspace(scan_range[0],scan_range[1],precis),precis2).flatten()
if log2:
X2ARRAY=np.repeat(np.logspace(np.log10(scan_range2[0]),np.log10(scan_range2[1]),precis2),precis).flatten()
else:
X2ARRAY=np.repeat(np.linspace(scan_range2[0],scan_range2[1],precis2),precis).flatten()
return XARRAY, X2ARRAY
评论列表
文章目录