Changeset 857


Ignore:
Timestamp:
Jul 6, 2012 5:29:38 PM (10 years ago)
Author:
srkline
Message:

Added support for reading 4-column data into the 2D reader

Calculation of kappa for ABS now does a specific byte check for ensuring a "good" DIV file. hopefully this will eliminate errors where incorrect DIV files are selected and bad kappa values are generated - and the program thinks (incorrectly) that there is a valid DVI file present, when there really isn't one (and then there is no easy recovery from this)

Added CheckIfDIVData() functions to NCNR_Utils and to FACILITY_Utils, and to other (facility)_Utils

Changed the calls to writing BT5 files after adding so that it could be more easily scripted in the future.

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

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Common/Packages/PlotManager/PlotUtils2D_v40.ipf

    r838 r857  
    9898         
    9999        endif           //8-columns 
    100          
     100 
     101 
     102// the very bad case where users don't supply the error data... 
    101103        if(numCols == 3) 
    102104                // put the names of the 3 loaded waves into local names 
     
    158160         
    159161        endif           //3-columns 
     162 
     163// with 4-columns, assume that they are qx,qy,I, err     
     164        if(numCols == 4) 
     165                // put the names of the 3 loaded waves into local names 
     166                n0 = StringFromList(0, S_waveNames ,";" ) 
     167                n1 = StringFromList(1, S_waveNames ,";" ) 
     168                n2 = StringFromList(2, S_waveNames ,";" ) 
     169                n3 = StringFromList(3, S_waveNames ,";" ) 
     170 
     171                //remove the semicolon AND period from file names 
     172                w0 = CleanupName((S_fileName + "_qx"),0) 
     173                w1 = CleanupName((S_fileName + "_qy"),0) 
     174                w2 = CleanupName((S_fileName + "_i"),0) 
     175                w3 = CleanupName((S_fileName + "_iErr"),0)              //make a name for the error wave, to be generated here 
     176 
     177                String baseStr=w1[0,strlen(w1)-4] 
     178                if(DataFolderExists("root:"+baseStr)) 
     179                                DoAlert 1,"The file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" 
     180                                if(V_flag==2)   //user selected No, don't load the data 
     181                                        SetDataFolder root: 
     182                                        KillWaves/Z $n0,$n1,$n2,$n3             // kill the default waveX that were loaded 
     183                                        return          //quits the macro 
     184                                endif 
     185                                SetDataFolder $("root:"+baseStr) 
     186                else 
     187                        NewDataFolder/S $("root:"+baseStr) 
     188                endif 
     189                 
     190                //read in the 18 lines of header (18th line starts w/ ASCII... 19th line is blank) 
     191                Make/O/T/N=18 header 
     192                Variable refnum,ii 
     193                string tmpStr="" 
     194                Open/R refNum  as (path+filename) 
     195                ii=0 
     196                do 
     197                        tmpStr = "" 
     198                        FReadLine refNum, tmpStr 
     199                        header[ii] = tmpStr 
     200                        ii+=1 
     201                while(ii < 18)           
     202                Close refnum             
     203                 
     204                ////overwrite the existing data, if it exists 
     205                Duplicate/O $("root:"+n0), $w0 
     206                Duplicate/O $("root:"+n1), $w1 
     207                Duplicate/O $("root:"+n2), $w2 
     208                Duplicate/O $("root:"+n3), $w3 
     209         
     210        endif           //4-columns      
    160211         
    161212         
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/ANSTO_Utils.ipf

    r795 r857  
    396396End 
    397397 
     398 
     399//function to test a file to see if it is a DIV file 
     400// 
     401// returns truth 0/1 
     402// 
     403// called by many procedures (both external and local) 
     404// 
     405Function CheckIfDIVData(fname) 
     406        String fname 
     407         
     408 
     409//      if(your test here) 
     410//              //true, is DIV data file 
     411                Return(1) 
     412//      else 
     413//              //some other file 
     414//              Return(0) 
     415//      Endif 
     416 
     417End 
     418 
    398419Function isScatFile(fname) 
    399420        String fname 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/FACILITY_Utils.ipf

    r795 r857  
    259259//      if(your test here) 
    260260//              //true, is raw data file 
     261//              Return(1) 
     262//      else 
     263//              //some other file 
     264//              Return(0) 
     265//      Endif 
     266 
     267End 
     268 
     269//function to test a file to see if it is a DIV file 
     270// 
     271// returns truth 0/1 
     272// 
     273// called by many procedures (both external and local) 
     274// 
     275Function CheckIfDIVData(fname) 
     276        String fname 
     277         
     278 
     279//      if(your test here) 
     280//              //true, is DIV data file 
    261281//              Return(1) 
    262282//      else 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/ILL_Utils.ipf

    r795 r857  
    450450End 
    451451 
     452//function to test a file to see if it is a DIV file 
     453// 
     454// returns truth 0/1 
     455// 
     456// called by many procedures (both external and local) 
     457// 
     458Function CheckIfDIVData(fname) 
     459        String fname 
     460         
     461 
     462//      if(your test here) 
     463//              //true, is DIV file data file 
     464                Return(1) 
     465//      else 
     466//              //some other file 
     467//              Return(0) 
     468//      Endif 
     469 
     470End 
    452471 
    453472// function returns 1 if file is a transmission file, 0 if not 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/KIST_Utils.ipf

    r807 r857  
    267267End 
    268268 
     269//function to test a file to see if it is a DIV file 
     270// 
     271// returns truth 0/1 
     272// 
     273// called by many procedures (both external and local) 
     274// 
     275Function CheckIfDIVData(fname) 
     276        String fname 
     277         
     278 
     279//      if(your test here) 
     280//              //true, is DIV data file 
     281//              Return(1) 
     282//      else 
     283//              //some other file 
     284//              Return(0) 
     285//      Endif 
     286 
     287End 
    269288 
    270289// function returns 1 if file is a transmission file, 0 if not 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/NCNR_Utils.ipf

    r838 r857  
    831831                Return(0) 
    832832        Endif 
     833End 
     834 
     835//function to test a file to see if it is a DIV file 
     836// 
     837// returns truth 0/1 
     838// 
     839// called by many procedures (both external and local) 
     840// 
     841Function CheckIfDIVData(fname) 
     842        String fname 
     843         
     844 
     845        Variable refnum,totalBytes 
     846//      String testStr="" 
     847         
     848        Open/R/T="????TEXT" refNum as fname 
     849        if(strlen(s_filename) == 0)     //user cancel (/Z not used, so V_flag not set) 
     850                return(0) 
     851        endif 
     852         
     853        //get the total number of bytes in the file 
     854        FStatus refNum 
     855        totalBytes = V_logEOF 
     856        //Print totalBytes 
     857        if(totalBytes < 100) 
     858                Close refNum 
     859                return(0)               //not a raw file 
     860        endif 
     861//      FSetPos refNum,75 
     862//      FReadLine/N=3 refNum,testStr 
     863        Close refNum 
     864         
     865        if(totalBytes == 66116)         // && ( cmpstr(testStr,"RAW")==0 ||  cmpstr(testStr,"SIM")==0)) 
     866                //true, is raw data file 
     867                Return(1) 
     868        else 
     869                //some other file 
     870                Return(0) 
     871        Endif 
     872 
    833873End 
    834874 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/ProtocolAsPanel.ipf

    r853 r857  
    21092109                        endif 
    21102110#else 
    2111                         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 
     2111                        if(strlen(junkStr)==0 || !CheckIfDIVData(junkStr))              //for NCNR, and other data confirm it is DIV if either is false, exit 
    21122112                                SetDataFolder root: 
    21132113                                Abort "No DIV (PLEX) file selected. Please use setABSParams again, selecting the empty beam file and then the detector sensitivity (Plex_) file" 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/USANS/BT5_AddFiles.ipf

    r807 r857  
    1212//      - it can be repeated multiple times to add more than two files together 
    1313//      - the two added files are listed in the title of the summed file. 
     14// -- see AddBT5AndSave() if you want something that cen be automated to bypass the user dialogs. 
    1415 
    1516// Adding two data sets: 
     
    758759        LoadAndAddUSANS(file1,file2) 
    759760         
    760 End 
     761        String filen = file1[0,strlen(file1)-5]+"_SUM"+".BT5" 
     762         
     763        GetAddedFileName(filen) 
     764End 
     765 
     766Proc GetAddedFileName(newName) 
     767        String newName 
     768        Prompt newName, "Enter new FileName" 
     769         
     770        SaveAddedBT5Files(newName,1)                    // 1 asks to confirm the name w/ a dialog 
     771End 
     772 
     773 
     774// this procedure will add two and name without any dialogs. Pass it the three names 
     775// if the save name is null, you'll get a dialog 
     776Proc AddBT5AndSave(file1,file2,filen) 
     777        String file1,file2,filen="TMP.BT5" 
     778        Prompt file1, "First File", popup, BT5FileList("") 
     779        Prompt file2, "Second File", popup, BT5FileList("") 
     780        Prompt filen, "output file name" 
     781         
     782        LoadAndAddUSANS(file1,file2) 
     783         
     784//      String filen = file1[0,strlen(file1)-5]+"_SUM"+".BT5" 
     785 
     786        PathInfo savePathName    
     787        filen = S_Path + filen  
     788        SaveAddedBT5Files(filen,0)              //0==no dialog 
     789 
     790End 
     791 
     792 
    761793 
    762794Function/S BT5FileList(filter) 
     
    896928        endfor 
    897929         
    898         // write out the final file (=tw3) 
    899         filen = file1[0,strlen(file1)-5]+"_SUM"+ext 
     930//      // write out the final file (=tw3) 
     931//      filen = file1[0,strlen(file1)-5]+"_SUM"+ext 
     932//       
     933//      if(dialog) 
     934//              PathInfo/S savePathName 
     935//              fullPath = DoSaveFileDialog("Save data as",fname=filen) 
     936//              If(cmpstr(fullPath,"")==0) 
     937//                      //user cancel, don't write out a file 
     938//                      Close/A 
     939//                      Abort "no data file was written" 
     940//              Endif 
     941//              //Print "dialog fullpath = ",fullpath 
     942//      Endif 
     943//       
     944//      Open refNum as fullPath 
     945//      wfprintf refnum, "%s",tw3 
     946//      Close refnum 
     947//               
     948//      //killwaves/Z tw1,tw2,tw3 
     949         
     950        return(0) 
     951end 
     952 
     953// if you bypass the dialog, newname needs to be a full path 
     954Function SaveAddedBT5Files(newName,dialog) 
     955        String newName 
     956        Variable dialog 
     957         
     958        Variable refnum 
     959        String fullPath 
     960         
     961        WAVE/T tw3=tw3 
    900962         
    901963        if(dialog) 
    902964                PathInfo/S savePathName 
    903                 fullPath = DoSaveFileDialog("Save data as",fname=filen) 
     965                fullPath = DoSaveFileDialog("Save data as",fname=newName) 
    904966                If(cmpstr(fullPath,"")==0) 
    905967                        //user cancel, don't write out a file 
     
    907969                        Abort "no data file was written" 
    908970                Endif 
     971                newName=FullPath 
    909972                //Print "dialog fullpath = ",fullpath 
    910973        Endif 
    911          
    912         Open refNum as fullPath 
     974 
     975 
     976        Open refNum as newName 
    913977        wfprintf refnum, "%s",tw3 
    914978        Close refnum 
    915                  
    916         //killwaves/Z tw1,tw2,tw3 
    917          
     979 
    918980        return(0) 
    919 end 
     981End 
    920982 
    921983//returns count time and start/stop angles as written in header 
Note: See TracChangeset for help on using the changeset viewer.