Changeset 984


Ignore:
Timestamp:
Mar 11, 2016 3:36:43 PM (6 years ago)
Author:
srkline
Message:

lots of changes to 1D averaging and the plotting routines, detector corrections, and basic reads

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

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/MC_Script_Panels.ipf

    r951 r984  
    1616//      x- configurations, samples, and listBox waves. 
    1717// 
     18//   -- the proc=MyListboxProc has been commented out. It was present for Igor 6 and did not generate an error. 
     19//      I don't think I ever wrote this procedure at all. In Igor 7 it generates an error, so it's out for now. 
    1820// 
    1921//              use Sim_ as a prefix for the functions rather than MC_ 
     
    100102// always visible 
    101103// clickEventModifiers=8  = ignore the shift key in the list box (I'm using that bit (3) of selWave to flag trans) 
    102         ListBox RLCtrlA,pos={17,290},size={660,250},proc=MyListboxProc,frame=2,clickEventModifiers=8 
     104        ListBox RLCtrlA,pos={17,290},size={660,250},frame=2,clickEventModifiers=8//,proc=MyListboxProc 
    103105        ListBox RLCtrlA,listWave=root:Packages:NIST:RunSim:textW,selWave=root:Packages:NIST:RunSim:selW//,colorWave=root:Packages:NIST:RunSim:myColors 
    104106        ListBox RLCtrlA,row= 0,mode= 2,editStyle= 2,widths= {40,70,120,120,50,120,30,30} 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_BeamCenter.ipf

    r983 r984  
    408408 
    409409// 
    410 // TODO -- currently hard-wired for the only fit function 
    411 // 
     410// TODO -- currently hard-wired for coefficients from the only fit function 
     411// 
     412// -- will need to recalc mm center AND q-values 
    412413Function WriteCtrButtonProc(ba) : ButtonControl 
    413414        STRUCT WMButtonAction &ba 
     
    427428                        V_putDet_beam_center_y(fname,detStr,coefW[10]) 
    428429 
     430                        DoAlert 0, "-- will need to recalc mm center AND q-values" 
     431                         
    429432                        break 
    430433                case -1: // control being killed 
     
    442445// 
    443446// 
    444 // function to call the fit fucntion (2D) 
     447// function to call the fit function (2D) 
    445448// 
    446449Function DetFitButtonProc(ba) : ButtonControl 
     
    572575// -- will need to remove the hard-wired values and get the proper values from the data 
    573576// -- ?? will the "proper" values be in pixels or distance? All depends on how I display the data... 
    574 // -- may want to keep the nominal scaling values around in case the proper values aren' in the file 
     577// -- may want to keep the nominal scaling values around in case the proper values aren't in the file 
     578// 
     579// 
     580// 
     581//•print xCtr_pix 
     582//  xCtr_pix[0]= {64,64,55,-8.1,64,64,55,-8.1,63.4} 
     583//•print yCtr_pix 
     584//  yCtr_pix[0]= {-8.7,55,64,64,-8.7,55,64,64,62.7} 
    575585// 
    576586Function V_RestorePanels() 
     
    580590        Variable ii,xCtr,yCtr 
    581591 
    582 //// this works if the proper centers are in the file - otherwise, it's a mess   
    583 //      fname = "RAW" 
    584 //      for(ii=0;ii<ItemsInList(ksDetectorListNoB);ii+=1) 
    585 //              detStr = StringFromList(ii, ksDetectorListNoB, ";") 
    586 //              xCtr = V_getDet_beam_center_x(fname,detStr) 
    587 //              yCtr = V_getDet_beam_center_y(fname,detStr) 
    588 //              V_RescaleToBeamCenter("RAW",detStr,xCtr,yCtr) 
    589 //      endfor 
     592// this works if the proper centers are in the file - otherwise, it's a mess     
     593// "B" is skipped here, as it should be... 
     594        fname = "RAW" 
     595        for(ii=0;ii<ItemsInList(ksDetectorListNoB);ii+=1) 
     596                detStr = StringFromList(ii, ksDetectorListNoB, ";") 
     597                xCtr = V_getDet_beam_center_x(fname,detStr) 
     598                yCtr = V_getDet_beam_center_y(fname,detStr) 
     599                V_RescaleToBeamCenter("RAW",detStr,xCtr,yCtr) 
     600        endfor 
    590601                 
    591602                 
    592603                // nominal values... better to use what's in the file 
    593 // 
    594                 V_RescaleToBeamCenter("RAW","MB",64,55) 
    595                 V_RescaleToBeamCenter("RAW","MT",64,-8.7) 
    596                 V_RescaleToBeamCenter("RAW","MR",-8.1,64) 
    597                 V_RescaleToBeamCenter("RAW","ML",55,64) 
    598                 V_RescaleToBeamCenter("RAW","FB",64,55) 
    599                 V_RescaleToBeamCenter("RAW","FT",64,-8.7) 
    600                 V_RescaleToBeamCenter("RAW","FR",-8.1,64) 
    601                 V_RescaleToBeamCenter("RAW","FL",55,64) 
     604//// 
     605//              V_RescaleToBeamCenter("RAW","MB",64,55) 
     606//              V_RescaleToBeamCenter("RAW","MT",64,-8.7) 
     607//              V_RescaleToBeamCenter("RAW","MR",-8.1,64) 
     608//              V_RescaleToBeamCenter("RAW","ML",55,64) 
     609//              V_RescaleToBeamCenter("RAW","FB",64,55) 
     610//              V_RescaleToBeamCenter("RAW","FT",64,-8.7) 
     611//              V_RescaleToBeamCenter("RAW","FR",-8.1,64) 
     612//              V_RescaleToBeamCenter("RAW","FL",55,64) 
     613                 
     614                 
    602615        return(0) 
    603616end 
     
    657670                // TODO 
    658671                // and now the mm values 
     672                xCtr_mm[ii] = V_getDet_beam_center_x_mm(fname,detStr) 
     673                yCtr_mm[ii] = V_getDet_beam_center_y_mm(fname,detStr) 
    659674                 
    660675        endfor 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_HDF5_VSANS_Utils.ipf

    r981 r984  
    6767                "Setup_VSANS_DIV_Struct" 
    6868                "Save_VSANS_DIV_Nexus" 
     69                "-" 
     70                "Read_Nexus with attributes",Read_Nexus_Xref()          //this will read with attributes 
    6971        End 
    7072End 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VSANS_Includes.ipf

    r982 r984  
    5252#include "V_Utilities_General"          // 
    5353#include "V_DataPlotting" 
     54 
     55// 1D binning, combining 
     56#include "V_IQ_Utilities" 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DataPlotting.ipf

    r982 r984  
    1717        if(V_flag==0) 
    1818                Execute "V_DrawPlotPanel()" 
     19        else 
     20                SVAR type = root:Packages:NIST:VSANS:Globals:gCurDispType 
     21 
     22                V_QBinAllPanels(type) 
     23 
     24        // TODO: 
     25        // x- "B" detector is currently skipped - Q is not yet calculated 
     26                Execute ("V_Back_IQ_Graph(\""+type+"\")") 
     27                Execute ("V_Middle_IQ_Graph(\""+type+"\")") 
     28                Execute ("V_Front_IQ_Graph(\""+type+"\")") 
    1929        endif 
    2030End 
     
    4151        V_QBinAllPanels(type) 
    4252 
    43 // TODO "B" detector is currently skipped - Q is not yet calculated 
    44 //      V_Back_IQ_Graph() 
     53// TODO  
     54// x- "B" detector is currently skipped - Q is not yet calculated 
     55        V_Back_IQ_Graph(type) 
    4556        V_Middle_IQ_Graph(type) 
    4657        V_Front_IQ_Graph(type) 
     
    5465// 
    5566// TODO  
    56 // -- detector "B" is currently skipped since the calibration waves are not faked 
     67// x- detector "B" is currently skipped since the calibration waves are not faked 
    5768//    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// 
    5872// -- figure out the binning type (where is it set?) 
    5973// -- binning type is HARD-WIRED 
     
    7286         
    7387 
    74 //// TODO -- currently the "B" detector is skipped - it was skipped in  
     88//// TODO: 
     89// x- currently the "B" detector is skipped - it was skipped in  
    7590//       previous functions where q values are calculated        
    7691//       
    77 //      delQ = SetDeltaQ("RAW","B") 
    78 //       
    79 //      // dispatch based on binning type 
    80 //      if(binType == 4) 
    81 //              VC_fDoBinning_QxQy2D("RAW", "B")                //normal binning, nothing to combine 
    82 //      endif 
    83 // 
    84 //// TODO -- this is only a temporary fix for slit mode  
    85 //      if(binType == 4) 
    86 //              /// this is for a tall, narrow slit mode         
    87 //              VC_fBinDetector_byRows("VCALC","B") 
    88 //      endif    
     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    
    89104 
    90105// these are the binning types where detectors are not combined 
     
    384399 
    385400 
    386  
     401// TODO 
     402// -- need to set binType 
     403// -- currently  hard-wired == 1 
     404// 
     405////////////to plot the back panel I(q) 
     406Proc V_Back_IQ_Graph(type) 
     407        String type 
     408         
     409        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_B 
     410 
     411        Variable binType 
     412         
     413//      ControlInfo/W=VCALC popup_b 
     414//      binType = V_Value               // V_value counts menu items from 1, so 1=1, 2=2, 3=4 
     415 
     416        bintype = 1 
     417         
     418                SetDataFolder $("root:Packages:NIST:VSANS:"+type)        
     419 
     420        if(binType==1 || binType==2 || binType==3) 
     421                 
     422                CheckDisplayed/W=V_1D_Data iBin_qxqy_B 
     423                 
     424                if(V_flag==0) 
     425                        AppendtoGraph/W=V_1D_Data iBin_qxqy_B vs qBin_qxqy_B 
     426                        ModifyGraph/W=V_1D_Data mode=4 
     427                        ModifyGraph/W=V_1D_Data marker=19 
     428                        ModifyGraph/W=V_1D_Data rgb(iBin_qxqy_B)=(1,52428,52428) 
     429                        ModifyGraph/W=V_1D_Data msize=2 
     430                        ModifyGraph/W=V_1D_Data grid=1 
     431                        ModifyGraph/W=V_1D_Data log=1 
     432                        ModifyGraph/W=V_1D_Data mirror=2 
     433                endif 
     434        endif 
     435 
     436        //nothing different here since there is ony a single detector to display, but for the future... 
     437        if(binType==4) 
     438                 
     439                CheckDisplayed/W=V_1D_Data iBin_qxqy_B 
     440                 
     441                if(V_flag==0) 
     442                        AppendtoGraph/W=V_1D_Data iBin_qxqy_B vs qBin_qxqy_B 
     443                        ModifyGraph/W=V_1D_Data mode=4 
     444                        ModifyGraph/W=V_1D_Data marker=19 
     445                        ModifyGraph/W=V_1D_Data rgb(iBin_qxqy_B)=(1,52428,52428) 
     446                        ModifyGraph/W=V_1D_Data msize=2 
     447                        ModifyGraph/W=V_1D_Data grid=1 
     448                        ModifyGraph/W=V_1D_Data log=1 
     449                        ModifyGraph/W=V_1D_Data mirror=2 
     450                endif 
     451        endif 
     452 
     453         
     454        SetDataFolder root: 
     455End 
     456 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DetectorCorrections.ipf

    r982 r984  
    8686// 
    8787// TODO 
     88// -- UNITS!!!! currently this is mm, which certainly doesn't match anything else!!! 
    8889// -- verify the direction of the tubes and indexing 
    8990// -- be sure I'm working in the right data folder 
     
    9495// -- do I want to make the distance array 3D to keep the x and y dims together? Calculate them all right now? 
    9596// -- what else do I need to pass to the function? (fname=folder? detStr?) 
    96 // 
     97// -- need a separate block or function to handle "B" detector which will be ? different 
    9798// 
    9899// 
     
    107108        Variable dimX,dimY 
    108109        dimX = DimSize(dataW,0) 
    109         dimY = DimSize(dataw,1) 
     110        dimY = DimSize(dataW,1) 
    110111        if(dimX > dimY) 
    111112                orientation = "horizontal" 
     
    126127        if(cmpstr(orientation,"vertical")==0) 
    127128                //      this is data dimensioned as (Ntubes,Npix) 
     129                data_realDistX[][] = tube_width*p 
    128130                data_realDistY[][] = coefW[0][p] + coefW[1][p]*q + coefW[2][p]*q*q 
    129  
    130                 data_realDistX[][] = tube_width*p 
    131                  
     131         
    132132        elseif(cmpstr(orientation,"horizontal")==0) 
    133133                //      this is data (horizontal) dimensioned as (Npix,Ntubes) 
    134134                data_realDistX[][] = coefW[0][q] + coefW[1][q]*p + coefW[2][q]*p*p 
    135          
    136135                data_realDistY[][] = tube_width*q 
    137136 
     
    142141        return(0) 
    143142end 
     143 
     144// TODO: 
     145// -- the cal_x and y coefficients are totally fake 
     146// -- the wave assignment may not be correct.. so beware 
     147// 
     148// 
     149Function NonLinearCorrection_B(folder,detStr,destPath) 
     150        String folder,detStr,destPath 
     151 
     152        if(cmpstr(detStr,"B") != 0) 
     153                return(0) 
     154        endif 
     155         
     156        // do I count on the orientation as an input, or do I just figure it out on my own? 
     157        Variable dimX,dimY 
     158         
     159        Wave dataW = V_getDetectorDataW(folder,detStr) 
     160         
     161        dimX = DimSize(dataW,0) 
     162        dimY = DimSize(dataW,1) 
     163 
     164        // make a wave of the same dimensions, in the same data folder for the distance 
     165        // ?? or a 3D wave? 
     166        Make/O/D/N=(dimX,dimY) $(destPath + ":entry:entry:instrument:detector_"+detStr+":data_realDistX") 
     167        Make/O/D/N=(dimX,dimY) $(destPath + ":entry:entry:instrument:detector_"+detStr+":data_realDistY") 
     168        Wave data_realDistX = $(destPath + ":entry:entry:instrument:detector_"+detStr+":data_realDistX") 
     169        Wave data_realDistY = $(destPath + ":entry:entry:instrument:detector_"+detStr+":data_realDistY") 
     170         
     171         
     172        Wave cal_x = V_getDet_cal_x(folder,detStr) 
     173        Wave cal_y = V_getDet_cal_y(folder,detStr) 
     174         
     175        data_realDistX[][] = cal_x[0]*p 
     176        data_realDistY[][] = cal_y[0]*q 
     177         
     178        return(0) 
     179end 
     180 
     181 
     182// 
     183// 
     184// TODO 
     185// -- VERIFY the calculations 
     186// -- verify where this needs to be done (if the beam center is changed) 
     187// -- then the q-calculation needs to be re-done 
     188// -- the position along the tube length is referenced to tube[0], for no particular reason 
     189//    It may be better to take an average? but [0] is an ASSUMPTION 
     190// -- distance along tube is simple interpolation, or do I use the coefficients to 
     191//    calculate the actual value 
     192// 
     193// -- distance in the lateral direction is based on tube width, which is well known 
     194// 
     195// 
     196Function ConvertBeamCtr_to_mm(folder,detStr,destPath) 
     197        String folder,detStr,destPath 
     198         
     199        Wave data_realDistX = $(destPath + ":entry:entry:instrument:detector_"+detStr+":data_realDistX") 
     200        Wave data_realDistY = $(destPath + ":entry:entry:instrument:detector_"+detStr+":data_realDistY")         
     201 
     202        String orientation 
     203        Variable dimX,dimY,xCtr,yCtr 
     204        dimX = DimSize(data_realDistX,0) 
     205        dimY = DimSize(data_realDistX,1) 
     206        if(dimX > dimY) 
     207                orientation = "horizontal" 
     208        else 
     209                orientation = "vertical" 
     210        endif 
     211         
     212        xCtr = V_getDet_beam_center_x(folder,detStr) 
     213        yCtr = V_getDet_beam_center_y(folder,detStr)     
     214         
     215        Make/O/D/N=1 $(destPath + ":entry:entry:instrument:detector_"+detStr+":beam_center_x_mm") 
     216        Make/O/D/N=1 $(destPath + ":entry:entry:instrument:detector_"+detStr+":beam_center_y_mm") 
     217        WAVE x_mm = $(destPath + ":entry:entry:instrument:detector_"+detStr+":beam_center_x_mm") 
     218        WAVE y_mm = $(destPath + ":entry:entry:instrument:detector_"+detStr+":beam_center_y_mm") 
     219 
     220        Variable tube_width = V_getDet_tubeWidth(folder,detStr) 
     221 
     222// 
     223        if(cmpstr(orientation,"vertical")==0) 
     224                //      this is data dimensioned as (Ntubes,Npix) 
     225//              data_realDistX[][] = tube_width*p 
     226//              data_realDistY[][] = coefW[0][p] + coefW[1][p]*q + coefW[2][p]*q*q 
     227                x_mm[0] = tube_width*xCtr 
     228                y_mm[0] = data_realDistY[0][yCtr] 
     229        else 
     230                //      this is data (horizontal) dimensioned as (Npix,Ntubes) 
     231//              data_realDistX[][] = coefW[0][q] + coefW[1][q]*p + coefW[2][q]*p*p 
     232//              data_realDistY[][] = tube_width*q 
     233                x_mm[0] = data_realDistX[xCtr][0] 
     234                y_mm[0] = tube_width*yCtr 
     235        endif 
     236                 
     237        return(0) 
     238end 
     239 
     240 
     241// 
     242// 
     243// TODO 
     244// -- VERIFY the calculations 
     245// -- verify where this needs to be done (if the beam center is changed) 
     246// -- then the q-calculation needs to be re-done 
     247// -- the position along the tube length is referenced to tube[0], for no particular reason 
     248//    It may be better to take an average? but [0] is an ASSUMPTION 
     249// -- distance along tube is simple interpolation 
     250// 
     251// -- distance in the lateral direction is based on tube width, which is well known 
     252// 
     253// 
     254Function ConvertBeamCtr_to_mmB(folder,detStr,destPath) 
     255        String folder,detStr,destPath 
     256         
     257        Wave data_realDistX = $(destPath + ":entry:entry:instrument:detector_"+detStr+":data_realDistX") 
     258        Wave data_realDistY = $(destPath + ":entry:entry:instrument:detector_"+detStr+":data_realDistY")         
     259         
     260        Variable xCtr,yCtr 
     261        xCtr = V_getDet_beam_center_x(folder,detStr) 
     262        yCtr = V_getDet_beam_center_y(folder,detStr)     
     263         
     264        Make/O/D/N=1 $(destPath + ":entry:entry:instrument:detector_"+detStr+":beam_center_x_mm") 
     265        Make/O/D/N=1 $(destPath + ":entry:entry:instrument:detector_"+detStr+":beam_center_y_mm") 
     266        WAVE x_mm = $(destPath + ":entry:entry:instrument:detector_"+detStr+":beam_center_x_mm") 
     267        WAVE y_mm = $(destPath + ":entry:entry:instrument:detector_"+detStr+":beam_center_y_mm") 
     268 
     269        x_mm[0] = data_realDistX[xCtr][0] 
     270        y_mm[0] = data_realDistY[0][yCtr] 
     271                 
     272        return(0) 
     273end 
     274 
     275 
     276 
     277 
    144278 
    145279 
     
    226360        endfor 
    227361         
     362        // now fake calibration for "B" 
     363        Wave cal_x = V_getDet_cal_x("RAW","B") 
     364        Wave cal_y = V_getDet_cal_y("RAW","B") 
     365         
     366        cal_x = 1               // mm, ignore the other 2 values 
     367        cal_y = 1               // mm 
    228368        return(0) 
    229369End 
    230370 
    231  
    232  
     371// 
     372// data_realDistX, Y must be previously generated from running NonLinearCorrection() 
     373// 
     374// call with: 
     375// fname as the WORK folder, "RAW" 
     376// detStr = detector String, "FL" 
     377// destPath = path to destination WORK folder ("root:Packages:NIST:VSANS:"+folder) 
     378// 
    233379Function V_Detector_CalcQVals(fname,detStr,destPath) 
    234380        String fname,detStr,destPath 
     
    240386        orientation = V_getDet_tubeOrientation(fname,detStr) 
    241387        sdd = V_getDet_distance(fname,detStr) 
    242         xCtr = V_getDet_beam_center_x(fname,detStr) 
    243         yCtr = V_getDet_beam_center_y(fname,detStr) 
     388        sdd/=100                // sdd reported in cm, pass in m 
     389        // this is the ctr in pixels 
     390//      xCtr = V_getDet_beam_center_x(fname,detStr) 
     391//      yCtr = V_getDet_beam_center_y(fname,detStr) 
     392        // this is ctr in mm 
     393        xCtr = V_getDet_beam_center_x_mm(fname,detStr) 
     394        yCtr = V_getDet_beam_center_y_mm(fname,detStr) 
    244395        lambda = V_getWavelength(fname) 
    245396        Wave data_realDistX = $(destPath + ":entry:entry:instrument:detector_"+detStr+":data_realDistX") 
     
    271422// TODO: 
    272423// -- verify the calculation (accuracy - in all input conditions) 
    273 // -- verify the units of everything here, it's currently all jumbled an wrong... 
     424// -- verify the units of everything here, it's currently all jumbled and wrong... and repeated 
    274425// -- the input data_realDistX and Y are essentially lookup tables of the real space distance corresponding 
    275426//    to each pixel 
     
    287438                 
    288439        sdd *=100               //convert to cm 
    289         dx = (distX[xaxval][yaxval] - xctr)             //delta x in cm 
    290         dy = (distY[xaxval][yaxval] - yctr)             //delta y in cm 
     440        dx = (distX[xaxval][yaxval] - xctr)             //delta x in mm 
     441        dy = (distY[xaxval][yaxval] - yctr)             //delta y in mm 
    291442        dist = sqrt(dx^2 + dy^2) 
    292443         
     444        dist /= 10  // convert mm to cm 
     445         
    293446        two_theta = atan(dist/sdd) 
    294447 
     
    301454// TODO: 
    302455// -- verify the calculation (accuracy - in all input conditions) 
    303 // -- verify the units of everything here, it's currently all jumbled an wrong... 
     456// -- verify the units of everything here, it's currently all jumbled and wrong... and repeated 
    304457// -- the input data_realDistX and Y are essentially lookup tables of the real space distance corresponding 
    305458//    to each pixel 
     
    317470         
    318471        sdd *=100               //convert to cm 
    319         dx = (distX[xaxval][yaxval] - xctr)             //delta x in cm 
    320         dy = (distY[xaxval][yaxval] - yctr)             //delta y in cm 
     472        dx = (distX[xaxval][yaxval] - xctr)             //delta x in mm 
     473        dy = (distY[xaxval][yaxval] - yctr)             //delta y in mm 
    321474        phi = V_FindPhi(dx,dy) 
    322475         
    323476        //get scattering angle to project onto flat detector => Qr = qval*cos(theta) 
    324477        dist = sqrt(dx^2 + dy^2) 
     478        dist /= 10  // convert mm to cm 
     479 
    325480        two_theta = atan(dist/sdd) 
    326481 
     
    333488// TODO: 
    334489// -- verify the calculation (accuracy - in all input conditions) 
    335 // -- verify the units of everything here, it's currently all jumbled an wrong... 
     490// -- verify the units of everything here, it's currently all jumbled and wrong... and repeated 
    336491// -- the input data_realDistX and Y are essentially lookup tables of the real space distance corresponding 
    337492//    to each pixel 
     
    349504         
    350505        sdd *=100               //convert to cm 
    351         dx = (distX[xaxval][yaxval] - xctr)             //delta x in cm 
    352         dy = (distY[xaxval][yaxval] - yctr)             //delta y in cm 
     506        dx = (distX[xaxval][yaxval] - xctr)             //delta x in mm 
     507        dy = (distY[xaxval][yaxval] - yctr)             //delta y in mm 
    353508        phi = V_FindPhi(dx,dy) 
    354509         
    355510        //get scattering angle to project onto flat detector => Qr = qval*cos(theta) 
    356511        dist = sqrt(dx^2 + dy^2) 
     512        dist /= 10  // convert mm to cm 
     513 
    357514        two_theta = atan(dist/sdd) 
    358515 
     
    365522// TODO: 
    366523// -- verify the calculation (accuracy - in all input conditions) 
    367 // -- verify the units of everything here, it's currently all jumbled an wrong... 
     524// -- verify the units of everything here, it's currently all jumbled and wrong... and repeated 
    368525// -- the input data_realDistX and Y are essentially lookup tables of the real space distance corresponding 
    369526//    to each pixel 
     
    382539         
    383540        sdd *=100               //convert to cm 
    384         dx = (distX[xaxval][yaxval] - xctr)             //delta x in cm 
    385         dy = (distY[xaxval][yaxval] - yctr)             //delta y in cm 
     541        dx = (distX[xaxval][yaxval] - xctr)             //delta x in mm 
     542        dy = (distY[xaxval][yaxval] - yctr)             //delta y in mm 
    386543         
    387544        //get scattering angle to project onto flat detector => Qr = qval*cos(theta) 
    388545        dist = sqrt(dx^2 + dy^2) 
     546        dist /= 10  // convert mm to cm 
     547 
    389548        two_theta = atan(dist/sdd) 
    390549 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_RW_Utils.ipf

    r983 r984  
    4040// 
    4141// TODO: -- is there an extra "entry" heading? Am I adding this by mistake by setting base_name="entry" for RAW data? 
    42 //                      -- as dumb as it is -- do I just leave it now, or break everything. ont the plus side, removing the extra entry 
     42//                      -- as dumb as it is -- do I just leave it now, or break everything. On the plus side, removing the extra "entry" 
    4343//          layer may catch a lot of the hard-wired junk that is present... 
    4444Function V_LoadHDF5Data(file,folder) 
     
    109109                                NonLinearCorrection(w,w_calib,tube_width,detStr,destPath) 
    110110                                 
     111                                 
     112                                //(2.4) Convert the beam center values from pixels to mm 
     113                                // TODO -- there needs to be a permanent location for these values?? 
     114                                // 
     115                                ConvertBeamCtr_to_mm(folder,detStr,destPath) 
     116                                 
    111117                                // (2.5) Calculate the q-values 
    112118                                // calculating q-values can't be done unless the non-linear corrections are calculated 
     
    122128                                 
    123129                        endfor 
     130                         
     131                        //"B" is separate 
     132                        NonLinearCorrection_B(folder,"B",destPath) 
     133                        ConvertBeamCtr_to_mmB(folder,"B",destPath) 
     134                        V_Detector_CalcQVals(folder,"B",destPath) 
     135                         
    124136                else 
    125137                        Print "Non-linear correction not done" 
     
    157169        det_B=tmpw 
    158170        det_B += 2 
     171        Wave distance=distance 
     172        distance = 2200 
     173 
    159174                         
    160175        Variable ctr=20,npix=128 
     
    170185        det_MT=tmpw 
    171186        det_MT += 2 
     187        Wave distance=distance 
     188        distance = 1030 
     189 
    172190         
    173191        SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_MB 
     
    182200        det_MB=tmpw 
    183201        det_MB += 2 
     202        Wave distance=distance 
     203        distance = 1030 
     204 
    184205         
    185206        ctr=30 
     
    195216        det_ML=tmpw 
    196217        det_ML += 2 
     218        Wave distance=distance 
     219        distance = 1000 
     220 
    197221                 
    198222        SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_MR 
     
    206230        det_MR=tmpw 
    207231        det_MR += 2 
     232        Wave distance=distance 
     233        distance = 1000 
     234         
    208235         
    209236        ctr=30 
     
    216243        wave tmpw=$"root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_FT:det_FT" 
    217244        det_FT=tmpw 
     245        Wave distance=distance 
     246        distance = 180 
     247 
    218248 
    219249        SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FB 
     
    225255        wave tmpw=$"root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_FB:det_FB" 
    226256        det_FB=tmpw 
     257        Wave distance=distance 
     258        distance = 180 
     259 
    227260                         
    228261        SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FL 
     
    234267        wave tmpw=$"root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_FL:det_FL" 
    235268        det_FL=tmpw 
     269        Wave distance=distance 
     270        distance = 150 
     271 
    236272         
    237273        SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FR 
     
    243279        wave tmpw=$"root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_FR:det_FR" 
    244280        det_FR=tmpw 
     281        Wave distance=distance 
     282        distance = 150 
     283 
    245284         
    246285// get rid of zeros 
     
    250289        det_FB += 2 
    251290 
    252 V_RescaleToBeamCenter("RAW","MB",64,55) 
    253 V_RescaleToBeamCenter("RAW","MT",64,-8.7) 
    254 V_RescaleToBeamCenter("RAW","MR",-8.1,64) 
    255 V_RescaleToBeamCenter("RAW","ML",55,64) 
    256 V_RescaleToBeamCenter("RAW","FL",55,64) 
    257 V_RescaleToBeamCenter("RAW","FR",-8.1,64) 
    258 V_RescaleToBeamCenter("RAW","FT",64,-8.7) 
    259 V_RescaleToBeamCenter("RAW","FB",64,55) 
     291 
     292// fake beam center values 
     293        V_putDet_beam_center_x("RAW","B",160) 
     294        V_putDet_beam_center_y("RAW","B",160) 
     295 
     296 
     297        V_putDet_beam_center_x("RAW","MB",64) 
     298        V_putDet_beam_center_y("RAW","MB",55) 
     299        V_putDet_beam_center_x("RAW","MT",64) 
     300        V_putDet_beam_center_y("RAW","MT",-8.7) 
     301        V_putDet_beam_center_x("RAW","MR",-8.1) 
     302        V_putDet_beam_center_y("RAW","MR",64) 
     303        V_putDet_beam_center_x("RAW","ML",55) 
     304        V_putDet_beam_center_y("RAW","ML",64) 
     305 
     306        V_putDet_beam_center_x("RAW","FB",64) 
     307        V_putDet_beam_center_y("RAW","FB",55) 
     308        V_putDet_beam_center_x("RAW","FT",64) 
     309        V_putDet_beam_center_y("RAW","FT",-8.7) 
     310        V_putDet_beam_center_x("RAW","FR",-8.1) 
     311        V_putDet_beam_center_y("RAW","FR",64) 
     312        V_putDet_beam_center_x("RAW","FL",55) 
     313        V_putDet_beam_center_y("RAW","FL",64) 
     314 
     315 
     316 
     317 
     318 
     319 
     320        V_RescaleToBeamCenter("RAW","MB",64,55) 
     321        V_RescaleToBeamCenter("RAW","MT",64,-8.7) 
     322        V_RescaleToBeamCenter("RAW","MR",-8.1,64) 
     323        V_RescaleToBeamCenter("RAW","ML",55,64) 
     324        V_RescaleToBeamCenter("RAW","FL",55,64) 
     325        V_RescaleToBeamCenter("RAW","FR",-8.1,64) 
     326        V_RescaleToBeamCenter("RAW","FT",64,-8.7) 
     327        V_RescaleToBeamCenter("RAW","FB",64,55) 
    260328 
    261329 
     
    269337// this will load in the whole HDF file all at once. 
    270338// Attributes are NOT loaded at all. 
     339// 
     340// -- the Gateway function H5GW_ReadHDF5(parentFolder, fileName, [hdf5Path]) 
     341//    reads in the attributes too, but is very slow 
     342//   -- the H5GW function is called by: H_HDF5Gate_Read_Raw(file) 
    271343// 
    272344// TODO:  
     
    275347// -- be sure I'm using all of the correct flags in the HDF5LoadGroup operation 
    276348// -- settle on how the base_name is to be used. "entry" for the RAW, fileName for the "rawVSANS"? 
     349// x- error check for path existence 
    277350// 
    278351// passing in "" for base_name will take the name from the file name as selected 
     
    284357//              hdf5Path = "/" 
    285358//      endif 
     359 
     360        PathInfo/S catPathName 
     361        if(V_flag == 0) 
     362                V_PickPath() 
     363        endif 
    286364 
    287365        String hdf5path = "/"           //always read from the top 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Read.ipf

    r981 r984  
    10701070// only defined for the "B" detector, and may not be necessary? 
    10711071// TODO -- write to return an ARRAY 
    1072 Function V_getDet_cal_x(fname,detStr,outW) 
    1073         String fname,detStr 
    1074         Wave outW 
     1072Function/WAVE V_getDet_cal_x(fname,detStr) 
     1073        String fname,detStr 
    10751074 
    10761075        if(cmpstr(detStr,"B") == 0) 
     
    10781077                WAVE w = V_getRealWaveFromHDF5(fname,path) 
    10791078 
    1080                 outW = w 
    1081                 return(0) 
     1079                return w 
    10821080        else 
    1083                 return(0) 
     1081                return $"" 
    10841082        endif 
    10851083End 
     
    10871085// only defined for the "B" detector, and may not be necessary? 
    10881086// TODO -- write to return an ARRAY 
    1089 Function V_getDet_cal_y(fname,detStr,outW) 
    1090         String fname,detStr 
    1091         Wave outW 
     1087Function/WAVE V_getDet_cal_y(fname,detStr) 
     1088        String fname,detStr 
    10921089 
    10931090        if(cmpstr(detStr,"B") == 0) 
     
    10951092                WAVE w = V_getRealWaveFromHDF5(fname,path) 
    10961093         
    1097                 outW = w 
    1098                 return(0) 
     1094                return w 
    10991095        else 
    1100                 return(0) 
     1096                return $"" 
    11011097        endif 
    11021098End 
     
    11731169        return(V_getRealValueFromHDF5(fname,path)) 
    11741170End 
     1171 
     1172 
     1173//TODO 
     1174// 
     1175// x and y center in mm is currently not part of the NExus definition 
     1176//  does it need to be? 
     1177// these lookups will fail if they have not been generated locally! 
     1178 
     1179Function V_getDet_beam_center_x_mm(fname,detStr) 
     1180        String fname,detStr 
     1181 
     1182        String path = "entry:instrument:detector_"+detStr+":beam_center_x_mm" 
     1183        return(V_getRealValueFromHDF5(fname,path)) 
     1184End 
     1185 
     1186//TODO 
     1187// 
     1188// x and y center in mm is currently not part of the NExus definition 
     1189//  does it need to be? 
     1190// these lookups will fail if they have not been generated locally! 
     1191 
     1192Function V_getDet_beam_center_y_mm(fname,detStr) 
     1193        String fname,detStr 
     1194 
     1195        String path = "entry:instrument:detector_"+detStr+":beam_center_y_mm" 
     1196        return(V_getRealValueFromHDF5(fname,path)) 
     1197End 
     1198 
     1199 
    11751200 
    11761201// TODO -- write this function to return a WAVE with the data 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_MainPanel.ipf

    r982 r984  
    122122End 
    123123 
    124 Proc FitRPA_MainButtonProc(ctrlName) : ButtonControl 
    125         String ctrlName 
    126  
    127         OpenFITRPAPanel() 
    128 End 
     124//Proc FitRPA_MainButtonProc(ctrlName) : ButtonControl 
     125//      String ctrlName 
     126// 
     127//      OpenFITRPAPanel() 
     128//End 
    129129 
    130130Proc Subtract1D_MainButtonProc(ctrlName) : ButtonControl 
     
    352352        Button MainButton_2c,pos={15,150},size={60,20},proc=Fit1D_MainButtonProc,title="FIT" 
    353353        Button MainButton_2c,help={"Shows panel for performing a variety of linearized fits to 1-D data files. Use \"Plot\" button to import 1-D data files"} 
    354         Button MainButton_2d,pos={15,180},size={60,20},proc=FITRPA_MainButtonProc,title="FIT/RPA" 
    355         Button MainButton_2d,help={"Shows panel for performing a fit to a polymer standard."} 
     354//      Button MainButton_2d,pos={15,180},size={60,20},proc=FITRPA_MainButtonProc,title="FIT/RPA" 
     355//      Button MainButton_2d,help={"Shows panel for performing a fit to a polymer standard."} 
    356356//      Button MainButton_2e,pos={120,90},size={90,20},proc=Subtract1D_MainButtonProc,title="Subtract 1D" 
    357357//      Button MainButton_2e,help={"Shows panel for subtracting two 1-D data sets"} 
     
    363363        Button MainButton_2b,disable=1 
    364364        Button MainButton_2c,disable=1 
    365         Button MainButton_2d,disable=1 
     365//      Button MainButton_2d,disable=1 
    366366        Button MainButton_2e,disable=1 
    367367        Button MainButton_2f,disable=1 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Menu.ipf

    r982 r984  
    2424        End 
    2525End 
    26  
    2726 
    2827 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Test_RAW_Panel.ipf

    r983 r984  
    336336                                        // TODO: beam center XY are pixels in the file, expected in the function, but are better suited for mm or cm 
    337337                                        // TODO: units of xy pixel size are likely wrong 
    338                                         xctr = V_getDet_beam_center_x(gCurDispType,detStr)              //written in pixels 
    339                                         yctr = V_getDet_beam_center_y(gCurDispType,detStr) 
     338//                                      xctr = V_getDet_beam_center_x(gCurDispType,detStr)              //written in pixels 
     339//                                      yctr = V_getDet_beam_center_y(gCurDispType,detStr) 
     340                                        xctr = V_getDet_beam_center_x_mm(gCurDispType,detStr)           //written in mm 
     341                                        yctr = V_getDet_beam_center_y_mm(gCurDispType,detStr)    
     342                                         
    340343                                        sdd = V_getDet_distance(gCurDispType,detStr)    / 100   //written in cm, pass in meters 
    341344                                        lam = V_getVSWavelength(gCurDispType)           //A 
    342                                         pixSizeX = V_getDet_x_pixel_size(gCurDispType,detStr)/10                // written mm? need cm 
    343                                         pixSizeY = V_getDet_y_pixel_size(gCurDispType,detStr)/10                // written mm? need cm 
     345//                                      pixSizeX = V_getDet_x_pixel_size(gCurDispType,detStr)           // written mm? need mm 
     346//                                      pixSizeY = V_getDet_y_pixel_size(gCurDispType,detStr)           // written mm? need mm 
    344347// 
    345348// TODO: these q-values ignore the non-linear corrections!!! 
    346 // -- What can I do about this?  
     349// -- What can I do about this? 
     350                                        String destPath = "root:Packages:NIST:VSANS:"+gCurDispType 
     351                                        Wave data_realDistX = $(destPath + ":entry:entry:instrument:detector_"+detStr+":data_realDistX") 
     352                                        Wave data_realDistY = $(destPath + ":entry:entry:instrument:detector_"+detStr+":data_realDistY")         
     353                                         
    347354// TODO: figure out what coordinates I need to pass -- xloc, yloc, textX, testY, (+1 on any?)                            
    348                                         gQQ = VC_CalcQval(testX,testY,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    349                                         gQX = VC_CalcQX(testX,testY,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    350                                         gQY = VC_CalcQY(testX,testY,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     355                                        //gQQ = VC_CalcQval(testX,testY,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     356                                        //gQX = VC_CalcQX(testX,testY,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     357                                        //gQY = VC_CalcQY(testX,testY,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     358                                        gQQ = V_CalcQval(testX,testY,xctr,yctr,sdd,lam,data_realDistX,data_realDistY) 
     359                                        gQX = V_CalcQX(testX,testY,xctr,yctr,sdd,lam,data_realDistX,data_realDistY) 
     360                                        gQY = V_CalcQY(testX,testY,xctr,yctr,sdd,lam,data_realDistX,data_realDistY) 
    351361 
    352362                                        ii = -1         //look no further, set ii to bad value to exit the for loop 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_WorkFolderUtils.ipf

    r982 r984  
    432432                        Variable tube_width = V_getDet_tubeWidth(fname,detStr) 
    433433                        NonLinearCorrection(w,w_calib,tube_width,detStr,destPath) 
    434                          
     434 
     435                        //(2.4) Convert the beam center values from pixels to mm 
     436                        // TODO -- there needs to be a permanent location for these values?? 
     437                        // 
     438                        ConvertBeamCtr_to_mm(fname,detStr,destPath) 
     439                                                         
    435440                        // (2.5) Calculate the q-values 
    436441                        // calculating q-values can't be done unless the non-linear corrections are calculated 
     
    446451                         
    447452                endfor 
     453                 
     454                //"B" is separate 
     455                NonLinearCorrection_B(fname,"B",destPath) 
     456                ConvertBeamCtr_to_mmB(fname,"B",destPath) 
     457                V_Detector_CalcQVals(fname,"B",destPath) 
     458                 
    448459        else 
    449460                Print "Non-linear correction not done" 
Note: See TracChangeset for help on using the changeset viewer.