Ignore:
Timestamp:
Apr 22, 2016 5:02:30 PM (7 years ago)
Author:
srkline
Message:

lots of changes to plotting of q-values, generating fake data with non-linear corrections, masking of data, etc.

File:
1 edited

Legend:

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

    r992 r993  
    2121Strconstant ksBaseDFPath = "root:Packages:NIST:VSANS:RawVSANS:" 
    2222 
     23// the list of WORK Folders 
     24Strconstant ksWorkFolderList = "RAW;SAM;EMP;BGD;COR;DIV;ABS;MSK;CAL;STO;SUB;DRK;ADJ;VCALC;RawVSANS;" 
     25 
    2326 
    2427// passing null file string presents a dialog 
    2528Macro LoadFakeDIVData() 
    2629        V_LoadHDF5Data("","DIV") 
     30End 
     31 
     32// passing null file string presents a dialog 
     33Macro LoadFakeMASKData() 
     34        V_LoadHDF5Data("","MSK") 
    2735End 
    2836 
     
    3947//    This is a fake since I don't have anything close to correct fake data yet. (1/29/16) 
    4048// 
    41 // 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. On the plus side, removing the extra "entry" 
     49// DONE: x- is there an extra "entry" heading? Am I adding this by mistake by setting base_name="entry" for RAW data? 
     50//                      x- as dumb as it is -- do I just leave it now, or break everything. On the plus side, removing the extra "entry" 
    4351//          layer may catch a lot of the hard-wired junk that is present... 
     52//      extra entry layer is no longer generated for any WORK folders 
     53// 
    4454Function V_LoadHDF5Data(file,folder) 
    4555        String file,folder 
     
    5262        destPath = "root:Packages:NIST:VSANS:"+folder 
    5363 
    54         if(cmpstr(folder,"RAW")==0) 
    55 //              base_name="entry" 
    56                 base_name="RAW"         // this acts as a flag to remove the duplicate "entry" level 
    57         else 
    58         // null will use the file name as the top level (above entry) 
    59                 base_name=""            //TODO -- remove this / change behavior in V_LoadHDF5_NoAtt() 
    60         endif 
    61          
    62         Variable err= V_LoadHDF5_NoAtt(file,base_name)  // reads into current folder 
     64        Variable err= V_LoadHDF5_NoAtt(file,folder)     // reads into current folder 
    6365         
    6466        // if RAW data, then generate the errors and linear data copy 
     
    7173         
    7274                // TODO -- once I get "real" data, get rid of this call to force the data to be proper dimensions. 
    73                 V_RedimFakeData() 
    74  
    75                 // makes data error and linear copy -- DP waves if V_RedimFakeData() called above  
     75//              V_RedimFakeData() 
     76                 
     77                V_MakeDataWaves_DP(folder) 
     78//              V_FakeBeamCenters() 
     79//              V_FakeScaleToCenter() 
     80                 
     81 
     82                // makes data error and linear copy -- DP waves if V_MakeDataWaves_DP() called above  
    7683                for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
    7784                        detStr = StringFromList(ii, ksDetectorListAll, ";") 
     
    7986                endfor 
    8087 
    81  
    82                 // TODO -- for the "real" data, may need a step in here to convert integer detector data to DP, or I'll 
    83                 //          get really odd results from the calculations, and may not even notice. 
    84                 // !!!! Where do I actually do this? - this is currently done in Raw_to_work() 
    85                 // -- is is better to do here, right as the data is loaded? 
    86                 // TODO -- some of this is done in V_RedimFakeData() above - which will disappear once I get real data 
    87  
    88          
    8988                // TODO 
    9089                //  -- get rid of these fake calibration waves as "real" ones are filled in by NICE 
    91                  
    92                 Execute "MakeFakeCalibrationWaves()" 
     90//              (currently does nothing) 
     91//              Execute "MakeFakeCalibrationWaves()" 
    9392                 
    9493                //              fMakeFakeCalibrationWaves()             //skips the alert 
     
    149148End 
    150149 
     150// fname is the folder = "RAW" 
     151Function V_MakeDataWaves_DP(fname) 
     152        String fname 
     153         
     154        Variable ii 
     155        String detStr 
     156         
     157        for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
     158                detStr = StringFromList(ii, ksDetectorListAll, ";") 
     159                Wave w = V_getDetectorDataW(fname,detStr) 
     160//              Wave w_err = V_getDetectorDataErrW(fname,detStr) 
     161                Redimension/D w 
     162//              Redimension/D w_err 
     163        endfor 
     164         
     165        return(0) 
     166End 
     167 
     168 
     169 
    151170// 
    152171// TODO -- this is all FAKED since all the data arrays are written to hdf as (1,128,128) 
     
    155174// the SetScale parts may be useful later. 
    156175// 
     176// This is NOT CALLED anymore. 
     177// the rescaling (SetScale) of the data sets is still done separately to a "fake" beam center 
    157178Function V_RedimFakeData() 
    158179         
     
    295316        V_putDet_beam_center_y("RAW","B",75) 
    296317 
    297  
    298318        V_putDet_beam_center_x("RAW","MB",64) 
    299319        V_putDet_beam_center_y("RAW","MB",55) 
     
    315335 
    316336 
    317  
    318  
    319  
    320  
    321337        V_RescaleToBeamCenter("RAW","MB",64,55) 
    322338        V_RescaleToBeamCenter("RAW","MT",64,-8.7) 
     
    388404         
    389405        //   read the data (too bad that HDF5LoadGroup does not read the attributes) 
    390         if(cmpstr(base_name,"") == 0) 
     406//      if(cmpstr(base_name,"") == 0) 
     407//              base_name = StringFromList(0,FileName,".") 
     408//      endif 
     409         
     410        // if base_name is from my list of WORK folders, then base_name = "" 
     411        // use a stringSwitch? WhichListItem? 
     412        Variable isFolder = WhichListItem(base_name,ksWorkFolderList) 
     413        if(isFolder != -1) 
     414                base_name = "" 
     415        else 
    391416                base_name = StringFromList(0,FileName,".") 
    392417        endif 
    393         if(cmpstr(base_name,"RAW") == 0) 
    394                 base_name = "" 
    395         endif 
    396         //base_name = "entry" 
    397418         
    398419        HDF5LoadGroup/Z/L=7/O/R/T=$base_name  :, fileID, hdf5Path               //      recursive 
     
    856877 
    857878 
    858  
    859  
    860 //////// function to take VCALC information and  
    861 // fill in the simulated information as needed to make a "fake" data file 
    862 // 
    863 // TODO: 
    864 // -- identify all of the necessary bits to change 
    865 // -- maybe want a panel to make it easier to decide what inputs to change in the file 
    866 // -- decide if it's better to write wholesale, or as individual waves 
    867 // 
    868 Macro Copy_VCALC_to_VSANSFile() 
    869          
    870         String fileName = V_DoSaveFileDialog("pick the file to write to") 
    871         print fileName 
    872 //       
    873         if(strlen(fileName) > 0) 
    874                 writeVCALC_to_file(fileName) 
    875         endif 
    876 End 
    877  
    878 // 
    879 // TODO -- fill this in as needed to get fake data that's different 
    880 // 
    881 Function writeVCALC_to_file(fileName) 
    882         String fileName 
    883  
    884  
    885 // the detectors, all 9 + the correct SDD (that accounts for the offset of T/B panels 
    886 // the data itself (as INT32) 
    887 // the front SDD (correct units) 
    888 // the middle SDD (correct units) 
    889 // the back SDD (correct units) 
    890         Variable ii,val 
    891         String detStr 
    892         for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
    893                 detStr = StringFromList(ii, ksDetectorListAll, ";") 
    894                 Duplicate/O $("root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_"+detStr+":det_"+detStr) tmpData 
    895                 Redimension/I tmpData 
    896                 tmpData = (tmpData ==   2147483647) ? 0 : tmpData               //the NaN "mask" in the sim data (T/B only)shows up as an ugly integer 
    897                 V_writeDetectorData(fileName,detStr,tmpData) 
    898                  
    899                 val = VCALC_getTopBottomSDDOffset(detStr)/10 + VCALC_getSDD(detStr)*100         // make sure value is in cm 
    900                 print val 
    901                 V_writeDet_distance(fileName,detStr,val) 
    902                  
    903 // x and y pixel sizes for each detector 
    904 //Function VCALC_getPixSizeX(type)              // returns the pixel X size, in [cm] 
    905 //Function VCALC_getPixSizeY(type) 
    906         V_writeDet_x_pixel_size(fileName,detStr,VCALC_getPixSizeX(detStr)*10)           // data file is expecting mm 
    907         V_writeDet_y_pixel_size(fileName,detStr,VCALC_getPixSizeY(detStr)*10) 
    908          
    909 // the calibration data for each detector 
    910 //V_writeDetTube_spatialCalib(fname,detStr,inW) 
    911 // and for "B" 
    912 //V_writeDet_cal_x(fname,detStr,inW) 
    913 //V_writeDet_cal_y(fname,detStr,inW) 
    914  
    915                  
    916 // the dead time for each detector 
    917 // V_writeDetector_deadtime(fname,detStr,inW) 
    918 // TODO: need a new, separate function to write the single deadtime value in/out of "B" 
    919  
    920         endfor 
    921          
    922         // TODO testing - delete this 
    923                 V_writeDet_beam_center_x(fileName,detStr,321) 
    924  
    925  
    926  
    927 //? other detector geometry - lateral separation? 
    928  
    929 // the wavelength 
    930 //      Variable lam = V_getWavelength("VCALC")         //doesn't work, the corresponding folder in VCALC has not been defined 
    931         V_writeWavelength(fileName,VCALC_getWavelength()) 
    932  
    933 // description of the sample 
    934  
    935 // sample information 
    936 // name, title, etc 
    937          
    938 // fake the information about the count setup, so I have different numbers to read 
    939 // count time = fake 
    940  
    941 // monitor count (= imon) 
    942 // returns the number of neutrons on the sample 
    943 //Function VCALC_getImon() 
    944  
    945 // ?? anything else that I'd like to see on the catalog - I could change them here to see different values 
    946 // different collimation types? 
    947 // 
    948  
    949         return(0) 
    950 end 
    951  
    952  
    953  
    954  
Note: See TracChangeset for help on using the changeset viewer.