使用DM Script加载Python生成的EDX线扫CSV时校准无效求助
EDX线扫CSV加载校准问题
我用DM Script将线扫剖面加载到DM软件,脚本加载Esprit导出的EDX线扫CSV文件正常,但加载Python生成的同类CSV时,弹出错误提示:“校准无效;请检查刻度非零且刻度和原点均可表示为32位浮点数”。以下是校准脚本、错误截图和CSV文件截图,求解决方案。
string path number filereference number counter number dobreak=0 number colcounter=1 image dataarray documentwindow win string unitstring number cltest // Select the file if(!opendialog(win,"Select Bruker Line Profile export file (.csv).","",path)) exit(0) string filename=pathextractbasename(path,0) string extension=pathextractextension(path, 0) // Check to see if the file is a text file - extension .txt if(extension!="csv") { if(!twobuttondialog("The selected file does not appear to be a csv (.csv) file.", "Continue", "Cancel")) exit(0) } // Remove any previous temporary information in the Global info deletepersistentnote("Bruker Import") try { filereference=openfileforreading(path) number readok=1 string thisline // While ever the end of file has not been reached (readok=0) continue reading lines from the file while(readok==1) { readok=readfileline(filereference, thisline) number linelen=len(thisline) // Check the first line contains the word 'Index'. Note, this checking is kept deliberately // loose because the Bruker export format has varied over the years, so the aim is to keep // it compatible. if(counter==0) { string indexstring number foundstring=find(thisline, "Index") number foundstring1=find(thisline, "x") number cl if(foundstring1<0) { cl=23; } else { if(foundstring<0) { cl=2; } else {cl=15; } } // Find the tabs - which are the delimiters number i string tempstring for(i=cl; i<linelen; i++) { string thischar=mid(thisline, i, 1) if(thischar==",") { thischar="" // nb i+1 because a space follows immediately after the comma // and +3 to deal with the carriage return at the end of the line //} //if(asc(thischar)==44) // tab found*/ //{ setpersistentstringnote("Bruker Import:Element "+colcounter, tempstring) colcounter=colcounter+1 tempstring="" } if(asc(thischar)==13) // Carriage return found { setpersistentstringnote("Bruker Import:Element "+colcounter, tempstring) break } tempstring=tempstring+thischar } } counter=counter+1 } } catch // there was an error - close the file { closefile(filereference) showalert("the file was opened by other process",2) exit(0) } number nooflines=counter-1 // ignore the headeer line counter=0 number i closefile(filereference) number noofcolumns=colcounter+2 try { filereference=openfileforreading(path) number readok=1 string thisline readok=readfileline(filereference, thisline) dataarray=realimage("",4, (nooflines-1), noofcolumns) number linecounter=0 while(readok==1) { string tempstring number columncounter=0 number xsize, ysize, reallines getsize(dataarray, xsize, ysize) for(i=0; i<xsize; i++) { number thisval=getpixel(dataarray, i,0) if(thisval!=0) reallines=reallines+1 } number totallength=getpixel(dataarray, xsize-1, 1) number calib if (totallength<1) {calib=totallength*1000/(xsize);} else {calib=totallength/(xsize);} result("calib :"+ calib+"\n" )
相关截图
- 错误提示截图:

- Python生成的CSV文件截图:

内容的提问来源于stack exchange,提问作者together
相关产品推荐
相关产品推荐

