Ignore:
Timestamp:
Mar 13, 2017 1:39:33 PM (6 years ago)
Author:
srkline
Message:

adding to the functionality of the data reduction protocol

getting the 1D plotting to work both as a standalone plot and part of the reduction protocol (where the choices are all made and fed in)

added log/lin toggle to 1D display. abc exponent scaling is fundamentally more messy, and has been shelved for now. Revisit if demand is there.

fixed bug in how raw data files are identified, to prevent .abs files from being incorrectly identified as raw (if same name before extension). Works correctly now, but may need tweak in future if naming scheme changes.

File:
1 edited

Legend:

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

    r1024 r1027  
    891891// 
    892892//test procedure, not called anymore 
    893 Proc V_AbsoluteScaling(type,c0,c1,c2,c3,c4,c5) 
     893Proc V_AbsoluteScaling(type,c0,c1,c2,c3,c4,c5,I_err) 
    894894        String type 
    895         Variable c0=1,c1=0.1,c2=0.95,c3=0.1,c4=1,c5=32.0 
     895        Variable c0=1,c1=0.1,c2=0.95,c3=0.1,c4=1,c5=32.0,I_err=0.32 
    896896        Prompt type,"WORK data type",popup,"CAL;COR;SAM" 
    897897        Prompt c0, "Sample Transmission" 
     
    901901        Prompt c4, "I(0) from standard fit (normalized to 1E8 monitor cts)" 
    902902        Prompt c5, "Standard Cross-Section (cm-1)" 
     903        Prompt I_err, "error in I(q=0) (one std dev)" 
    903904 
    904905        Variable err 
    905906        //call the function to do the math 
    906907        //data from "type" will be scaled and deposited in ABS 
    907         err = V_Absolute_Scale(type,c0,c1,c2,c3,c4,c5) 
     908        err = V_Absolute_Scale(type,c0,c1,c2,c3,c4,c5,I_err) 
    908909         
    909910        if(err) 
    910                 Abort "Error in Absolute_Scale()" 
     911                Abort "Error in V_Absolute_Scale()" 
    911912        endif 
    912913         
    913914        //contents are always dumped to ABS 
    914915        type = "ABS" 
    915          
    916         String newTitle = "WORK_"+type 
    917         DoWindow/F SANS_Data 
    918         DoWindow/T SANS_Data, newTitle 
    919         KillStrings/Z newTitle 
    920916         
    921917        //need to update the display with "data" from the correct dataFolder 
     
    924920        gCurDispType = Type      
    925921         
    926         V_fRawWindowHook() 
     922        V_UpdateDisplayInformation(Type) 
    927923         
    928924End 
     
    930926// 
    931927// TODO: 
    932 //   --         DoAlert 0,"This has not yet been updated for VSANS" 
    933 // 
     928// 
     929// kappa comes in as s_izero, so be sure to use 1/kappa_err 
     930// 
     931//convert the "type" data to absolute scale using the given standard information 
    934932//s_ is the standard 
    935933//w_ is the "work" file 
     
    939937        Variable w_trans,w_thick,s_trans,s_thick,s_izero,s_cross,kappa_err 
    940938 
    941         DoAlert 0,"This has not yet been updated for VSANS" 
     939 
     940        Variable defmon = 1e8,w_moncount,s1,s2,s3,s4 
     941        Variable scale,trans_err 
     942        Variable err,ii 
     943        String detStr 
     944         
     945        // be sure that the starting data exists 
     946        err = V_WorkDataExists(type) 
     947        if(err==1) 
     948                return(err) 
     949        endif 
    942950                 
    943         //convert the "type" data to absolute scale using the given standard information 
    944         //copying the "type" waves to ABS 
    945          
    946         //check for existence of data, rescale to linear if needed 
    947         String destPath 
    948         //check for "type" 
    949         if(WaveExists($("root:Packages:NIST:"+Type + ":data")) == 0) 
    950                 Print "There is no work file in "+type+"--Aborting" 
    951                 Return(1)               //error condition 
    952         Endif 
    953         //check for log-scaling of the "type" data and adjust if necessary 
    954         destPath = "root:Packages:NIST:"+Type 
    955         NVAR gIsLogScale = $(destPath + ":gIsLogScale") 
    956         if(gIsLogScale) 
    957                 Duplicate/O $(destPath + ":linear_data") $(destPath + ":data")//back to linear scale 
    958                 Variable/G $(destPath + ":gIsLogScale")=0       //the "type" data is not logscale anymore 
    959         endif 
    960          
    961         //copy "oldtype" information to ABS 
    962         //overwriting out the old contents of the ABS folder (/O option in Duplicate) 
    963         //copy over the waves data,vlegend,text,integers,reals(read) 
    964  
    965         String oldType= "root:Packages:NIST:"+type              //this is where the data to be absoluted is  
    966         //copy from current dir (type) to ABS, defined by destPath 
    967         Duplicate/O $(oldType + ":data"),$"root:Packages:NIST:ABS:data" 
    968         Duplicate/O $(oldType + ":linear_data"),$"root:Packages:NIST:ABS:linear_data" 
    969         Duplicate/O $(oldType + ":linear_data_error"),$"root:Packages:NIST:ABS:linear_data_error" 
    970 //      Duplicate/O $(oldType + ":vlegend"),$"root:Packages:NIST:ABS:vlegend" 
    971         Duplicate/O $(oldType + ":textread"),$"root:Packages:NIST:ABS:textread" 
    972         Duplicate/O $(oldType + ":integersread"),$"root:Packages:NIST:ABS:integersread" 
    973         Duplicate/O $(oldType + ":realsread"),$"root:Packages:NIST:ABS:realsread" 
    974         //need to save a copy of filelist string too (from the current type folder) 
    975         SVAR oldFileList = $(oldType + ":fileList") 
    976         //need to copy filelist string too 
    977         String/G $"root:Packages:NIST:ABS:fileList" = oldFileList 
    978          
    979         //now switch to ABS folder 
    980         //make appropriate wave references 
    981         WAVE data=$"root:Packages:NIST:ABS:linear_data"                                 // these wave references point to the "type" data in ABS 
    982         WAVE data_err=$"root:Packages:NIST:ABS:linear_data_error"                                       // these wave references point to the "type" data in ABS 
    983         WAVE data_copy=$"root:Packages:NIST:ABS:data"                                   // just for display 
    984         WAVE/T textread=$"root:Packages:NIST:ABS:textread"                      //that are to be directly operated on 
    985         WAVE integersread=$"root:Packages:NIST:ABS:integersread" 
    986         WAVE realsread=$"root:Packages:NIST:ABS:realsread" 
    987         Variable/G $"root:Packages:NIST:ABS:gIsLogscale"=0                      //make new flag in ABS folder, data is linear scale 
    988          
    989         //do the actual absolute scaling here, modifying the data in ABS 
    990         Variable defmon = 1e8,w_moncount,s1,s2,s3,s4 
    991          
    992         w_moncount = realsread[0]               //monitor count in "type" 
     951        //copy from current dir (type) to ABS 
     952        V_CopyHDFToWorkFolder(type,"ABS")        
     953 
     954         
     955        w_moncount = V_getMonitorCount(type)            //monitor count in "type" 
    993956        if(w_moncount == 0) 
    994957                //zero monitor counts will give divide by zero --- 
     
    998961         
    999962        //calculate scale factor 
    1000         Variable scale,trans_err 
    1001         s1 = defmon/realsread[0]                //[0] is monitor count (s1 should be 1) 
     963        s1 = defmon/w_moncount          // monitor count (s1 should be 1) 
    1002964        s2 = s_thick/w_thick 
    1003965        s3 = s_trans/w_trans 
    1004966        s4 = s_cross/s_izero 
     967        scale = s1*s2*s3*s4 
     968 
     969        trans_err = V_getSampleTransError(type)  
    1005970         
    1006971        // kappa comes in as s_izero, so be sure to use 1/kappa_err 
    1007          
    1008         data *= s1*s2*s3*s4 
    1009          
    1010         scale = s1*s2*s3*s4 
    1011         trans_err = realsRead[41] 
    1012          
    1013 //      print scale 
    1014 //      print data[0][0] 
    1015          
    1016         data_err = sqrt(scale^2*data_err^2 + scale^2*data^2*(kappa_err^2/s_izero^2 +trans_err^2/w_trans^2)) 
    1017  
    1018 //      print data_err[0][0] 
    1019          
    1020 // keep "data" in sync with linear_data  
    1021         data_copy = data 
     972 
     973        // and now loop through all of the detectors 
     974        //do the actual absolute scaling here, modifying the data in ABS 
     975        for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
     976                detStr = StringFromList(ii, ksDetectorListAll, ";") 
     977                Wave data = V_getDetectorDataW("ABS",detStr) 
     978                Wave data_err = V_getDetectorDataErrW("ABS",detStr) 
     979                 
     980                data *= s1*s2*s3*s4 
     981                data_err = sqrt(scale^2*data_err^2 + scale^2*data^2*(kappa_err^2/s_izero^2 +trans_err^2/w_trans^2)) 
     982        endfor 
    1022983         
    1023984        //********* 15APR02 
    1024         // DO NOt correct for atenuators here - the COR step already does this, putting all of the data one equal 
     985        // DO NOT correct for atenuators here - the COR step already does this, putting all of the data one equal 
    1025986        // footing (zero atten) before doing the subtraction. 
    1026         // 
    1027         //Print "ABS data multiplied by  ",s1*s2*s3*s4/attenFactor 
    1028          
    1029         //update the ABS header information 
    1030         textread[1] = date() + " " + time()             //date + time stamp 
    1031987         
    1032988        Return (0) //no error 
Note: See TracChangeset for help on using the changeset viewer.