Ignore:
Timestamp:
Nov 16, 2017 10:57:32 AM (5 years ago)
Author:
srkline
Message:

lots of changes here:
many little fixes to clean up TODO items and marke them DONE

changed the handling of the panel "gap" to split the gap evenly. Q-calculations have been re-verified with this change.

re-named the list of "bin Type" values, and added a few more choices. Streamlined how the averaging and plotting works with this list so that it can be more easily modified as different combinations of binning are envisioned. This resulted in a lot of excess code being cut out and replaced with cleaner logic. This change has also been verified to work as intended.

Attenuation is now always calculated from the table. The table also by (NEW) definition has values for the white beam (one waelength) and graphite (multiple possible wavelengths) where the wavelengths are artificially scaled (*1000) or *1e6) so that the interpolations can be done internally without the need for multiple attenuator tables.

File:
1 edited

Legend:

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

    r1071 r1073  
    2727// same old equation, just written in a more complex form. 
    2828// 
    29 // TODO 
     29// (DONE) 
    3030// x- verify the direction of the tubes and indexing 
    3131// x- decide on the appropriate functional form for the tubes 
     
    109109// 
    110110// 
    111 // TODO 
    112 // -- UNITS!!!! currently this is mm, which certainly doesn't match anything else!!! 
     111// (DONE) 
     112// x- UNITS!!!! currently this is mm, which certainly doesn't match anything else!!! 
     113// 
    113114// x- verify the direction of the tubes and indexing 
    114115// x- be sure I'm working in the right data folder (it is passed in, and the full path is used) 
     
    151152         
    152153        // TODO 
    153         // -- GAP IS HARD-WIRED 
     154        // -- GAP IS HARD-WIRED as a single constant value (there really are 4 values) 
    154155        Variable offset,gap 
    155156 
    156157// kPanelTouchingGap is in mm    
     158// the gap is added to the RIGHT and TOP panels ONLY 
     159// TODO -- replace with V_getDet_panel_gap(fname,detStr) once it is added to the file 
    157160        gap = kPanelTouchingGap 
    158161         
    159162        if(cmpstr(orientation,"vertical")==0) 
    160163                //      this is data dimensioned as (Ntubes,Npix) 
    161                 data_realDistX[][] = tube_width*p 
    162                 data_realDistY[][] = coefW[0][p] + coefW[1][p]*q + coefW[2][p]*q*q 
    163164         
    164165                // adjust the x postion based on the beam center being nominally (0,0) in units of cm, not pixels 
     
    180181                if(kBCTR_CM) 
    181182                        if(cmpstr("L",detStr[1]) == 0) 
    182                                 data_realDistX[][] = offset - (dimX - p)*tube_width                     // TODO should this be dimX-1-p = 47-p? 
    183 //                              data_realDistX[][] = -offset - (dimX - p)*tube_width                    // TODO should this be dimX-1-p = 47-p? 
     183//                              data_realDistX[][] = offset - (dimX - p)*tube_width                     // TODO should this be dimX-1-p = 47-p? 
     184                                data_realDistX[][] = offset - (dimX - p)*tube_width - gap/2             // TODO should this be dimX-1-p = 47-p? 
    184185                        else 
    185                                 data_realDistX[][] += offset + gap + tube_width                 //add to the Right det, not recalculate 
     186                        //      right 
     187//                              data_realDistX[][] = tube_width*(p+1) + offset + gap            //add to the Right det, 
     188                                data_realDistX[][] = tube_width*(p+1) + offset + gap/2          //add to the Right det 
    186189                        endif 
     190                else 
     191                        data_realDistX[][] = tube_width*(p) 
    187192                endif 
     193                data_realDistY[][] = coefW[0][p] + coefW[1][p]*q + coefW[2][p]*q*q 
    188194         
    189195         
    190196        elseif(cmpstr(orientation,"horizontal")==0) 
    191197                //      this is data (horizontal) dimensioned as (Npix,Ntubes) 
    192                 data_realDistX[][] = coefW[0][q] + coefW[1][q]*p + coefW[2][q]*p*p 
    193198                data_realDistY[][] = tube_width*q 
    194199 
     
    208213                if(kBCTR_CM) 
    209214                        if(cmpstr("T",detStr[1]) == 0) 
    210                                 data_realDistY[][] += offset + gap + tube_width                  
     215//                              data_realDistY[][] = tube_width*(q+1) + offset + gap                     
     216                                data_realDistY[][] = tube_width*(q+1) + offset + gap/2                   
    211217                        else 
    212                                 data_realDistY[][] = offset - (dimY - q)*tube_width     // TODO should this be dimY-1-q = 47-q? 
     218                                // bottom 
     219//                              data_realDistY[][] = offset - (dimY - q)*tube_width     // TODO should this be dimY-1-q = 47-q? 
     220                                data_realDistY[][] = offset - (dimY - q)*tube_width - gap/2     // TODO should this be dimY-1-q = 47-q? 
    213221                        endif 
     222                else 
     223                        data_realDistY[][] = tube_width*(q) 
    214224                endif 
     225                data_realDistX[][] = coefW[0][q] + coefW[1][q]*p + coefW[2][q]*p*p 
    215226 
    216227        else             
     
    325336// 
    326337// 
    327 // TODO 
    328 // -- VERIFY the calculations 
    329 // -- verify where this needs to be done (if the beam center is changed) 
    330 // -- then the q-calculation needs to be re-done 
    331 // -- the position along the tube length is referenced to tube[0], for no particular reason 
     338// (DONE) 
     339// x- VERIFY the calculations 
     340// x- verify where this needs to be done (if the beam center is changed) 
     341// x- then the q-calculation needs to be re-done 
     342// x- the position along the tube length is referenced to tube[0], for no particular reason 
    332343//    It may be better to take an average? but [0] is an ASSUMPTION 
    333 // -- distance along tube is simple interpolation, or do I use the coefficients to 
    334 //    calculate the actual value 
    335 // 
    336 // -- distance in the lateral direction is based on tube width, which is a fixed parameter 
    337 // 
     344// x- distance along tube is simple interpolation 
     345// 
     346// x- distance in the lateral direction is based on tube width, which is a fixed parameter 
     347// 
     348// the value in pixels is written to the local data folder, NOT to disk (it is recalculated as needed) 
    338349// 
    339350Function V_ConvertBeamCtr_to_pix(folder,detStr,destPath) 
     
    364375 
    365376        variable edge,delta 
     377        Variable gap = kPanelTouchingGap                // TODO: -- replace with V_getDet_panel_gap(fname,detStr) 
    366378 
    367379// 
     
    377389                        // R panel 
    378390                                edge = data_realDistX[0][0] 
    379                                 delta = abs(xCtr*10 - edge + kPanelTouchingGap) 
     391                                delta = abs(xCtr*10 - edge + gap) 
    380392                                x_pix[0] = -delta/tube_width            //since the left edge of the R panel is pixel 0 
    381393                        endif 
     
    394406                        if(cmpstr("T",detStr[1]) == 0) 
    395407                                edge = data_realDistY[0][0]             //tube 0 
    396                                 delta = abs(yCtr*10 - edge + kPanelTouchingGap) 
     408                                delta = abs(yCtr*10 - edge + gap) 
    397409                                y_pix[0] =  -delta/tube_width           //since the bottom edge of the T panel is pixel 0 
    398410                        else 
     
    478490//// 
    479491 
    480 // TODO 
    481 // get rid of this in the real data 
     492 
    482493// 
    483494// TESTING ONLY 
     
    496507 
    497508 
    498 // TODO 
    499 // get rid of this in the real data 
    500509// 
    501510// TESTING ONLY 
     
    549558 
    550559// 
    551 // TODO: 
    552 // -- MUST VERIFY the definition of SDD and how (if) setback is written to the data files 
    553 // -- currently I'm assuming that the SDD is the "nominal" value which is correct for the  
     560// (DONE) 
     561// x- MUST VERIFY the definition of SDD and how (if) setback is written to the data files 
     562// x- currently I'm assuming that the SDD is the "nominal" value which is correct for the  
    554563//    L/R panels, but is not correct for the T/B panels (must add in the setback) 
    555564// 
     
    609618//function to calculate the overall q-value, given all of the necesary trig inputs 
    610619// 
    611 // TODO: 
    612 // -- verify the calculation (accuracy - in all input conditions) 
    613 // -- verify the units of everything here, it's currently all jumbled and wrong... and repeated 
    614 // -- the input data_realDistX and Y are essentially lookup tables of the real space distance corresponding 
     620// (DONE) 
     621// x- verify the calculation (accuracy - in all input conditions) 
     622// x- verify the units of everything here, it's currently all jumbled and wrong... and repeated 
     623// x- the input data_realDistX and Y are essentially lookup tables of the real space distance corresponding 
    615624//    to each pixel 
    616625// 
     
    642651 
    643652//calculates just the q-value in the x-direction on the detector 
    644 // TODO: 
    645 // -- verify the calculation (accuracy - in all input conditions) 
    646 // -- verify the units of everything here, it's currently all jumbled and wrong... and repeated 
    647 // -- the input data_realDistX and Y are essentially lookup tables of the real space distance corresponding 
     653// (DONE) 
     654// x- verify the calculation (accuracy - in all input conditions) 
     655// x- verify the units of everything here, it's currently all jumbled and wrong... and repeated 
     656// x- the input data_realDistX and Y are essentially lookup tables of the real space distance corresponding 
    648657//    to each pixel 
    649658// 
     
    676685 
    677686//calculates just the q-value in the y-direction on the detector 
    678 // TODO: 
    679 // -- verify the calculation (accuracy - in all input conditions) 
    680 // -- verify the units of everything here, it's currently all jumbled and wrong... and repeated 
    681 // -- the input data_realDistX and Y are essentially lookup tables of the real space distance corresponding 
     687// (DONE) 
     688// x- verify the calculation (accuracy - in all input conditions) 
     689// x- verify the units of everything here, it's currently all jumbled and wrong... and repeated 
     690// x- the input data_realDistX and Y are essentially lookup tables of the real space distance corresponding 
    682691//    to each pixel 
    683692// 
     
    710719 
    711720//calculates just the q-value in the z-direction on the detector 
    712 // TODO: 
    713 // -- verify the calculation (accuracy - in all input conditions) 
    714 // -- verify the units of everything here, it's currently all jumbled and wrong... and repeated 
    715 // -- the input data_realDistX and Y are essentially lookup tables of the real space distance corresponding 
     721// (DONE) 
     722// x- verify the calculation (accuracy - in all input conditions) 
     723// x- verify the units of everything here, it's currently all jumbled and wrong... and repeated 
     724// x- the input data_realDistX and Y are essentially lookup tables of the real space distance corresponding 
    716725//    to each pixel 
    717726// 
    718727// not actually used for any calculations, but here for completeness if anyone asks, or for 2D data export 
    719728// 
    720 // this properly accounts for qz 
     729// this properly accounts for qz, because it is qz 
    721730// 
    722731Function V_CalcQZ(xaxval,yaxval,xctr,yctr,sdd,lam,distX,distY) 
     
    745754 
    746755// 
    747 // TODO -- VERIFY calculations 
    748 // -- This is the actual solid angle per pixel, not a ratio vs. some "unit SA"  
     756// (DONE) 
     757// x- VERIFY calculations 
     758// x- This is the actual solid angle per pixel, not a ratio vs. some "unit SA"  
    749759//    Do I just correct for the different area vs. the "nominal" central area? 
    750 // -- decide how to implement - either directly change the data values (as was done in the past) 
    751 //    or use this as a weighting for when the data is binned to I(q). In the second method, 2D data 
    752 //    would need this to be applied before exporting 
    753 // -- do I keep a wave note indicating that this correction has been applied to the data 
    754 //    so that it can be "un-applied"? 
    755 // -- do I calculate theta from geometry directly, or get it from Q (Assuming it's present?) 
    756 //    (probably just from geometry, since I need SDD and dx and dy values...) 
     760// x- decide how to implement - YES - directly change the data values (as was done in the past) 
     761//    or (NOT done this way...use this as a weighting for when the data is binned to I(q). In the second method, 2D data 
     762//    would need this to be applied before exporting) 
     763// x- do I keep a wave note indicating that this correction has been applied to the data 
     764//    so that it can be "un-applied"? NO 
     765// x- do I calculate theta from geometry directly, or get it from Q (Assuming it's present?) 
     766//    (YES just from geometry, since I need SDD and dx and dy values...) 
    757767// 
    758768// 
     
    827837        w /= solid_angle 
    828838         
    829          
    830         // TODO: 
     839        // 
    831840        // correctly apply the correction to the error wave (assume a perfect value?) 
    832         w_err /= solid_angle            //is this correct?? 
     841        w_err /= solid_angle            // 
    833842 
    834843// TODO -- clean up after I'm satisfied computations are correct                 
     
    844853// 
    845854// 
    846 // TODO :  
    847 //   -- DoAlert 0,"This has not yet been updated for VSANS" 
     855// NOV 2017 
     856// Currently, this is not called from any VSANS routines. it is only referenced 
     857// from V_Add_raw_to_work(), which would add two VSANS raw data files together. This has 
     858// not yet been implemented. I am only keeping this function around to be sure that  
     859// if/when V_Add_raw_to_work() is implemented, all of the functionality of V_DetCorr() is 
     860// properly duplicated. 
     861// 
     862// 
    848863// 
    849864//performs solid angle and non-linear detector corrections to raw data as it is "added" to a work folder 
     
    977992 
    978993 
    979  
     994// 
     995// Large angle transmission correction 
    980996// 
    981997// DIVIDE the intensity by this correction to get the right answer 
    982 // TODO: 
    983 //   --         DoAlert 0,"This has not yet been updated for VSANS" 
    984 // 
    985 // 
    986  
     998// 
     999// 
    9871000// Apply the large angle transmssion correction as the data is converted to WORK 
    9881001// so that whether the data is saved as 2D or 1D, the correction has properly been done. 
     
    10481061                        endif 
    10491062                          
    1050                         // TODO 
    1051                         // -- properly calculate and apply the 2D error propagation 
     1063                        // (DONE) 
     1064                        // x- properly calculate and apply the 2D error propagation 
    10521065                        if(trans == 1) 
    10531066                                lat_err[ii][jj] = 0             //no correction, no error 
     
    10771090        w_err = tmp_err  
    10781091         
    1079         // TODO: 
    1080         // correctly apply the correction to the error wave (assume a perfect value?) 
    1081         // w_err /= tmp         //is this correct?? 
    10821092 
    10831093        // TODO -- clean up after I'm satisfied computations are correct                 
     
    11271137 
    11281138// 
    1129 // TODO: 
    11301139// 
    11311140// kappa comes in as s_izero, so be sure to use 1/kappa_err 
     
    12561265 
    12571266// 
    1258 // TODO: 
    1259 //   --         DoAlert 0,"This has not yet been updated for VSANS" 
    1260 // 
    1261 //************************ 
    1262 //unused testing procedure, may not be up-to-date with other procedures 
    1263 //check before re-implementing 
     1267// testing procedure, called from a menu selection 
    12641268// 
    12651269Proc V_DIV_a_Workfile(type) 
Note: See TracChangeset for help on using the changeset viewer.