- Timestamp:
- May 20, 2016 4:28:56 PM (7 years ago)
- Location:
- sans/Dev/trunk
- Files:
-
- 1 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Analysis/Models/NewModels_2006/SchulzSpheres_v40.ipf
r835 r999 72 72 End 73 73 74 74 // 75 Proc PlotSchulzSpheresBeta(num,qmin,qmax) 76 Variable num=128,qmin=0.001,qmax=0.7 77 Prompt num "Enter number of data points for model: " 78 Prompt qmin "Enter minimum q-value (A^-1) for model: " 79 Prompt qmax "Enter maximum q-value (A^-1) for model: " 80 81 Make/O/D/N=(num) xwave_sch_beta,ywave_sch_beta 82 xwave_sch_beta = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) ) 83 Make/O/D coef_sch_beta = {0.01,60,0.2,1e-6,3e-6,0.001} 84 make/O/T parameters_sch_beta = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","bkg (cm-1 sr-1)"} 85 Edit parameters_sch_beta,coef_sch_beta 86 87 Variable/G root:g_sch_beta 88 g_sch_beta := SchulzSpheresBeta(coef_sch_beta,ywave_sch_beta,xwave_sch_beta) 89 Display ywave_sch_beta vs xwave_sch_beta 90 ModifyGraph log=1,marker=29,msize=2,mode=4 91 Label bottom "q (A\\S-1\\M)" 92 Label left "Intensity (cm\\S-1\\M)" 93 AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 94 95 AddModelToStrings("SchulzSpheresBeta","coef_sch_beta","parameters_sch_beta","sch_beta") 96 End 75 97 76 98 Function Schulz_Point(x,avg,zz) -
sans/Dev/trunk/NCNR_User_Procedures/Analysis/Models/ProlateCoreShell_Sq_v40.ipf
r774 r999 108 108 // Killwaves/Z form_PEF_HS,struct_PEF_HS 109 109 110 return ( yw)110 return (0) 111 111 End 112 112 … … 528 528 // Killwaves/Z form_PEF_2Y,struct_PEF_2Y 529 529 530 return ( yw)530 return (0) 531 531 End 532 532 -
sans/Dev/trunk/NCNR_User_Procedures/Analysis/Packages/ModelPicker/SANSModelPicker_v40.ipf
r896 r999 80 80 81 81 // always turn off file checking for me 82 checkForFiles = !(stringmatch(ParseFilePath(0,SpecialDirPath("Desktop",0,0,0),":",1,1),"s*ine")) //zero for me 83 checkForFiles = !(stringmatch(ParseFilePath(0,SpecialDirPath("Desktop",0,0,0),":",1,1),"ajj")) //and zero for me 84 checkForFiles = !(stringmatch(ParseFilePath(0,SpecialDirPath("Desktop",0,0,0),":",1,1),"andrewjackson")) //and zero for me 85 82 if( stringmatch(ParseFilePath(0,SpecialDirPath("Desktop",0,0,0),":",1,1),"s*ine") ) 83 checkforfiles = 0 84 endif 85 if( stringmatch(ParseFilePath(0,SpecialDirPath("Desktop",0,0,0),":",1,1),"ajj") ) 86 checkforfiles = 0 87 endif 88 if( stringmatch(ParseFilePath(0,SpecialDirPath("Desktop",0,0,0),":",1,1),"andrewjackson") ) 89 checkforfiles = 0 90 endif 91 86 92 // turn off file checking if the proper alias to the NCNR procedures is there 87 93 PathInfo igor 88 94 NewPath/O/Q tmpUPPath S_Path + "User Procedures" 89 95 String fileList = IndexedFile(tmpUPPath,-1,"????") 96 if(strsearch(fileList, "NCNR_User_Procedures", 0 , 2) != -1) //ignore case 97 checkforfiles = 0 98 Print "found the proper procedures" 99 endif 100 101 // check the Documents:WaveMetrics:IP: UP folder (always writeable) 102 // print SpecialDirPath("Igor Pro User Files",0,0,0) 103 // Macintosh HD:Users:srkline:Documents:WaveMetrics:Igor Pro 7 User Files: 104 105 NewPath/O/Q tmpUPPath SpecialDirPath("Igor Pro User Files",0,0,0) + "User Procedures" 106 fileList = IndexedFile(tmpUPPath,-1,"????") 90 107 if(strsearch(fileList, "NCNR_User_Procedures", 0 , 2) != -1) //ignore case 91 108 checkforfiles = 0 -
sans/Dev/trunk/NCNR_User_Procedures/Analysis/Packages/Wrapper_v40.ipf
r941 r999 627 627 w[0] += 1e-6 628 628 w[0] -= 1e-6 629 629 630 631 630 632 break 631 633 endswitch -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/EventModeProcessing.ipf
r990 r999 16 16 // 17 17 // -- NEW 2016 18 // 19 // -- see the Procedure DecodeBinaryEvents(numToPrint) for a first implementation of a "viewer" 20 // for the binary events. Prints out the decoded 32-bit binary to the command window for inspection 21 // Could be modified as needed to flag events, see what bad events really look like, etc. (May 2016) 22 18 23 // -- see the proc DisplayForSlicing() that may aid in setting the bins properly by plotting the 19 24 // bins along with the differential collection rate … … 189 194 190 195 // for decimation 191 Variable/G root:Packages:NIST:Event:gEventFileTooLarge = 150 // 150 MB considered too large196 Variable/G root:Packages:NIST:Event:gEventFileTooLarge = 2500 // 2500 MB considered too large 192 197 Variable/G root:Packages:NIST:Event:gDecimation = 100 193 198 Variable/G root:Packages:NIST:Event:gEvent_t_longest_decimated = 0 … … 280 285 Button button16_1,pos={488,450},size={110,20},proc=AccumulateSlicesButton,title="Add Next Slice" 281 286 Button button17_2,pos={620,425},size={110,20},proc=AccumulateSlicesButton,title="Display Total" 287 Button button22,pos={620,450},size={120,20},proc=Osc_LoadAdjList_BinOnFly,title="Load+Accumulate" 282 288 283 289 CheckBox chkbox1_0,pos={25,34},size={69,14},title="Oscillatory",fSize=10 … … 584 590 // now before binning, sort the data 585 591 586 // this is slow -undoing the sorting and starting over, but if you don't,592 //MakeIndex is REALLY SLOW - this is slow - to allow undoing the sorting and starting over, but if you don't, 587 593 // you'll never be able to undo the sort 588 594 // 595 // 596 // for a 500 MB hst, MakeIndex = 83s, everything else in this function totalled < 5s 597 // 589 598 SetDataFolder root:Packages:NIST:Event: 590 599 591 600 if(WaveExists($"root:Packages:NIST:Event:OscSortIndex") == 0 ) 592 601 Duplicate/O rescaledTime OscSortIndex 602 // tic() 593 603 MakeIndex rescaledTime OscSortIndex 604 // toc() 605 // tic() 594 606 IndexSort OscSortIndex, yLoc,xLoc,timePt,rescaledTime 607 // toc() 595 608 //SetDataFolder root:Packages:NIST:Event 609 // tic() 596 610 IndexForHistogram(xLoc,yLoc,binnedData) // index the events AFTER sorting 611 // toc() 597 612 //SetDataFolder root: 598 613 Endif … … 600 615 Wave index = root:Packages:NIST:Event:SavedIndex //this is the histogram index 601 616 617 // tic() 602 618 for(ii=0;ii<nslices;ii+=1) 603 619 if(ii==0) … … 634 650 endfor 635 651 652 // toc() 636 653 Duplicate/O slicedData,root:Packages:NIST:Event:dispsliceData,root:Packages:NIST:Event:logSlicedData 637 654 Wave logSlicedData = root:Packages:NIST:Event:logSlicedData … … 992 1009 993 1010 // MODE_TISANE 994 1011 //TODO -- tisane doesn't do anything different than oscillatory. Is this really correct?? 1012 if(mode == MODE_TISANE) // TISANE mode - don't adjust the times, we get periodic t0 to reset t=0 1013 Duplicate/O timePt rescaledTime 1014 rescaledTime *= 1e-7 //convert to seconds and that's all 1015 t_longest = waveMax(rescaledTime) //if oscillatory, won't be the last point, so get it this way 1016 1017 KillWaves/Z OscSortIndex //to make sure that there is no old index hanging around 1018 endif 1019 995 1020 // MODE_TOF 996 1021 if(mode == MODE_TOF) // TOF mode - don't adjust the times, we get periodic t0 to reset t=0 … … 1275 1300 totBytes = V_logEOF 1276 1301 Print "total bytes = ", totBytes 1277 1302 if(EventDataType(filePathStr) != 1) //if not hst extension of raw data 1303 Abort "Data must be raw event data with file extension .hst for this operation" 1304 return(0) 1305 endif 1278 1306 //toc() 1279 1307 // … … 1768 1796 Print "total bytes = ", totBytes 1769 1797 1798 if(EventDataType(filePathStr) != 1) //if not hst extension of raw data 1799 Abort "Data must be raw event data with file extension .hst for this operation" 1800 return(0) 1801 endif 1770 1802 // 1771 1803 // Print "scan only" … … 2436 2468 Wave xLoc = xLoc 2437 2469 Wave yLoc = yLoc 2438 Save/T xLoc,yLoc,timePt 2470 Save/T xLoc,yLoc,timePt,rescaledTime //will ask for a name 2439 2471 2440 2472 SetDataFolder root: … … 2464 2496 // load in the waves, saved as Igor text to preserve the data type 2465 2497 PathInfo/S catPathName //should set the next dialog to the proper path... 2466 LoadWave/T/O/P=catPathName 2467 filePathStr = S_fileName 2498 filePathStr = PromptForPath("Pick the edited event data") 2499 if(EventDataType(filePathStr) != 2) //if not itx extension of edited data 2500 Abort "Data must be edited data with file extension .itx for this operation" 2501 return(0) 2502 endif 2503 LoadWave/T/O/P=catPathName filePathStr 2504 // filePathStr = S_fileName 2505 2468 2506 if(strlen(S_fileName) == 0) 2469 2507 //user cancelled … … 3047 3085 3048 3086 for(ii=0;ii<numSplit;ii+=1) 3049 outStr = (thePath+baseStr+num2str(ii) )3087 outStr = (thePath+baseStr+num2str(ii)+".hst") 3050 3088 // Print "outStr = ",outStr 3051 3089 Open outRef as outStr … … 3057 3095 3058 3096 Close outRef 3059 // listStr += outStr+";" 3060 listStr += baseStr+num2str(ii)+" ;"3097 // listStr += outStr+";" //no, this is the FULL path 3098 listStr += baseStr+num2str(ii)+".hst"+";" 3061 3099 endfor 3062 3100 3063 3101 Make/O/B/U/N=(frac) leftover 3064 3102 // ii was already incremented past the loop 3065 outStr = (thePath+baseStr+num2str(ii) )3103 outStr = (thePath+baseStr+num2str(ii)+".hst") 3066 3104 Open outRef as outStr 3067 3105 for(jj=0;jj<num;jj+=1) … … 3074 3112 Close outRef 3075 3113 // listStr += outStr+";" 3076 listStr += baseStr+num2str(ii)+" ;"3114 listStr += baseStr+num2str(ii)+".hst"+";" 3077 3115 3078 3116 FSetPos refNum,V_logEOF … … 3127 3165 End 3128 3166 3129 Function AccumulateSlices(mode) 3130 Variable mode 3131 3167 // added an extra (optional) parameter for silent operation - to be used when a list of 3168 // files are processed - so the user can walk away as it works. Using the buttons from the 3169 // panel will still present the alerts 3170 // 3171 Function AccumulateSlices(mode,[skipAlert]) 3172 Variable mode,skipAlert 3173 3174 if(ParamIsDefault(skipAlert)) 3175 skipAlert = 0 3176 endif 3132 3177 SetDataFolder root:Packages:NIST:Event: 3133 3178 3134 3179 switch(mode) 3135 3180 case 0: 3136 DoAlert 0,"The current data has been copied to the accumulated set. You are now ready to add more data." 3181 if(!skipAlert) 3182 DoAlert 0,"The current data has been copied to the accumulated set. You are now ready to add more data." 3183 endif 3137 3184 KillWaves/Z accumulatedData 3138 Duplicate/O slicedData accumulatedData 3185 Duplicate/O slicedData accumulatedData 3186 KillWaves/Z accum_BinCount // the accumulated BinCount 3187 Duplicate/O binCount accum_binCount 3139 3188 break 3140 3189 case 1: 3141 DoAlert 0,"The current data has been added to the accumulated data. You can add more data." 3190 if(!skipAlert) 3191 DoAlert 0,"The current data has been added to the accumulated data. You can add more data." 3192 endif 3142 3193 Wave acc=accumulatedData 3143 3194 Wave cur=slicedData 3144 3195 acc += cur 3196 Wave binCount = binCount 3197 Wave accum_binCount = accum_BinCount 3198 accum_BinCount += binCount 3199 binCount = accum_binCount // !! NOTE - the bin count wave is now the total 3200 // AccumulateSlices(2,skipAlert=skipAlert) // and a recursive call to show the total! 3145 3201 break 3146 3202 case 2: 3147 DoAlert 0,"The accumulated data is now the display data and is ready for display or export." 3203 if(!skipAlert) 3204 DoAlert 0,"The accumulated data is now the display data and is ready for display or export." 3205 endif 3148 3206 Duplicate/O accumulatedData slicedData 3149 3207 // do something to "touch" the display to force it to update … … 3413 3471 3414 3472 Variable fileref 3415 3473 Variable num,ii 3474 3416 3475 SVAR filename = root:Packages:NIST:Event:gEvent_logfile 3417 3476 NVAR t_longest = root:Packages:NIST:Event:gEvent_t_longest … … 3444 3503 3445 3504 //loop through everything in the list 3446 Variable num,ii3447 3505 num = ItemsInList(listStr) 3506 if(num == 0) 3507 DoAlert 0,"Enter the file names in the table, then click 'Load From List' again." 3508 return (0) 3509 endif 3448 3510 3449 3511 for(ii=0;ii<num;ii+=1) … … 3451 3513 // (1) load the file, prepending the path 3452 3514 filename = pathStr + StringFromList(ii, listStr ,";") 3453 3515 if(EventDataType(filename) != 1) //if not hst extension of raw data 3516 Abort "Data must be raw event data with file extension .hst for this operation" 3517 return(0) 3518 endif 3454 3519 3455 3520 #if (exists("EventLoadWave")==4) … … 3555 3620 num = ItemsInList(listStr) 3556 3621 3622 if(num == 0) 3623 DoAlert 0,"Enter the file names in the table, then click 'Load From List' again." 3624 return(0) 3625 endif 3626 3557 3627 for(ii=0;ii<num;ii+=1) 3558 3628 3559 3629 // (1) load the file, prepending the path 3560 3630 filename = pathStr + StringFromList(ii, listStr ,";") 3561 3631 if(EventDataType(filename) != 2) //if not itx extension of edited data 3632 Abort "Data must be edited data with file extension .itx for this operation" 3633 return(0) 3634 endif 3562 3635 SetDataFolder root:Packages:NIST:Event: 3563 3636 LoadWave/T/O fileName … … 3635 3708 Variable num,ii,jj 3636 3709 num = ItemsInList(listStr) 3637 3638 3710 if(num == 0) 3711 DoAlert 0,"Enter the file names in the table, then click 'Load From List' again." 3712 return(0) 3713 endif 3714 3639 3715 //////////////// 3640 3716 // declarations for the binning … … 3679 3755 // (1) load the file, prepending the path 3680 3756 filename = pathStr + StringFromList(jj, listStr ,";") 3681 3757 if(EventDataType(filename) != 2) //if not itx extension of edited data 3758 Abort "Data must be edited data with file extension .itx for this operation" 3759 return(0) 3760 endif 3682 3761 SetDataFolder root:Packages:NIST:Event: 3683 3762 LoadWave/T/O fileName … … 3825 3904 end 3826 3905 ///////////////////////////// 3906 3907 Proc GetListofITXorSplitFiles(searchStr) 3908 String searchStr = ".itx" 3909 ShowList_ToLoad("") 3910 GetListofITXHST(searchStr) 3911 end 3912 3913 // needs SANS_Utilites.ipf 3914 Function GetListofITXHST(searchStr) 3915 String searchStr 3916 3917 String fullList = IndexedFile(catpathName, -1, "????" ) 3918 3919 // list is currently everything -- trim it 3920 searchStr = "*" + searchStr + "*" 3921 String list = ListMatch(fullList, searchStr ) 3922 3923 Print "searchString = ",searchStr 3924 // 3925 Wave/T tw = root:Packages:NIST:Event:SplitFileWave 3926 List2TextWave(list,tw) 3927 Sort/A tw,tw //alphanumeric sort 3928 Edit tw 3929 return(0) 3930 End 3931 3932 // 3933 // loads a list of files that have been adjusted and saved 3934 // -- MUST run one through first manually to set the bin sapcing, then this 3935 // won't touch that, just process all of the files 3936 // -- bins as they are loaded 3937 // 3938 Function Osc_LoadAdjList_BinOnFly(ctrlName) 3939 String ctrlName 3940 3941 Variable fileref 3942 3943 SVAR filename = root:Packages:NIST:Event:gEvent_logfile 3944 SVAR listStr = root:Packages:NIST:Event:gSplitFileList 3945 3946 String pathStr,fileStr,tmpStr 3947 PathInfo catPathName 3948 pathStr = S_Path 3949 3950 // if "Osc" mode is not checked - abort 3951 NVAR gEventModeRadioVal= root:Packages:NIST:Event:gEvent_mode 3952 if(gEventModeRadioVal != MODE_OSCILL) 3953 Abort "The mode must be 'Oscillatory' to use this function" 3954 return(0) 3955 endif 3956 3957 // if the list has been edited, turn it into a list 3958 WAVE/T/Z tw = root:Packages:NIST:Event:SplitFileWave 3959 if(WaveExists(tw)) 3960 listStr = TextWave2SemiList(tw) 3961 else 3962 ShowSplitFileTable() 3963 DoAlert 0,"Enter the file names in the table, then click 'Load From List' again." 3964 return(0) 3965 endif 3966 3967 3968 //loop through everything in the list 3969 Variable num,ii,jj 3970 num = ItemsInList(listStr) 3971 3972 //handle the first file differently 3973 //(1) load (import edited) 3974 jj=0 3975 filename = pathStr + StringFromList(jj, listStr ,";") 3976 if(EventDataType(filename) != 2) //if not itx extension of edited data 3977 Abort "Data must be edited data with file extension .itx for this operation" 3978 return(0) 3979 endif 3980 3981 SetDataFolder root:Packages:NIST:Event: 3982 LoadWave/T/O fileName 3983 SetDataFolder root:Packages:NIST:Event: //LoadEvents sets back to root: ?? 3984 3985 // clear out the old sort index, if present, since new data is being loaded 3986 KillWaves/Z OscSortIndex 3987 SVAR dispStr = root:Packages:NIST:Event:gEventDisplayString 3988 sprintf tmpStr, "%s: a user-modified event file\r",StringFromList(jj, listStr ,";") 3989 dispStr = tmpStr 3990 3991 //(2) bin 3992 Osc_ProcessEventLog("") 3993 3994 //(3) display bin details 3995 Execute "ShowBinTable()" 3996 Execute "BinEventBarGraph()" 3997 3998 //(4) add first 3999 AccumulateSlices(0,skipAlert=1) //bypass the dialog 4000 4001 // with remaining files 4002 // load 4003 // bin 4004 // add next 4005 4006 // start w/file 1, since "0th" file was already processed 4007 for(jj=1;jj<num;jj+=1) 4008 4009 //(1) load (import edited) 4010 filename = pathStr + StringFromList(jj, listStr ,";") 4011 if(EventDataType(filename) != 2) //if not itx extension of edited data 4012 Abort "Data must be edited data with file extension .itx for this operation" 4013 return(0) 4014 endif 4015 SetDataFolder root:Packages:NIST:Event: 4016 LoadWave/T/O fileName 4017 SetDataFolder root:Packages:NIST:Event: //LoadEvents sets back to root: ?? 4018 4019 // clear out the old sort index, if present, since new data is being loaded 4020 KillWaves/Z OscSortIndex 4021 SVAR dispStr = root:Packages:NIST:Event:gEventDisplayString 4022 sprintf tmpStr, "%s: a user-modified event file\r",StringFromList(jj, listStr ,";") 4023 dispStr = tmpStr 4024 4025 //(2) bin 4026 Osc_ProcessEventLog("") 4027 4028 //(3) display bin details 4029 Execute "ShowBinTable()" 4030 Execute "BinEventBarGraph()" 4031 4032 //(4) add next 4033 AccumulateSlices(1,skipAlert=1) 4034 4035 endfor //end loop over the file list 4036 4037 4038 //display total 4039 AccumulateSlices(2,skipAlert=1) 4040 4041 // let user know we're done 4042 DoAlert 0,"The list has been processed and is ready for export" 4043 SetDataFolder root: 4044 4045 return(0) 4046 End 4047 4048 4049 //returns 0 for unknown data 4050 // 1 for raw hst files 4051 // 2 for edited ITX files 4052 // 4053 // TODO 4054 // -- currently, this blindly assumes an .hst extension for raw HST data, and .itx for edited data 4055 // 4056 Function EventDataType(filename) 4057 string filename 4058 4059 Variable type 4060 Variable offset = strsearch(filename,".",Inf,1) //work backwards 4061 String extension = filename[offset+1,strlen(filename)-1] 4062 //Print extension 4063 type = 0 4064 if(cmpstr(extension,"hst") == 0) 4065 type = 1 4066 endif 4067 if(cmpstr(extension,"itx") == 0) 4068 type = 2 4069 endif 4070 return(type) 4071 end 4072 4073 //////////// 4074 // this could be jazzed up quite a bit, but it is a first pass at 4075 // figuring out what is going on with the events 4076 // 4077 Proc DecodeBinaryEvents(numToPrint) 4078 Variable numToPrint=10 4079 4080 DecodeEvents(numToPrint) 4081 end 4082 4083 // sscanf %x takes hex input and gives a real value output 4084 // printf %d val gives the integer representation of the sscanf output 4085 // printf %b val gives the binary representation. 4086 Function DecodeEvents(numToPrint) 4087 Variable numToPrint 4088 4089 String filePathStr,buffer 4090 Variable fileRef,type,dataval,num0,num1,num2,num3 4091 Variable numT0,numPP,numZero,numXYevents,bit29 4092 Variable ii 4093 4094 ii=0 4095 Open/R fileref 4096 tic() 4097 do 4098 do 4099 FReadLine fileref, buffer //skip the "blank" lines that have one character 4100 while(strlen(buffer) == 1) 4101 4102 if (strlen(buffer) == 0) 4103 break 4104 endif 4105 4106 sscanf buffer,"%x",dataval 4107 if(ii<numToPrint) 4108 printf "%s %0.32b ",buffer[0,7],dataval 4109 endif 4110 4111 // two most sig bits (31-30) 4112 type = (dataval & 0xC0000000)/1073741824 //right shift by 2^30 4113 4114 if(ii<numToPrint) 4115 printf "%0.2b ",type 4116 endif 4117 4118 if(type == 0) 4119 num0 += 1 4120 numXYevents += 1 4121 endif 4122 if(type == 2) 4123 num2 += 1 4124 numXYevents += 1 4125 endif 4126 if(type == 1) 4127 num1 += 1 4128 endif 4129 if(type == 3) 4130 num3 += 1 4131 endif 4132 4133 bit29 = (dataval & 0x20000000)/536870912 //bit 29 only , shift by 2^29 4134 if(ii<numToPrint) 4135 printf "%0.1b ",bit29 4136 endif 4137 4138 if(type==0 || type==2) 4139 numPP += round(bit29) 4140 endif 4141 4142 if(type==1 || type==3) 4143 numT0 += round(bit29) 4144 endif 4145 4146 if(dataval == 0) 4147 numZero += 1 4148 endif 4149 4150 if(ii<numToPrint) 4151 printf "\r" 4152 ii += 1 4153 endif 4154 4155 while(1) 4156 Close fileref 4157 toc() 4158 4159 Print "(Igor) numT0 = ",numT0 4160 Print "num0 = ",num0 4161 Print "num1 = ",num1 4162 Print "num2 = ",num2 4163 Print "num3 = rollover = ",num3 4164 Print "numXY = ",numXYevents 4165 Print "numZero = ",numZero 4166 Print "numPP = ",numPP 4167 4168 return(0) 4169 4170 End -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/Menu.ipf
r885 r999 50 50 "-" 51 51 "Split Large File",SplitBigFile() 52 "Get List of ITX or Split Files",GetListofITXorSplitFiles() 52 53 "Accumulate First Slice",AccumulateSlices(0) 53 54 "Add Current Slice",AccumulateSlices(1) -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_DetectorBinning_Utils.ipf
r993 r999 238 238 newX = data_realDistX[xCtr][0] 239 239 newY = data_realDistY[0][yCtr] 240 //newX = xCtr 241 //newY = yCtr 240 242 endif 241 243 … … 668 670 // a blanket correction (matrix multiply) for an entire panel? 669 671 // 672 // 673 // 670 674 // folderStr = WORK folder, type = the binning type (may include multiple detectors) 671 675 Function VC_fDoBinning_QxQy2D(folderStr,type) … … 690 694 // 691 695 696 // TODO: 697 // -- Solid_Angle -- waves will be present for WORK data other than RAW, but not for RAW 698 // 692 699 // assume that the mask files are missing unless we can find them. If VCALC data, 693 700 // then the Mask is missing by definition … … 986 993 987 994 //TODO: properly define the errors here - I'll have this if I do the simulation 995 // -- need to propagate the errors up to this point 996 // 988 997 if(WaveExists(iErr)==0 && WaveExists(inten) != 0) 989 998 Duplicate/O inten,iErr … … 1055 1064 // 1056 1065 // this needs to be a double loop now... 1066 // TODO: 1067 // -- the iErr wave and accumulation of error is NOT CALCULATED CORRECTLY YET 1068 // -- the solid angle per pixel is not yet implemented. 1069 // it will be present for WORK data other than RAW, but not for RAW 1057 1070 1058 1071 // if any of the masks don't exist, display the error, and proceed with the averaging, using all data … … 1074 1087 val = inten[ii][jj] 1075 1088 1076 if(isVCALC || maskMissing) // mask_val == 1 == keep1077 mask_val = 11089 if(isVCALC || maskMissing) // mask_val == 0 == keep, mask_val == 1 = YES, mask out the point 1090 mask_val = 0 1078 1091 else 1079 1092 mask_val = mask[ii][jj] 1080 1093 endif 1081 if (numType(val)==0 && mask_val == 1) //count only the good points, ignore Nan or Inf1094 if (numType(val)==0 && mask_val == 0) //count only the good points, ignore Nan or Inf 1082 1095 iBin_qxqy[binIndex] += val 1083 1096 iBin2_qxqy[binIndex] += val*val … … 1103 1116 1104 1117 if(isVCALC || maskMissing) 1105 mask_val = 11118 mask_val = 0 1106 1119 else 1107 1120 mask_val = mask2[ii][jj] 1108 1121 endif 1109 if (numType(val)==0 && mask_val == 1) //count only the good points, ignore Nan or Inf1122 if (numType(val)==0 && mask_val == 0) //count only the good points, ignore Nan or Inf 1110 1123 iBin_qxqy[binIndex] += val 1111 1124 iBin2_qxqy[binIndex] += val*val … … 1131 1144 1132 1145 if(isVCALC || maskMissing) 1133 mask_val = 11146 mask_val = 0 1134 1147 else 1135 1148 mask_val = mask3[ii][jj] 1136 1149 endif 1137 if (numType(val)==0 && mask_val == 1) //count only the good points, ignore Nan or Inf1150 if (numType(val)==0 && mask_val == 0) //count only the good points, ignore Nan or Inf 1138 1151 iBin_qxqy[binIndex] += val 1139 1152 iBin2_qxqy[binIndex] += val*val … … 1156 1169 1157 1170 if(isVCALC || maskMissing) 1158 mask_val = 11171 mask_val = 0 1159 1172 else 1160 1173 mask_val = mask4[ii][jj] 1161 1174 endif 1162 if (numType(val)==0 && mask_val == 1) //count only the good points, ignore Nan or Inf1175 if (numType(val)==0 && mask_val == 0) //count only the good points, ignore Nan or Inf 1163 1176 iBin_qxqy[binIndex] += val 1164 1177 iBin2_qxqy[binIndex] += val*val … … 1174 1187 // after looping through all of the data on the panels, calculate errors on I(q), 1175 1188 // just like in CircSectAve.ipf 1189 // TODO: 1190 // -- Errors were NOT properly acculumated above, so this loop of calculations is NOT MEANINGFUL (yet) 1176 1191 for(ii=0;ii<nq;ii+=1) 1177 1192 if(nBin_qxqy[ii] == 0) -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_HDF5_VSANS_Utils.ipf
r994 r999 302 302 303 303 304 ////////////////////// MASK FILE 305 306 307 // TODO 308 // currently, there are no dummy fill values or attributes for the fake MASK file 309 // 310 Proc Setup_VSANS_MASK_Struct() 311 312 // lays out the tree and fills with dummy values 313 H_Setup_VSANS_MASK_Structure() 314 315 // writes in the attributes 316 // H_Fill_VSANS_Attributes() 317 318 // fill in with VCALC simulation bits 319 // H_Fill_VSANS_wSim() 320 321 End 322 323 Proc Save_VSANS_MASK_Nexus(fileName) 324 String fileName="Test_VSANS_MASK_file" 325 326 // save as HDF5 (no attributes saved yet) 327 Save_VSANS_file("root:VSANS_MASK_file", fileName+".h5") 328 329 // read in a data file using the gateway-- reads from the home path 330 H_HDF5Gate_Read_Raw(fileName+".h5") 331 332 // after reading in a "partial" file using the gateway (to generate the xref) 333 // Save the xref to disk (for later use) 334 Save_HDF5___xref("root:"+fileName,"HDF5___xref") 335 336 // after you've generated the HDF5___xref, load it in and copy it 337 // to the necessary folder location. 338 Copy_HDF5___xref("root:VSANS_MASK_file", "HDF5___xref") 339 340 // writes out the contents of a data folder using the gateway 341 H_HDF5Gate_Write_Raw("root:VSANS_MASK_file", fileName+".h5") 342 343 // re-load the data file using the gateway-- reads from the home path 344 // now with attributes 345 H_HDF5Gate_Read_Raw(fileName+".h5") 346 347 End 348 349 ////////////// fake MASK file tests 350 // 351 // 352 // Make/O/T/N=1 file_name = "VSANS_MASK_test.h5" 353 // 354 // simple generation of a fake MASK file. for sans, nothing other than the creation date was written to the 355 // file header. nothing more is needed (possibly) 356 // 357 // 358 // TODO -- make the number of pixels GLOBAL 359 // TODO -- there will be lots of work to do to develop the procedures necessary to actually generate the 360 // 9 data sets to become the MASK file contents. More complexity here than for the simple SANS case. 361 // 362 // TODO -- this is currently random 0|1 values, need to write an editor 363 // 364 // currently set up to use 0 = exclude and 1 = keep 365 // 366 Proc H_Setup_VSANS_MASK_Structure() 367 368 NewDataFolder/O/S root:VSANS_MASK_file 369 370 NewDataFolder/O/S root:VSANS_MASK_file:entry 371 Make/O/T/N=1 title = "This is a fake MASK file for VSANS" 372 Make/O/T/N=1 start_date = "2015-02-28T08:15:30-5:00" 373 NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument 374 Make/O/T/N=1 name = "NG3_VSANS" 375 NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_B 376 Make/O/I/N=(150,150) data = 1 377 NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_MR 378 Make/O/I/N=(48,128) data = 1 379 NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_ML 380 Make/O/I/N=(48,128) data = 1 381 NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_MT 382 Make/O/I/N=(128,48) data = 1 383 data[0,49][] = 0 384 data[78,127][] = 0 385 data[50,77][] = 1 386 387 NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_MB 388 Make/O/I/N=(128,48) data = 1 389 data[0,49][] = 0 390 data[78,127][] = 0 391 data[50,77][] = 1 392 393 NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_FR 394 Make/O/I/N=(48,128) data = 1 395 NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_FL 396 Make/O/I/N=(48,128) data = 1 397 NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_FT 398 Make/O/I/N=(128,48) data = 1 399 data[0,49][] = 0 400 data[78,127][] = 0 401 data[50,77][] = 1 402 403 NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_FB 404 Make/O/I/N=(128,48) data = 1 405 data[0,49][] = 0 406 data[78,127][] = 0 407 data[50,77][] = 1 408 409 SetDataFolder root: 410 411 End 304 305 412 306 413 307 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_VCALCPanel_MockUp.ipf
r993 r999 647 647 NewDataFolder/O root:Packages:NIST:VSANS 648 648 NewDataFolder/O root:Packages:NIST:VSANS:VCALC 649 650 651 652 653 654 655 656 657 658 659 660 649 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry 650 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry 651 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument 652 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_B 653 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MB 654 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MT 655 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_ML 656 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MR 657 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FB 658 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FT 659 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FL 660 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FR 661 661 662 662 // NewDataFolder/O root:Packages:NIST:VSANS:VCALC:Front … … 808 808 Variable/G gBack_h = 150 809 809 810 Make/O/D/N=1 :entry:instrument:detector_B:x_pixel_size = 0.1 // 1 mm resolution (units of cm here)810 Make/O/D/N=1 :entry:instrument:detector_B:x_pixel_size = 0.1 // 1 mm resolution (units of cm here) 811 811 Make/O/D/N=1 :entry:instrument:detector_B:y_pixel_size = 0.1 812 812 // Variable/G gBack_pixelX = 0.1 … … 873 873 Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_B 874 874 Duplicate/O det_B qTot_B,qx_B,qy_B,qz_B 875 876 877 875 878 876 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VSANS_Includes.ipf
r993 r999 59 59 #include "V_Testing_Data_Procs" 60 60 61 // mask files 62 #include "V_MaskUtils" 63 64 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DataPlotting.ipf
r995 r999 59 59 End 60 60 61 62 63 //64 // see the VCALC BinAllMiddlePanels() for an example of this65 //66 // TODO67 // x- detector "B" is currently skipped since the calibration waves are not faked68 // when the raw data is loaded. Then the qxqyqz waves are not generated.69 //70 // -- REDO the logic here. It's a mess, and will get the calculation wrong71 //72 // -- figure out the binning type (where is it set?)73 // -- binning type is HARD-WIRED74 // -- figure out when this is to be called to re-calculate the I vs Q75 //76 Function V_QBinAllPanels(folderStr)77 String folderStr78 79 // do the back, middle, and front separately80 81 // figure out the binning type (where is it set?)82 Variable binType,ii,delQ83 String detStr84 binType = 185 86 87 88 //// TODO:89 // x- currently the "B" detector is skipped - it was skipped in90 // previous functions where q values are calculated91 //92 delQ = SetDeltaQ(folderStr,"B")93 94 // dispatch based on binning type95 if(binType == 1)96 VC_fDoBinning_QxQy2D(folderStr, "B") //normal binning, nothing to combine97 endif98 99 // TODO -- this is only a temporary fix for slit mode100 if(binType == 4)101 /// this is for a tall, narrow slit mode102 VC_fBinDetector_byRows(folderStr,"B")103 endif104 105 // these are the binning types where detectors are not combined106 // other combined binning is below the loop107 for(ii=0;ii<ItemsInList(ksDetectorListNoB);ii+=1)108 detStr = StringFromList(ii, ksDetectorListNoB, ";")109 110 // set delta Q for binning111 delQ = SetDeltaQ(folderStr,detStr)112 113 // dispatch based on binning type114 if(binType==1)115 VC_fDoBinning_QxQy2D(folderStr,detStr)116 endif117 118 // TODO -- this is only a temporary fix for slit mode119 if(binType == 4)120 /// this is for a tall, narrow slit mode121 VC_fBinDetector_byRows(folderStr,detStr)122 endif123 124 endfor125 126 // bin in pairs127 if(binType == 2)128 VC_fDoBinning_QxQy2D(folderStr,"MLR")129 VC_fDoBinning_QxQy2D(folderStr,"MTB")130 VC_fDoBinning_QxQy2D(folderStr,"FLR")131 VC_fDoBinning_QxQy2D(folderStr,"FTB")132 endif133 134 // bin everything on front or middle together135 if(binType == 3)136 VC_fDoBinning_QxQy2D(folderStr,"MLRTB")137 VC_fDoBinning_QxQy2D(folderStr,"FLRTB")138 endif139 140 return(0)141 End142 61 143 62 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DetectorCorrections.ipf
r995 r999 370 370 if(cmpstr(orientation,"vertical")==0) 371 371 // this is vertical tube data dimensioned as (Ntubes,Npix) 372 pixSize = 8 372 pixSize = 8.4 //V_getDet_y_pixel_size(fname,detStr) 373 373 374 374 elseif(cmpstr(orientation,"horizontal")==0) … … 396 396 397 397 // 398 // TODO: 399 // -- MUST VERIFY the definition of SDD and how (if) setback is written to the data files 400 // -- currently I'm assuming that the SDD is the "nominal" value which is correct for the 401 // L/R panels, but is not correct for the T/B panels (must add in the setback) 402 // 403 // 404 // 398 405 // data_realDistX, Y must be previously generated from running NonLinearCorrection() 399 406 // … … 411 418 // get all of the geometry information 412 419 orientation = V_getDet_tubeOrientation(fname,detStr) 413 sdd = V_getDet_distance(fname,detStr) 420 // sdd = V_getDet_distance(fname,detStr) //[cm] 421 // sdd += V_getDet_TBSetback(fname,detStr)/10 // written in [mm], convert to [cm], returns 0 for L/R/B panels 422 423 sdd = V_getDet_ActualDistance(fname,detStr) //sdd derived, including setback [cm] 414 424 sdd/=100 // sdd reported in cm, pass in m 415 425 // this is the ctr in pixels … … 552 562 // to each pixel 553 563 // 554 // not actually used for any thing, but here for completeness if anyone asks564 // not actually used for any calculations, but here for completeness if anyone asks, or for 2D data export 555 565 // 556 566 // this properly accounts for qz … … 579 589 End 580 590 591 592 // 593 // TODO -- VERIFY calculations 594 // -- This is the actual solid angle per pixel, not a ratio vs. some "unit SA" 595 // Do I just correct for the different area vs. the "nominal" central area? 596 // -- decide how to implement - either directly change the data values (as was done in the past) 597 // or use this as a weighting for when the data is binned to I(q). In the second method, 2D data 598 // would need this to be applied before exporting 599 // -- do I keep a wave note indicating that this correction has been applied to the data 600 // so that it can be "un-applied"? 601 // -- do I calculate theta from geometry directly, or get it from Q (Assuming it's present?) 602 // (probably just from geometry, since I need SDD and dx and dy values...) 603 // 604 // 605 Function SolidAngleCorrection(w,w_err,fname,detStr,destPath) 606 Wave w,w_err 607 String fname,detStr,destPath 608 609 Variable sdd,xCtr,yCtr,lambda 610 611 // get all of the geometry information 612 // orientation = V_getDet_tubeOrientation(fname,detStr) 613 sdd = V_getDet_ActualDistance(fname,detStr) 614 sdd/=100 // sdd in cm, pass in m 615 616 // this is ctr in mm 617 xCtr = V_getDet_beam_center_x_mm(fname,detStr) 618 yCtr = V_getDet_beam_center_y_mm(fname,detStr) 619 lambda = V_getWavelength(fname) 620 621 SetDataFolder $(destPath + ":entry:instrument:detector_"+detStr) 622 623 Wave data_realDistX = data_realDistX 624 Wave data_realDistY = data_realDistY 625 626 Duplicate/O w solid_angle,tmp_theta,tmp_dist //in the current df 627 628 //// calculate the scattering angle 629 // dx = (distX - xctr) //delta x in mm 630 // dy = (distY - yctr) //delta y in mm 631 tmp_dist = sqrt((data_realDistX - xctr)^2 + (data_realDistY - yctr)^2) 632 633 tmp_dist /= 10 // convert mm to cm 634 sdd *=100 //convert to cm 635 636 tmp_theta = atan(tmp_dist/sdd) //this is two_theta, the scattering angle 637 638 Variable ii,jj,numx,numy,dx,dy 639 numx = DimSize(tmp_theta,0) 640 numy = DimSize(tmp_theta,1) 641 642 for(ii=0 ;ii<numx;ii+=1) 643 for(jj=0;jj<numy;jj+=1) 644 645 if(ii==0) //do a forward difference if ii==0 646 dx = (data_realDistX[ii+1][jj] - data_realDistX[ii][jj]) //delta x for the pixel 647 else 648 dx = (data_realDistX[ii][jj] - data_realDistX[ii-1][jj]) //delta x for the pixel 649 endif 650 651 652 if(jj==0) 653 dy = (data_realDistY[ii][jj+1] - data_realDistY[ii][jj]) //delta y for the pixel 654 else 655 dy = (data_realDistY[ii][jj] - data_realDistY[ii][jj-1]) //delta y for the pixel 656 endif 657 658 dx /= 10 659 dy /= 10 // convert mm to cm (since sdd is in cm) 660 solid_angle[ii][jj] = dx*dy //this is in cm^2 661 endfor 662 endfor 663 664 // to cover up any issues w/negative dx or dy 665 solid_angle = abs(solid_angle) 666 667 // solid_angle correction 668 // == dx*dy*cos^3/sdd^2 669 solid_angle *= (cos(tmp_theta))^3 670 solid_angle /= sdd^2 671 672 // Here it is! Apply the correction to the intensity (I divide -- to get the counts per solid angle!!) 673 w /= solid_angle 674 675 676 // TODO: 677 // correctly apply the correction to the error wave (assume a perfect value?) 678 // w_err /= solid_angle //is this correct?? 679 680 // TODO -- clean up after I'm satisfied computations are correct 681 // KillWaves/Z tmp_theta,tmp_dist 682 683 return(0) 684 end 581 685 582 686 … … 668 772 // so divide here to get the correct answer (5/22/08 SRK) 669 773 if(doEfficiency) 670 data[ii][jj] /= DetEffCorr(lambda,dtdist,xd,yd)671 data_err[ii][jj] /= DetEffCorr(lambda,dtdist,xd,yd)774 // data[ii][jj] /= DetEffCorr(lambda,dtdist,xd,yd) 775 // data_err[ii][jj] /= DetEffCorr(lambda,dtdist,xd,yd) 672 776 // solidAngle[ii][jj] /= DetEffCorr(lambda,dtdist,xd,yd) //testing only 673 777 endif … … 718 822 719 823 720 //distances passed in are in mm721 // dtdist is SDD722 // xd and yd are distances from the beam center to the current pixel723 //724 // TODO:725 // -- DoAlert 0,"This has not yet been updated for VSANS"726 //727 Function DetEffCorr(lambda,dtdist,xd,yd)728 Variable lambda,dtdist,xd,yd729 730 DoAlert 0,"This has not yet been updated for VSANS"731 732 Variable theta,cosT,ff,stAl,stHe733 734 theta = atan( (sqrt(xd^2 + yd^2))/dtdist )735 cosT = cos(theta)736 737 stAl = 0.00967*lambda*0.8 //dimensionless, constants from JGB memo738 stHe = 0.146*lambda*2.5739 740 ff = exp(-stAl/cosT)*(1-exp(-stHe/cosT)) / ( exp(-stAl)*(1-exp(-stHe)) )741 742 return(ff)743 End744 824 745 825 // DIVIDE the intensity by this correction to get the right answer … … 1031 1111 1032 1112 Variable err 1033 err = DIVCorrection(type) //returns err = 1 if data doesn't exist in specified folders1113 err = V_DIVCorrection(type) //returns err = 1 if data doesn't exist in specified folders 1034 1114 1035 1115 if(err) 1036 Abort "error in DIVCorrection()"1116 Abort "error in V_DIVCorrection()" 1037 1117 endif 1038 1118 … … 1056 1136 // TODO: 1057 1137 // -- DoAlert 0,"This has not yet been updated for VSANS" 1058 // -- how is the error propagationhandled?1138 // -- how is the error propagation handled? 1059 1139 // 1060 1140 //function will divide the contents of "workType" folder with the contents of … … 1062 1142 // all data is linear scale for the calculation 1063 1143 // 1064 Function DIVCorrection(data,data_err,detStr,workType)1144 Function V_DIVCorrection(data,data_err,detStr,workType) 1065 1145 Wave data,data_err 1066 1146 String detStr,workType … … 1071 1151 1072 1152 if(WaveExists(data) == 0) 1073 Print "The data wave does not exist in DIVCorrection()"1153 Print "The data wave does not exist in V_DIVCorrection()" 1074 1154 Return(1) //error condition 1075 1155 Endif … … 1080 1160 WAVE/Z div_data = $("root:Packages:NIST:VSANS:DIV:entry:instrument:detector_"+detStr+":data") 1081 1161 if(WaveExists(div_data) == 0) 1082 Print "The DIV wave does not exist in DIVCorrection()"1162 Print "The DIV wave does not exist in V_DIVCorrection()" 1083 1163 Return(1) //error condition 1084 1164 Endif -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Read.ipf
r994 r999 1385 1385 End 1386 1386 1387 Function V_getDet_ distance(fname,detStr)1387 Function V_getDet_NominalDistance(fname,detStr) 1388 1388 String fname,detStr 1389 1389 1390 1390 String path = "entry:instrument:detector_"+detStr+":distance" 1391 1391 return(V_getRealValueFromHDF5(fname,path)) 1392 End 1393 1394 //this is a DERIVED distance, since the nominal sdd is for the carriage (=LR panels) 1395 Function V_getDet_ActualDistance(fname,detStr) 1396 String fname,detStr 1397 1398 Variable sdd 1399 sdd = V_getDet_NominalDistance(fname,detStr) //[cm] 1400 sdd += V_getDet_TBSetback(fname,detStr)/10 // written in [mm], convert to [cm], returns 0 for L/R/B panels 1401 1402 return(sdd) 1392 1403 End 1393 1404 … … 1426 1437 End 1427 1438 1428 // TODO - be sure this is defined correctly 1439 // TODO - be sure this is defined correctly (with correct units!) 1429 1440 // -- only returns for T/B detectors 1430 1441 Function V_getDet_TBSetback(fname,detStr) -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_IQ_Utilities.ipf
r984 r999 10 10 // -- fill in all of the details... 11 11 // 12 13 14 // 15 // see the VCALC BinAllMiddlePanels() for an example of this 16 // see the binning routines in VC_DetectorBinning_Utils.ipf for the details 17 // 18 // TODO 19 // x- detector "B" is currently skipped since the calibration waves are not faked 20 // when the raw data is loaded. Then the qxqyqz waves are not generated. 21 // 22 // -- REDO the logic here. It's a mess, and will get the calculation wrong 23 // 24 // -- figure out the binning type (where is it set for VSANS?) 25 // -- don't know, so currently VSANS binning type is HARD-WIRED 26 // -- figure out when this needs to be called to (force) re-calculate I vs Q 27 // 28 Function V_QBinAllPanels(folderStr) 29 String folderStr 30 31 // do the back, middle, and front separately 32 33 // figure out the binning type (where is it set?) 34 Variable binType,ii,delQ 35 String detStr 36 binType = 1 37 38 39 40 //// TODO: 41 // x- currently the "B" detector is skipped - it was skipped in 42 // previous functions where q values are calculated 43 // 44 delQ = SetDeltaQ(folderStr,"B") 45 46 // dispatch based on binning type 47 if(binType == 1) 48 VC_fDoBinning_QxQy2D(folderStr, "B") //normal binning, nothing to combine 49 endif 50 51 // TODO -- this is only a temporary fix for slit mode 52 if(binType == 4) 53 /// this is for a tall, narrow slit mode 54 VC_fBinDetector_byRows(folderStr,"B") 55 endif 56 57 58 59 // these are the binning types where detectors are not combined 60 // other combined binning is below the loop 61 for(ii=0;ii<ItemsInList(ksDetectorListNoB);ii+=1) 62 detStr = StringFromList(ii, ksDetectorListNoB, ";") 63 64 // set delta Q for binning 65 delQ = SetDeltaQ(folderStr,detStr) 66 67 // dispatch based on binning type 68 if(binType==1) 69 VC_fDoBinning_QxQy2D(folderStr,detStr) 70 endif 71 72 // TODO -- this is only a temporary fix for slit mode 73 if(binType == 4) 74 /// this is for a tall, narrow slit mode 75 VC_fBinDetector_byRows(folderStr,detStr) 76 endif 77 78 endfor 79 80 // bin in pairs 81 if(binType == 2) 82 VC_fDoBinning_QxQy2D(folderStr,"MLR") 83 VC_fDoBinning_QxQy2D(folderStr,"MTB") 84 VC_fDoBinning_QxQy2D(folderStr,"FLR") 85 VC_fDoBinning_QxQy2D(folderStr,"FTB") 86 endif 87 88 // bin everything on front or middle together 89 if(binType == 3) 90 VC_fDoBinning_QxQy2D(folderStr,"MLRTB") 91 VC_fDoBinning_QxQy2D(folderStr,"FLRTB") 92 endif 93 94 return(0) 95 End 96 97 98 99 100 12 101 Macro V_Combine1DData() 13 102 … … 26 115 27 116 // write out the data set to a file 28 29 30 End 31 32 33 117 String/G saveName="" 118 V_GetNameForSave("") 119 V_Write1DData(type,saveName) 120 121 End 122 123 Proc V_GetNameForSave(str) 124 String str 125 String/G saveName=str 126 End 34 127 35 128 … … 122 215 123 216 // TODO: 217 // -- resolution waves are ignored 218 // -- only a sort is done, no rescaling of data sets 219 // (it's too late now anyways, since the data was concatenated 220 // 124 221 // see Auto_Sort() in the SANS Automation ipf for the rest of the details of 125 // how to combine the resolution waves (they also need to be concatenated, which is currently not done .126 // 222 // how to combine the resolution waves (they also need to be concatenated, which is currently not done) 223 // 127 224 Function V_TmpSort1D(folderStr) 128 225 String folderStr … … 197 294 198 295 296 199 297 // TODO: 200 298 // -- this is a temporary solution before a real writer is created 201 299 // -- resolution is not handled here (and it shouldn't be) since resolution is not known yet. 202 300 // 203 //204 301 // this will bypass save dialogs 205 302 // -- AND WILL OVERWITE DATA WITH THE SAME NAME 206 303 // 207 Function V_Write1DData(folderStr, delim,term)208 String folderStr, delim,term304 Function V_Write1DData(folderStr,saveName) 305 String folderStr,saveName 209 306 210 307 String formatStr="",fullpath="" 211 308 Variable refnum,dialog=1 309 310 SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr) 311 312 Wave qw = tmp_q 313 Wave iw = tmp_i 314 Wave sw = tmp_s 212 315 213 316 String dataSetFolderParent,basestr 214 317 215 // AbuseParseFilePath to get path without folder name216 dataSetFolderParent = ParseFilePath(1,folderStr,":",1,0)217 // AbuseParseFilePath to get basestr218 basestr = ParseFilePath(0,folderStr,":",1,0)318 // ParseFilePath to get path without folder name 319 // dataSetFolderParent = ParseFilePath(1,folderStr,":",1,0) 320 // ParseFilePath to get basestr 321 // basestr = ParseFilePath(0,folderStr,":",1,0) 219 322 220 323 //make sure the waves exist 221 SetDataFolder $(dataSetFolderParent+basestr)222 WAVE/Z qw = $(baseStr+"_q")223 WAVE/Z iw = $(baseStr+"_i")224 WAVE/Z sw = $(baseStr+"_s")225 WAVE/Z resw = $(baseStr+"_res")226 324 227 325 if(WaveExists(qw) == 0) … … 234 332 Abort "s is missing" 235 333 endif 236 if(WaveExists(resw) == 0) 237 Abort "Resolution information is missing." 238 endif 239 240 Duplicate/O qw qbar,sigQ,fs 241 if(dimsize(resW,1) > 4) 242 //it's USANS put -dQv back in the last 3 columns 243 NVAR/Z dQv = USANS_dQv 244 if(NVAR_Exists(dQv) == 0) 245 SetDataFolder root: 246 Abort "It's USANS data, and I don't know what the slit height is." 247 endif 248 sigQ = -dQv 249 qbar = -dQv 250 fs = -dQv 251 else 252 //it's SANS 253 sigQ = resw[p][0] 254 qbar = resw[p][1] 255 fs = resw[p][2] 256 endif 257 334 // if(WaveExists(resw) == 0) 335 // Abort "Resolution information is missing." 336 // endif 337 338 // Duplicate/O qw qbar,sigQ,fs 339 // if(dimsize(resW,1) > 4) 340 // //it's USANS put -dQv back in the last 3 columns 341 // NVAR/Z dQv = USANS_dQv 342 // if(NVAR_Exists(dQv) == 0) 343 // SetDataFolder root: 344 // Abort "It's USANS data, and I don't know what the slit height is." 345 // endif 346 // sigQ = -dQv 347 // qbar = -dQv 348 // fs = -dQv 349 // else 350 // //it's SANS 351 // sigQ = resw[p][0] 352 // qbar = resw[p][1] 353 // fs = resw[p][2] 354 // endif 355 // 356 258 357 PathInfo catPathName 259 fullPath = S_Path + folderStr358 fullPath = S_Path + saveName 260 359 261 360 Open refnum as fullpath 262 361 263 362 fprintf refnum,"Combined data written from folder %s on %s\r\n",folderStr,(date()+" "+time()) 264 formatStr = "%15.4g %15.4g %15.4g %15.4g %15.4g %15.4g\r\n" 265 fprintf refnum, "The 6 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm) | sigmaQ | meanQ | ShadowFactor|\r\n" 266 267 wfprintf refnum,formatStr,qw,iw,sw,sigQ,qbar,fs 363 364 // TODO -- make this work for 6-columns 365 // formatStr = "%15.4g %15.4g %15.4g %15.4g %15.4g %15.4g\r\n" 366 // fprintf refnum, "The 6 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm) | sigmaQ | meanQ | ShadowFactor|\r\n" 367 // wfprintf refnum,formatStr,qw,iw,sw,sigQ,qbar,fs 368 369 //currently, only three columns 370 formatStr = "%15.4g %15.4g %15.4g\r\n" 371 fprintf refnum, "The 3 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm)\r\n" 372 373 wfprintf refnum,formatStr,qw,iw,sw 268 374 Close refnum 269 375 270 KillWaves/Z sigQ,qbar,fs376 // KillWaves/Z sigQ,qbar,fs 271 377 272 378 SetDataFolder root: -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Initialize.ipf
r993 r999 156 156 // Analysis is not mine. So for VSANS, there is a new, separate file: V_VSANS_Preferences.ipf 157 157 158 //this is critical to initialize now - as it has the y/n flags for the detector correction steps 158 159 Execute "Initialize_VSANSPreferences()" 159 160 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Test_RAW_Panel.ipf
r995 r999 141 141 142 142 Button button_tagFile,pos={603,412},size={70,20},proc=TagFileButtonProc,title="Tag File" 143 Button button_saveIQ,pos={720,412},size={70,20},proc=SaveIQ_ButtonProc,title="Save I(Q)" 143 144 Button button_BeamCtr,pos={603,450},size={70,20},proc=BeamCtrButtonProc,title="Beam Ctr" 144 145 Button button_SpreadPanels,pos={603,488},size={100,20},proc=SpreadPanelButtonProc,title="Spread Panels" 145 146 Button button_RestorePanels,pos={603,526},size={100,20},proc=RestorePanelButtonProc,title="Restore Panels" 147 146 148 147 149 // on the tabs, always visible … … 350 352 yctr = V_getDet_beam_center_y_mm(gCurDispType,detStr) 351 353 352 sdd = V_getDet_ distance(gCurDispType,detStr) / 100 //written in cm, pass in meters354 sdd = V_getDet_ActualDistance(gCurDispType,detStr) / 100 //written in cm, pass in meters 353 355 lam = V_getVSWavelength(gCurDispType) //A 354 356 // pixSizeX = V_getDet_x_pixel_size(gCurDispType,detStr) // written mm? need mm … … 697 699 // ? controls here to select how the data is processed/grouped/saved, etc. 698 700 // 701 // -- currently just the graph, no controls 702 // -- this re-bins the data every time by calling V_QBinAllPanels(folderStr) 699 703 Function IvsQPanelButtonProc(ba) : ButtonControl 700 704 STRUCT WMButtonAction &ba … … 737 741 str += "Wavelength is "+num2str(V_getWavelength(type)) + " A \r" 738 742 if(curTab == 2) 739 str += "SDD B = "+num2str(V_getDet_ distance(type,"B")) + " cm \r" //V_getDet_distance(fname,detStr)743 str += "SDD B = "+num2str(V_getDet_ActualDistance(type,"B")) + " cm \r" //V_getDet_distance(fname,detStr) 740 744 endif 741 745 if(curTab == 1) 742 str += "SDD ML = "+num2str(V_getDet_ distance(type,"ML")) + " cm \r"743 str += "SDD MR = "+num2str(V_getDet_ distance(type,"MR")) + " cm \r"744 str += "SDD MT = "+num2str(V_getDet_ distance(type,"MT")) + " cm \r"745 str += "SDD MB = "+num2str(V_getDet_ distance(type,"MB")) + " cm \r"746 str += "SDD ML = "+num2str(V_getDet_ActualDistance(type,"ML")) + " cm \r" 747 str += "SDD MR = "+num2str(V_getDet_ActualDistance(type,"MR")) + " cm \r" 748 str += "SDD MT = "+num2str(V_getDet_ActualDistance(type,"MT")) + " cm \r" 749 str += "SDD MB = "+num2str(V_getDet_ActualDistance(type,"MB")) + " cm \r" 746 750 endif 747 751 if(curTab == 0) 748 str += "SDD FL = "+num2str(V_getDet_ distance(type,"FL")) + " cm \r"749 str += "SDD FR = "+num2str(V_getDet_ distance(type,"FR")) + " cm \r"750 str += "SDD FT = "+num2str(V_getDet_ distance(type,"FT")) + " cm \r"751 str += "SDD FB = "+num2str(V_getDet_ distance(type,"FB")) + " cm \r"752 str += "SDD FL = "+num2str(V_getDet_ActualDistance(type,"FL")) + " cm \r" 753 str += "SDD FR = "+num2str(V_getDet_ActualDistance(type,"FR")) + " cm \r" 754 str += "SDD FT = "+num2str(V_getDet_ActualDistance(type,"FT")) + " cm \r" 755 str += "SDD FB = "+num2str(V_getDet_ActualDistance(type,"FB")) + " cm \r" 752 756 endif 753 757 … … 849 853 case 2: // mouse up 850 854 // click code here 851 DoAlert 0, "TagFileButtonProc(ba) unfinished" 852 855 DoAlert 0, "TagFileButtonProc(ba) unfinished - thes may be used to 'tag' a file as scatter, trans, emp, bkg, etc." 856 857 858 break 859 case -1: // control being killed 860 break 861 endswitch 862 863 return 0 864 End 865 866 // TODO 867 // -- fill in more functionality 868 // -- currently a straight concatentation of all data, no options 869 // -- maybe allow save of single panels? 870 // -- any other options? 871 Function SaveIQ_ButtonProc(ba) : ButtonControl 872 STRUCT WMButtonAction &ba 873 874 switch( ba.eventCode ) 875 case 2: // mouse up 876 // click code here 877 878 Execute "V_Combine1DData()" 853 879 854 880 break -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Testing_Data_Procs.ipf
r995 r999 75 75 76 76 endfor 77 77 78 79 // writes out "perfect" detector calibration constants for all 8 tube banks 80 V_WritePerfectSpatialCalib(filename) 81 // writes out "perfect" dead time constants for all 8 tube banks + back detector 82 V_WritePerfectDeadTime(filename) 78 83 79 84 //? other detector geometry - lateral separation? … … 106 111 107 112 108 // writes out "perfect" detector calibration constants for all 8 tube banks 109 Function V_WritePerfectCalibration() 110 113 // writes out "perfect" detector calibration constants for all 8 tube banks + back detector 114 Function V_WritePerfectSpatialCalib(filename) 115 String filename 116 117 // String fileName = V_DoSaveFileDialog("pick the file to write to") 118 111 119 Make/O/D/N=(3,48) tmpCalib 112 120 // for the "tall" L/R banks … … 115 123 tmpCalib[2][] = 0 116 124 117 V_writeDetTube_spatialCalib( "","FR",tmpCalib)118 V_writeDetTube_spatialCalib( "","FL",tmpCalib)119 V_writeDetTube_spatialCalib( "","MR",tmpCalib)120 V_writeDetTube_spatialCalib( "","ML",tmpCalib)125 V_writeDetTube_spatialCalib(filename,"FR",tmpCalib) 126 V_writeDetTube_spatialCalib(filename,"FL",tmpCalib) 127 V_writeDetTube_spatialCalib(filename,"MR",tmpCalib) 128 V_writeDetTube_spatialCalib(filename,"ML",tmpCalib) 121 129 122 130 // for the "short" T/B banks … … 125 133 tmpCalib[2][] = 0 126 134 127 V_writeDetTube_spatialCalib( "","FT",tmpCalib)128 V_writeDetTube_spatialCalib( "","FB",tmpCalib)129 V_writeDetTube_spatialCalib( "","MT",tmpCalib)130 V_writeDetTube_spatialCalib( "","MB",tmpCalib)135 V_writeDetTube_spatialCalib(filename,"FT",tmpCalib) 136 V_writeDetTube_spatialCalib(filename,"FB",tmpCalib) 137 V_writeDetTube_spatialCalib(filename,"MT",tmpCalib) 138 V_writeDetTube_spatialCalib(filename,"MB",tmpCalib) 131 139 132 140 KillWaves tmpCalib 141 142 // and for the back detector "B" 143 Make/O/D/N=3 tmpCalib 144 tmpCalib[0] = 1 145 tmpCalib[1] = 1 146 tmpcalib[2] = 10000 147 V_writeDet_cal_x(filename,"B",tmpCalib) 148 V_writeDet_cal_y(filename,"B",tmpCalib) 149 150 KillWaves tmpCalib 151 133 152 return(0) 134 153 end … … 138 157 //V_writeDetector_deadtime(fname,detStr,inW) 139 158 //V_writeDetector_deadtime_B(fname,detStr,val) 159 // simulated count rate per tube can be Å 10^8, so I need dt >> 10^-15 to completely cancel this out 160 // (partly due to fake I(q), fake count time in file...) 161 162 // writes out "perfect" dead time constants for all 8 tube banks + back detector 163 Function V_WritePerfectDeadTime(filename) 164 String filename 165 166 Make/O/D/N=(48) tmpDT 167 tmpDT = 1e-18 168 V_writeDetector_deadtime(filename,"FT",tmpDT) 169 V_writeDetector_deadtime(filename,"FB",tmpDT) 170 V_writeDetector_deadtime(filename,"FL",tmpDT) 171 V_writeDetector_deadtime(filename,"FR",tmpDT) 172 V_writeDetector_deadtime(filename,"MT",tmpDT) 173 V_writeDetector_deadtime(filename,"MB",tmpDT) 174 V_writeDetector_deadtime(filename,"ML",tmpDT) 175 V_writeDetector_deadtime(filename,"MR",tmpDT) 176 177 178 // and for the back detector "B", a single value, not a wave 179 V_writeDetector_deadtime_B(filename,"B",1e-20) 180 181 KillWaves tmpDT 182 183 return(0) 184 end 140 185 141 186 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_VSANS_Preferences.ipf
r979 r999 87 87 Variable/G root:Packages:NIST:VSANS:Globals:gDoTubeShadowCor = 1 88 88 89 89 val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoMonitorNormalizaton", 1 ) 90 Variable/G root:Packages:NIST:VSANS:Globals:gDoMonitorNormalizaton = 1 91 90 92 91 93 // flag to allow adding raw data files with different attenuation (normally not done) … … 197 199 gVal = checked 198 200 End 201 202 Function V_DoMonitorNormPref(ctrlName,checked) : CheckBoxControl 203 String ctrlName 204 Variable checked 205 206 NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoMonitorNormalizaton 207 gVal = checked 208 End 209 199 210 200 211 Function V_PrefDoneButtonProc(ctrlName) : ButtonControl … … 243 254 SetVariable PrefCtrl_1e,pos={21,195},size={200,15},title="# Phi Steps (annular avg)" 244 255 SetVariable PrefCtrl_1e,limits={1,360,1},value= root:Packages:NIST:VSANS:Globals:gNPhiSteps 256 245 257 CheckBox PrefCtrl_1f title="Do Transmssion Correction?",size={140,14},value=root:Packages:NIST:VSANS:Globals:gDoTransmissionCor,proc=V_DoTransCorrPref 246 CheckBox PrefCtrl_1f pos={255, 100},help={"TURN OFF ONLY FOR DEBUGGING. This corrects the data for angle dependent transmssion."}258 CheckBox PrefCtrl_1f pos={255,80},help={"TURN OFF ONLY FOR DEBUGGING. This corrects the data for angle dependent transmssion."} 247 259 CheckBox PrefCtrl_1g title="Do Efficiency Correction?",size={140,14},proc=V_DoEfficiencyCorrPref 248 CheckBox PrefCtrl_1g value=root:Packages:NIST:VSANS:Globals:gDoDetectorEffCor,pos={255,1 20},help={"TURN OFF ONLY FOR DEBUGGING. This corrects the data for angle dependent detector efficiency."}260 CheckBox PrefCtrl_1g value=root:Packages:NIST:VSANS:Globals:gDoDetectorEffCor,pos={255,100},help={"TURN OFF ONLY FOR DEBUGGING. This corrects the data for angle dependent detector efficiency."} 249 261 // CheckBox PrefCtrl_1h title="Adjust RAW attenuation?",size={140,14},proc=V_DoRawAttenAdjPref 250 262 // CheckBox PrefCtrl_1h value=root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten,pos={255,140},help={"This is normally not done"} 251 263 252 264 CheckBox PrefCtrl_1i title="Do DIV Correction?",size={140,14},proc=V_DoDIVCorPref 253 CheckBox PrefCtrl_1i value=root:Packages:NIST:VSANS:Globals:gDoDIVCor,pos={255,1 40},help={"TURN OFF ONLY FOR DEBUGGING."}265 CheckBox PrefCtrl_1i value=root:Packages:NIST:VSANS:Globals:gDoDIVCor,pos={255,120},help={"TURN OFF ONLY FOR DEBUGGING."} 254 266 CheckBox PrefCtrl_1j title="Do DeadTime Correction?",size={140,14},proc=V_DoDeadTimeCorPref 255 CheckBox PrefCtrl_1j value=root:Packages:NIST:VSANS:Globals:gDoDeadTimeCor,pos={255,1 60},help={"TURN OFF ONLY FOR DEBUGGING."}267 CheckBox PrefCtrl_1j value=root:Packages:NIST:VSANS:Globals:gDoDeadTimeCor,pos={255,140},help={"TURN OFF ONLY FOR DEBUGGING."} 256 268 CheckBox PrefCtrl_1k title="Do Solid Angle Correction?",size={140,14},proc=V_DoSolidAngleCorPref 257 CheckBox PrefCtrl_1k value=root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor,pos={255,1 80},help={"TURN OFF ONLY FOR DEBUGGING."}269 CheckBox PrefCtrl_1k value=root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor,pos={255,160},help={"TURN OFF ONLY FOR DEBUGGING."} 258 270 CheckBox PrefCtrl_1l title="Do Non-linear Correction?",size={140,14},proc=V_DoNonLinearCorPref 259 CheckBox PrefCtrl_1l value=root:Packages:NIST:VSANS:Globals:gDoNonLinearCor,pos={255, 200},help={"TURN OFF ONLY FOR DEBUGGING."}271 CheckBox PrefCtrl_1l value=root:Packages:NIST:VSANS:Globals:gDoNonLinearCor,pos={255,180},help={"TURN OFF ONLY FOR DEBUGGING."} 260 272 CheckBox PrefCtrl_1m title="Do Tube Shadow Correction?",size={140,14},proc=V_DoTubeShadowCorPref 261 CheckBox PrefCtrl_1m value=root:Packages:NIST:VSANS:Globals:gDoTubeShadowCor,pos={255,220},help={"TURN OFF ONLY FOR DEBUGGING."} 273 CheckBox PrefCtrl_1m value=root:Packages:NIST:VSANS:Globals:gDoTubeShadowCor,pos={255,200},help={"TURN OFF ONLY FOR DEBUGGING."} 274 CheckBox PrefCtrl_1n title="Do Tube Shadow Correction?",size={140,14},proc=V_DoMonitorNormPref 275 CheckBox PrefCtrl_1n value=root:Packages:NIST:VSANS:Globals:gDoMonitorNormalizaton,pos={255,220},help={"TURN OFF ONLY FOR DEBUGGING."} 276 262 277 263 278 // CheckBox PrefCtrl_1a,disable=1 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_WorkFolderUtils.ipf
r995 r999 408 408 Wave w_err = V_getDetectorDataErrW(fname,detStr) 409 409 410 DIVCorrection(w,w_err,detStr,newType)410 V_DIVCorrection(w,w_err,detStr,newType) 411 411 endfor 412 412 else 413 Print "DIV correction not done" // not an error since correction was unchecked413 Print "DIV correction NOT DONE" // not an error since correction was unchecked 414 414 endif 415 415 416 416 // (2) non-linear correction 417 417 // TODO: 418 // x- currently, the "B" detector is skipped418 // x- the "B" detector is calculated in its own routines 419 419 // -- document what is generated here: 420 420 // **in each detector folder: data_realDistX and data_realDistY (2D waves of the mm? position of the pixel) 421 // -- still not sure whether to duplicate these calculations as the RAW data is loaded. It would allowthe RAW422 // data to be properly displayed, but without all of the (complete) set of corrections421 // x- these spatial calculations ARE DONE as the RAW data is loaded. It allows the RAW 422 // data to be properly displayed, but without all of the (complete) set of detector corrections 423 423 // * the corrected distances are calculated into arrays, but nothing is done with them yet 424 // * there is enough information now to calculate the q-arrays 425 // - other corrections modify the data, this does NOT424 // * there is enough information now to calculate the q-arrays, so it is done now 425 // - other corrections may modify the data, this calculation does NOT modify the data 426 426 NVAR gDoNonLinearCor = root:Packages:NIST:VSANS:Globals:gDoNonLinearCor 427 427 // generate a distance matrix for each of the detectors … … 461 461 462 462 else 463 Print "Non-linear correction not done"463 Print "Non-linear correction NOT DONE" 464 464 endif 465 465 466 466 // (3) solid angle correction 467 // TODO -- this currently calculates the correction factor AND applys it to the data 468 // -- as a result, the data values are very large since they are divided by a very small 469 // solid angle per pixel. But all of the count values are now on the basis of 470 // counts/(solid angle) --- meaning that they can all be binned together for I(q) 471 // -and- TODO - this will need to be taken into account for absolute scaling (this part is already done) 472 // 473 // the solid angle correction is calculated for ALL detector panels. 467 474 NVAR gDoSolidAngleCor = root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor 468 475 if (gDoSolidAngleCor == 1) … … 473 480 Wave w_err = V_getDetectorDataErrW(fname,detStr) 474 481 // any other dimensions to pass in? 475 // SolidAngleCorrection(fill this in)482 SolidAngleCorrection(w,w_err,fname,detStr,destPath) 476 483 477 484 endfor 478 485 else 479 Print "Solid Angle correction not done"486 Print "Solid Angle correction NOT DONE" 480 487 endif 481 488 482 489 // (4) dead time correction 483 // TODO: -- remove the hard-wired test 490 // TODO: 491 // x- remove the hard-wired test - done 484 492 // -- test for correct operation 485 // -- loop over all of the detectors486 // -- B detector is a special case (do separately, then loop over NoB)493 // x- loop over all of the detectors 494 // x- B detector is a special case (do separately, then loop over NoB) 487 495 // -- this DOES alter the data 488 // -- verify the error propagation 496 // -- verify the error propagation (not done yet) 489 497 // 490 498 Variable countRate … … 515 523 516 524 else 517 Print "Dead Time correction not done"525 Print "Dead Time correction NOT DONE" 518 526 endif 519 527 520 528 521 529 // (5) angle-dependent tube shadowing 530 // TODO: 531 // -- not sure about this correction yet... 532 // 522 533 NVAR gDoTubeShadowCor = root:Packages:NIST:VSANS:Globals:gDoTubeShadowCor 523 534 if (gDoTubeShadowCor == 1) 524 525 else 526 Print "Tube shadowing correction not done"535 Print "(stub)Tube Shadow correction" 536 else 537 Print "Tube shadowing correction NOT DONE" 527 538 endif 528 539 529 540 // (6) angle dependent transmission correction 541 // TODO: 542 // -- this still needs to be filled in 543 // -- still some debate of when/where in the corrections that this is best applied 544 // - do it here, and it's done whether the output is 1D or 2D 545 // - do it later (where SAMPLE information is used) since this section is ONLY instrument-specific 530 546 NVAR gDoTrans = root:Packages:NIST:VSANS:Globals:gDoTransmissionCor 531 547 if (gDoTrans == 1) 532 Print " Doing Large-angle transmission correction"// for "+ detStr548 Print "(stub)Doing Large-angle transmission correction"// for "+ detStr 533 549 for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 534 550 detStr = StringFromList(ii, ksDetectorListAll, ";") … … 539 555 endfor 540 556 else 541 Print "Sample Transmission correction not done"557 Print "Sample Transmission correction NOT DONE" 542 558 endif 543 559 … … 546 562 // TODO -- but there are TWO monitors - so how to switch? 547 563 // TODO -- what do I really need to save? 548 Print "Doing monitor normalization"// for "+ detStr 549 550 defmon=1e8 //default monitor counts 551 for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 552 detStr = StringFromList(ii, ksDetectorListAll, ";") 553 Wave w = V_getDetectorDataW(fname,detStr) 554 Wave w_err = V_getDetectorDataErrW(fname,detStr) 555 Variable monCt = V_getBeamMonNormData(fname) 556 // MonitorNormalization(fill this in) 557 //scale the data to the default montor counts 558 559 // TODO -- un-comment these three lines once monitor counts are reasonable - currently monCt = 9!!! 560 // scale = defmon/monCt 561 // w *= scale 562 // w_err *= scale //assumes total monitor count is so large there is essentially no error 563 564 // TODO 565 // -- to write back to the local value, get the wave reference rather than the value, then I can 566 // re-assign the value directly, rather than this method (which is not terrible) 567 // V_getBeamMonNormSaved_count() 568 // save the true monitor counts? save the scaling factor? 569 String path = "entry:instrument:beam_monitor_norm:saved_count" 570 Wave/Z savW = $("root:Packages:NIST:VSANS:"+fname+":"+path) 571 savW[0] = scale 572 endfor 573 564 565 NVAR gDoMonitorNormalizaton = root:Packages:NIST:VSANS:Globals:gDoMonitorNormalizaton 566 if (gDoMonitorNormalizaton == 1) 567 Print "(stub)Doing monitor normalization"// for "+ detStr 568 569 defmon=1e8 //default monitor counts 570 for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 571 detStr = StringFromList(ii, ksDetectorListAll, ";") 572 Wave w = V_getDetectorDataW(fname,detStr) 573 Wave w_err = V_getDetectorDataErrW(fname,detStr) 574 Variable monCt = V_getBeamMonNormData(fname) 575 // MonitorNormalization(fill this in) 576 //scale the data to the default montor counts 577 578 // TODO -- un-comment these three lines once monitor counts are reasonable - currently monCt = 9!!! 579 // scale = defmon/monCt 580 // w *= scale 581 // w_err *= scale //assumes total monitor count is so large there is essentially no error 582 583 // TODO 584 // -- to write back to the local value, get the wave reference rather than the value, then I can 585 // re-assign the value directly, rather than this method (which is not terrible) 586 // V_getBeamMonNormSaved_count() 587 // save the true monitor counts? save the scaling factor? 588 String path = "entry:instrument:beam_monitor_norm:saved_count" 589 Wave/Z savW = $("root:Packages:NIST:VSANS:"+fname+":"+path) 590 savW[0] = scale 591 endfor 592 else 593 Print "Monitor Normalization correction NOT DONE" 594 endif 574 595 575 596 // (not done) angle dependent efficiency correction 576 597 NVAR doEfficiency = root:Packages:NIST:VSANS:Globals:gDoDetectorEffCor 577 598 578 579 // this function, in the past did the non-linear, solid angle, transmission, and efficiency corrections all at once 580 // DetCorr(data,data_err,realsread,doEfficiency,doTrans) //the parameters are waves, and will be changed by the function 581 582 583 584 //update totals to put in the work header (at the end of the function) 599 //update totals to put in the work header (at the end of the function) 585 600 // total_mon += realsread[0] 586 601 //
Note: See TracChangeset
for help on using the changeset viewer.