Ignore:
Timestamp:
May 20, 2016 4:28:56 PM (7 years ago)
Author:
srkline
Message:

changes to a few analysis models to make these Igor 7-ready

adding mask editing utilities

many changes to event mode for easier processing of split lists

updated event mode help file

+ lots more!

Location:
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS
Files:
1 added
13 edited

Legend:

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

    r993 r999  
    238238                        newX = data_realDistX[xCtr][0] 
    239239                        newY = data_realDistY[0][yCtr] 
     240                        //newX = xCtr 
     241                        //newY = yCtr 
    240242                endif            
    241243                                 
     
    668670//    a blanket correction (matrix multiply) for an entire panel? 
    669671// 
     672// 
     673// 
    670674// folderStr = WORK folder, type = the binning type (may include multiple detectors) 
    671675Function VC_fDoBinning_QxQy2D(folderStr,type) 
     
    690694// 
    691695 
     696// TODO: 
     697// -- Solid_Angle -- waves will be present for WORK data other than RAW, but not for RAW 
     698// 
    692699// assume that the mask files are missing unless we can find them. If VCALC data,  
    693700//  then the Mask is missing by definition 
     
    986993 
    987994//TODO: properly define the errors here - I'll have this if I do the simulation 
     995// -- need to propagate the errors up to this point 
     996// 
    988997        if(WaveExists(iErr)==0  && WaveExists(inten) != 0) 
    989998                Duplicate/O inten,iErr 
     
    10551064// 
    10561065// this needs to be a double loop now... 
     1066// TODO: 
     1067// -- the iErr wave and accumulation of error is NOT CALCULATED CORRECTLY YET 
     1068// -- the solid angle per pixel is not yet implemented. 
     1069//    it will be present for WORK data other than RAW, but not for RAW 
    10571070 
    10581071// if any of the masks don't exist, display the error, and proceed with the averaging, using all data 
     
    10741087                                val = inten[ii][jj] 
    10751088                                 
    1076                                 if(isVCALC || maskMissing)              // mask_val == 1 == keep 
    1077                                         mask_val = 1 
     1089                                if(isVCALC || maskMissing)              // mask_val == 0 == keep, mask_val == 1 = YES, mask out the point 
     1090                                        mask_val = 0 
    10781091                                else 
    10791092                                        mask_val = mask[ii][jj] 
    10801093                                endif 
    1081                                 if (numType(val)==0 && mask_val == 1)           //count only the good points, ignore Nan or Inf 
     1094                                if (numType(val)==0 && mask_val == 0)           //count only the good points, ignore Nan or Inf 
    10821095                                        iBin_qxqy[binIndex] += val 
    10831096                                        iBin2_qxqy[binIndex] += val*val 
     
    11031116                                 
    11041117                                if(isVCALC || maskMissing) 
    1105                                         mask_val = 1 
     1118                                        mask_val = 0 
    11061119                                else 
    11071120                                        mask_val = mask2[ii][jj] 
    11081121                                endif 
    1109                                 if (numType(val)==0 && mask_val == 1)           //count only the good points, ignore Nan or Inf 
     1122                                if (numType(val)==0 && mask_val == 0)           //count only the good points, ignore Nan or Inf 
    11101123                                        iBin_qxqy[binIndex] += val 
    11111124                                        iBin2_qxqy[binIndex] += val*val 
     
    11311144                                 
    11321145                                if(isVCALC || maskMissing) 
    1133                                         mask_val = 1 
     1146                                        mask_val = 0 
    11341147                                else 
    11351148                                        mask_val = mask3[ii][jj] 
    11361149                                endif 
    1137                                 if (numType(val)==0 && mask_val == 1)           //count only the good points, ignore Nan or Inf 
     1150                                if (numType(val)==0 && mask_val == 0)           //count only the good points, ignore Nan or Inf 
    11381151                                        iBin_qxqy[binIndex] += val 
    11391152                                        iBin2_qxqy[binIndex] += val*val 
     
    11561169                                 
    11571170                                if(isVCALC || maskMissing) 
    1158                                         mask_val = 1 
     1171                                        mask_val = 0 
    11591172                                else 
    11601173                                        mask_val = mask4[ii][jj] 
    11611174                                endif 
    1162                                 if (numType(val)==0 && mask_val == 1)           //count only the good points, ignore Nan or Inf 
     1175                                if (numType(val)==0 && mask_val == 0)           //count only the good points, ignore Nan or Inf 
    11631176                                        iBin_qxqy[binIndex] += val 
    11641177                                        iBin2_qxqy[binIndex] += val*val 
     
    11741187// after looping through all of the data on the panels, calculate errors on I(q), 
    11751188// just like in CircSectAve.ipf 
     1189// TODO: 
     1190// -- Errors were NOT properly acculumated above, so this loop of calculations is NOT MEANINGFUL (yet) 
    11761191        for(ii=0;ii<nq;ii+=1) 
    11771192                if(nBin_qxqy[ii] == 0) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_HDF5_VSANS_Utils.ipf

    r994 r999  
    302302 
    303303 
    304 ////////////////////// MASK FILE 
    305  
    306  
    307 // TODO 
    308 // currently, there are no dummy fill values or attributes for the fake MASK file 
    309 // 
    310 Proc Setup_VSANS_MASK_Struct() 
    311  
    312         // lays out the tree and fills with dummy values 
    313         H_Setup_VSANS_MASK_Structure() 
    314          
    315         // writes in the attributes 
    316 //      H_Fill_VSANS_Attributes() 
    317          
    318         // fill in with VCALC simulation bits 
    319 //      H_Fill_VSANS_wSim() 
    320          
    321 End 
    322  
    323 Proc Save_VSANS_MASK_Nexus(fileName) 
    324         String fileName="Test_VSANS_MASK_file" 
    325  
    326         // save as HDF5 (no attributes saved yet) 
    327         Save_VSANS_file("root:VSANS_MASK_file", fileName+".h5") 
    328          
    329         // read in a data file using the gateway-- reads from the home path 
    330         H_HDF5Gate_Read_Raw(fileName+".h5") 
    331          
    332         // after reading in a "partial" file using the gateway (to generate the xref) 
    333         // Save the xref to disk (for later use) 
    334         Save_HDF5___xref("root:"+fileName,"HDF5___xref") 
    335          
    336         // after you've generated the HDF5___xref, load it in and copy it 
    337         // to the necessary folder location. 
    338         Copy_HDF5___xref("root:VSANS_MASK_file", "HDF5___xref") 
    339          
    340         // writes out the contents of a data folder using the gateway 
    341         H_HDF5Gate_Write_Raw("root:VSANS_MASK_file", fileName+".h5") 
    342  
    343         // re-load the data file using the gateway-- reads from the home path 
    344         // now with attributes 
    345         H_HDF5Gate_Read_Raw(fileName+".h5") 
    346          
    347 End 
    348  
    349 ////////////// fake MASK file tests 
    350 // 
    351 // 
    352 //      Make/O/T/N=1    file_name       = "VSANS_MASK_test.h5" 
    353 // 
    354 // simple generation of a fake MASK file. for sans, nothing other than the creation date was written to the  
    355 // file header. nothing more is needed (possibly) 
    356 // 
    357 // 
    358 // TODO -- make the number of pixels GLOBAL 
    359 // TODO -- there will be lots of work to do to develop the procedures necessary to actually generate the  
    360 //      9 data sets to become the MASK file contents. More complexity here than for the simple SANS case. 
    361 // 
    362 // TODO -- this is currently random 0|1 values, need to write an editor 
    363 // 
    364 // currently set up to use 0 = exclude and 1 = keep  
    365 // 
    366 Proc H_Setup_VSANS_MASK_Structure() 
    367          
    368         NewDataFolder/O/S root:VSANS_MASK_file           
    369  
    370         NewDataFolder/O/S root:VSANS_MASK_file:entry     
    371                 Make/O/T/N=1    title   = "This is a fake MASK file for VSANS" 
    372                 Make/O/T/N=1    start_date      = "2015-02-28T08:15:30-5:00" 
    373                 NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument          
    374                         Make/O/T/N=1    name    = "NG3_VSANS" 
    375                 NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_B       
    376                         Make/O/I/N=(150,150)    data    = 1 
    377                 NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_MR              
    378                         Make/O/I/N=(48,128)     data    = 1 
    379                 NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_ML              
    380                         Make/O/I/N=(48,128)     data    = 1 
    381                 NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_MT              
    382                         Make/O/I/N=(128,48)     data    = 1 
    383                         data[0,49][] = 0 
    384                         data[78,127][] = 0 
    385                         data[50,77][] = 1 
    386                          
    387                 NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_MB              
    388                         Make/O/I/N=(128,48)     data    = 1 
    389                         data[0,49][] = 0 
    390                         data[78,127][] = 0 
    391                         data[50,77][] = 1 
    392                          
    393                 NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_FR              
    394                         Make/O/I/N=(48,128)     data    = 1 
    395                 NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_FL              
    396                         Make/O/I/N=(48,128)     data    = 1 
    397                 NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_FT              
    398                         Make/O/I/N=(128,48)     data    = 1 
    399                         data[0,49][] = 0 
    400                         data[78,127][] = 0 
    401                         data[50,77][] = 1 
    402  
    403                 NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_FB              
    404                         Make/O/I/N=(128,48)     data    = 1 
    405                         data[0,49][] = 0 
    406                         data[78,127][] = 0 
    407                         data[50,77][] = 1 
    408                          
    409         SetDataFolder root: 
    410  
    411 End 
     304 
     305 
    412306 
    413307 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_VCALCPanel_MockUp.ipf

    r993 r999  
    647647        NewDataFolder/O root:Packages:NIST:VSANS 
    648648        NewDataFolder/O root:Packages:NIST:VSANS:VCALC 
    649                 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry 
    650                 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry 
    651                 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument 
    652                 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_B 
    653                 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MB 
    654                 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MT 
    655                 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_ML 
    656                 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MR 
    657                 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FB 
    658                 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FT 
    659                 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FL 
    660                 NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FR 
     649        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry 
     650        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry 
     651        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument 
     652        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_B 
     653        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MB 
     654        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MT 
     655        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_ML 
     656        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MR 
     657        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FB 
     658        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FT 
     659        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FL 
     660        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FR 
    661661 
    662662//      NewDataFolder/O root:Packages:NIST:VSANS:VCALC:Front 
     
    808808        Variable/G gBack_h = 150 
    809809         
    810         Make/O/D/N=1 :entry:instrument:detector_B:x_pixel_size = 0.1            // 1mm resolution (units of cm here) 
     810        Make/O/D/N=1 :entry:instrument:detector_B:x_pixel_size = 0.1            // 1 mm resolution (units of cm here) 
    811811        Make/O/D/N=1 :entry:instrument:detector_B:y_pixel_size = 0.1             
    812812//      Variable/G gBack_pixelX = 0.1            
     
    873873        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_B 
    874874        Duplicate/O det_B qTot_B,qx_B,qy_B,qz_B 
    875  
    876  
    877875 
    878876 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VSANS_Includes.ipf

    r993 r999  
    5959#include "V_Testing_Data_Procs" 
    6060 
     61// mask files 
     62#include "V_MaskUtils" 
     63 
     64 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DataPlotting.ipf

    r995 r999  
    5959End 
    6060 
    61  
    62  
    63 // 
    64 // see the VCALC BinAllMiddlePanels() for an example of this 
    65 // 
    66 // TODO  
    67 // x- detector "B" is currently skipped since the calibration waves are not faked 
    68 //    when the raw data is loaded. Then the qxqyqz waves are not generated. 
    69 // 
    70 // -- REDO the logic here. It's a mess, and will get the calculation wrong  
    71 // 
    72 // -- figure out the binning type (where is it set?) 
    73 // -- binning type is HARD-WIRED 
    74 // -- figure out when this is to be called to re-calculate the I vs Q 
    75 // 
    76 Function V_QBinAllPanels(folderStr) 
    77         String folderStr 
    78  
    79         // do the back, middle, and front separately 
    80          
    81 //      figure out the binning type (where is it set?) 
    82         Variable binType,ii,delQ 
    83         String detStr 
    84         binType = 1 
    85          
    86          
    87  
    88 //// TODO: 
    89 // x- currently the "B" detector is skipped - it was skipped in  
    90 //       previous functions where q values are calculated        
    91 //       
    92         delQ = SetDeltaQ(folderStr,"B") 
    93          
    94         // dispatch based on binning type 
    95         if(binType == 1) 
    96                 VC_fDoBinning_QxQy2D(folderStr, "B")            //normal binning, nothing to combine 
    97         endif 
    98  
    99 // TODO -- this is only a temporary fix for slit mode    
    100         if(binType == 4) 
    101                 /// this is for a tall, narrow slit mode         
    102                 VC_fBinDetector_byRows(folderStr,"B") 
    103         endif    
    104  
    105 // these are the binning types where detectors are not combined 
    106 // other combined binning is below the loop 
    107         for(ii=0;ii<ItemsInList(ksDetectorListNoB);ii+=1) 
    108                 detStr = StringFromList(ii, ksDetectorListNoB, ";") 
    109                  
    110                 // set delta Q for binning 
    111                 delQ = SetDeltaQ(folderStr,detStr) 
    112                  
    113                 // dispatch based on binning type 
    114                 if(binType==1) 
    115                         VC_fDoBinning_QxQy2D(folderStr,detStr) 
    116                 endif 
    117                  
    118                 // TODO -- this is only a temporary fix for slit mode    
    119                 if(binType == 4) 
    120                         /// this is for a tall, narrow slit mode         
    121                         VC_fBinDetector_byRows(folderStr,detStr) 
    122                 endif    
    123                  
    124         endfor 
    125          
    126         // bin in pairs 
    127         if(binType == 2) 
    128                 VC_fDoBinning_QxQy2D(folderStr,"MLR") 
    129                 VC_fDoBinning_QxQy2D(folderStr,"MTB") 
    130                 VC_fDoBinning_QxQy2D(folderStr,"FLR") 
    131                 VC_fDoBinning_QxQy2D(folderStr,"FTB")    
    132         endif 
    133          
    134         // bin everything on front or middle together 
    135         if(binType == 3) 
    136                 VC_fDoBinning_QxQy2D(folderStr,"MLRTB") 
    137                 VC_fDoBinning_QxQy2D(folderStr,"FLRTB") 
    138         endif 
    139  
    140         return(0) 
    141 End 
    14261 
    14362 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DetectorCorrections.ipf

    r995 r999  
    370370                if(cmpstr(orientation,"vertical")==0) 
    371371                //      this is vertical tube data dimensioned as (Ntubes,Npix) 
    372                         pixSize = 8                     //V_getDet_y_pixel_size(fname,detStr) 
     372                        pixSize = 8.4           //V_getDet_y_pixel_size(fname,detStr) 
    373373                         
    374374                elseif(cmpstr(orientation,"horizontal")==0) 
     
    396396 
    397397// 
     398// TODO: 
     399// -- MUST VERIFY the definition of SDD and how (if) setback is written to the data files 
     400// -- currently I'm assuming that the SDD is the "nominal" value which is correct for the  
     401//    L/R panels, but is not correct for the T/B panels (must add in the setback) 
     402// 
     403// 
     404// 
    398405// data_realDistX, Y must be previously generated from running NonLinearCorrection() 
    399406// 
     
    411418// get all of the geometry information   
    412419        orientation = V_getDet_tubeOrientation(fname,detStr) 
    413         sdd = V_getDet_distance(fname,detStr) 
     420//      sdd = V_getDet_distance(fname,detStr)           //[cm] 
     421//      sdd += V_getDet_TBSetback(fname,detStr)/10              // written in [mm], convert to [cm], returns 0 for L/R/B panels 
     422 
     423        sdd = V_getDet_ActualDistance(fname,detStr)             //sdd derived, including setback [cm] 
    414424        sdd/=100                // sdd reported in cm, pass in m 
    415425        // this is the ctr in pixels 
     
    552562//    to each pixel 
    553563// 
    554 // not actually used for anything, but here for completeness if anyone asks 
     564// not actually used for any calculations, but here for completeness if anyone asks, or for 2D data export 
    555565// 
    556566// this properly accounts for qz 
     
    579589End 
    580590 
     591 
     592// 
     593// TODO -- VERIFY calculations 
     594// -- This is the actual solid angle per pixel, not a ratio vs. some "unit SA"  
     595//    Do I just correct for the different area vs. the "nominal" central area? 
     596// -- decide how to implement - either directly change the data values (as was done in the past) 
     597//    or use this as a weighting for when the data is binned to I(q). In the second method, 2D data 
     598//    would need this to be applied before exporting 
     599// -- do I keep a wave note indicating that this correction has been applied to the data 
     600//    so that it can be "un-applied"? 
     601// -- do I calculate theta from geometry directly, or get it from Q (Assuming it's present?) 
     602//    (probably just from geometry, since I need SDD and dx and dy values...) 
     603// 
     604// 
     605Function SolidAngleCorrection(w,w_err,fname,detStr,destPath) 
     606        Wave w,w_err 
     607        String fname,detStr,destPath 
     608 
     609        Variable sdd,xCtr,yCtr,lambda 
     610 
     611// get all of the geometry information   
     612//      orientation = V_getDet_tubeOrientation(fname,detStr) 
     613        sdd = V_getDet_ActualDistance(fname,detStr) 
     614        sdd/=100                // sdd in cm, pass in m 
     615 
     616        // this is ctr in mm 
     617        xCtr = V_getDet_beam_center_x_mm(fname,detStr) 
     618        yCtr = V_getDet_beam_center_y_mm(fname,detStr) 
     619        lambda = V_getWavelength(fname) 
     620         
     621        SetDataFolder $(destPath + ":entry:instrument:detector_"+detStr) 
     622         
     623        Wave data_realDistX = data_realDistX 
     624        Wave data_realDistY = data_realDistY 
     625 
     626        Duplicate/O w solid_angle,tmp_theta,tmp_dist            //in the current df 
     627 
     628//// calculate the scattering angle 
     629//      dx = (distX - xctr)             //delta x in mm 
     630//      dy = (distY - yctr)             //delta y in mm 
     631        tmp_dist = sqrt((data_realDistX - xctr)^2 + (data_realDistY - yctr)^2) 
     632         
     633        tmp_dist /= 10  // convert mm to cm 
     634        sdd *=100               //convert to cm 
     635 
     636        tmp_theta = atan(tmp_dist/sdd)          //this is two_theta, the scattering angle 
     637 
     638        Variable ii,jj,numx,numy,dx,dy 
     639        numx = DimSize(tmp_theta,0) 
     640        numy = DimSize(tmp_theta,1) 
     641         
     642        for(ii=0        ;ii<numx;ii+=1) 
     643                for(jj=0;jj<numy;jj+=1) 
     644                         
     645                        if(ii==0)               //do a forward difference if ii==0 
     646                                dx = (data_realDistX[ii+1][jj] - data_realDistX[ii][jj])        //delta x for the pixel 
     647                        else 
     648                                dx = (data_realDistX[ii][jj] - data_realDistX[ii-1][jj])        //delta x for the pixel 
     649                        endif 
     650                         
     651                         
     652                        if(jj==0) 
     653                                dy = (data_realDistY[ii][jj+1] - data_realDistY[ii][jj])        //delta y for the pixel 
     654                        else 
     655                                dy = (data_realDistY[ii][jj] - data_realDistY[ii][jj-1])        //delta y for the pixel 
     656                        endif 
     657         
     658                        dx /= 10 
     659                        dy /= 10                // convert mm to cm (since sdd is in cm) 
     660                        solid_angle[ii][jj] = dx*dy             //this is in cm^2 
     661                endfor 
     662        endfor 
     663         
     664        // to cover up any issues w/negative dx or dy 
     665        solid_angle = abs(solid_angle) 
     666         
     667        // solid_angle correction 
     668        // == dx*dy*cos^3/sdd^2 
     669        solid_angle *= (cos(tmp_theta))^3 
     670        solid_angle /= sdd^2 
     671         
     672        // Here it is! Apply the correction to the intensity (I divide -- to get the counts per solid angle!!) 
     673        w /= solid_angle 
     674         
     675         
     676        // TODO: 
     677        // correctly apply the correction to the error wave (assume a perfect value?) 
     678        // w_err /= solid_angle         //is this correct?? 
     679 
     680// TODO -- clean up after I'm satisfied computations are correct                 
     681//      KillWaves/Z tmp_theta,tmp_dist 
     682         
     683        return(0) 
     684end 
    581685 
    582686 
     
    668772                        // so divide here to get the correct answer (5/22/08 SRK) 
    669773                        if(doEfficiency) 
    670                                 data[ii][jj] /= DetEffCorr(lambda,dtdist,xd,yd) 
    671                                 data_err[ii][jj] /= DetEffCorr(lambda,dtdist,xd,yd) 
     774//                              data[ii][jj] /= DetEffCorr(lambda,dtdist,xd,yd) 
     775//                              data_err[ii][jj] /= DetEffCorr(lambda,dtdist,xd,yd) 
    672776//                              solidAngle[ii][jj] /= DetEffCorr(lambda,dtdist,xd,yd)           //testing only 
    673777                        endif 
     
    718822 
    719823 
    720 //distances passed in are in mm 
    721 // dtdist is SDD 
    722 // xd and yd are distances from the beam center to the current pixel 
    723 // 
    724 // TODO: 
    725 //   --         DoAlert 0,"This has not yet been updated for VSANS" 
    726 // 
    727 Function DetEffCorr(lambda,dtdist,xd,yd) 
    728         Variable lambda,dtdist,xd,yd 
    729  
    730         DoAlert 0,"This has not yet been updated for VSANS" 
    731          
    732         Variable theta,cosT,ff,stAl,stHe 
    733          
    734         theta = atan( (sqrt(xd^2 + yd^2))/dtdist ) 
    735         cosT = cos(theta) 
    736          
    737         stAl = 0.00967*lambda*0.8               //dimensionless, constants from JGB memo 
    738         stHe = 0.146*lambda*2.5 
    739          
    740         ff = exp(-stAl/cosT)*(1-exp(-stHe/cosT)) / ( exp(-stAl)*(1-exp(-stHe)) ) 
    741                  
    742         return(ff) 
    743 End 
    744824 
    745825// DIVIDE the intensity by this correction to get the right answer 
     
    10311111         
    10321112        Variable err 
    1033         err = DIVCorrection(type)               //returns err = 1 if data doesn't exist in specified folders 
     1113        err = V_DIVCorrection(type)             //returns err = 1 if data doesn't exist in specified folders 
    10341114         
    10351115        if(err) 
    1036                 Abort "error in DIVCorrection()" 
     1116                Abort "error in V_DIVCorrection()" 
    10371117        endif 
    10381118         
     
    10561136// TODO: 
    10571137//   --         DoAlert 0,"This has not yet been updated for VSANS" 
    1058 //  -- how is the error propagation handled? 
     1138//   -- how is the error propagation handled? 
    10591139// 
    10601140//function will divide the contents of "workType" folder with the contents of  
     
    10621142// all data is linear scale for the calculation 
    10631143// 
    1064 Function DIVCorrection(data,data_err,detStr,workType) 
     1144Function V_DIVCorrection(data,data_err,detStr,workType) 
    10651145        Wave data,data_err 
    10661146        String detStr,workType 
     
    10711151 
    10721152        if(WaveExists(data) == 0) 
    1073                 Print "The data wave does not exist in DIVCorrection()" 
     1153                Print "The data wave does not exist in V_DIVCorrection()" 
    10741154                Return(1)               //error condition 
    10751155        Endif 
     
    10801160        WAVE/Z div_data = $("root:Packages:NIST:VSANS:DIV:entry:instrument:detector_"+detStr+":data") 
    10811161        if(WaveExists(div_data) == 0) 
    1082                 Print "The DIV wave does not exist in DIVCorrection()" 
     1162                Print "The DIV wave does not exist in V_DIVCorrection()" 
    10831163                Return(1)               //error condition 
    10841164        Endif 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Read.ipf

    r994 r999  
    13851385End 
    13861386 
    1387 Function V_getDet_distance(fname,detStr) 
     1387Function V_getDet_NominalDistance(fname,detStr) 
    13881388        String fname,detStr 
    13891389 
    13901390        String path = "entry:instrument:detector_"+detStr+":distance" 
    13911391        return(V_getRealValueFromHDF5(fname,path)) 
     1392End 
     1393 
     1394//this is a DERIVED distance, since the nominal sdd is for the carriage (=LR panels) 
     1395Function V_getDet_ActualDistance(fname,detStr) 
     1396        String fname,detStr 
     1397 
     1398        Variable sdd 
     1399        sdd = V_getDet_NominalDistance(fname,detStr)            //[cm] 
     1400        sdd += V_getDet_TBSetback(fname,detStr)/10              // written in [mm], convert to [cm], returns 0 for L/R/B panels 
     1401                 
     1402        return(sdd) 
    13921403End 
    13931404 
     
    14261437End 
    14271438 
    1428 // TODO - be sure this is defined correctly 
     1439// TODO - be sure this is defined correctly (with correct units!) 
    14291440// -- only returns for T/B detectors 
    14301441Function V_getDet_TBSetback(fname,detStr) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_IQ_Utilities.ipf

    r984 r999  
    1010// -- fill in all of the details... 
    1111// 
     12 
     13 
     14// 
     15// see the VCALC BinAllMiddlePanels() for an example of this 
     16// see the binning routines in VC_DetectorBinning_Utils.ipf for the details 
     17// 
     18// TODO  
     19// x- detector "B" is currently skipped since the calibration waves are not faked 
     20//    when the raw data is loaded. Then the qxqyqz waves are not generated. 
     21// 
     22// -- REDO the logic here. It's a mess, and will get the calculation wrong  
     23// 
     24// -- figure out the binning type (where is it set for VSANS?) 
     25// -- don't know, so currently VSANS binning type is HARD-WIRED 
     26// -- figure out when this needs to be called to (force) re-calculate I vs Q 
     27// 
     28Function V_QBinAllPanels(folderStr) 
     29        String folderStr 
     30 
     31        // do the back, middle, and front separately 
     32         
     33//      figure out the binning type (where is it set?) 
     34        Variable binType,ii,delQ 
     35        String detStr 
     36        binType = 1 
     37         
     38         
     39 
     40//// TODO: 
     41// x- currently the "B" detector is skipped - it was skipped in  
     42//       previous functions where q values are calculated        
     43//       
     44        delQ = SetDeltaQ(folderStr,"B") 
     45         
     46        // dispatch based on binning type 
     47        if(binType == 1) 
     48                VC_fDoBinning_QxQy2D(folderStr, "B")            //normal binning, nothing to combine 
     49        endif 
     50 
     51// TODO -- this is only a temporary fix for slit mode    
     52        if(binType == 4) 
     53                /// this is for a tall, narrow slit mode         
     54                VC_fBinDetector_byRows(folderStr,"B") 
     55        endif    
     56 
     57 
     58 
     59// these are the binning types where detectors are not combined 
     60// other combined binning is below the loop 
     61        for(ii=0;ii<ItemsInList(ksDetectorListNoB);ii+=1) 
     62                detStr = StringFromList(ii, ksDetectorListNoB, ";") 
     63                 
     64                // set delta Q for binning 
     65                delQ = SetDeltaQ(folderStr,detStr) 
     66                 
     67                // dispatch based on binning type 
     68                if(binType==1) 
     69                        VC_fDoBinning_QxQy2D(folderStr,detStr) 
     70                endif 
     71                 
     72                // TODO -- this is only a temporary fix for slit mode    
     73                if(binType == 4) 
     74                        /// this is for a tall, narrow slit mode         
     75                        VC_fBinDetector_byRows(folderStr,detStr) 
     76                endif    
     77                 
     78        endfor 
     79         
     80        // bin in pairs 
     81        if(binType == 2) 
     82                VC_fDoBinning_QxQy2D(folderStr,"MLR") 
     83                VC_fDoBinning_QxQy2D(folderStr,"MTB") 
     84                VC_fDoBinning_QxQy2D(folderStr,"FLR") 
     85                VC_fDoBinning_QxQy2D(folderStr,"FTB")    
     86        endif 
     87         
     88        // bin everything on front or middle together 
     89        if(binType == 3) 
     90                VC_fDoBinning_QxQy2D(folderStr,"MLRTB") 
     91                VC_fDoBinning_QxQy2D(folderStr,"FLRTB") 
     92        endif 
     93 
     94        return(0) 
     95End 
     96 
     97 
     98 
     99 
     100 
    12101Macro V_Combine1DData() 
    13102 
     
    26115         
    27116// write out the data set to a file 
    28  
    29  
    30 End 
    31  
    32  
    33  
     117        String/G saveName="" 
     118        V_GetNameForSave("") 
     119        V_Write1DData(type,saveName) 
     120 
     121End 
     122 
     123Proc V_GetNameForSave(str) 
     124        String str 
     125        String/G saveName=str 
     126End 
    34127 
    35128 
     
    122215 
    123216// TODO: 
     217// -- resolution waves are ignored 
     218// -- only a sort is done, no rescaling of data sets 
     219//    (it's too late now anyways, since the data was concatenated 
     220// 
    124221// see Auto_Sort() in the SANS Automation ipf for the rest of the details of 
    125 // how to combine the resolution waves (they also need to be concatenated, which is currently not done. 
    126 // 
     222// how to combine the resolution waves (they also need to be concatenated, which is currently not done) 
     223//  
    127224Function V_TmpSort1D(folderStr) 
    128225        String folderStr 
     
    197294 
    198295 
     296 
    199297// TODO: 
    200298// -- this is a temporary solution before a real writer is created 
    201299// -- resolution is not handled here (and it shouldn't be) since resolution is not known yet. 
    202300// 
    203 // 
    204301// this will bypass save dialogs 
    205302// -- AND WILL OVERWITE DATA WITH THE SAME NAME 
    206303// 
    207 Function V_Write1DData(folderStr,delim,term) 
    208         String folderStr,delim,term 
     304Function V_Write1DData(folderStr,saveName) 
     305        String folderStr,saveName 
    209306         
    210307        String formatStr="",fullpath="" 
    211308        Variable refnum,dialog=1 
     309 
     310        SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr) 
     311 
     312        Wave qw = tmp_q 
     313        Wave iw = tmp_i 
     314        Wave sw = tmp_s 
    212315         
    213316        String dataSetFolderParent,basestr 
    214317         
    215         //Abuse ParseFilePath to get path without folder name 
    216         dataSetFolderParent = ParseFilePath(1,folderStr,":",1,0) 
    217         //Abuse ParseFilePath to get basestr 
    218         basestr = ParseFilePath(0,folderStr,":",1,0) 
     318        // ParseFilePath to get path without folder name 
     319//      dataSetFolderParent = ParseFilePath(1,folderStr,":",1,0) 
     320        // ParseFilePath to get basestr 
     321//      basestr = ParseFilePath(0,folderStr,":",1,0) 
    219322         
    220323        //make sure the waves exist 
    221         SetDataFolder $(dataSetFolderParent+basestr) 
    222         WAVE/Z qw = $(baseStr+"_q") 
    223         WAVE/Z iw = $(baseStr+"_i") 
    224         WAVE/Z sw = $(baseStr+"_s") 
    225         WAVE/Z resw = $(baseStr+"_res") 
    226324         
    227325        if(WaveExists(qw) == 0) 
     
    234332                Abort "s is missing" 
    235333        endif 
    236         if(WaveExists(resw) == 0) 
    237                 Abort "Resolution information is missing." 
    238         endif 
    239          
    240         Duplicate/O qw qbar,sigQ,fs 
    241         if(dimsize(resW,1) > 4) 
    242                 //it's USANS put -dQv back in the last 3 columns 
    243                 NVAR/Z dQv = USANS_dQv 
    244                 if(NVAR_Exists(dQv) == 0) 
    245                         SetDataFolder root: 
    246                         Abort "It's USANS data, and I don't know what the slit height is." 
    247                 endif 
    248                 sigQ = -dQv 
    249                 qbar = -dQv 
    250                 fs = -dQv 
    251         else 
    252                 //it's SANS 
    253                 sigQ = resw[p][0] 
    254                 qbar = resw[p][1] 
    255                 fs = resw[p][2] 
    256         endif 
    257          
     334//      if(WaveExists(resw) == 0) 
     335//              Abort "Resolution information is missing." 
     336//      endif 
     337         
     338//      Duplicate/O qw qbar,sigQ,fs 
     339//      if(dimsize(resW,1) > 4) 
     340//              //it's USANS put -dQv back in the last 3 columns 
     341//              NVAR/Z dQv = USANS_dQv 
     342//              if(NVAR_Exists(dQv) == 0) 
     343//                      SetDataFolder root: 
     344//                      Abort "It's USANS data, and I don't know what the slit height is." 
     345//              endif 
     346//              sigQ = -dQv 
     347//              qbar = -dQv 
     348//              fs = -dQv 
     349//      else 
     350//              //it's SANS 
     351//              sigQ = resw[p][0] 
     352//              qbar = resw[p][1] 
     353//              fs = resw[p][2] 
     354//      endif 
     355//       
     356 
    258357        PathInfo catPathName 
    259         fullPath = S_Path + folderStr 
     358        fullPath = S_Path + saveName 
    260359 
    261360        Open refnum as fullpath 
    262361 
    263362        fprintf refnum,"Combined data written from folder %s on %s\r\n",folderStr,(date()+" "+time()) 
    264         formatStr = "%15.4g %15.4g %15.4g %15.4g %15.4g %15.4g\r\n"      
    265         fprintf refnum, "The 6 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm) | sigmaQ | meanQ | ShadowFactor|\r\n"         
    266  
    267         wfprintf refnum,formatStr,qw,iw,sw,sigQ,qbar,fs 
     363 
     364// TODO -- make this work for 6-columns 
     365//      formatStr = "%15.4g %15.4g %15.4g %15.4g %15.4g %15.4g\r\n"      
     366//      fprintf refnum, "The 6 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm) | sigmaQ | meanQ | ShadowFactor|\r\n"         
     367//      wfprintf refnum,formatStr,qw,iw,sw,sigQ,qbar,fs 
     368 
     369        //currently, only three columns 
     370        formatStr = "%15.4g %15.4g %15.4g\r\n"   
     371        fprintf refnum, "The 3 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm)\r\n"  
     372 
     373        wfprintf refnum,formatStr,qw,iw,sw 
    268374        Close refnum 
    269375         
    270         KillWaves/Z sigQ,qbar,fs 
     376//      KillWaves/Z sigQ,qbar,fs 
    271377         
    272378        SetDataFolder root: 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Initialize.ipf

    r993 r999  
    156156        // Analysis is not mine. So for VSANS, there is a new, separate file: V_VSANS_Preferences.ipf 
    157157 
     158        //this is critical to initialize now - as it has the y/n flags for the detector correction steps 
    158159        Execute "Initialize_VSANSPreferences()"  
    159160 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Test_RAW_Panel.ipf

    r995 r999  
    141141         
    142142        Button button_tagFile,pos={603,412},size={70,20},proc=TagFileButtonProc,title="Tag File" 
     143        Button button_saveIQ,pos={720,412},size={70,20},proc=SaveIQ_ButtonProc,title="Save I(Q)" 
    143144        Button button_BeamCtr,pos={603,450},size={70,20},proc=BeamCtrButtonProc,title="Beam Ctr" 
    144145        Button button_SpreadPanels,pos={603,488},size={100,20},proc=SpreadPanelButtonProc,title="Spread Panels" 
    145146        Button button_RestorePanels,pos={603,526},size={100,20},proc=RestorePanelButtonProc,title="Restore Panels" 
     147 
    146148 
    147149// on the tabs, always visible 
     
    350352                                        yctr = V_getDet_beam_center_y_mm(gCurDispType,detStr)    
    351353                                         
    352                                         sdd = V_getDet_distance(gCurDispType,detStr)    / 100   //written in cm, pass in meters 
     354                                        sdd = V_getDet_ActualDistance(gCurDispType,detStr)      / 100   //written in cm, pass in meters 
    353355                                        lam = V_getVSWavelength(gCurDispType)           //A 
    354356//                                      pixSizeX = V_getDet_x_pixel_size(gCurDispType,detStr)           // written mm? need mm 
     
    697699// ? controls here to select how the data is processed/grouped/saved, etc. 
    698700// 
     701// -- currently just the graph, no controls 
     702// -- this re-bins the data every time by calling V_QBinAllPanels(folderStr) 
    699703Function IvsQPanelButtonProc(ba) : ButtonControl 
    700704        STRUCT WMButtonAction &ba 
     
    737741                        str += "Wavelength is "+num2str(V_getWavelength(type)) + " A \r" 
    738742                        if(curTab == 2) 
    739                                 str += "SDD B = "+num2str(V_getDet_distance(type,"B")) + " cm \r"               //V_getDet_distance(fname,detStr) 
     743                                str += "SDD B = "+num2str(V_getDet_ActualDistance(type,"B")) + " cm \r"         //V_getDet_distance(fname,detStr) 
    740744                        endif 
    741745                        if(curTab == 1) 
    742                                 str += "SDD ML = "+num2str(V_getDet_distance(type,"ML")) + " cm \r" 
    743                                 str += "SDD MR = "+num2str(V_getDet_distance(type,"MR")) + " cm \r" 
    744                                 str += "SDD MT = "+num2str(V_getDet_distance(type,"MT")) + " cm \r" 
    745                                 str += "SDD MB = "+num2str(V_getDet_distance(type,"MB")) + " cm \r" 
     746                                str += "SDD ML = "+num2str(V_getDet_ActualDistance(type,"ML")) + " cm \r" 
     747                                str += "SDD MR = "+num2str(V_getDet_ActualDistance(type,"MR")) + " cm \r" 
     748                                str += "SDD MT = "+num2str(V_getDet_ActualDistance(type,"MT")) + " cm \r" 
     749                                str += "SDD MB = "+num2str(V_getDet_ActualDistance(type,"MB")) + " cm \r" 
    746750                        endif 
    747751                        if(curTab == 0) 
    748                                 str += "SDD FL = "+num2str(V_getDet_distance(type,"FL")) + " cm \r" 
    749                                 str += "SDD FR = "+num2str(V_getDet_distance(type,"FR")) + " cm \r" 
    750                                 str += "SDD FT = "+num2str(V_getDet_distance(type,"FT")) + " cm \r" 
    751                                 str += "SDD FB = "+num2str(V_getDet_distance(type,"FB")) + " cm \r" 
     752                                str += "SDD FL = "+num2str(V_getDet_ActualDistance(type,"FL")) + " cm \r" 
     753                                str += "SDD FR = "+num2str(V_getDet_ActualDistance(type,"FR")) + " cm \r" 
     754                                str += "SDD FT = "+num2str(V_getDet_ActualDistance(type,"FT")) + " cm \r" 
     755                                str += "SDD FB = "+num2str(V_getDet_ActualDistance(type,"FB")) + " cm \r" 
    752756                        endif 
    753757                         
     
    849853                case 2: // mouse up 
    850854                        // click code here 
    851                         DoAlert 0, "TagFileButtonProc(ba) unfinished" 
    852                          
     855                        DoAlert 0, "TagFileButtonProc(ba) unfinished - thes may be used to 'tag' a file as scatter, trans, emp, bkg, etc." 
     856                         
     857                                 
     858                        break 
     859                case -1: // control being killed 
     860                        break 
     861        endswitch 
     862 
     863        return 0 
     864End 
     865 
     866// TODO 
     867// -- fill in more functionality 
     868// -- currently a straight concatentation of all data, no options 
     869// -- maybe allow save of single panels? 
     870// -- any other options? 
     871Function SaveIQ_ButtonProc(ba) : ButtonControl 
     872        STRUCT WMButtonAction &ba 
     873 
     874        switch( ba.eventCode ) 
     875                case 2: // mouse up 
     876                        // click code here 
     877 
     878                        Execute "V_Combine1DData()"                      
    853879                                 
    854880                        break 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Testing_Data_Procs.ipf

    r995 r999  
    7575 
    7676        endfor 
    77          
     77 
     78         
     79// writes out "perfect" detector calibration constants for all 8 tube banks 
     80        V_WritePerfectSpatialCalib(filename) 
     81// writes out "perfect" dead time constants for all 8 tube banks + back detector 
     82        V_WritePerfectDeadTime(filename) 
    7883         
    7984//? other detector geometry - lateral separation? 
     
    106111 
    107112 
    108 // writes out "perfect" detector calibration constants for all 8 tube banks 
    109 Function V_WritePerfectCalibration() 
    110  
     113// writes out "perfect" detector calibration constants for all 8 tube banks + back detector 
     114Function V_WritePerfectSpatialCalib(filename) 
     115        String filename 
     116         
     117//      String fileName = V_DoSaveFileDialog("pick the file to write to") 
     118         
    111119        Make/O/D/N=(3,48) tmpCalib 
    112120        // for the "tall" L/R banks 
     
    115123        tmpCalib[2][] = 0 
    116124         
    117         V_writeDetTube_spatialCalib("","FR",tmpCalib) 
    118         V_writeDetTube_spatialCalib("","FL",tmpCalib) 
    119         V_writeDetTube_spatialCalib("","MR",tmpCalib) 
    120         V_writeDetTube_spatialCalib("","ML",tmpCalib) 
     125        V_writeDetTube_spatialCalib(filename,"FR",tmpCalib) 
     126        V_writeDetTube_spatialCalib(filename,"FL",tmpCalib) 
     127        V_writeDetTube_spatialCalib(filename,"MR",tmpCalib) 
     128        V_writeDetTube_spatialCalib(filename,"ML",tmpCalib) 
    121129 
    122130        // for the "short" T/B banks 
     
    125133        tmpCalib[2][] = 0 
    126134         
    127         V_writeDetTube_spatialCalib("","FT",tmpCalib) 
    128         V_writeDetTube_spatialCalib("","FB",tmpCalib) 
    129         V_writeDetTube_spatialCalib("","MT",tmpCalib) 
    130         V_writeDetTube_spatialCalib("","MB",tmpCalib) 
     135        V_writeDetTube_spatialCalib(filename,"FT",tmpCalib) 
     136        V_writeDetTube_spatialCalib(filename,"FB",tmpCalib) 
     137        V_writeDetTube_spatialCalib(filename,"MT",tmpCalib) 
     138        V_writeDetTube_spatialCalib(filename,"MB",tmpCalib) 
    131139         
    132140        KillWaves tmpCalib 
     141         
     142        // and for the back detector "B" 
     143        Make/O/D/N=3 tmpCalib 
     144        tmpCalib[0] = 1 
     145        tmpCalib[1] = 1 
     146        tmpcalib[2] = 10000 
     147        V_writeDet_cal_x(filename,"B",tmpCalib) 
     148        V_writeDet_cal_y(filename,"B",tmpCalib) 
     149 
     150        KillWaves tmpCalib 
     151 
    133152        return(0) 
    134153end 
     
    138157//V_writeDetector_deadtime(fname,detStr,inW) 
    139158//V_writeDetector_deadtime_B(fname,detStr,val) 
     159// simulated count rate per tube can be Å 10^8, so I need dt >> 10^-15 to completely cancel this out 
     160// (partly due to fake I(q), fake count time in file...) 
     161 
     162// writes out "perfect" dead time constants for all 8 tube banks + back detector 
     163Function V_WritePerfectDeadTime(filename) 
     164        String filename 
     165                 
     166        Make/O/D/N=(48) tmpDT 
     167        tmpDT = 1e-18 
     168        V_writeDetector_deadtime(filename,"FT",tmpDT) 
     169        V_writeDetector_deadtime(filename,"FB",tmpDT) 
     170        V_writeDetector_deadtime(filename,"FL",tmpDT) 
     171        V_writeDetector_deadtime(filename,"FR",tmpDT) 
     172        V_writeDetector_deadtime(filename,"MT",tmpDT) 
     173        V_writeDetector_deadtime(filename,"MB",tmpDT) 
     174        V_writeDetector_deadtime(filename,"ML",tmpDT) 
     175        V_writeDetector_deadtime(filename,"MR",tmpDT) 
     176 
     177 
     178        // and for the back detector "B", a single value, not a wave 
     179        V_writeDetector_deadtime_B(filename,"B",1e-20) 
     180 
     181        KillWaves tmpDT 
     182 
     183        return(0) 
     184end 
    140185 
    141186 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_VSANS_Preferences.ipf

    r979 r999  
    8787        Variable/G root:Packages:NIST:VSANS:Globals:gDoTubeShadowCor = 1 
    8888         
    89  
     89        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoMonitorNormalizaton", 1 ) 
     90        Variable/G root:Packages:NIST:VSANS:Globals:gDoMonitorNormalizaton = 1 
     91         
    9092 
    9193// flag to allow adding raw data files with different attenuation (normally not done)    
     
    197199        gVal = checked 
    198200End 
     201 
     202Function V_DoMonitorNormPref(ctrlName,checked) : CheckBoxControl 
     203        String ctrlName 
     204        Variable checked 
     205         
     206        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoMonitorNormalizaton 
     207        gVal = checked 
     208End 
     209 
    199210 
    200211Function V_PrefDoneButtonProc(ctrlName) : ButtonControl 
     
    243254        SetVariable PrefCtrl_1e,pos={21,195},size={200,15},title="# Phi Steps (annular avg)" 
    244255        SetVariable PrefCtrl_1e,limits={1,360,1},value= root:Packages:NIST:VSANS:Globals:gNPhiSteps 
     256         
    245257        CheckBox PrefCtrl_1f title="Do Transmssion Correction?",size={140,14},value=root:Packages:NIST:VSANS:Globals:gDoTransmissionCor,proc=V_DoTransCorrPref 
    246         CheckBox PrefCtrl_1f pos={255,100},help={"TURN OFF ONLY FOR DEBUGGING. This corrects the data for angle dependent transmssion."} 
     258        CheckBox PrefCtrl_1f pos={255,80},help={"TURN OFF ONLY FOR DEBUGGING. This corrects the data for angle dependent transmssion."} 
    247259        CheckBox PrefCtrl_1g title="Do Efficiency Correction?",size={140,14},proc=V_DoEfficiencyCorrPref 
    248         CheckBox PrefCtrl_1g value=root:Packages:NIST:VSANS:Globals:gDoDetectorEffCor,pos={255,120},help={"TURN OFF ONLY FOR DEBUGGING. This corrects the data for angle dependent detector efficiency."} 
     260        CheckBox PrefCtrl_1g value=root:Packages:NIST:VSANS:Globals:gDoDetectorEffCor,pos={255,100},help={"TURN OFF ONLY FOR DEBUGGING. This corrects the data for angle dependent detector efficiency."} 
    249261//      CheckBox PrefCtrl_1h title="Adjust RAW attenuation?",size={140,14},proc=V_DoRawAttenAdjPref 
    250262//      CheckBox PrefCtrl_1h value=root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten,pos={255,140},help={"This is normally not done"} 
    251263 
    252264        CheckBox PrefCtrl_1i title="Do DIV Correction?",size={140,14},proc=V_DoDIVCorPref 
    253         CheckBox PrefCtrl_1i value=root:Packages:NIST:VSANS:Globals:gDoDIVCor,pos={255,140},help={"TURN OFF ONLY FOR DEBUGGING."} 
     265        CheckBox PrefCtrl_1i value=root:Packages:NIST:VSANS:Globals:gDoDIVCor,pos={255,120},help={"TURN OFF ONLY FOR DEBUGGING."} 
    254266        CheckBox PrefCtrl_1j title="Do DeadTime Correction?",size={140,14},proc=V_DoDeadTimeCorPref 
    255         CheckBox PrefCtrl_1j value=root:Packages:NIST:VSANS:Globals:gDoDeadTimeCor,pos={255,160},help={"TURN OFF ONLY FOR DEBUGGING."}   
     267        CheckBox PrefCtrl_1j value=root:Packages:NIST:VSANS:Globals:gDoDeadTimeCor,pos={255,140},help={"TURN OFF ONLY FOR DEBUGGING."}   
    256268        CheckBox PrefCtrl_1k title="Do Solid Angle Correction?",size={140,14},proc=V_DoSolidAngleCorPref 
    257         CheckBox PrefCtrl_1k value=root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor,pos={255,180},help={"TURN OFF ONLY FOR DEBUGGING."} 
     269        CheckBox PrefCtrl_1k value=root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor,pos={255,160},help={"TURN OFF ONLY FOR DEBUGGING."} 
    258270        CheckBox PrefCtrl_1l title="Do Non-linear Correction?",size={140,14},proc=V_DoNonLinearCorPref 
    259         CheckBox PrefCtrl_1l value=root:Packages:NIST:VSANS:Globals:gDoNonLinearCor,pos={255,200},help={"TURN OFF ONLY FOR DEBUGGING."} 
     271        CheckBox PrefCtrl_1l value=root:Packages:NIST:VSANS:Globals:gDoNonLinearCor,pos={255,180},help={"TURN OFF ONLY FOR DEBUGGING."} 
    260272        CheckBox PrefCtrl_1m title="Do Tube Shadow Correction?",size={140,14},proc=V_DoTubeShadowCorPref 
    261         CheckBox PrefCtrl_1m value=root:Packages:NIST:VSANS:Globals:gDoTubeShadowCor,pos={255,220},help={"TURN OFF ONLY FOR DEBUGGING."} 
     273        CheckBox PrefCtrl_1m value=root:Packages:NIST:VSANS:Globals:gDoTubeShadowCor,pos={255,200},help={"TURN OFF ONLY FOR DEBUGGING."} 
     274        CheckBox PrefCtrl_1n title="Do Tube Shadow Correction?",size={140,14},proc=V_DoMonitorNormPref 
     275        CheckBox PrefCtrl_1n value=root:Packages:NIST:VSANS:Globals:gDoMonitorNormalizaton,pos={255,220},help={"TURN OFF ONLY FOR DEBUGGING."} 
     276                 
    262277         
    263278//      CheckBox PrefCtrl_1a,disable=1 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_WorkFolderUtils.ipf

    r995 r999  
    408408                        Wave w_err = V_getDetectorDataErrW(fname,detStr) 
    409409                         
    410                         DIVCorrection(w,w_err,detStr,newType) 
     410                        V_DIVCorrection(w,w_err,detStr,newType) 
    411411                endfor 
    412412        else 
    413                 Print "DIV correction not done"         // not an error since correction was unchecked 
     413                Print "DIV correction NOT DONE"         // not an error since correction was unchecked 
    414414        endif 
    415415         
    416416        // (2) non-linear correction     
    417417        // TODO: 
    418         // x- currently, the "B" detector is skipped 
     418        // x-  the "B" detector is calculated in its own routines 
    419419        // -- document what is generated here: 
    420420        //    **in each detector folder: data_realDistX and data_realDistY (2D waves of the mm? position of the pixel) 
    421         // -- still not sure whether to duplicate these calculations as the RAW data is loaded. It would allow the RAW 
    422         //    data to be properly displayed, but without all of the (complete) set of corrections 
     421        // x- these spatial calculations ARE DONE as the RAW data is loaded. It allows the RAW 
     422        //    data to be properly displayed, but without all of the (complete) set of detector corrections 
    423423        // * the corrected distances are calculated into arrays, but nothing is done with them yet 
    424         // * there is enough information now to calculate the q-arrays 
    425         // -other corrections modify the data, this does NOT 
     424        // * there is enough information now to calculate the q-arrays, so it is done now 
     425        // - other corrections may modify the data, this calculation does NOT modify the data 
    426426        NVAR gDoNonLinearCor = root:Packages:NIST:VSANS:Globals:gDoNonLinearCor 
    427427        // generate a distance matrix for each of the detectors 
     
    461461                 
    462462        else 
    463                 Print "Non-linear correction not done" 
     463                Print "Non-linear correction NOT DONE" 
    464464        endif 
    465465 
    466466        // (3) solid angle correction 
     467        // TODO -- this currently calculates the correction factor AND applys it to the data 
     468        //  -- as a result, the data values are very large since they are divided by a very small 
     469        //     solid angle per pixel. But all of the count values are now on the basis of  
     470        //    counts/(solid angle) --- meaning that they can all be binned together for I(q) 
     471        //    -and- TODO - this will need to be taken into account for absolute scaling (this part is already done) 
     472        // 
     473        // the solid angle correction is calculated for ALL detector panels. 
    467474        NVAR gDoSolidAngleCor = root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor 
    468475        if (gDoSolidAngleCor == 1) 
     
    473480                        Wave w_err = V_getDetectorDataErrW(fname,detStr) 
    474481                        // any other dimensions to pass in? 
    475 //                      SolidAngleCorrection(fill this in) 
     482                        SolidAngleCorrection(w,w_err,fname,detStr,destPath) 
    476483                         
    477484                endfor 
    478485        else 
    479                 Print "Solid Angle correction not done" 
     486                Print "Solid Angle correction NOT DONE" 
    480487        endif    
    481488         
    482489        // (4) dead time correction 
    483         // TODO: -- remove the hard-wired test 
     490        // TODO: 
     491        // x- remove the hard-wired test - done 
    484492        // -- test for correct operation 
    485         // -- loop over all of the detectors 
    486         // -- B detector is a special case (do separately, then loop over NoB) 
     493        // x- loop over all of the detectors 
     494        // x- B detector is a special case (do separately, then loop over NoB) 
    487495        // -- this DOES alter the data 
    488         // -- verify the error propagation 
     496        // -- verify the error propagation (not done yet) 
    489497        // 
    490498        Variable countRate 
     
    515523                 
    516524        else 
    517                 Print "Dead Time correction not done" 
     525                Print "Dead Time correction NOT DONE" 
    518526        endif    
    519527         
    520528         
    521529        // (5) angle-dependent tube shadowing 
     530        // TODO: 
     531        // -- not sure about this correction yet... 
     532        // 
    522533        NVAR gDoTubeShadowCor = root:Packages:NIST:VSANS:Globals:gDoTubeShadowCor 
    523534        if (gDoTubeShadowCor == 1) 
    524          
    525         else 
    526                 Print "Tube shadowing correction not done" 
     535                Print "(stub)Tube Shadow correction" 
     536        else 
     537                Print "Tube shadowing correction NOT DONE" 
    527538        endif    
    528539                 
    529540        // (6) angle dependent transmission correction 
     541        // TODO: 
     542        // -- this still needs to be filled in 
     543        // -- still some debate of when/where in the corrections that this is best applied 
     544        //    - do it here, and it's done whether the output is 1D or 2D 
     545        //    - do it later (where SAMPLE information is used) since this section is ONLY instrument-specific 
    530546        NVAR gDoTrans = root:Packages:NIST:VSANS:Globals:gDoTransmissionCor 
    531547        if (gDoTrans == 1) 
    532                 Print "Doing Large-angle transmission correction"// for "+ detStr 
     548                Print "(stub)Doing Large-angle transmission correction"// for "+ detStr 
    533549                for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
    534550                        detStr = StringFromList(ii, ksDetectorListAll, ";") 
     
    539555                endfor 
    540556        else 
    541                 Print "Sample Transmission correction not done" 
     557                Print "Sample Transmission correction NOT DONE" 
    542558        endif    
    543559         
     
    546562        // TODO -- but there are TWO monitors - so how to switch? 
    547563        // TODO -- what do I really need to save? 
    548         Print "Doing monitor normalization"// for "+ detStr 
    549  
    550         defmon=1e8                      //default monitor counts 
    551         for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
    552                 detStr = StringFromList(ii, ksDetectorListAll, ";") 
    553                 Wave w = V_getDetectorDataW(fname,detStr) 
    554                 Wave w_err = V_getDetectorDataErrW(fname,detStr) 
    555                 Variable monCt = V_getBeamMonNormData(fname) 
    556 //                      MonitorNormalization(fill this in) 
    557         //scale the data to the default montor counts 
    558          
    559         // TODO -- un-comment these three lines once monitor counts are reasonable - currently monCt = 9!!! 
    560 //              scale = defmon/monCt 
    561 //              w *= scale 
    562 //              w_err *= scale          //assumes total monitor count is so large there is essentially no error 
    563  
    564 // TODO 
    565 // -- to write back to the local value, get the wave reference rather than the value, then I can  
    566 //    re-assign the value directly, rather than this method (which is not terrible)      
    567                 // V_getBeamMonNormSaved_count() 
    568                 // save the true monitor counts? save the scaling factor? 
    569                 String path = "entry:instrument:beam_monitor_norm:saved_count" 
    570                 Wave/Z savW = $("root:Packages:NIST:VSANS:"+fname+":"+path) 
    571                 savW[0] = scale 
    572         endfor 
    573          
     564         
     565        NVAR gDoMonitorNormalizaton = root:Packages:NIST:VSANS:Globals:gDoMonitorNormalizaton 
     566        if (gDoMonitorNormalizaton == 1) 
     567                Print "(stub)Doing monitor normalization"// for "+ detStr 
     568                 
     569                defmon=1e8                      //default monitor counts 
     570                for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
     571                        detStr = StringFromList(ii, ksDetectorListAll, ";") 
     572                        Wave w = V_getDetectorDataW(fname,detStr) 
     573                        Wave w_err = V_getDetectorDataErrW(fname,detStr) 
     574                        Variable monCt = V_getBeamMonNormData(fname) 
     575        //                      MonitorNormalization(fill this in) 
     576                //scale the data to the default montor counts 
     577                 
     578                // TODO -- un-comment these three lines once monitor counts are reasonable - currently monCt = 9!!! 
     579        //              scale = defmon/monCt 
     580        //              w *= scale 
     581        //              w_err *= scale          //assumes total monitor count is so large there is essentially no error 
     582         
     583        // TODO 
     584        // -- to write back to the local value, get the wave reference rather than the value, then I can  
     585        //    re-assign the value directly, rather than this method (which is not terrible)      
     586                        // V_getBeamMonNormSaved_count() 
     587                        // save the true monitor counts? save the scaling factor? 
     588                        String path = "entry:instrument:beam_monitor_norm:saved_count" 
     589                        Wave/Z savW = $("root:Packages:NIST:VSANS:"+fname+":"+path) 
     590                        savW[0] = scale 
     591                endfor 
     592        else 
     593                Print "Monitor Normalization correction NOT DONE" 
     594        endif 
    574595         
    575596        // (not done) angle dependent efficiency correction 
    576597        NVAR doEfficiency = root:Packages:NIST:VSANS:Globals:gDoDetectorEffCor 
    577598 
    578          
    579 // this function, in the past did the non-linear, solid angle, transmission, and efficiency corrections all at once 
    580 //      DetCorr(data,data_err,realsread,doEfficiency,doTrans)           //the parameters are waves, and will be changed by the function 
    581  
    582  
    583          
    584         //update totals to put in the work header (at the end of the function) 
     599//update totals to put in the work header (at the end of the function) 
    585600//      total_mon += realsread[0] 
    586601// 
Note: See TracChangeset for help on using the changeset viewer.