Ignore:
Timestamp:
Feb 19, 2016 4:37:30 PM (7 years ago)
Author:
srkline
Message:

more changes, filling in functionality of the initial data correction

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_WorkFolderUtils.ipf

    r980 r981  
    1010// 
    1111// - adding RAW data to a workfile 
    12 // -- this conversion applies the detector corrections 
     12// -- **this conversion applies the detector corrections** 
    1313// 
    1414// - copying workfiles to another folder 
     
    5555//  data is actually in use - so it will fail every time. need an alternate solution. in SANS, 
    5656// there are a limited number of waves to carry over, so Dupliate/O is used for rw, tw, data, etc. 
    57 // 
    58 // 
    5957// 
    6058// TODO : I also need a list of what is generated during processing that may be hanging around - that I need to 
     
    103101                 
    104102                // everything on the top level 
    105                 V_DuplicateDataFolder($(toDF+":entry:entry"),fromStr,toStr,0,"",0)      //no recursion here 
     103                V_DuplicateDataFolder($(fromDF+":entry:entry"),fromStr,toStr,0,"",0)    //no recursion here 
    106104                // control 
    107                 V_DuplicateDataFolder($(toDF+":entry:entry:control"),fromStr,toStr,0,"",1)      //yes recursion here 
     105                V_DuplicateDataFolder($(fromDF+":entry:entry:control"),fromStr,toStr,0,"",1)    //yes recursion here 
    108106                // instrument 
    109                 V_DuplicateDataFolder($(toDF+":entry:entry:instrument"),fromStr,toStr,0,"",1)   //yes recursion here 
     107                V_DuplicateDataFolder($(fromDF+":entry:entry:instrument"),fromStr,toStr,0,"",1) //yes recursion here 
    110108                // reduction 
    111                 V_DuplicateDataFolder($(toDF+":entry:entry:reduction"),fromStr,toStr,0,"",1)    //yes recursion here 
     109                V_DuplicateDataFolder($(fromDF+":entry:entry:reduction"),fromStr,toStr,0,"",1)  //yes recursion here 
    112110                // sample 
    113                 V_DuplicateDataFolder($(toDF+":entry:entry:sample"),fromStr,toStr,0,"",1)       //yes recursion here 
     111                V_DuplicateDataFolder($(fromDF+":entry:entry:sample"),fromStr,toStr,0,"",1)     //yes recursion here 
    114112 
    115113        endif    
     
    266264 
    267265 
     266// 
    268267// given the folder, duplicate the data -> linear_data and generate the error 
     268// TODO 
     269// -- do I want to use different names here? If it turns out that I don't need to drag a copy of 
     270//    the data around as "linear_data", then I can eliminate that, and rename the error wave 
     271// -- be sure the data is either properly written as 2D in the file, or converted to 2D before 
     272//    duplicating here 
     273// -- ? do I recast to DP here. Probably necessary since I'm doing a DP calculation, but Redimension 
     274//    is done in the Raw_to_Work step too. very confusing. 
    269275Function V_MakeDataError(folderStr) 
    270276        String folderStr 
     
    287293 
    288294 
    289  
    290  
    291  
    292295///////////////////// 
    293296 
     
    299302//   line fails (but reports no error), then DuplicateDataFolder fails, and reports an error. Trying 
    300303//   to simplify this condition, I can't duplicate the error for WM... 
    301 Proc Add_to_Workfile(newtype, doadd) 
     304Macro Convert_to_Workfile(newtype, doadd) 
    302305        String newtype,doadd 
    303306        Prompt newtype,"WORK data type",popup,"SAM;EMP;BGD;ADJ;" 
     
    315318        else 
    316319                //yes, add RAW to the current work folder contents 
     320                Abort "Adding RAW data files is currently unsupported" 
    317321                err = Add_raw_to_work(newtype) 
    318322        endif 
     
    330334 
    331335// 
     336// THIS IS THE MAJOR ROUTINE TO APPLY DATA CORRECTIONS 
     337//  
    332338//will copy the current contents of the RAW folder to the newType work folder 
    333339//and do the geometric corrections and normalization to monitor counts 
    334 //(the function Add_Raw_to_work(type) adds multiple runs together) 
     340//(the function Add_Raw_to_work(type) adds multiple runs together - and is LOW priority) 
    335341// 
    336342//the current display type is updated to newType (global) 
     
    363369         
    364370        // now work with the waves from the destination folder.  
    365         Variable/G $(destPath + ":gIsLogscale")=0                       //overwite flag in newType folder, data converted (above) to linear scale 
    366 //      String/G $(destPath + ":fileList") = textread[0]                        //a list of names of the files in the work file (1)             //02JUL13 
    367371         
    368372        // apply corrections --- 
     
    373377 
    374378// each correction must loop over each detector. tedious. 
     379 
     380        // (0) Redimension the data waves in the destination folder 
     381        //     so that they are DP, not integer 
     382        // TODO 
     383        // -- currently only redimensioning the data and linear_data_error - What else??? 
     384        // 
     385        for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
     386                detStr = StringFromList(ii, ksDetectorListAll, ";") 
     387                Wave w = V_getDetectorDataW(fname,detStr) 
     388                Wave w_err = V_getDetectorDataErrW(fname,detStr) 
     389                Redimension/D w,w_err 
     390        endfor 
     391         
    375392         
    376393        // (1) DIV correction 
     
    382399                // need extra check here for file existence 
    383400                // if not in DIV folder, load. 
    384                 // if unable to load, skip correction and report error (Alert?) 
    385                 for(ii=0;ii<8;ii+=1) 
    386                         detStr = StringFromList(ii, ksDetectorListNoB, ";") 
     401                // if unable to load, skip correction and report error (Alert?) (Ask to Load?) 
     402                 
     403                for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
     404                        detStr = StringFromList(ii, ksDetectorListAll, ";") 
    387405                        Wave w = V_getDetectorDataW(fname,detStr) 
    388406                        Wave w_err = V_getDetectorDataErrW(fname,detStr) 
    389                         Wave w_dt = V_getDetector_deadtime(fname,detStr) 
    390407                        Print "Doing DIV correction for "+ detStr 
    391 //                      DIVCorrection(fill this in) 
    392                          
     408                        DIVCorrection(w,w_err,detStr,newType) 
    393409                endfor 
    394410        else 
     
    400416        // generate a distance matrix for each of the detectors 
    401417        if (gDoNonLinearCor == 1) 
    402                 for(ii=0;ii<8;ii+=1) 
    403                         detStr = StringFromList(ii, ksDetectorListNoB, ";") 
     418                for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
     419                        detStr = StringFromList(ii, ksDetectorListAll, ";") 
    404420                        Wave w = V_getDetectorDataW(fname,detStr) 
    405421                        Wave w_err = V_getDetectorDataErrW(fname,detStr) 
    406                         Wave w_dt = V_getDetector_deadtime(fname,detStr) 
     422                        Wave w_calib = V_getDetTube_spatialCalib(fname,detStr) 
    407423                        Print "Doing Non-linear correction for "+ detStr 
    408424//                      NonLinearCorrection(fill this in) 
     
    416432        NVAR gDoSolidAngleCor = root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor 
    417433        if (gDoSolidAngleCor == 1) 
    418                 for(ii=0;ii<8;ii+=1) 
    419                         detStr = StringFromList(ii, ksDetectorListNoB, ";") 
     434                for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
     435                        detStr = StringFromList(ii, ksDetectorListAll, ";") 
    420436                        Wave w = V_getDetectorDataW(fname,detStr) 
    421437                        Wave w_err = V_getDetectorDataErrW(fname,detStr) 
     
    433449        // -- test for correct operation 
    434450        // -- loop over all of the detectors 
    435         // -- B detector is a special case 
     451        // -- B detector is a special case (do separately, then loop over NoB) 
    436452        NVAR gDoDeadTimeCor = root:Packages:NIST:VSANS:Globals:gDoDeadTimeCor 
    437453        ctTime = V_getCount_time(fname) 
    438454        if (gDoDeadTimeCor == 1) 
    439                 for(ii=0;ii<8;ii+=1) 
    440                         detStr = StringFromList(ii, ksDetectorListNoB, ";") 
     455                for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
     456                        detStr = StringFromList(ii, ksDetectorListAll, ";") 
    441457                        Wave w = V_getDetectorDataW(fname,detStr) 
    442458                        Wave w_err = V_getDetectorDataErrW(fname,detStr) 
     
    472488        NVAR gDoTrans = root:Packages:NIST:VSANS:Globals:gDoTransmissionCor 
    473489        if (gDoTrans == 1) 
    474                 for(ii=0;ii<8;ii+=1) 
    475                         detStr = StringFromList(ii, ksDetectorListNoB, ";") 
     490                for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
     491                        detStr = StringFromList(ii, ksDetectorListAll, ";") 
    476492                        Wave w = V_getDetectorDataW(fname,detStr) 
    477493                        Wave w_err = V_getDetectorDataErrW(fname,detStr) 
     
    490506        // TODO -- what do I really need to save? 
    491507        defmon=1e8                      //default monitor counts 
    492         for(ii=0;ii<8;ii+=1) 
    493                 detStr = StringFromList(ii, ksDetectorListNoB, ";") 
     508        for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
     509                detStr = StringFromList(ii, ksDetectorListAll, ";") 
    494510                Wave w = V_getDetectorDataW(fname,detStr) 
    495511                Wave w_err = V_getDetectorDataErrW(fname,detStr) 
     
    498514//                      MonitorNormalization(fill this in) 
    499515        //scale the data to the default montor counts 
    500                 scale = defmon/monCt 
    501                 w *= scale 
    502                 w_err *= scale          //assumes total monitor count is so large there is essentially no error 
    503                  
     516         
     517        // TODO -- un-comment these three lines once monitor counts are reasonable - currently monCt = 9!!! 
     518//              scale = defmon/monCt 
     519//              w *= scale 
     520//              w_err *= scale          //assumes total monitor count is so large there is essentially no error 
     521 
     522// TODO 
     523// -- to write back to the local value, get the wave reference rather than the value, then I can  
     524//    re-assign the value directly, rather than this method (which is not terrible)      
    504525                // V_getBeamMonNormSaved_count() 
    505526                // save the true monitor counts? save the scaling factor? 
     
    537558//       
    538559        //reset the current displaytype to "newtype" 
    539         String/G root:myGlobals:gDataDisplayType=newType 
     560        String/G root:Packages:NIST:VSANS:Globals:gCurDispType=newType 
    540561         
    541562        //return to root folder (redundant) 
Note: See TracChangeset for help on using the changeset viewer.