Changeset 72 for sans/SANSReduction
- Timestamp:
- Mar 30, 2007 5:26:06 PM (16 years ago)
- Location:
- sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/CatVSTable.ipf
r48 r72 208 208 String fname,sname 209 209 210 String textstr,temp,lbl,date_time,suffix 211 Variable ctime,lambda,sdd,detcnt,cntrate,refNum,trans,thick,xcenter,ycenter,numatten 212 Variable lastPoint, beamstop,dum 210 // String textstr,temp,lbl,date_time,suffix 211 // Variable ,lambda,sdd,,refNum,trans,thick,xcenter,ycenter,numatten 212 // Variable lastPoint, beamstop,dum 213 Variable lastPoint,ctime,detcnt,cntrate 213 214 214 215 Wave/T GFilenames = $"root:myGlobals:CatVSHeaderInfo:Filenames" … … 234 235 235 236 lastPoint = numpnts(GLambda) 236 237 Open/R refNum as fname 238 237 238 //filename 239 239 InsertPoints lastPoint,1,GFilenames 240 240 GFilenames[lastPoint]=sname 241 241 242 //read the file alphanumeric suffix 243 InsertPoints lastPoint,1,GSuffix 244 GSuffix[lastPoint]=getSuffix(fname) 245 246 //read the counting time (integer) 247 InsertPoints lastPoint,1,GCntTime 248 ctime = getCountTime(fname) 249 GCntTime[lastPoint]=ctime 250 242 251 //read the file creation date 243 FSetPos refNum,19244 FReadLine/N=4 refNum,suffix245 InsertPoints lastPoint,1,GSuffix246 GSuffix[lastPoint]=suffix247 248 //read the counting time (integer)249 FSetPos refNum,31250 FBinRead/F=3/B=3 refNum, ctime251 InsertPoints lastPoint,1,GCntTime252 GCntTime[lastPoint]=ctime253 254 //read the file creation date255 FSetPos refNum,55256 FReadLine/N=20 refNum,date_time257 252 InsertPoints lastPoint,1,GDateTime 258 GDateTime[lastPoint]= date_time253 GDateTime[lastPoint]=getFileCreationDate(fname) 259 254 260 255 // read the sample.label text field 261 FSetPos refNum,98 //will start reading at byte 99262 FReadLine/N=60 refNum,lbl263 256 InsertPoints lastPoint,1,GLabels 264 GLabels[lastPoint]=lbl 265 266 Close refNum 267 268 //read the reals with GBLoadWave 269 String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" 270 String strToExecute 271 272 //detector count 273 strToExecute = GBLoadStr + "/S=47/U=1" + "\"" + fname + "\"" 274 Execute strToExecute 275 Wave w=$"tempGBWave0" 276 detcnt = w[0] 257 GLabels[lastPoint]=getSampleLabel(fname) 258 259 //read the reals 260 //detector count and (derived) count rate 261 detcnt = getDetCount(fname) 277 262 cntrate = detcnt/ctime 278 263 InsertPoints lastPoint,1,GTotCnts … … 282 267 283 268 //Attenuators 284 strToExecute = GBLoadStr + "/S=51/U=1" + "\"" + fname + "\""285 Execute strToExecute286 numatten = w[0]287 269 InsertPoints lastPoint,1,GNumAttens 288 GNumAttens[lastPoint]= numatten270 GNumAttens[lastPoint]=getAttenNumber(fname) 289 271 290 272 //Transmission 291 strToExecute = GBLoadStr + "/S=158/U=1" + "\"" + fname + "\""292 Execute strToExecute293 trans = w[0]294 273 InsertPoints lastPoint,1,GTransmission 295 GTransmission[lastPoint]= trans274 GTransmission[lastPoint]=getSampleTrans(fname) 296 275 297 276 //Thickness 298 strToExecute = GBLoadStr + "/S=162/U=1" + "\"" + fname + "\""299 Execute strToExecute300 thick = w[0]301 277 InsertPoints lastPoint,1,GThickness 302 GThickness[lastPoint]=thick 303 304 //XCenter 305 strToExecute = GBLoadStr + "/S=252/U=1" + "\"" + fname + "\"" 306 Execute strToExecute 307 xcenter = w[0] 278 GThickness[lastPoint]=getSampleThickness(fname) 279 280 //XCenter of beam on detector 308 281 InsertPoints lastPoint,1,GXCenter 309 GXCenter[lastPoint]= xCenter282 GXCenter[lastPoint]=getBeamXPos(fname) 310 283 311 284 //YCenter 312 strToExecute = GBLoadStr + "/S=256/U=1" + "\"" + fname + "\""313 Execute strToExecute314 ycenter = w[0]315 285 InsertPoints lastPoint,1,GYCenter 316 GYCenter[lastPoint]= ycenter286 GYCenter[lastPoint]=getBeamYPos(fname) 317 287 318 288 //SDD 319 strToExecute = GBLoadStr + "/S=260/U=1" + "\"" + fname + "\""320 Execute strToExecute321 sdd = w[0]322 289 InsertPoints lastPoint,1,GSDD 323 GSDD[lastPoint]= sdd290 GSDD[lastPoint]=getSDD(fname) 324 291 325 292 //wavelength 326 strToExecute = GBLoadStr + "/S=292/U=1" + "\"" + fname + "\""327 Execute strToExecute328 lambda = w[0]329 293 InsertPoints lastPoint,1,GLambda 330 GLambda[lastPoint]= lambda294 GLambda[lastPoint]=getWavelength(fname) 331 295 332 296 //Rotation Angle 333 strToExecute = GBLoadStr + "/S=170/U=1" + "\"" + fname + "\""334 Execute strToExecute335 dum = w[0]336 297 InsertPoints lastPoint,1,GRot 337 GRot[lastPoint]= dum298 GRot[lastPoint]=getSampleRotationAngle(fname) 338 299 339 300 //Sample Temperature 340 strToExecute = GBLoadStr + "/S=186/U=1" + "\"" + fname + "\""341 Execute strToExecute342 dum = w[0]343 301 InsertPoints lastPoint,1,GTemp 344 GTemp[lastPoint]= dum302 GTemp[lastPoint]=getTemperature(fname) 345 303 346 304 //Sample Field 347 strToExecute = GBLoadStr + "/S=190/U=1" + "\"" + fname + "\""348 Execute strToExecute349 dum = w[0]350 305 InsertPoints lastPoint,1,GField 351 GField[lastPoint]= dum306 GField[lastPoint]=getFieldStrength(fname) 352 307 353 308 //Beamstop position (not reported) … … 362 317 GIsTrans[lastPoint] = CheckIfBeamstopOut(fname, -5) //returns one if beamstop is "out" 363 318 364 KillWaves/Z w365 319 return(0) 366 320 End … … 457 411 Variable ctime,lambda,sdd,detcnt,cntrate,refNum,trans,thick 458 412 459 Open/R refNum as fname460 413 //read the file creation date 461 FSetPos refNum,55 462 FReadLine/N=20 refnum,date_time 414 date_time = getFileCreationDate(fname) 463 415 464 416 // read the sample.label text field 465 FSetPos refNum,98 //will start reading at byte 99 466 FReadLine/N=60 refNum,lbl 417 lbl = getSampleLabel(fname) 467 418 468 419 //read the counting time (integer) 469 FSetPos refNum,31 470 FBinRead/F=3/B=3 refNum, ctime 471 472 Close refNum 473 474 //read the reals with GBLoadWave 475 String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" 476 String strToExecute 477 478 //detector count 479 strToExecute = GBLoadStr + "/S=47/U=1" + "\"" + fname + "\"" 480 Execute strToExecute 481 Wave w=$"tempGBWave0" 482 detcnt = w[0] 420 ctime = getCountTime(fname) 421 422 //read the reals 423 424 //detector count + countrate 425 detcnt = getDetCount(fname) 483 426 cntrate = detcnt/ctime 484 427 485 428 //wavelength 486 strToExecute = GBLoadStr + "/S=292/U=1" + "\"" + fname + "\"" 487 Execute strToExecute 488 lambda = w[0] 429 lambda = getWavelength(fname) 489 430 490 431 //SDD 491 strToExecute = GBLoadStr + "/S=260/U=1" + "\"" + fname + "\"" 492 Execute strToExecute 493 sdd = w[0] 432 sdd = getSDD(fname) 494 433 495 434 //Transmission 496 strToExecute = GBLoadStr + "/S=158/U=1" + "\"" + fname + "\"" 497 Execute strToExecute 498 trans = w[0] 435 trans = getSampleTrans(fname) 499 436 500 437 //Thickness 501 strToExecute = GBLoadStr + "/S=162/U=1" + "\"" + fname + "\"" 502 Execute strToExecute 503 thick = w[0] 504 505 KillWaves/Z w 506 438 thick = getSampleThickness(fname) 439 507 440 temp = "FILE: " 508 441 Notebook CatWin,textRGB=(0,0,0),text=temp … … 647 580 Variable ctime,lambda,sdd,detcnt,cntrate,refNum,trans,thick,xcenter,ycenter,numatten 648 581 649 Open/R refNum as fname650 582 //read the file creation date 651 FSetPos refNum,55 652 FReadLine/N=20 refnum,date_time 583 date_time = getFileCreationDate(fname) 653 584 654 585 // read the sample.label text field 655 FSetPos refNum,98 //will start reading at byte 99 656 // Only read the first 10 letters in the run label 657 FReadLine/N=15 refNum,lbl 586 lbl = getSampleLabel(fname) 658 587 659 588 //read the counting time (integer) 660 FSetPos refNum,31 661 FBinRead/F=3/B=3 refNum, ctime 662 663 Close refNum 664 665 //read the reals with GBLoadWave 666 String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" 667 String strToExecute 668 669 //detector count 670 strToExecute = GBLoadStr + "/S=47/U=1" + "\"" + fname + "\"" 671 Execute strToExecute 672 Wave w=$"tempGBWave0" 673 detcnt = w[0] 589 ctime = getCountTime(fname) 590 591 //read the reals 592 //detector count + countrate 593 detcnt = getDetCount(fname) 674 594 cntrate = detcnt/ctime 675 595 596 //wavelength 597 lambda = getWavelength(fname) 598 599 //SDD 600 sdd = getSDD(fname) 601 602 //Transmission 603 trans = getSampleTrans(fname) 604 605 //Thickness 606 thick = getSampleThickness(fname) 607 676 608 //Attenuators 677 strToExecute = GBLoadStr + "/S=154/U=1" + "\"" + fname + "\"" 678 Execute strToExecute 679 numatten = w[0] 680 681 //Transmission 682 strToExecute = GBLoadStr + "/S=158/U=1" + "\"" + fname + "\"" 683 Execute strToExecute 684 trans = w[0] 685 686 //Thickness 687 strToExecute = GBLoadStr + "/S=162/U=1" + "\"" + fname + "\"" 688 Execute strToExecute 689 thick = w[0] 609 numatten = getAttenNumber(fname) 690 610 691 611 //XCenter 692 strToExecute = GBLoadStr + "/S=252/U=1" + "\"" + fname + "\"" 693 Execute strToExecute 694 xCenter = w[0] 612 xCenter = getBeamXPos(fname) 695 613 696 614 //YCenter 697 strToExecute = GBLoadStr + "/S=256/U=1" + "\"" + fname + "\"" 698 Execute strToExecute 699 yCenter = w[0] 700 701 //SDD 702 strToExecute = GBLoadStr + "/S=260/U=1" + "\"" + fname + "\"" 703 Execute strToExecute 704 sdd = w[0] 705 706 //wavelength 707 strToExecute = GBLoadStr + "/S=292/U=1" + "\"" + fname + "\"" 708 Execute strToExecute 709 lambda = w[0] 710 711 KillWaves/Z w 615 yCenter = getBeamYPos(fname) 616 712 617 713 618 temp = "" -
sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/Marquee.ipf
r70 r72 4 4 5 5 //////////// 6 // vers 1.21 3 may 06 needs some changes aftertotal transmission incorporated (BSG)6 // vers 1.21 3 may 06 total transmission incorporated (BSG) 7 7 // 8 8 //************************** … … 143 143 Endif 144 144 145 //go find the file, open it and write 4 integers to the file 146 //in the positions for analysis.rows(2), .cols(2) = 4 unused 4byte integers 147 Variable refnum 148 Open/A/T="????TEXT" refnum as filename 149 FSetPos refnum,478 150 FBinWrite/F=3/B=3 refNum, x1 151 FBinWrite/F=3/B=3 refNum, x2 152 FBinWrite/F=3/B=3 refNum, y1 153 FBinWrite/F=3/B=3 refNum, y2 154 //move to the end of the file before closing 155 FStatus refnum 156 FSetPos refnum,V_logEOF 157 Close refnum 145 WriteXYBoxToHeader(filename,x1,x2,y1,y2) 146 158 147 //ReWriteReal() takes care of open/close on its own 159 148 Print counts, " counts in XY box" -
sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/NCNR_DataReadWrite.ipf
r71 r72 801 801 End 802 802 803 ///// ASC FORMAT READER ////// 804 ///// FOR WORKFILE MATH PANEL ////// 805 806 //function to read in the ASC output of SANS reduction 807 // currently the file has 20 header lines, followed by a single column 808 // of 16384 values, Data is written by row, starting with Y=1 and X=(1->128) 809 // 810 //returns 0 if read was ok 811 //returns 1 if there was an error 812 // 813 // assumes a square detector 814 // 815 Function ReadASCData(fname,destPath) 816 String fname, destPath 817 //this function is for reading in ASCII data so put data in user-specified folder 818 SetDataFolder "root:"+destPath 819 820 NVAR pixelsX = root:myGlobals:gNPixelsX 821 NVAR pixelsY = root:myGlobals:gNPixelsY 822 Variable refNum=0,ii,p1,p2,tot,num=pixelsX,numHdrLines=20 823 String str="" 824 //data is initially linear scale 825 Variable/G :gIsLogScale=0 826 Make/O/T/N=(numHdrLines) hdrLines 827 Make/O/D/N=(num*num) data//,linear_data 828 829 //full filename and path is now passed in... 830 //actually open the file 831 // SetDataFolder destPath 832 Open/R/Z refNum as fname // /Z flag means I must handle open errors 833 if(refnum==0) //FNF error, get out 834 DoAlert 0,"Could not find file: "+fname 835 Close/A 836 SetDataFolder root: 837 return(1) 838 endif 839 if(V_flag!=0) 840 DoAlert 0,"File open error: V_flag="+num2Str(V_Flag) 841 Close/A 842 SetDataFolder root: 843 return(1) 844 Endif 845 // 846 for(ii=0;ii<numHdrLines;ii+=1) //read (or skip) 18 header lines 847 FReadLine refnum,str 848 hdrLines[ii]=str 849 endfor 850 // 851 Close refnum 852 853 // SetDataFolder destPath 854 LoadWave/Q/G/D/N=temp fName 855 Wave/Z temp0=temp0 856 data=temp0 857 Redimension/N=(pixelsX,pixelsY) data//,linear_data 858 859 //linear_data = data 860 861 KillWaves/Z temp0 862 863 //return the data folder to root 864 SetDataFolder root: 865 866 Return(0) 867 End 868 869 // fills the "default" fake header so that the SANS Reduction machinery does not have to be altered 870 // pay attention to what is/not to be trusted due to "fake" information 871 // 872 // destFolder is of the form "myGlobals:WorkMath:AAA" 873 // 874 Function FillFakeHeader_ASC(destFolder) 875 String destFolder 876 Make/O/N=23 $("root:"+destFolder+":IntegersRead") 877 Make/O/N=52 $("root:"+destFolder+":RealsRead") 878 Make/O/T/N=11 $("root:"+destFolder+":TextRead") 879 880 Wave intw=$("root:"+destFolder+":IntegersRead") 881 Wave realw=$("root:"+destFolder+":RealsRead") 882 Wave/T textw=$("root:"+destFolder+":TextRead") 883 884 //Put in appropriate "fake" values 885 //parse values as needed from headerLines 886 Wave/T hdr=$("root:"+destFolder+":hdrLines") 887 Variable monCt,lam,offset,sdd,trans,thick 888 Variable xCtr,yCtr,a1,a2,a1a2Dist,dlam,bsDiam 889 String detTyp="" 890 String tempStr="",formatStr="",junkStr="" 891 formatStr = "%g %g %g %g %g %g" 892 tempStr=hdr[3] 893 sscanf tempStr, formatStr, monCt,lam,offset,sdd,trans,thick 894 // Print monCt,lam,offset,sdd,trans,thick,avStr,step 895 formatStr = "%g %g %g %g %g %g %g %s" 896 tempStr=hdr[5] 897 sscanf tempStr,formatStr,xCtr,yCtr,a1,a2,a1a2Dist,dlam,bsDiam,detTyp 898 // Print xCtr,yCtr,a1,a2,a1a2Dist,dlam,bsDiam,detTyp 899 900 realw[16]=xCtr //xCtr(pixels) 901 realw[17]=yCtr //yCtr (pixels) 902 realw[18]=sdd //SDD (m) 903 realw[26]=lam //wavelength (A) 904 // 905 // necessary values 906 realw[10]=5 //detector calibration constants, needed for averaging 907 realw[11]=10000 908 realw[12]=0 909 realw[13]=5 910 realw[14]=10000 911 realw[15]=0 912 // 913 // used in the resolution calculation, ONLY here to keep the routine from crashing 914 realw[20]=65 //det size 915 realw[27]=dlam //delta lambda 916 realw[21]=bsDiam //BS size 917 realw[23]=a1 //A1 918 realw[24]=a2 //A2 919 realw[25]=a1a2Dist //A1A2 distance 920 realw[4]=trans //trans 921 realw[3]=0 //atten 922 realw[5]=thick //thick 923 // 924 // 925 realw[0]=monCt //def mon cts 926 927 // fake values to get valid deadtime and detector constants 928 // 929 textw[9]=detTyp+" " //6 characters 4+2 spaces 930 textw[3]="[NGxSANS00]" //11 chars, NGx will return default values for atten trans, deadtime... 931 932 //set the string values 933 formatStr="FILE: %s CREATED: %s" 934 sscanf hdr[0],formatStr,tempStr,junkStr 935 // Print tempStr 936 // Print junkStr 937 String/G $("root:"+destFolder+":fileList") = tempStr 938 textw[0] = tempStr //filename 939 textw[1] = junkStr //run date-time 940 941 //file label = hdr[1] 942 tempStr = hdr[1] 943 tempStr = tempStr[0,strlen(tempStr)-2] //clean off the last LF 944 // Print tempStr 945 textW[6] = tempStr //sample label 946 947 return(0) 948 End 949 950 951 952 953 954 803 955 ////testing procedure that is not called anymore and is out-of-date 804 956 ////with the new data structures. update before re-implementing … … 979 1131 End 980 1132 1133 // file creation date (20 characters @ byte 55) 1134 Function/S getFileCreationDate(fname) 1135 String fname 1136 1137 return(getStringFromHeader(fname,55,20)) 1138 End 1139 981 1140 // read a single real value with GBLoadWave 982 1141 Function getRealValueFromHeader(fname,start) … … 1035 1194 end 1036 1195 1196 //Sample Rotation Angle is at byte 170 1197 Function getSampleRotationAngle(fname) 1198 String fname 1199 1200 return(getRealValueFromHeader(fname,170)) 1201 end 1202 1037 1203 //temperature is at byte 186 1038 1204 Function getTemperature(fname) … … 1049 1215 end 1050 1216 1051 //beam stopxPos is at byte 2521052 Function getB SXPos(fname)1217 //beam xPos is at byte 252 1218 Function getBeamXPos(fname) 1053 1219 String fname 1054 1220 … … 1056 1222 end 1057 1223 1058 //beam stopY pos is at byte 2561059 Function getB SYPos(fname)1224 //beam Y pos is at byte 256 1225 Function getBeamYPos(fname) 1060 1226 String fname 1061 1227 … … 1126 1292 end 1127 1293 1128 1294 ////// integer values 1129 1295 1130 1296 Function getIntegerFromHeader(fname,start) … … 1172 1338 End 1173 1339 1340 ///// TRANSMISSION RELATED FUNCTIONS //////// 1341 //box coordinate are returned by reference 1342 Function GetXYBoxFromFile(filename,x1,x2,y1,y2) 1343 String filename 1344 Variable &x1,&x2,&y1,&y2 1345 1346 Variable refnum 1347 String tmpFile = FindValidFilename(filename) 1348 1349 Open/R/P=catPathName refnum as tmpFile 1350 FSetPos refnum,478 1351 FBinRead/F=3/B=3 refnum, x1 1352 FBinRead/F=3/B=3 refnum, x2 1353 FBinRead/F=3/B=3 refnum, y1 1354 FBinRead/F=3/B=3 refnum, y2 1355 Close refnum 1356 1357 return(0) 1358 End 1359 1360 //go find the file, open it and write 4 integers to the file 1361 //in the positions for analysis.rows(2), .cols(2) = 4 unused 4byte integers 1362 Function WriteXYBoxToHeader(filename,x1,x2,y1,y2) 1363 String filename 1364 Variable x1,x2,y1,y2 1365 1366 Variable refnum 1367 Open/A/T="????TEXT" refnum as filename 1368 FSetPos refnum,478 1369 FBinWrite/F=3/B=3 refNum, x1 1370 FBinWrite/F=3/B=3 refNum, x2 1371 FBinWrite/F=3/B=3 refNum, y1 1372 FBinWrite/F=3/B=3 refNum, y2 1373 //move to the end of the file before closing 1374 FStatus refnum 1375 FSetPos refnum,V_logEOF 1376 Close refnum 1377 1378 return(0) 1379 End -
sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/PatchFiles.ipf
r71 r72 793 793 Variable/G root:myGlobals:Patch:gPV1 = getSampleTrans(fname) 794 794 Variable/G root:myGlobals:Patch:gPV2 = getSampleThickness(fname) 795 Variable/G root:myGlobals:Patch:gPV3 = getB SXPos(fname)796 Variable/G root:myGlobals:Patch:gPV4 = getB SYPos(fname)795 Variable/G root:myGlobals:Patch:gPV3 = getBeamXPos(fname) 796 Variable/G root:myGlobals:Patch:gPV4 = getBeamYPos(fname) 797 797 Variable/G root:myGlobals:Patch:gPV5 = getAttenNumber(fname) 798 798 Variable/G root:myGlobals:Patch:gPV6 = getCountTime(fname) -
sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/ProtocolAsPanel.ipf
r47 r72 1099 1099 1100 1100 //procedure called by protocol panel to ask user for agerage type choices 1101 // somewhat confusing and complex, but may be as good as it gets.1101 // somewhat confusing and complex, but may be as good as it gets. 1102 1102 // 1103 1103 Proc GetAvgInfo(av_typ,autoSave,autoName,autoPlot,side,phi,dphi,width,QCtr,QDelta) … … 2166 2166 Abort "Box not selected properly - Please re-set the ABS parameters" 2167 2167 Endif 2168 //box is OK, write box values to file (this does the same as SetXYBoxCoords) 2169 String tempName = FindValidFilename(filename) 2168 //box is OK, write box values to file 2170 2169 PathInfo/S catPathName 2171 print S_Path + tempname 2172 Open/A/T="????TEXT" refnum as (S_Path + tempname) 2173 FSetPos refnum,478 2174 FBinWrite/F=3/B=3 refNum, x1 2175 FBinWrite/F=3/B=3 refNum, x2 2176 FBinWrite/F=3/B=3 refNum, y1 2177 FBinWrite/F=3/B=3 refNum, y2 2178 //move to the end of the file before closing 2179 FStatus refnum 2180 FSetPos refnum,V_logEOF 2181 Close refnum 2170 String tempName = S_Path + FindValidFilename(filename) 2171 WriteXYBoxToHeader(tempName,x1,x2,y1,y2) 2182 2172 else 2183 2173 //give option to override … … 2233 2223 End 2234 2224 2235 //box coordinate are returned by reference2236 Function GetXYBoxFromFile(filename,x1,x2,y1,y2)2237 String filename2238 Variable &x1,&x2,&y1,&y22239 2240 Variable refnum2241 String emptyFile = FindValidFilename(filename)2242 2243 // Print emptyfile2244 2245 Open/R/P=catPathName refnum as emptyFile2246 FSetPos refnum,4782247 FBinRead/F=3/B=3 refnum, x12248 FBinRead/F=3/B=3 refnum, x22249 FBinRead/F=3/B=3 refnum, y12250 FBinRead/F=3/B=3 refnum, y22251 Close refnum2252 2253 return(0)2254 End2255 2256 2225 Function UserSelectBox_Continue(ctrlName) :buttonControl 2257 2226 String ctrlName -
sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/WorkFileUtils.ipf
r47 r72 1130 1130 End 1131 1131 1132 //function to read in the ASC output of SANS reduction 1133 // currently the file has 20 header lines, followed by a single column 1134 // of 16384 values, Data is written by row, starting with Y=1 and X=(1->128) 1135 // 1136 //returns 0 if read was ok 1137 //returns 1 if there was an error 1138 // 1139 // assumes a square detector 1140 // 1141 Function ReadASCData(fname,destPath) 1142 String fname, destPath 1143 //this function is for reading in ASCII data so put data in user-specified folder 1144 SetDataFolder "root:"+destPath 1145 1146 NVAR pixelsX = root:myGlobals:gNPixelsX 1147 NVAR pixelsY = root:myGlobals:gNPixelsY 1148 Variable refNum=0,ii,p1,p2,tot,num=pixelsX,numHdrLines=20 1149 String str="" 1150 //data is initially linear scale 1151 Variable/G :gIsLogScale=0 1152 Make/O/T/N=(numHdrLines) hdrLines 1153 Make/O/D/N=(num*num) data//,linear_data 1154 1155 //full filename and path is now passed in... 1156 //actually open the file 1157 // SetDataFolder destPath 1158 Open/R/Z refNum as fname // /Z flag means I must handle open errors 1159 if(refnum==0) //FNF error, get out 1160 DoAlert 0,"Could not find file: "+fname 1161 Close/A 1162 SetDataFolder root: 1163 return(1) 1164 endif 1165 if(V_flag!=0) 1166 DoAlert 0,"File open error: V_flag="+num2Str(V_Flag) 1167 Close/A 1168 SetDataFolder root: 1169 return(1) 1170 Endif 1171 // 1172 for(ii=0;ii<numHdrLines;ii+=1) //read (or skip) 18 header lines 1173 FReadLine refnum,str 1174 hdrLines[ii]=str 1175 endfor 1176 // 1177 Close refnum 1178 1179 // SetDataFolder destPath 1180 LoadWave/Q/G/D/N=temp fName 1181 Wave/Z temp0=temp0 1182 data=temp0 1183 Redimension/N=(pixelsX,pixelsY) data//,linear_data 1184 1185 //linear_data = data 1186 1187 KillWaves/Z temp0 1188 1189 //return the data folder to root 1190 SetDataFolder root: 1191 1192 Return(0) 1193 End 1132 1194 1133 1195 1134 //fileStr must be the FULL path and filename on disk … … 1262 1201 End 1263 1202 1264 // fills the "default" fake header so that the SANS Reduction machinery does not have to be altered 1265 // pay attention to what is/not to be trusted due to "fake" information 1266 // 1267 // destFolder is of the form "myGlobals:WorkMath:AAA" 1268 // 1269 Function FillFakeHeader_ASC(destFolder) 1270 String destFolder 1271 Make/O/N=23 $("root:"+destFolder+":IntegersRead") 1272 Make/O/N=52 $("root:"+destFolder+":RealsRead") 1273 Make/O/T/N=11 $("root:"+destFolder+":TextRead") 1274 1275 Wave intw=$("root:"+destFolder+":IntegersRead") 1276 Wave realw=$("root:"+destFolder+":RealsRead") 1277 Wave/T textw=$("root:"+destFolder+":TextRead") 1278 1279 //Put in appropriate "fake" values 1280 //parse values as needed from headerLines 1281 Wave/T hdr=$("root:"+destFolder+":hdrLines") 1282 Variable monCt,lam,offset,sdd,trans,thick 1283 Variable xCtr,yCtr,a1,a2,a1a2Dist,dlam,bsDiam 1284 String detTyp="" 1285 String tempStr="",formatStr="",junkStr="" 1286 formatStr = "%g %g %g %g %g %g" 1287 tempStr=hdr[3] 1288 sscanf tempStr, formatStr, monCt,lam,offset,sdd,trans,thick 1289 // Print monCt,lam,offset,sdd,trans,thick,avStr,step 1290 formatStr = "%g %g %g %g %g %g %g %s" 1291 tempStr=hdr[5] 1292 sscanf tempStr,formatStr,xCtr,yCtr,a1,a2,a1a2Dist,dlam,bsDiam,detTyp 1293 // Print xCtr,yCtr,a1,a2,a1a2Dist,dlam,bsDiam,detTyp 1294 1295 realw[16]=xCtr //xCtr(pixels) 1296 realw[17]=yCtr //yCtr (pixels) 1297 realw[18]=sdd //SDD (m) 1298 realw[26]=lam //wavelength (A) 1299 // 1300 // necessary values 1301 realw[10]=5 //detector calibration constants, needed for averaging 1302 realw[11]=10000 1303 realw[12]=0 1304 realw[13]=5 1305 realw[14]=10000 1306 realw[15]=0 1307 // 1308 // used in the resolution calculation, ONLY here to keep the routine from crashing 1309 realw[20]=65 //det size 1310 realw[27]=dlam //delta lambda 1311 realw[21]=bsDiam //BS size 1312 realw[23]=a1 //A1 1313 realw[24]=a2 //A2 1314 realw[25]=a1a2Dist //A1A2 distance 1315 realw[4]=trans //trans 1316 realw[3]=0 //atten 1317 realw[5]=thick //thick 1318 // 1319 // 1320 realw[0]=monCt //def mon cts 1321 1322 // fake values to get valid deadtime and detector constants 1323 // 1324 textw[9]=detTyp+" " //6 characters 4+2 spaces 1325 textw[3]="[NGxSANS00]" //11 chars, NGx will return default values for atten trans, deadtime... 1326 1327 //set the string values 1328 formatStr="FILE: %s CREATED: %s" 1329 sscanf hdr[0],formatStr,tempStr,junkStr 1330 // Print tempStr 1331 // Print junkStr 1332 String/G $("root:"+destFolder+":fileList") = tempStr 1333 textw[0] = tempStr //filename 1334 textw[1] = junkStr //run date-time 1335 1336 //file label = hdr[1] 1337 tempStr = hdr[1] 1338 tempStr = tempStr[0,strlen(tempStr)-2] //clean off the last LF 1339 // Print tempStr 1340 textW[6] = tempStr //sample label 1341 1342 return(0) 1343 End 1203 1344 1204 1345 1205 //function called by the popups to get a file list of data that can be sorted
Note: See TracChangeset
for help on using the changeset viewer.