scan_tools.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:HYDROS 作者: dtold 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号