Changeset 1092


Ignore:
Timestamp:
Mar 23, 2018 10:29:07 AM (4 years ago)
Author:
srkline
Message:

added a few corrections to the reduction:

Added sample apertures to the patch panel so that they can be corrected

A flag is now written to the data files if the "flip" has been done, and it will refuse to flip again. This flag can be reset if something goes wrong.

Multiple reduce now allows run numbers to be entered as is for SANS,

Filtering of files for the protocol panel should be better behaved now.

Location:
sans/Dev/trunk/NCNR_User_Procedures
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/Alpha/Tinker/FFT_Panel.ipf

    r1000 r1092  
    10951095                else 
    10961096                        list += num2str(V_max) + ";" 
    1097                         MultiThread mz = mz[p][q] == V_max ? V_min : mz[p][q]           // replace the max with min                      
     1097                        MultiThread mz = mz[p][q][r] == V_max ? V_min : mz[p][q][r]             // replace the max with min                      
    10981098                endif 
    10991099        while(!done)     
    11001100         
    11011101//      Print "Found values in matrix = ",list 
    1102         KillWaves/Z mz 
     1102//      KillWaves/Z mz 
    11031103 
    11041104        return(list) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_DetectorBinning_Utils.ipf

    r1090 r1092  
    14181418        S1 = str2num(V_getSourceAp_size(folderStr)) 
    14191419         
    1420 // S2 = sample aperture diameter [mm] 
     1420// S2 = sample aperture diameter [cm] 
    14211421// as of 3/2018, the "internal" sample aperture is not in use, only the external 
    1422         S2 = V_getSampleAp2_size(folderStr)*10          // sample ap 1 or 2? 2 = the "external", but may not exist? 
     1422// TODO : verify the units on the Ap2 (external) 
     1423// sample aperture 1(internal) is set to report "12.7 mm" as a STRING 
     1424// sample aperture 2(external) reports the number typed in... 
     1425// 
     1426// so I'm trusting [cm] is in the file 
     1427        S2 = V_getSampleAp2_size(folderStr)*10          // sample ap 1 or 2? 2 = the "external", convert to [cm] 
    14231428         
    14241429// L1 = source to sample distance [m]  
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_VCALCPanel_MockUp.ipf

    r1081 r1092  
    890890        String/G gSourceShape = "circular;rectangular;converging pinholes;" 
    891891        String/G gSourceDiam = "1.0 cm;2.0 cm;5.0 cm;" 
     892        String/G gSourceDiam_0g = "0.75 cm;1.5 cm;3.0 cm;"              // values from John Mar 2018 
    892893        String/G gDeltaLambda = "0.10;0.20;0.30;" 
    893894         
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Read.ipf

    r1074 r1092  
    26162616         
    26172617end 
    2618          
     2618 
     2619// this is a NON NICE entered field 
     2620// so if it's not there, it returns -999999 
     2621// 
     2622// this is a flag to mark the file as "flipped" so it prevents a 2nd flip 
     2623// if the flip has been done, the field is written with a value of 1 (= true) 
     2624// 
     2625Function V_getLeftRightFlipDone(fname) 
     2626        String fname 
     2627         
     2628        String path = "entry:reduction:left_right_flip"  
     2629        return(V_getRealValueFromHDF5(fname,path)) 
     2630end      
    26192631 
    26202632 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Write.ipf

    r1083 r1092  
    69296929end 
    69306930 
     6931 
     6932// this is a NON NICE entered field 
     6933// 
     6934// this is a flag to mark the file as "flipped" so it prevents a 2nd flip 
     6935// if the flip has been done, the field is written with a value of 1 (= true) 
     6936// 
     6937// to "un-mark" the file and allow the flip to be re-done, write -999999 
     6938Function V_writeLeftRightFlipDone(fname,val) 
     6939        String fname 
     6940        Variable val 
     6941         
     6942        String path = "entry:reduction:left_right_flip"  
     6943         
     6944        Make/O/D/N=1 wTmpWrite 
     6945//      Make/O/R/N=1 wTmpWrite 
     6946        String groupName = "/entry/reduction" 
     6947        String varName = "left_right_flip" 
     6948        wTmpWrite[0] = val 
     6949 
     6950        variable err 
     6951        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite) 
     6952        if(err) 
     6953                Print "HDF write err = ",err 
     6954        endif 
     6955        // now be sure to kill the data folder to force a re-read of the data next time this file is read in 
     6956//      err = V_KillNamedDataFolder(fname) 
     6957//      if(err) 
     6958//              Print "DataFolder kill err = ",err 
     6959//      endif 
     6960        return(err) 
     6961end 
    69316962 
    69326963 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Menu.ipf

    r1083 r1092  
    4949                "Copy_VCALC_to_VSANSFile",Copy_VCALC_to_VSANSFile() 
    5050                "Flip Lateral Offset",V_PatchDet_Offset() 
     51                "Mark Lateral Flip Done",V_MarkLeftRightFlip_Done() 
     52                "Mark Lateral Flip NOT Done",V_MarkLeftRightFlip_Not_Done() 
     53                "-" 
    5154                "Patch GroupID using CatTable",V_Patch_GroupID_catTable() 
    5255                "Patch Purpose using CatTable",V_Patch_Purpose_catTable() 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_MultipleReduce.ipf

    r1073 r1092  
    7575        Button helpButton,pos={385,3},size={25,20},proc=V_ShowMRHelp,title="?" 
    7676        Button helpButton,help={"Show the help file for reducing multiple files using the same protocol"} 
    77         PopupMenu MRFilesPopup,pos={3,44},size={167,19},proc=V_MRedPopMenuProc,title="File(s) to Reduce" 
     77        PopupMenu MRFilesPopup,pos={3,72},size={167,19},proc=V_MRedPopMenuProc,title="File(s) to Reduce" 
    7878        PopupMenu MRFilesPopup,help={"The displayed file is the one that will be reduced. The entire list will be reduced if \"Reduce All..\" is selected. \r If no items, or the wrong items appear, click on the popup to refresh."} 
    7979        PopupMenu MRFilesPopup,mode=1,popvalue="none",value= #"root:Packages:NIST:VSANS:Globals:MRED:gMRedList" 
    80 //      SetVariable MRList,pos={3,72},size={350,13},proc=FileNumberListProc,title="File number list: " 
    81 //      SetVariable MRList,help={"Enter a comma delimited list of file numbers to reduce. Ranges can be entered using a dash."} 
    82 //      SetVariable MRList,limits={-Inf,Inf,1},value= root:Packages:NIST:VSANS:Globals:MRED:gFileNumList 
     80        SetVariable MRList,pos={3,48},size={350,13},proc=V_FileNumberListProc,title="File number list: " 
     81        SetVariable MRList,help={"Enter a comma delimited list of file numbers to reduce. Ranges can be entered using a dash."} 
     82        SetVariable MRList,limits={-Inf,Inf,1},value= root:Packages:NIST:VSANS:Globals:MRED:gFileNumList 
    8383        Button ReduceAllButton,pos={3,128},size={180,20},proc=V_ReduceAllPopupFiles,title="Reduce All Files in Popup" 
    8484        Button ReduceAllButton,help={"This will reduce ALL of the files in the popup list, not just the top file."} 
    85         Button ReduceOneButton,pos={3,98},size={180,20},proc=V_ReduceTopPopupFile,title="Reduce Top File in Popup" 
    86         Button ReduceOneButton,help={"This will reduce TOP files in the popup list, not all of the files."} 
     85//      Button ReduceOneButton,pos={3,98},size={180,20},proc=V_ReduceTopPopupFile,title="Reduce Top File in Popup" 
     86//      Button ReduceOneButton,help={"This will reduce TOP files in the popup list, not all of the files."} 
    8787        Button DoneButton,pos={290,128},size={110,20},proc=V_MRDoneButtonProc,title="Done Reducing" 
    8888        Button DoneButton,help={"When done reducing files, this will close this control panel."} 
     
    9595//      Button acceptList,pos={280,98},size={120,20},proc=AcceptMREDList,title="Accept List" 
    9696//      Button acceptList,help={"Accept the list of files to reduce."} 
    97         PopupMenu MRProto_pop,pos={3,72},size={119,19},proc=V_MRProtoPopMenuProc,title="Protocol " 
     97        PopupMenu MRProto_pop,pos={3,98},size={119,19},proc=V_MRProtoPopMenuProc,title="Protocol " 
    9898        PopupMenu MRProto_pop,help={"All of the data files in the popup will be reduced using this protocol"} 
    9999        PopupMenu MRProto_pop,mode=1,popvalue="none",value= #"root:Packages:NIST:VSANS:Globals:MRED:gMRProtoList" 
     
    254254// get a  list of all of the sample files, based on intent 
    255255// 
     256//parses the file number list to get valid raw data filenames for reduction 
     257// -if the numbers and full ranges can be translated to correspond to actual files 
     258// on disk, the popup list is updated - otherwise the offending number is reported 
     259// and the user must fix the problem before any reduction can be done 
     260// 
     261//              V_ParseRunNumberList() does the work 
     262// 
     263// only accepts files in the list that are purpose=scattering 
     264// 
    256265Function/S V_GetValidMRedPopupList() 
    257266 
    258         String semiList = V_GetSAMList() 
     267//      String semiList = V_GetSAMList() 
     268 
     269        String commaList="",semiList="",fname="",purpose="" 
     270        SVAR numList=root:Packages:NIST:VSANS:Globals:MRED:gFileNumList 
     271         
     272        commaList = V_ParseRunNumberList(numList) 
     273        //convert commaList to a semicolon delimited list, checking that files are SCATTERING 
     274        Variable num=ItemsinList(commaList,","),ii 
     275        for(ii=0;ii<num;ii+=1) 
     276                fname = StringFromList(ii, commaList  ,",") 
     277                purpose = V_getReduction_Purpose(fname) 
     278                if(cmpstr(purpose,"SCATTERING") == 0) 
     279                        semiList += StringFromList(ii, commaList  ,",") + ";" 
     280                endif 
     281        endfor 
     282//      print semiList 
     283//sort the list 
     284        semiList = SortList(semiList,";",0) 
     285        return(semiList) 
     286 
    259287 
    260288        return(semiList) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_PatchFiles.ipf

    r1091 r1092  
    446446        fname = S_path + fname 
    447447 
    448         Variable nRows = 6 
     448        Variable nRows = 9 
    449449        Redimension/N=(nRows,3) ListWave 
    450450        Redimension/N=(nRows,3) selWave 
     
    473473        listWave[5][1] = "distance (source aperture) (cm)" 
    474474        listWave[5][2] = num2str(V_getSourceAp_distance(fname))          
    475                  
     475 
     476        listWave[6][1] = "source aperture size (mm)" 
     477        listWave[6][2] = V_getSourceAp_size(fname) 
     478         
     479        listWave[7][1] = "sample aperture size (internal) (mm)" 
     480        listWave[7][2] = V_getSampleAp_size(fname) 
     481 
     482        listWave[8][1] = "sample aperture diam (external) (cm)" 
     483        listWave[8][2] = num2str(V_getSampleAp2_size(fname))     
     484                                 
    476485        return(0) 
    477486End 
     
    662671        // (don't update the list - not until someone enters a search critera) -- Jul09 
    663672        // 
    664         V_SetMatchStrProc("",0,"*","")          //this is equivalent to finding everything, typical startup case 
     673         
     674        STRUCT WMSetVariableAction sva 
     675        sva.eventCode = 2        
     676        V_SetMatchStrProc(sva)          //this is equivalent to finding everything, typical startup case 
    665677 
    666678        return(0) 
     
    845857End 
    846858 
     859 
    847860//when text is entered in the match string, the popup list is refined to  
    848861//include only the selected files, useful for trimming a lengthy list, or selecting 
     
    850863//only one wildcard (*) is allowed 
    851864// 
    852 Function V_SetMatchStrProc(ctrlName,varNum,varStr,varName) : SetVariableControl 
    853         String ctrlName 
    854         Variable varNum 
    855         String varStr 
    856         String varName 
    857  
    858         //change the contents of gPatchList that is displayed 
    859         //based on selected Path, match str, and 
    860         //further trim list to include only RAW SANS files 
    861         //this will exclude version numbers, .AVE, .ABS files, etc. from the popup (which can't be patched) 
    862          
    863         String list = V_GetValidPatchPopupList() 
    864          
    865         String/G root:Packages:NIST:VSANS:Globals:Patch:gPatchList = list 
    866         ControlUpdate PatchPopup 
    867         PopupMenu PatchPopup,mode=1 
    868          
    869         if(strlen(list) > 0) 
    870                 V_ShowHeaderButtonProc("SHButton") 
    871         endif 
    872         return(0) 
    873 End 
    874  
     865//change the contents of gPatchList that is displayed 
     866//based on selected Path, match str, and 
     867//further trim list to include only RAW SANS files 
     868//this will exclude version numbers, .AVE, .ABS files, etc. from the popup (which can't be patched) 
     869Function V_SetMatchStrProc(sva) : SetVariableControl 
     870        STRUCT WMSetVariableAction &sva 
     871 
     872        switch( sva.eventCode ) 
     873                case 1: // mouse up 
     874                case 2: // Enter key 
     875                case 8:         // edit end 
     876                        Variable dval = sva.dval 
     877                        String sval = sva.sval 
     878                         
     879                        String list = V_GetValidPatchPopupList() 
     880         
     881                        String/G root:Packages:NIST:VSANS:Globals:Patch:gPatchList = list 
     882                        ControlUpdate PatchPopup 
     883                        PopupMenu PatchPopup,mode=1 
     884                         
     885                        if(strlen(list) > 0) 
     886                                V_ShowHeaderButtonProc("SHButton") 
     887                        endif 
     888                case 3: // Live update 
     889 
     890                        break 
     891                case -1: // control being killed 
     892                        break 
     893        endswitch 
     894 
     895        return 0 
     896End 
    875897 
    876898//displays the header of the selected file (top in the popup) when the button is clicked 
     
    12191241                err = V_writeSourceAp_distance(fname,val) 
    12201242        endif            
    1221          
    1222          
     1243 
     1244        if ((selWave[6][0] & 2^4) != 0)         //"source aperture size (mm)" (a string with units) 
     1245                str = listWave[6][2] 
     1246                err = V_writeSourceAp_size(fname,str) 
     1247        endif            
     1248 
     1249        if ((selWave[7][0] & 2^4) != 0)         //"sample aperture size (internal) (mm)" (a string with units) 
     1250                str = listWave[7][2] 
     1251                err = V_writeSampleAp_size(fname,str) 
     1252        endif    
     1253                 
     1254        if ((selWave[8][0] & 2^4) != 0)         //"sample aperture diam (external) (cm)" 
     1255                val = str2num(listWave[8][2]) 
     1256                err = V_writeSampleAp2_size(fname,val) 
     1257        endif            
     1258 
    12231259        return(0) 
    12241260End 
     
    23462382End 
    23472383 
    2348 // V_fReadDet_Offset(lo,hi) 
     2384Proc V_MarkLeftRightFlip_Done(lo,hi) 
     2385        Variable lo,hi 
     2386         
     2387        V_fWriteFlipState(lo,hi,1)      // value == 1 means flip done 
     2388End 
     2389 
     2390Proc V_MarkLeftRightFlip_Not_Done(lo,hi) 
     2391        Variable lo,hi 
     2392         
     2393        V_fWriteFlipState(lo,hi,-999999)        // value == -999999 means flip not done 
     2394End 
     2395 
    23492396 
    23502397Proc V_Patch_GroupID_catTable() 
     
    23762423        V_fPatchDet_distance(lo,hi,dist_f,dist_m,dist_b) 
    23772424End 
     2425 
     2426 
    23782427// simple utility to patch the offset values in the file headers 
    23792428// 
     
    23822431// hi is the last file number (inclusive) 
    23832432// 
     2433//              V_getLeftRightFlipDone(fname) 
     2434// 
     2435// 
     2436// updated the function to check for the "already done" flag 
     2437// - if already done, report this and do nothing. 
     2438// - if not done, do the flip and set the flag 
     2439// 
    23842440Function V_fPatchDet_Offset(lo,hi) 
    23852441        Variable lo,hi 
    23862442 
    23872443         
    2388         Variable ii,jj 
     2444        Variable ii,jj,flipDone=0 
    23892445        String fname,detStr 
    23902446         
     
    23972453                if(strlen(fname) != 0) 
    23982454                 
    2399                         offset_FL = V_getDet_LateralOffset(fname,"FL") 
    2400                         offset_FR = V_getDet_LateralOffset(fname,"FR") 
    2401  
    2402                         offset_ML = V_getDet_LateralOffset(fname,"ML") 
    2403                         offset_MR = V_getDet_LateralOffset(fname,"MR") 
    2404                  
    2405                 // swap L/R offset values 
    2406                         V_WriteDet_LateralOffset(fname,"FL",-offset_FR) 
    2407                         V_WriteDet_LateralOffset(fname,"FR",-offset_FL) 
    2408                          
    2409                         V_WriteDet_LateralOffset(fname,"ML",-offset_MR) 
    2410                         V_WriteDet_LateralOffset(fname,"MR",-offset_ML) 
    2411                  
    2412                         Print fname 
    2413                         Print "swapped FL, FR = ",-offset_FR,-offset_FL 
    2414                         Print "swapped ML, MR = ",-offset_MR,-offset_ML 
     2455                        flipDone = V_getLeftRightFlipDone(fname) 
     2456                        if(flipDone == 1) 
     2457                                printf "run number %d already flipped - nothing done\r",jj 
     2458                        else 
     2459                                offset_FL = V_getDet_LateralOffset(fname,"FL") 
     2460                                offset_FR = V_getDet_LateralOffset(fname,"FR") 
     2461         
     2462                                offset_ML = V_getDet_LateralOffset(fname,"ML") 
     2463                                offset_MR = V_getDet_LateralOffset(fname,"MR") 
     2464                         
     2465                        // swap L/R offset values 
     2466                                V_WriteDet_LateralOffset(fname,"FL",-offset_FR) 
     2467                                V_WriteDet_LateralOffset(fname,"FR",-offset_FL) 
     2468                                 
     2469                                V_WriteDet_LateralOffset(fname,"ML",-offset_MR) 
     2470                                V_WriteDet_LateralOffset(fname,"MR",-offset_ML) 
     2471                         
     2472                        // set the flag 
     2473                                V_writeLeftRightFlipDone(fname,1)               // value == 1 means the flip was done 
     2474                                Print fname 
     2475                                Print "swapped FL, FR = ",-offset_FR,-offset_FL 
     2476                                Print "swapped ML, MR = ",-offset_MR,-offset_ML 
     2477                         
     2478                        endif 
    24152479                 
    24162480                else 
    24172481                        printf "run number %d not found\r",jj 
    24182482                endif 
     2483                 
    24192484        endfor 
    24202485         
    24212486        return(0) 
    24222487End 
     2488 
     2489//  utility to reset the flip state in the file headers 
     2490// 
     2491// lo is the first file number 
     2492// hi is the last file number (inclusive) 
     2493// 
     2494// setting value == 1 means done 
     2495// setting value == -999999 means not done (mimics a missing /entry) 
     2496// 
     2497Function V_fWriteFlipState(lo,hi,val) 
     2498        Variable lo,hi,val 
     2499 
     2500         
     2501        Variable ii,jj,flipDone=0 
     2502        String fname,detStr 
     2503         
     2504        Variable offset_ML,offset_MR,offset_FL,offset_FR 
     2505 
     2506        //loop over all files 
     2507        for(jj=lo;jj<=hi;jj+=1) 
     2508                fname = V_FindFileFromRunNumber(jj) 
     2509                if(strlen(fname) != 0) 
     2510         
     2511                // set the flag 
     2512                        V_writeLeftRightFlipDone(fname,val)             //  
     2513                        Print fname 
     2514                        printf "run number %d flag reset to %d\r",jj,val 
     2515                         
     2516                else 
     2517                        printf "run number %d not found\r",jj 
     2518                endif 
     2519                 
     2520        endfor 
     2521         
     2522        return(0) 
     2523End 
     2524 
     2525 
    24232526 
    24242527// simple utility to read the detector offset stored in the file header 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Protocol_Reduction.ipf

    r1088 r1092  
    583583Function/S V_GetBGDList() 
    584584 
    585         String match="BLOCKED BEAM" 
    586         String list = V_getFileIntentList(match,0) 
    587  
     585        String intent="BLOCKED BEAM" 
     586        String purpose="SCATTERING" 
     587//      String list = V_getFileIntentList(match,0) 
     588        String list = V_getFileIntentPurposeList(intent,purpose,0) 
     589         
    588590//      Printf "BGD files = %s\r",list   
    589591        return(list) 
    590592end 
    591593 
    592  
     594// 
     595// V_getFileIntentPurposeList(intent,purpose,method) 
    593596Function/S V_GetEMPList() 
    594597 
    595         String match="EMPTY CELL" 
    596         String list = V_getFileIntentList(match,0) 
     598        String intent="EMPTY CELL" 
     599        String purpose="SCATTERING" 
     600//      String list = V_getFileIntentList(match,0) 
     601        String list = V_getFileIntentPurposeList(intent,purpose,0) 
     602 
    597603 
    598604//      Printf "EMP files = %s\r",list   
     
    755761 
    756762 
    757  
    758763         
    759764        return(list) 
     
    769774         
    770775        newList = V_Get_NotRawDataFileList() 
     776        newList = V_RemoveEXTFromList(newlist,"hst")            // remove the event files 
     777        newList = V_RemoveEXTFromList(newlist,"ave")            // remove the ave files 
     778        newList = V_RemoveEXTFromList(newlist,"abs")            // remove the abs files 
     779 
    771780        num=ItemsInList(newList) 
    772781         
     
    812821         
    813822        newList = V_Get_NotRawDataFileList() 
     823        newList = V_RemoveEXTFromList(newlist,"hst")            // remove the event files 
    814824        num=ItemsInList(newList) 
    815825         
     
    852862         
    853863        newList = V_Get_NotRawDataFileList() 
     864        newList = V_RemoveEXTFromList(newlist,"hst")            // remove the event files 
     865        newList = V_RemoveEXTFromList(newlist,"ave")            // remove the ave files 
     866        newList = V_RemoveEXTFromList(newlist,"abs")            // remove the abs files 
     867 
    854868        num=ItemsInList(newList) 
    855869         
     
    899913         
    900914        newList = V_Get_NotRawDataFileList() 
     915        newList = V_RemoveEXTFromList(newlist,"hst")            // remove the event files 
    901916        num=ItemsInList(newList) 
    902917         
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Utilities_General.ipf

    r1084 r1092  
    962962End 
    963963 
     964// removes any item with ".EXT" from the list 
     965// don't pass the "." 
     966// returns a modified list 
     967Function/S V_RemoveEXTFromList(list,ext) 
     968        String list,ext 
     969         
     970        ext = "*."+ext 
     971        Variable num=ItemsInList(list,";"),ii 
     972        String item,newList="" 
     973         
     974        for(ii=0;ii<num;ii+=1) 
     975                item = StringFromList(ii, list  ,";") 
     976 
     977                if( !stringmatch(item,ext) ) 
     978                        newlist += item + ";" 
     979                endif 
     980                 
     981        endfor 
     982        return(newList) 
     983End 
    964984 
    965985//the following is a WaveMetrics procedure from <StrMatchList> 
Note: See TracChangeset for help on using the changeset viewer.