Changeset 981 for sans/Dev


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

more changes, filling in functionality of the initial data correction

Location:
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS
Files:
12 edited

Legend:

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

    r960 r981  
    22 
    33 
     4// 
     5// 
     6// 
     7// 
    48// AUG 2015 ************** 
    59//////////// 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/Nexus_VSANS_Write.ipf

    r980 r981  
    201201 
    202202 
    203 ////////////// fake DIV file tests 
    204 // 
    205 // 
    206 //      Make/O/T/N=1    file_name       = "VSANS_DIV_test.h5" 
    207 // 
    208 // simple generation of a fake div file. for sans, nothing other than the creation date was written to the  
    209 // file header. nothing more is needed (possibly) 
    210 // 
    211 // TODO -- I want to re-visit the propagation of errors in the DIV file. No errors are ever calculated/saved  
    212 //   during the generation of the file, but there's no reason it couldn't. the idea is that the plex 
    213 //   is counted so long that the errors are insignificant compared to the data errors, but that may not 
    214 //   always be the case. A bit of math may prove this. or not. Plus, the situation for VSANS may be different. 
    215 // 
    216 // 
    217 // TODO -- make the number of pixels GLOBAL 
    218 // TODO -- there will be lots of work to do to develop the procedures necessary to actually generate the  
    219 //      9 data sets to become the DIV file contents. More complexity here than for the simple SANS case. 
    220 // 
    221 Proc H_Setup_VSANS_DIV_Structure() 
    222          
    223         NewDataFolder/O/S root:VSANS_DIV_file            
    224  
    225         NewDataFolder/O/S root:VSANS_DIV_file:entry      
    226                 Make/O/T/N=1    title   = "This is a fake DIV file for VSANS" 
    227                 Make/O/T/N=1    start_date      = "2015-02-28T08:15:30-5:00" 
    228                 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument           
    229                         Make/O/T/N=1    name    = "NG3_VSANS" 
    230                 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_B        
    231                         Make/O/D/N=(320,320)    data    = abs(gnoise(p+q)) 
    232                         Make/O/D/N=(320,320)    linear_data_error       = 0.01*abs(gnoise(p+q)) 
    233                 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MR               
    234                         Make/O/D/N=(48,128)     data    = abs(gnoise(p+q)) 
    235                         Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(p+q)) 
    236                 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_ML               
    237                         Make/O/D/N=(48,128)     data    = abs(gnoise(p+q)) 
    238                         Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(p+q)) 
    239                 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MT               
    240                         Make/O/D/N=(128,48)     data    = abs(gnoise(p+q)) 
    241                         Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(p+q)) 
    242                 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MB               
    243                         Make/O/D/N=(128,48)     data    = abs(gnoise(p+q)) 
    244                         Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(p+q)) 
    245                 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FR               
    246                         Make/O/D/N=(48,128)     data    = abs(gnoise(p+q)) 
    247                         Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(p+q)) 
    248                 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FL               
    249                         Make/O/D/N=(48,128)     data    = abs(gnoise(p+q)) 
    250                         Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(p+q)) 
    251                 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FT               
    252                         Make/O/D/N=(128,48)     data    = abs(gnoise(p+q)) 
    253                         Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(p+q)) 
    254                 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FB               
    255                         Make/O/D/N=(128,48)     data    = abs(gnoise(p+q)) 
    256                         Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(p+q)) 
    257                          
    258         SetDataFolder root: 
    259  
    260 End 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_BeamCenter.ipf

    r963 r981  
    77// x- when selecting the detector, set the x/y pixel sizes 
    88// -- figure out how to re-plot the images when swapping between LR and TB panels 
    9 // 
     9// -- Modify to accept mm (real space dimensions) rather than pixels 
     10//    -- or be able to swap the answer to mm for a more natural definition of the beam center 
     11// -- add method to be able to write the values to the local folder / or better, to file on disk 
     12// -- graphically show the beam center / radius of where it is in relation to the panel 
    1013 
    1114 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_HDF5_VSANS_Utils.ipf

    r969 r981  
    5555// 
    5656 
    57  
    58 Macro Load_Nexus_V_Template() 
     57Menu "VSANS" 
     58        SubMenu "Nexus File Testing" 
     59                "Fill_Nexus_V_Template" 
     60                "Save_Nexus_V_Template" 
     61                "Load_Nexus_V_Template" 
     62                "-" 
     63                "IgorOnly_Setup_VSANS_Struct" 
     64                "IgorOnly_Save_VSANS_Nexus" 
     65                "IgorOnly_Setup_SANS_Struct" 
     66                "IgorOnly_Save_SANS_Struct" 
     67                "Setup_VSANS_DIV_Struct" 
     68                "Save_VSANS_DIV_Nexus" 
     69        End 
     70End 
     71 
     72 
     73Proc Load_Nexus_V_Template() 
    5974        H_HDF5Gate_Read_Raw("") 
    6075        String tmpStr=root:file_name  //SRK - so I can get the file name that was loaded 
     
    6681 
    6782 
    68 Macro Fill_Nexus_V_Template() 
     83Proc Fill_Nexus_V_Template() 
    6984        H_Fill_VSANS_Template_wSim() 
    7085End 
    7186 
    7287 
    73 Macro Save_Nexus_V_Template() 
     88Proc Save_Nexus_V_Template() 
    7489        H_HDF5Gate_Write_Raw("root:V_Nexus_Template:","") 
    7590End 
     
    94109 
    95110 
    96 Macro IgorOnly_Setup_VSANS_Struct() 
     111Proc IgorOnly_Setup_VSANS_Struct() 
    97112 
    98113        // lays out the tree and fills with dummy values 
     
    107122End 
    108123 
    109 Macro IgorOnly_Save_VSANS_Nexus(fileName) 
     124Proc IgorOnly_Save_VSANS_Nexus(fileName) 
    110125        String fileName="Test_VSANS_file" 
    111126 
     
    135150 
    136151 
    137 Macro IgorOnly_Setup_SANS_Struct() 
     152Proc IgorOnly_Setup_SANS_Struct() 
    138153 
    139154        // lays out the tree and fills with dummy values 
     
    148163End 
    149164 
    150 Macro IgorOnly_Save_SANS_Nexus(fileName) 
     165Proc IgorOnly_Save_SANS_Nexus(fileName) 
    151166        String fileName="Test_SANS_file" 
    152167         
     
    176191 
    177192 
     193 
    178194// TODO 
    179195// currently, there are no dummy fill values or attributes for the fake DIV file 
    180196// 
    181 Macro Setup_VSANS_DIV_Struct() 
     197Proc Setup_VSANS_DIV_Struct() 
    182198 
    183199        // lays out the tree and fills with dummy values 
     
    192208End 
    193209 
    194 Macro Save_VSANS_DIV_Nexus(fileName) 
     210Proc Save_VSANS_DIV_Nexus(fileName) 
    195211        String fileName="Test_VSANS_DIV_file" 
    196212 
     
    216232        H_HDF5Gate_Read_Raw(fileName+".h5") 
    217233         
     234End 
     235 
     236////////////// fake DIV file tests 
     237// 
     238// 
     239//      Make/O/T/N=1    file_name       = "VSANS_DIV_test.h5" 
     240// 
     241// simple generation of a fake div file. for sans, nothing other than the creation date was written to the  
     242// file header. nothing more is needed (possibly) 
     243// 
     244// TODO -- I want to re-visit the propagation of errors in the DIV file. No errors are ever calculated/saved  
     245//   during the generation of the file, but there's no reason it couldn't. the idea is that the plex 
     246//   is counted so long that the errors are insignificant compared to the data errors, but that may not 
     247//   always be the case. A bit of math may prove this. or not. Plus, the situation for VSANS may be different. 
     248// 
     249// 
     250// TODO -- make the number of pixels GLOBAL 
     251// TODO -- there will be lots of work to do to develop the procedures necessary to actually generate the  
     252//      9 data sets to become the DIV file contents. More complexity here than for the simple SANS case. 
     253// 
     254Proc H_Setup_VSANS_DIV_Structure() 
     255         
     256        NewDataFolder/O/S root:VSANS_DIV_file            
     257 
     258        NewDataFolder/O/S root:VSANS_DIV_file:entry      
     259                Make/O/T/N=1    title   = "This is a fake DIV file for VSANS" 
     260                Make/O/T/N=1    start_date      = "2015-02-28T08:15:30-5:00" 
     261                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument           
     262                        Make/O/T/N=1    name    = "NG3_VSANS" 
     263                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_B        
     264                        Make/O/D/N=(320,320)    data    = abs(gnoise(10)) 
     265                        Make/O/D/N=(320,320)    linear_data_error       = 0.01*abs(gnoise(10)) 
     266                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MR               
     267                        Make/O/D/N=(48,128)     data    = abs(gnoise(10)) 
     268                        Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(10)) 
     269                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_ML               
     270                        Make/O/D/N=(48,128)     data    = abs(gnoise(10)) 
     271                        Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(10)) 
     272                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MT               
     273                        Make/O/D/N=(128,48)     data    = abs(gnoise(10)) 
     274                        Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(10)) 
     275                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MB               
     276                        Make/O/D/N=(128,48)     data    = abs(gnoise(10)) 
     277                        Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(10)) 
     278                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FR               
     279                        Make/O/D/N=(48,128)     data    = abs(gnoise(10)) 
     280                        Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(10)) 
     281                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FL               
     282                        Make/O/D/N=(48,128)     data    = abs(gnoise(10)) 
     283                        Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(10)) 
     284                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FT               
     285                        Make/O/D/N=(128,48)     data    = abs(gnoise(10)) 
     286                        Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(10)) 
     287                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FB               
     288                        Make/O/D/N=(128,48)     data    = abs(gnoise(10)) 
     289                        Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(10)) 
     290                         
     291        SetDataFolder root: 
     292 
    218293End 
    219294 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DetectorCorrections.ipf

    r979 r981  
    7676end 
    7777 
     78// 
     79// Non-linear data correction 
     80//  
     81// input is the data array (N tubes x M pixels) 
     82// input of N x M array of quadratic coefficients 
     83// 
     84// output is wave of corrected real space distance corresponding to each pixel of the data 
     85// 
     86// 
     87// TODO 
     88// -- verify the direction of the tubes and indexing 
     89// -- be sure I'm working in the right data folder 
     90// -- clean up when done 
     91// -- calculate + return the error contribution? 
     92// -- do I want this to return a wave? 
     93// -- do I need to write a separate function that returns the distance wave for later calculations? 
     94// -- do I want to make the distance array 2D to keep the x and y dims together? Calculate them all right now? 
     95// -- what else do I need to pass to the function? (fname=folder? detStr?) 
     96// 
     97// 
     98// 
     99Function NonLinearCorrection(dataW,data_errW,coefW) 
     100        Wave dataW,data_errW,coefW 
     101         
     102        // do I count on the orientation as an input, or do I just figure it out on my own? 
     103        String orientation 
     104        Variable dimX,dimY 
     105        dimX = DimSize(dataW,0) 
     106        dimY = DimSize(dataw,1) 
     107        if(dimX > dimY) 
     108                orientation = "horizontal" 
     109        else 
     110                orientation = "vertical" 
     111        endif 
     112 
     113        // make a wave of the same dimensions, in the same data folder for the distance 
     114        // ?? or a 2D wave? 
     115         
     116        // then per tube, do the quadratic calculation to get the real space distance along the tube 
     117        // the distance perpendicular to the tube is n*(8.4mm) per tube index 
     118         
     119        if(cmpstr(orientation,"vertical")==0) 
     120                //      this is data dimensioned as (Ntubes,Npix) 
     121                 
     122 
     123        elseif(cmpstr(orientation,"horizontal")==0) 
     124                //      this is data (horizontal) dimensioned as (Npix,Ntubes) 
     125 
     126         
     127        else             
     128                DoAlert 0,"Orientation not correctly passed in NonLinearCorrection(). No correction done." 
     129        endif 
     130         
     131        return(0) 
     132end 
    78133 
    79134 
     
    101156//// 
    102157 
    103  
    104  
     158// TODO 
     159// get rid of this in the real data 
     160// 
     161// TESTING ONLY 
     162Macro MakeFakeCalibrationWaves() 
     163        // make these in the RAW data folder, before converting to a work folder 
     164        // - then they will be "found" by get() 
     165        // -- only for the tube, not the Back det 
     166         
     167        DoAlert 0, "re-do this and do a better job of filling the fake data" 
     168         
     169        fMakeFakeCalibrationWaves() 
     170End 
     171 
     172 
     173 
     174// TODO 
     175// get rid of this in the real data 
     176// 
     177// TESTING ONLY 
     178// 
     179// orientation does not matter, there are 48 tubes in each bank 
     180// so dimension (3,48) for everything. 
     181// 
     182// -- but the orientation does indicate TB vs LR, which has implications for  
     183//  the (fictional) dimension of the pixel along the tube axis, at least as far 
     184// as for making the fake coefficients. 
     185// 
     186Function fMakeFakeCalibrationWaves() 
     187 
     188        Variable ii,pixSize 
     189        String detStr,fname="RAW",orientation 
     190         
     191        for(ii=0;ii<ItemsInList(ksDetectorListNoB);ii+=1) 
     192                detStr = StringFromList(ii, ksDetectorListNoB, ";") 
     193//              Wave w = V_getDetectorDataW(fname,detStr) 
     194                Make/O/D/N=(3,48) $("root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_"+detStr+":spatial_calibration") 
     195                Wave calib = $("root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_"+detStr+":spatial_calibration") 
     196                // !!!! this overwrites what is there 
     197 
     198                orientation = V_getDet_tubeOrientation(fname,detStr) 
     199                if(cmpstr(orientation,"vertical")==0) 
     200                //      this is vertical tube data dimensioned as (Ntubes,Npix) 
     201                        pixSize = 8                     //V_getDet_y_pixel_size(fname,detStr) 
     202                elseif(cmpstr(orientation,"horizontal")==0) 
     203                //      this is data (horizontal) dimensioned as (Npix,Ntubes) 
     204                        pixSize = 4                     //V_getDet_x_pixel_size(fname,detStr) 
     205                else             
     206                        DoAlert 0,"Orientation not correctly passed in NonLinearCorrection(). No correction done." 
     207                endif 
     208                 
     209                calib[0][] = -64 
     210                calib[1][] = pixSize 
     211                calib[2][] = 2e-4 
     212                 
     213        endfor 
     214         
     215        return(0) 
     216End 
    105217 
    106218 
     
    543655//check before re-implementing 
    544656// 
    545 Proc DIV_a_Workfile(type) 
     657Macro DIV_a_Workfile(type) 
    546658        String type 
    547         Prompt type,"WORK data type",popup,"COR;SAM;EMP;BGD" 
     659        Prompt type,"WORK data type",popup,"SAM;EMP;BGD;ADJ;" 
    548660         
    549661        //macro will take whatever is in SELECTED folder and DIVide it by the current 
    550662        //contents of the DIV folder - the function will check for existence  
    551663        //before proceeding 
     664 
     665//DoAlert 0,"This has not yet been updated for VSANS" 
    552666         
    553667        Variable err 
    554         err = Divide_work(type)         //returns err = 1 if data doesn't exist in specified folders 
     668        err = DIVCorrection(type)               //returns err = 1 if data doesn't exist in specified folders 
    555669         
    556670        if(err) 
    557                 Abort "error in Divide_work" 
    558         endif 
    559          
    560         //contents are always dumped to CAL 
    561         type = "CAL" 
     671                Abort "error in DIVCorrection()" 
     672        endif 
     673         
     674        //contents are NOT always dumped to CAL, but are in the new type folder 
    562675         
    563676        String newTitle = "WORK_"+type 
    564         DoWindow/F SANS_Data 
    565         DoWindow/T SANS_Data, newTitle 
     677        DoWindow/F VSANS_Data 
     678        DoWindow/T VSANS_Data, newTitle 
    566679        KillStrings/Z newTitle 
    567680         
    568681        //need to update the display with "data" from the correct dataFolder 
    569682        //reset the current displaytype to "type" 
    570         String/G root:myGlobals:gDataDisplayType=Type 
    571          
    572         fRawWindowHook() 
    573          
    574 End 
     683        String/G root:Packages:NIST:VSANS:Globals:gCurDispType=Type 
     684         
     685        UpdateDisplayInformation(type) 
     686         
     687End 
     688 
    575689 
    576690// 
     
    578692//   --         DoAlert 0,"This has not yet been updated for VSANS" 
    579693// 
    580 //function will divide the contents of "type" folder with the contents of  
    581 //the DIV folder 
    582 // all data is converted to linear scale for the calculation 
    583 // 
    584 Function Divide_work(type) 
    585         String type 
    586  
    587         DoAlert 0,"This has not yet been updated for VSANS" 
     694//function will divide the contents of "workType" folder with the contents of  
     695//the DIV folder + detStr 
     696// all data is linear scale for the calculation 
     697// 
     698Function DIVCorrection(data,data_err,detStr,workType) 
     699        Wave data,data_err 
     700        String detStr,workType 
    588701         
    589702        //check for existence of data in type and DIV 
    590         // if the desired workfile doesn't exist, let the user know, and abort 
     703        // if the desired data doesn't exist, let the user know, and abort 
    591704        String destPath="" 
    592705 
    593         if(WaveExists($("root:Packages:NIST:"+Type + ":data")) == 0) 
    594                 Print "There is no work file in "+type+"--Aborting" 
     706        if(WaveExists(data) == 0) 
     707                Print "The data wave does not exist in DIVCorrection()" 
    595708                Return(1)               //error condition 
    596709        Endif 
     710         
    597711        //check for DIV 
    598712        // if the DIV workfile doesn't exist, let the user know,and abort 
    599713 
    600         if(WaveExists($"root:Packages:NIST:DIV:data") == 0) 
    601                 Print "There is no work file in DIV --Aborting" 
     714        WAVE/Z div_data = $("root:Packages:NIST:VSANS:DIV:entry:entry:instrument:detector_"+detStr+":data") 
     715        if(WaveExists(div_data) == 0) 
     716                Print "The DIV wave does not exist in DIVCorrection()" 
    602717                Return(1)               //error condition 
    603718        Endif 
    604719        //files exist, proceed 
    605          
    606         //check for log-scaling of the "DIV" data and adjust if necessary 
    607         // should not be needed now - using display flag instead 
    608 //      ConvertFolderToLinearScale("DIV") 
    609          
    610         //copy type information to CAL, wiping out the old contents of the CAL folder first 
    611          
    612         //destPath = "root:Packages:NIST:CAL" 
    613         //SetDataFolder destPath 
    614         //KillWaves/A/Z                 //get rid of the old data in CAL folder 
    615  
    616         //check for log-scaling of the "type" data and adjust if necessary 
    617         // should not be needed now - using display flag instead 
    618 //      ConvertFolderToLinearScale(type) 
    619         //then continue 
    620  
    621         //copy from current dir (type)=destPath to CAL, overwriting CAL contents 
    622         destPath = "root:Packages:NIST:" + type 
    623         Duplicate/O $(destPath + ":data"),$"root:Packages:NIST:CAL:data" 
    624         Duplicate/O $(destPath + ":linear_data"),$"root:Packages:NIST:CAL:linear_data" 
    625         Duplicate/O $(destPath + ":linear_data_error"),$"root:Packages:NIST:CAL:linear_data_error" 
    626 //      Duplicate/O $(destPath + ":vlegend"),$"root:Packages:NIST:CAL:vlegend" 
    627         Duplicate/O $(destPath + ":textread"),$"root:Packages:NIST:CAL:textread" 
    628         Duplicate/O $(destPath + ":integersread"),$"root:Packages:NIST:CAL:integersread" 
    629         Duplicate/O $(destPath + ":realsread"),$"root:Packages:NIST:CAL:realsread" 
    630         //need to save a copy of filelist string too (from the current type folder) 
    631         SVAR oldFileList = $(destPath + ":fileList") 
    632  
    633         //now switch to reference waves in CAL folder 
    634         destPath = "root:Packages:NIST:CAL" 
    635         //make appropriate wave references 
    636         Wave data=$(destPath + ":linear_data")                                  // these wave references point to the data in CAL 
    637 //      Wave data_err=$(destPath + ":linear_data_err")                                  // these wave references point to the data in CAL 
    638         Wave data_copy=$(destPath + ":data")                                    // these wave references point to the data in CAL 
    639         Wave/t textread=$(destPath + ":textread")                       //that are to be directly operated on 
    640         Wave integersread=$(destPath + ":integersread") 
    641         Wave realsread=$(destPath + ":realsread") 
    642         Variable/G $(destPath + ":gIsLogScale")=0                       //make new flag in CAL folder, data is linear scale 
    643         //need to copy filelist string too 
    644         String/G $(destPath + ":fileList") = oldFileList 
    645  
    646         Wave div_data = $"root:Packages:NIST:DIV:data"          //hard-wired in.... 
    647         //do the division, changing data in CAL 
     720 
    648721        data /= div_data 
    649722         
    650723//      data_err /= div_data 
    651724         
    652         // keep "data" in sync with linear_data 
    653         data_copy = data 
    654          
    655         //update CAL header 
    656         textread[1] = date() + " " + time()             //date + time stamp 
    657          
    658725        Return(0) 
    659726End 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_RW_Utils.ipf

    r980 r981  
    2323 
    2424// passing null file string presents a dialog 
    25 Proc LoadFakeDIVData() 
     25Macro LoadFakeDIVData() 
    2626        V_LoadHDF5Data("","DIV") 
    2727End 
     
    7171// TODO -- once I get "real" data, get rid of this call to force the data to be proper dimensions. 
    7272                V_RedimFakeData() 
    73                  
     73// 
     74// TODO -- for the "real" data, may need a step in here to convert integer detector data to DP, or I'll 
     75//          get really odd results from the calculations, and may not even notice. 
     76 
     77// TODO 
     78//  -- get rid of these fake calibration waves as "real" ones are filled in 
     79                Execute "MakeFakeCalibrationWaves()" 
     80//              fMakeFakeCalibrationWaves()             //skips the alert 
     81                 
     82                                 
    7483/// END FAKE DATA CORRECTIONS            
    7584                 
     
    91100                Wave det_B=data 
    92101                Redimension/N=(320,320)/E=1 det_B 
     102                det_B = p+q+2 
    93103                 
    94104                Variable ctr=20,npix=128 
     
    151161                SetScale/I y -npix/2,npix/2,"",det_FR 
    152162 
     163// get rid of zeros 
     164                det_FL += 2 
     165                det_FR += 2 
     166                det_FT += 2 
     167                det_FB += 2 
    153168 
    154169        return(0) 
     
    161176// Attributes are NOT loaded at all. 
    162177// 
    163 // TODO: remove the P=home restriction top make this more generic 
     178// TODO:  
     179// -x remove the P=home restriction top make this more generic (replaced with catPathName from PickPath) 
    164180// -- get rid of bits leftover here that I don't need 
    165181// -- be sure I'm using all of the correct flags in the HDF5LoadGroup operation 
     
    179195 
    180196        Variable fileID = 0 
    181         HDF5OpenFile/R/P=home/Z fileID as fileName              //read file from home directory? 
    182 //      HDF5OpenFile/R/P=catPathName/Z fileID as fileName 
     197//      HDF5OpenFile/R/P=home/Z fileID as fileName              //read file from home directory? 
     198        HDF5OpenFile/R/P=catPathName/Z fileID as fileName 
    183199        if (V_Flag != 0) 
    184200                return 0 
     
    432448// -- do I need to write separate functions for real, integer, etc.? 
    433449//       
    434 // -- change the /P=home to the user-defined data path (which may be home)               
     450// -x change the /P=home to the user-defined data path (catPathName)             
    435451// 
    436452Function V_WriteWaveToHDF(fname, groupName, varName, wav) 
     
    443459         
    444460        try      
    445                 HDF5OpenFile/P=home /Z fileID  as fname  //open file read-write 
     461                HDF5OpenFile/P=catPathName /Z fileID  as fname  //open file read-write 
    446462                if(!fileID) 
    447463                        err = 1 
     
    518534// TODO 
    519535// 
    520 // -- change the /P=home to the user-defined data path (which may be home)               
     536// -x change the /P=home to the user-defined data path (catPathName)             
    521537// 
    522538Function V_WriteTextWaveToHDF(fname, groupName, varName, wav) 
     
    529545         
    530546        try      
    531                 HDF5OpenFile/P=home /Z fileID  as fname  //open file read-write 
     547                HDF5OpenFile/P=catPathName /Z fileID  as fname  //open file read-write 
    532548                if(!fileID) 
    533549                        err = 1 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Read.ipf

    r979 r981  
    465465end 
    466466 
     467// transmission value (error) for the attenuator in the beam 
     468// use this, but if something wrong, the tables are present 
     469Function V_getAttenuator_trans_err(fname) 
     470        String fname 
     471         
     472        String path = "entry:instrument:attenuator:attenuator_transmission_error"        
     473        return(V_getRealValueFromHDF5(fname,path)) 
     474end 
    467475 
    468476// distance from the attenuator to the sample (units??) 
     
    12511259End 
    12521260 
     1261Function V_getDet_VerticalOffset(fname,detStr) 
     1262        String fname,detStr 
     1263 
     1264        String path = "entry:instrument:detector_"+detStr+":vertical_offset" 
     1265        return(V_getRealValueFromHDF5(fname,path)) 
     1266End 
     1267 
     1268 
    12531269// only defined for the "B" detector, and only to satisfy NXsas 
    12541270Function V_getDet_polar_angle(fname,detStr) 
     
    13401356// TODO -- write this function to return a WAVE with the data 
    13411357// either as a wave reference, or as an input parameter 
    1342 Function V_getDetTube_spatialCalib(fname,detStr,outW) 
    1343         String fname,detStr 
    1344         Wave outW 
     1358Function/WAVE V_getDetTube_spatialCalib(fname,detStr) 
     1359        String fname,detStr 
    13451360 
    13461361        String path = "entry:instrument:detector_"+detStr+":spatial_calibration" 
    13471362        if(cmpstr(detStr,"B") == 0) 
    1348                 return(0) 
     1363                return $("")    // return should be null 
    13491364        else 
    13501365                WAVE w = V_getRealWaveFromHDF5(fname,path) 
    1351          
    1352                 outW = w 
    1353                 return(0) 
     1366                return w 
    13541367        endif 
    13551368End 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Write.ipf

    r979 r981  
    997997end 
    998998 
     999// transmission value (error) for the attenuator in the beam 
     1000// use this, but if something wrong, the tables are present 
     1001Function V_writeAttenuator_trans_err(fname,val) 
     1002        String fname 
     1003        Variable val 
     1004         
     1005//      String path = "entry:instrument:attenuator:attenuator_transmission_error"        
     1006         
     1007        Make/O/D/N=1 wTmpWrite 
     1008//      Make/O/R/N=1 wTmpWrite 
     1009        String groupName = "/entry/instrument/attenuator"        
     1010        String varName = "attenuator_transmission_error" 
     1011        wTmpWrite[0] = val 
     1012 
     1013        variable err 
     1014        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite) 
     1015        if(err) 
     1016                Print "HDF write err = ",err 
     1017        endif 
     1018        // now be sure to kill the data folder to force a re-read of the data next time this file is read in 
     1019        err = V_KillNamedDataFolder(fname) 
     1020        if(err) 
     1021                Print "DataFolder kill err = ",err 
     1022        endif 
     1023        return(err) 
     1024end 
     1025 
    9991026 
    10001027// distance from the attenuator to the sample (units??) 
     
    33913418End 
    33923419 
     3420Function V_writeDet_VerticalOffset(fname,detStr,val) 
     3421        String fname,detStr 
     3422        Variable val 
     3423 
     3424//      String path = "entry:instrument:detector_"+detStr+":vertical_offset" 
     3425         
     3426        Make/O/D/N=1 wTmpWrite 
     3427//      Make/O/R/N=1 wTmpWrite 
     3428        String groupName = "/entry/instrument/detector_"+detStr  
     3429        String varName = "vertical_offset" 
     3430        wTmpWrite[0] = val 
     3431 
     3432        variable err 
     3433        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite) 
     3434        if(err) 
     3435                Print "HDF write err = ",err 
     3436        endif 
     3437        // now be sure to kill the data folder to force a re-read of the data next time this file is read in 
     3438        err = V_KillNamedDataFolder(fname) 
     3439        if(err) 
     3440                Print "DataFolder kill err = ",err 
     3441        endif 
     3442        return(err) 
     3443End 
     3444 
    33933445// only defined for the "B" detector, and only to satisfy NXsas 
    33943446Function V_writeDet_polar_angle(fname,detStr,val) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_MainPanel.ipf

    r979 r981  
    143143        String ctrlName 
    144144 
    145         ChangeDisplay() 
     145        V_ChangeDisplay() 
    146146End 
    147147 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Test_RAW_Panel.ipf

    r979 r981  
    66// this will become the equivalent of "RawWindowHook" 
    77// 
    8 // Procedures to display the detector data along with whatever visualization tools 
    9 // necessary to understand the data 
    10 // 
     8// Procedures to: 
     9// display the detector data 
     10// visualization tools 
     11// mouse interaction 
     12// status information necessary to understand the data 
     13// buttons to more functionality to process data 
    1114 
    1215 
     
    3437         
    3538        DoWindow/F VSANS_Data 
    36         Print V_flag 
     39//      Print V_flag 
    3740        if(V_flag==0) 
    3841         
     
    4043                 
    4144                VSANS_DataPanel()               //draws the panel 
    42                 // fake a click on all three tabs - to populate the data 
    43                 FakeTabClick(2) 
    44                 FakeTabClick(1) 
    45                 FakeTabClick(0) 
     45 
    4646        endif 
    4747         
     
    4949        // what isn't automatically picked up? What is "stale" on the display? 
    5050        String/G root:Packages:NIST:VSANS:Globals:gCurDispType = type 
     51         
     52        // fake a click on all three tabs - to populate the data 
     53        FakeTabClick(2) 
     54        FakeTabClick(1) 
     55        FakeTabClick(0) 
    5156//      DoWindow/T VSANS_Data,type + " VSANS_Data" 
     57 
     58        String newTitle = "WORK_"+type 
     59        DoWindow/F VSANS_Data 
     60        DoWindow/T VSANS_Data, newTitle 
     61        KillStrings/Z newTitle 
     62         
    5263end 
    5364 
     
    354365//  x- remove the dependency on VCALC being initialized first, and using dummy waves from there... 
    355366// 
     367// -- can I use "ReplaceWave" to do this? 
    356368Function VDataTabProc(tca) : TabControl 
    357369        STRUCT WMTabControlAction &tca 
     
    368380                        SetDataFolder root: 
    369381                         
     382                        SVAR dataType = root:Packages:NIST:VSANS:Globals:gCurDispType 
     383                         
     384                        //************ 
     385                        // -- can I use "ReplaceWave/W=VSANS_Data#det_panelsB allinCDF" to do this? 
     386                        // -- only works for "B", since for M and F panels, all 4 data sets are named "data" 
     387                        // in their respective folders... 
     388 
     389                        String tmpStr 
     390                        Variable ii 
    370391                        if(tab==2) 
    371                                 //SetDataFolder root:Packages:NIST:VSANS:VCALC:Back 
    372                                 //Wave det_B 
    373                                 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_B 
     392                                tmpStr = ImageNameList("VSANS_Data#det_panelsB",";") 
     393                                // for some odd reason, it appears that I need to work from the back of the list 
     394                                // since the traces get "renumbered" as I take them off !! A do loop may be a better choice 
     395                                if(ItemsInList(tmpStr) > 0) 
     396                                        do 
     397                                                RemoveImage /W=VSANS_Data#det_panelsB $(StringFromList(0,tmpStr,";"))           //get 1st item 
     398                                                tmpStr = ImageNameList("VSANS_Data#det_panelsB",";")                                                            //refresh list 
     399                                        while(ItemsInList(tmpStr) > 0) 
     400                                endif 
     401                                 
     402                                SetDataFolder $("root:Packages:NIST:VSANS:"+dataType+":entry:entry:instrument:detector_B") 
    374403                                Wave det_B=data 
    375                                 CheckDisplayed /W=VSANS_Data#det_panelsB det_B 
    376                                 if(V_flag == 0) 
     404                                 
     405                                CheckDisplayed /W=VSANS_Data#det_panelsB det_B   
     406                                if(V_flag == 0)         // 0 == data is not displayed, so append it 
    377407                                        AppendImage/W=VSANS_Data#det_panelsB det_B 
    378 //                                      ModifyImage/W=VSANS_Data#det_panelsB det_B ctab= {*,*,ColdWarm,0} 
    379408                                        ModifyImage/W=VSANS_Data#det_panelsB ''#0 ctab= {*,*,ColdWarm,0} 
    380409                                endif 
     
    388417         
    389418                        if(tab==1) 
    390                                 //SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle 
    391                                 //Wave det_MR,det_ML,det_MB,det_MT 
    392                                 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_ML 
    393                                 Wave det_ML=data 
    394                                 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_MR 
     419                                tmpStr = ImageNameList("VSANS_Data#det_panelsM",";") 
     420                                // for some odd reason, it appears that I need to work from the back of the list 
     421                                // since the traces get "renumbered" as I take them off !! A do loop may be a better choice 
     422                                if(ItemsInList(tmpStr) > 0) 
     423                                        do 
     424                                                RemoveImage /W=VSANS_Data#det_panelsM $(StringFromList(0,tmpStr,";"))           //get 1st item 
     425                                                tmpStr = ImageNameList("VSANS_Data#det_panelsM",";")                                                            //refresh list 
     426                                        while(ItemsInList(tmpStr) > 0) 
     427                                endif 
     428 
     429                                SetDataFolder $("root:Packages:NIST:VSANS:"+dataType+":entry:entry:instrument:detector_ML") 
     430                                Wave det_ML=data                                 
     431                                SetDataFolder $("root:Packages:NIST:VSANS:"+dataType+":entry:entry:instrument:detector_MR") 
    395432                                Wave det_MR=data 
    396                                 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_MT 
     433                                SetDataFolder $("root:Packages:NIST:VSANS:"+dataType+":entry:entry:instrument:detector_MT") 
    397434                                Wave det_MT=data 
    398                                 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_MB 
     435                                SetDataFolder $("root:Packages:NIST:VSANS:"+dataType+":entry:entry:instrument:detector_MB") 
    399436                                Wave det_MB=data 
     437 
    400438                                CheckDisplayed /W=VSANS_Data#det_panelsM det_MR 
    401439                                if(V_flag == 0) 
     
    404442                                        AppendImage/W=VSANS_Data#det_panelsM det_ML 
    405443                                        AppendImage/W=VSANS_Data#det_panelsM det_MR 
    406 //                                      ModifyImage/W=VSANS_Data#det_panelsM det_MT ctab= {*,*,ColdWarm,0} 
    407 //                                      ModifyImage/W=VSANS_Data#det_panelsM det_MB ctab= {*,*,ColdWarm,0} 
    408 //                                      ModifyImage/W=VSANS_Data#det_panelsM det_ML ctab= {*,*,ColdWarm,0} 
    409 //                                      ModifyImage/W=VSANS_Data#det_panelsM det_MR ctab= {*,*,ColdWarm,0} 
    410444                                        ModifyImage/W=VSANS_Data#det_panelsM ''#0 ctab= {*,*,ColdWarm,0}                // ''#n means act on the nth image (there are 4) 
    411445                                        ModifyImage/W=VSANS_Data#det_panelsM ''#1 ctab= {*,*,ColdWarm,0} 
     
    422456 
    423457                        if(tab==0) 
    424                                 //SetDataFolder root:Packages:NIST:VSANS:VCALC:Front 
    425                                 //Wave det_FL,det_FR,det_FT,det_FB 
    426                                 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FL 
     458                                tmpStr = ImageNameList("VSANS_Data#det_panelsF",";") 
     459                                // for some odd reason, it appears that I need to work from the back of the list 
     460                                // since the traces get "renumbered" as I take them off !! A do loop may be a better choice 
     461                                if(ItemsInList(tmpStr) > 0) 
     462                                        do 
     463                                                RemoveImage /W=VSANS_Data#det_panelsF $(StringFromList(0,tmpStr,";"))           //get 1st item 
     464                                                tmpStr = ImageNameList("VSANS_Data#det_panelsF",";")                                                            //refresh list 
     465                                        while(ItemsInList(tmpStr) > 0) 
     466                                endif 
     467 
     468                                SetDataFolder $("root:Packages:NIST:VSANS:"+dataType+":entry:entry:instrument:detector_FL") 
    427469                                Wave det_FL=data 
    428                                 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FR 
     470                                SetDataFolder $("root:Packages:NIST:VSANS:"+dataType+":entry:entry:instrument:detector_FR") 
    429471                                Wave det_FR=data 
    430                                 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FT 
    431                                 Wave det_FT=data 
    432                                 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FB 
     472                                SetDataFolder $("root:Packages:NIST:VSANS:"+dataType+":entry:entry:instrument:detector_FT") 
     473                                Wave det_FT=data                                 
     474                                SetDataFolder $("root:Packages:NIST:VSANS:"+dataType+":entry:entry:instrument:detector_FB") 
    433475                                Wave det_FB=data 
     476                                                                 
    434477                                CheckDisplayed /W=VSANS_Data#det_panelsF det_FL 
    435478                                if(V_flag == 0) 
     
    438481                                        AppendImage/W=VSANS_Data#det_panelsF det_FL 
    439482                                        AppendImage/W=VSANS_Data#det_panelsF det_FR 
    440 //                                      ModifyImage/W=VSANS_Data#det_panelsF det_FT ctab= {*,*,ColdWarm,0} 
    441 //                                      ModifyImage/W=VSANS_Data#det_panelsF det_FB ctab= {*,*,ColdWarm,0} 
    442 //                                      ModifyImage/W=VSANS_Data#det_panelsF det_FL ctab= {*,*,ColdWarm,0} 
    443 //                                      ModifyImage/W=VSANS_Data#det_panelsF det_FR ctab= {*,*,ColdWarm,0} 
    444483                                        ModifyImage/W=VSANS_Data#det_panelsF ''#0 ctab= {*,*,ColdWarm,0} 
    445484                                        ModifyImage/W=VSANS_Data#det_panelsF ''#1 ctab= {*,*,ColdWarm,0} 
     
    454493                                SetDataFolder root: 
    455494                        endif 
    456                          
     495 
     496// make sure log scaling is correct                      
     497                        NVAR state = root:Packages:NIST:VSANS:Globals:gIsLogScale 
     498                         
     499                        // on the front:                         
     500                        ModifyImage/W=VSANS_Data#det_panelsF ''#0 log=State 
     501                        ModifyImage/W=VSANS_Data#det_panelsF ''#1 log=State 
     502                        ModifyImage/W=VSANS_Data#det_panelsF ''#2 log=State 
     503                        ModifyImage/W=VSANS_Data#det_panelsF ''#3 log=State 
     504                        //on the middle: 
     505                        ModifyImage/W=VSANS_Data#det_panelsM ''#0 log=State 
     506                        ModifyImage/W=VSANS_Data#det_panelsM ''#1 log=State 
     507                        ModifyImage/W=VSANS_Data#det_panelsM ''#2 log=State 
     508                        ModifyImage/W=VSANS_Data#det_panelsM ''#3 log=State 
     509                        // on the back: 
     510                        ModifyImage/W=VSANS_Data#det_panelsB ''#0 log=State 
     511//// 
     512         
    457513                                                 
    458514                        break 
     
    602658 
    603659 
    604 // TODO 
     660// TODO -- this appears to be complete... 
    605661// toggle the (z) value of the display log/lin 
    606662// 
     
    658714// TODO 
    659715// possibly function to "tag" files right here in the disaply with things 
    660 // like their intent, or other values that reduction will need,  
     716// like their intent, or other values that reduction will need, kind of like a "quick patch" 
     717// with limited functionality (since full function would be a nightmare!)  
    661718Function TagFileButtonProc(ba) : ButtonControl 
    662719        STRUCT WMButtonAction &ba 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Utilities_General.ipf

    r979 r981  
    4242End 
    4343 
     44// 
     45// entry from the Main Panel 
     46// 
     47Proc V_ChangeDisplay(type) 
     48        String type 
     49        Prompt type,"WORK data type to display",popup,"RAW;SAM;EMP;BGD;ADJ;" 
     50 
     51        UpdateDisplayInformation(type) 
     52End 
    4453 
    4554// 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_WorkFolderUtils.ipf

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