Changeset 641


Ignore:
Timestamp:
Mar 16, 2010 5:50:17 PM (13 years ago)
Author:
srkline
Message:

A variety of changes to get some of the basic reduction functions working with HFIR raw data files.

Patch now works correctly without duplicating file names in the popup list.

Transmissions can be assigned and calculated now that I've changed the critera for deciding if a file is a transmission file. Hopefully this will always work - it's based on the beamstop y-position being less than 30 mm for all four beam stops.

When checking for a DIV file, it returns an OK if the extension is .xml, since the raw data and div files can't be distinguished like the binary VAX data.

The file catalog is correct, but still excruciatingly slow.

Location:
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/CatVSTable.ipf

    r605 r641  
    2424         
    2525        Variable err 
     26        Variable t1 = ticks 
     27         
    2628        PathInfo catPathName 
    2729        if(v_flag==0) 
     
    102104#endif 
    103105 
     106#if (exists("NCNR")==6) 
    104107                ModifyTable width(:myGlobals:CatVSHeaderInfo:nGuides)=40 
     108#endif 
    105109 
    106110                ModifyTable width(Point)=0              //JUN04, remove point numbers - confuses users since point != run 
     
    124128        Make/T/O/N=0 notRAWlist 
    125129        do 
     130         
    126131                //get current item in the list 
    127132                partialName = StringFromList(ii, list, ";") 
    128133                //get a valid file based on this partialName and catPathName 
    129134                tempName = FindValidFilename(partialName) 
     135                 
    130136                If(cmpstr(tempName,"")==0)              //a null string was returned 
    131137                        //write to notebook that file was not found 
     
    141147                        //make sure the file is really a RAW data file 
    142148                        ok = CheckIfRawData(fullName) 
     149                 
    143150                        if (!ok) 
    144151                                //write to notebook that file was not a RAW SANS file 
     
    159166        KillWaves/Z notRAWlist 
    160167// 
    161  
     168        Print "Total time (s) = ",(ticks - t1)/60.15 
     169        Print "Time per raw data file (s) = ",(ticks - t1)/60.15/(numItems-numpnts(notRawList)) 
     170        return(0) 
    162171End 
    163172 
     
    200209        Wave GField = $"root:myGlobals:CatVSHeaderInfo:Field" 
    201210        Wave GMCR = $"root:myGlobals:CatVSHeaderInfo:MCR"               //added Mar 2008 
     211         
    202212#if (exists("ILL_D22")==6) 
    203213        Wave GReactPow = $"root:myGlobals:CatVSHeaderInfo:ReactorPower"         //activate for ILL June 2008 ( and the sort line too) 
    204214        Sort GSuffix, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens,GRunNumber,GIsTrans,GRot,GTemp,GField,GMCR,GReactPow 
     215#endif 
     216 
     217#if (exists("NCNR")==6) 
     218        //      Sort GSuffix, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens,GRunNumber,GIsTrans,GRot,GTemp,GField,GMCR 
     219        Sort GSuffix, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens,GRunNumber,GIsTrans,GRot,GTemp,GField,GMCR,gNumGuides 
    205220#else 
    206 //      Sort GSuffix, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens,GRunNumber,GIsTrans,GRot,GTemp,GField,GMCR 
    207         Sort GSuffix, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens,GRunNumber,GIsTrans,GRot,GTemp,GField,GMCR,gNumGuides 
    208 #endif 
     221        //must be HFIR or ANSTO 
     222        Sort GSuffix, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens,GRunNumber,GIsTrans,GRot,GTemp,GField,GMCR 
     223#endif 
     224 
    209225 
    210226        return(0) 
     
    236252        Wave ReactorPower = $"root:myGlobals:CatVSHeaderInfo:reactorpower"       //activate for ILL, June 08 (+ edit line) 
    237253        Edit Filenames, Labels, DateAndTime, SDD, Lambda, CntTime, TotCnts, CntRate, Transmission, Thickness, XCenter, YCenter, NumAttens, RotAngle, Temperature, Field, MCR, ReactorPower as "Data File Catalog" 
    238 #else 
     254#endif 
     255 
     256#if (exists("NCNR")==6) 
    239257// original order, magnetic at the end 
    240258//      Edit Filenames, Labels, DateAndTime, SDD, Lambda, CntTime, TotCnts, CntRate, Transmission, Thickness, XCenter, YCenter, NumAttens, RotAngle, Temperature, Field, MCR as "Data File Catalog" 
     
    243261// alternate ordering, put the magnetic information first 
    244262//      Edit Filenames, Labels, RotAngle, Temperature, Field, DateAndTime, SDD, Lambda, CntTime, TotCnts, CntRate, Transmission, Thickness, XCenter, YCenter, NumAttens as "Data File Catalog" 
     263#else 
     264        // either HFIR or ANSTO 
     265        Edit Filenames, Labels, DateAndTime, SDD, Lambda, CntTime, TotCnts, CntRate, Transmission, Thickness, XCenter, YCenter, NumAttens, RotAngle, Temperature, Field, MCR as "Data File Catalog" 
    245266#endif 
    246267 
     
    379400#endif   
    380401 
    381 // number of guides 
     402// number of guides, only for NCNR 
     403#if (exists("NCNR")==6) 
    382404        InsertPoints lastPoint,1,GNumGuides 
    383405        GNumGuides[lastPoint]  = numGuides(getSourceToSampleDist(fname)) 
     406#endif 
    384407 
    385408        return(0) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/HFIR_DataReadWrite.ipf

    r572 r641  
    5050        Endif 
    5151         
     52        Variable t1=ticks 
    5253         
    5354        variable error 
     
    8990        KillWaves/Z M_listAttr, nsList,W_xmlcontentnodes 
    9091         
     92        Print "Time to load and display (s) = ",(ticks-t1)/60.15 
    9193        Return(0)               //Do not change. 
    9294End 
     
    127129        //Open/R refNum as fname 
    128130        STRING/G errorMsg        
    129         Variable refNum 
     131        Variable refNum,t1=ticks 
    130132        //print "Loading", filename, "..."       
    131133        if (stringmatch(filename,"*.xml") <1) 
     
    216218        //data =0 
    217219         
     220//      Print "Time to open (s) = ",(ticks-t1)/60.15 
    218221 
    219222        //ORNL HFIR SANS DATA 
    220223        String tempheadhfir 
    221224        tempheadhfir = "" 
    222        ReadHFIRSansRaw(refNum,curFolder,tempheadhfir)  
     225         
     226        ReadHFIRSansRaw(refNum,curFolder,tempheadhfir)  
    223227        
    224        i=0 
    225        do        
    226         //Take the file name from "actual file name", not from the header: (JC found some cases that those are different.) 
    227         //This DOLOOP can be removed where the problem is solved.... 
    228         textw[0]=stringfromlist(i,filename,":")  
    229         if (stringmatch(textw[0],"*.xml")>0)                     
    230                 break 
    231         endif 
    232         i +=1 
    233        while (1) 
     228        i=0 
     229        do       
     230                //Take the file name from "actual file name", not from the header: (JC found some cases that those are different.) 
     231                //This DOLOOP can be removed where the problem is solved.... 
     232                textw[0]=stringfromlist(i,filename,":")  
     233                if (stringmatch(textw[0],"*.xml")>0)                     
     234                        break 
     235                endif 
     236                i +=1 
     237        while (1) 
    234238         
    235239        //return the data folder to root 
     
    605609                return 0                                //Not a xml file. Do nothing... 
    606610        endif 
    607  
     611         
    608612        //ORNL HFIR SANS strings meta DATA 
    609613       vresult=ReadVFromHHead(refNum,wantedterm,unit)  
    610          
     614        
    611615        //return the data folder to root 
    612616        //SetDataFolder root: 
     
    641645        String fname 
    642646         
    643         return(getRealValueFromHeader(fname,"attenuation","percent")) //in unit od percents 
     647        return(getRealValueFromHeader(fname,"attenuation","percent")) //in unit of percents 
    644648end 
    645649 
     
    989993//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
    990994Function ReadHFIRSansRaw(refNum,curFolder,tempheadhfir) 
    991       Variable refNum 
    992       String curFolder,tempheadhfir 
     995        Variable refNum 
     996        String curFolder,tempheadhfir 
    993997       
    994       String curPath="root:Packages:NIST:"+curFolder 
    995       SetDataFolder curPath 
     998        String curPath="root:Packages:NIST:"+curFolder 
     999        SetDataFolder curPath 
    9961000        Make/O/N=23 $(curPath+":IntegersRead") 
    9971001        Make/O/N=52 $(curPath+":RealsRead") 
     
    10051009        Variable pixnumx=0,pixnumy=0 
    10061010        String val = ""// numerical and text values 
    1007         Variable value 
     1011        Variable value,t1=ticks 
    10081012 
    10091013        //Initialize wave values          
     
    10431047                endfor     
    10441048        //endif 
    1045          
     1049//      Print "Time to list attributes (s) = ",(ticks-t1)/60.15 
    10461050         
    10471051        XMLelemlist(refNum) 
    10481052        WAVE/T W_ElementList 
     1053//      Print "Time to list elements (s) = ",(ticks-t1)/60.15 
    10491054 
    10501055        for (ind = 0; ind<DimSize(W_ElementList,0); ind +=1) 
     
    11791184                 
    11801185       endfor 
    1181  
     1186        
     1187//      Print "Time to loop over elements (s) = ",(ticks-t1)/60.15 
     1188 
     1189       //If the data is a sensitivity scan, normalize so that the average =1. 
     1190       print curFolder 
     1191        if (stringmatch(curFolder,"DIV") >0) 
     1192                WaveStats/Z/Q data 
     1193                data /= V_avg 
     1194        endif 
    11821195        //keep a string with the filename in the RAW folder 
    11831196         
     
    12131226         
    12141227        SetDataFolder curPath 
    1215         Killwaves/Z nsList,M_listAttr,M_xmlContent,W_ElementList,M_listXPath,W_xmlcontentnodes 
     1228         
     1229//      Print "Time to exit reader (s) = ",(ticks-t1)/60.15 
     1230                 
     1231//      Killwaves/Z nsList,M_listAttr,M_xmlContent,W_ElementList,M_listXPath,W_xmlcontentnodes 
     1232        return(0) 
     1233         
    12161234End 
    12171235 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/HFIR_Utils.ipf

    r572 r641  
    269269        String fullName="",partialName="",item="" 
    270270        //get list of raw data files in folder that match "num" (add leading zeros) 
    271         if( (num>999) || (num<=0) ) 
     271        if( (num>9999) || (num<=0) ) 
    272272                //Print "error in  FindFileFromRunNumber(num), file number too large or too small" 
    273273                Return ("") 
    274274        Endif 
    275         //make a three character string of the run number 
     275        //make a four character string of the run number 
    276276        String numStr="" 
    277         if(num<10) 
     277         
     278        if(num > 999) 
     279                numStr = num2str(num) 
     280        endif 
     281        if(num > 99) 
     282                numStr = "0"+num2str(num) 
     283        endif 
     284        if(num > 9) 
    278285                numStr = "00"+num2str(num) 
    279286        else 
    280                 if(num<100) 
    281                         numStr = "0"+num2str(num) 
    282                 else 
    283                         numStr = num2str(num) 
    284                 Endif 
    285         Endif 
     287                numStr = "000"+num2Str(num) 
     288        endif 
    286289         
    287290        //make sure that path exists 
     
    397400End 
    398401 
     402// for HFIR data, both DIV and RAW are determined by looking for "*.xml" 
     403Function CheckIfDIVData(fname) 
     404        String fname 
     405        return(CheckIfRawData(fname)) 
     406End 
     407 
    399408// function returns 1 if file is a transmission file, 0 if not 
    400409// 
    401410// called by Transmission.ipf, CatVSTable.ipf, NSORT.ipf 
     411// 
     412// SRK MAR 2010 - apparently from what I can see in the files, the beam stop "out" 
     413// position is 25 mm for all four beam stop Y POSITIONS 
     414// - if one is larger, (in the hundreds of mm) then it's in, and the run is not a transmission 
     415// - so if all four y positions are less than (tol) 30 mm, call it a trans file 
     416// 
     417// there is a field for this in the header, write "True", so I don't need to guess again. 
    402418// 
    403419Function isTransFile(fName)   ///  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
     
    409425        else 
    410426                //Check from beam stop motor position 
    411         Variable beamtrap_1y=0,beamtrap_2y=0,beamtrap_3y=0,beamtrap_4y=0 
     427        Variable beamtrap_1y=0,beamtrap_2y=0,beamtrap_3y=0,beamtrap_4y=0,tol=30 
    412428        //      if(your test here) 
    413429        beamtrap_1y=getRealValueFromHeader(fname,"trap_y_101mm","mm") 
     
    416432        beamtrap_4y=getRealValueFromHeader(fname,"trap_y_76mm","mm") 
    417433 
    418          if (beamtrap_1y<10 && beamtrap_2y<10 && beamtrap_3y<10 && beamtrap_4y<10)       
     434//       if (beamtrap_1y<10 && beamtrap_2y<10 && beamtrap_3y<10 && beamtrap_4y<10)       
     435         if (beamtrap_1y < tol && beamtrap_2y < tol && beamtrap_3y < tol && beamtrap_4y < tol)   
    419436                        //Write the flag ON 
    420437                        Write_isTransmissionToHeader(fName,"True") 
     
    530547Function/S ValidFileString(partialName) 
    531548        String partialName 
    532  
    533         String tempName = ""  
    534         //Variable ii,refnum 
     549         
     550        String tempName = "",msg="" 
     551        Variable ii,refnum 
     552 
     553        ii=0 
     554        do 
     555                if(ii==0) 
     556                        //first pass, try the partialName 
    535557        tempName = partialName 
     558                        Open/Z/R/T="????TEXT"/P=catPathName refnum tempName     //Does open file (/Z flag) 
     559                        if(V_flag == 0) 
     560                                //file exists 
     561                                Close refnum            //YES needed,  
     562                                break 
     563                        endif 
     564                else 
     565                        tempName = partialName + ";" + num2str(ii) 
     566                        Open/Z/R/T="????TEXT"/P=catPathName refnum tempName 
     567                        if(V_flag == 0) 
     568                                //file exists 
     569                                Close refnum 
     570                                break 
     571                        endif 
     572                Endif 
     573                ii+=1 
     574                //print "ii=",ii 
     575        while(ii<11) 
     576        //go get the selected bits of information, using tempName, which exists 
     577        if(ii>=11) 
     578                //msg = partialName + " not found. is version number > 11?" 
     579                //DoAlert 0, msg 
     580                //PathInfo catPathName 
     581                //Print S_Path 
     582                Return ("")             //use null string as error condition 
     583        Endif 
     584                 
    536585        Return (tempName) 
    537586End 
     
    835884Function AttenuationFactor(fileStr,lam,attenuation) 
    836885        String fileStr 
    837         Variable lam,attenuation  //    0 =< attenuation <= 1 : where no attenuator stands for 0. 
     886        Variable lam,attenuation  //    0 =< attenuation <= 100 (%) : where no attenuator stands for 0. 
    838887         
    839888        Variable attenFactor=1 
    840889         
    841890        // your code here 
    842         attenFactor = 1- attenuation  //???Attenuate transmission 
     891        attenFactor = 1- attenuation*0.01  //???Attenuate transmission 
    843892 
    844893        return(attenFactor) 
     
    915964                        endif 
    916965                endif 
    917                 if( stringmatch(item,"*.xml") ) 
    918                         if (CheckIfRawData(S_path+item) >0) 
    919                                 newlist += item + ";" 
    920                         endif 
    921                 endif 
     966                // if condition is in here twice, not sure why since they are both "*.xml" 
     967//              if( stringmatch(item,"*.xml") ) 
     968//                      if (CheckIfRawData(S_path+item) >0) 
     969//                              newlist += item + ";" 
     970//                      endif 
     971//              endif 
    922972        endfor 
    923973        newList = SortList(newList,";",0) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/Includes_v520.ipf

    r607 r641  
    22#pragma version=5.0 
    33#pragma IgorVersion=6.1 
     4 
     5 
     6// to properly set up the template for other facility reduction templates,  
     7// function NCNR() must exist here in the Includes file. 
     8// 
     9Function NCNR() 
     10        //does nothing but define NCNR() 
     11        return(0) 
     12End 
     13 
    414 
    515//************* 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/NCNR_DataReadWrite.ipf

    r596 r641  
    4141                return(1) 
    4242        Endif 
     43//      Variable t1=ticks 
    4344        //Print  "GetFileNameFromPath(filename) = " +  GetFileNameFromPathNoSemi(filename) 
    4445        ReadHeaderAndData(filename)     //this is the full Path+file 
     
    5051//      //data is displayed here 
    5152//      fRawWindowHook() 
    52          
     53 
     54//      Print "time to load and display (s) = ",(ticks-t1)/60.15 
    5355        Return(0) 
    5456End 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/ProtocolAsPanel.ipf

    r601 r641  
    20622062                String junkStr="" 
    20632063                if(! waveexists($"root:Packages:NIST:DIV:data")) 
    2064                          junkStr = PromptForPath("Select the detector sensitivity file") 
    2065                         If(strlen(junkStr)==0 || CheckIfRawData(junkStr))               //raw check==1 if RAW, DIV is not 
     2064                        junkStr = PromptForPath("Select the detector sensitivity file") 
     2065                        Print junkStr 
     2066#if(exists("HFIR")==6) 
     2067                        if(strlen(junkStr)==0 || !CheckIfDIVData(junkStr))              //if either is false, exit 
     2068                                //Print strlen(junkStr) 
     2069                                //Print CheckIfDIVData(junkStr) 
    20662070                                SetDataFolder root: 
    20672071                                Abort "No DIV (PLEX) file selected. Please use setABSParams again, selecting the empty beam file and then the detector sensitivity (Plex_) file" 
    2068                         Endif 
    2069                          ReadHeaderAndWork("DIV", junkStr) 
     2072                        endif 
     2073#else 
     2074                        if(strlen(junkStr)==0 || CheckIfRawData(junkStr))               //for NCNR, not raw is sufficient, but better in the future to confirm it is DIV if either is false, exit 
     2075                                SetDataFolder root: 
     2076                                Abort "No DIV (PLEX) file selected. Please use setABSParams again, selecting the empty beam file and then the detector sensitivity (Plex_) file" 
     2077                        endif 
     2078#endif 
     2079                        ReadHeaderAndWork("DIV", junkStr) 
    20702080                endif 
    20712081                //toggle SANS_Data to linear display if needed, so that we're working with linear scaled data 
Note: See TracChangeset for help on using the changeset viewer.