Ignore:
Timestamp:
Mar 17, 2016 5:00:30 PM (7 years ago)
Author:
srkline
Message:

lots of changes to how VCALC simulations can be written to Nexus files to effectively make test data with different callues before the virtual machine is ready. many changes for visualization to effectively handle zeros in log scaled images

File:
1 edited

Legend:

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

    r985 r987  
    8989                // TODO 
    9090                //  -- get rid of these fake calibration waves as "real" ones are filled in by NICE 
     91                 
    9192                Execute "MakeFakeCalibrationWaves()" 
     93                 
    9294                //              fMakeFakeCalibrationWaves()             //skips the alert 
    9395 
     
    163165        SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_B 
    164166        Wave det_B=data 
    165         Redimension/N=(150,150)/E=1 det_B        
     167//      Redimension/N=(150,150)/E=1 det_B        
    166168        Redimension/D det_B 
    167 //      det_B = p+q+2 
    168169        wave tmpw=$"root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_B:det_B" 
    169         det_B=tmpw 
    170         det_B += 2 
     170//      det_B=tmpw 
     171//      det_B += 2 
    171172        Wave distance=distance 
    172         distance = 2200 
     173        distance = VCALC_getSDD("B")*100                // to convert m to cm 
    173174 
    174175                         
     
    176177        SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_MT 
    177178        Wave det_MT=data 
    178         Redimension/N=(npix,48)/E=1 det_MT 
     179//      Redimension/N=(npix,48)/E=1 det_MT 
    179180        Redimension/D det_MT             
    180181        SetScale/I x -npix/2,npix/2,"",det_MT 
     
    183184//      det_MT += 2 
    184185        wave tmpw=$"root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_MT:det_MT" 
    185         det_MT=tmpw 
    186         det_MT += 2 
     186//      det_MT=tmpw 
     187//      det_MT += 2 
    187188        Wave distance=distance 
    188         distance = 1030 
     189        distance = VCALC_getSDD("MT")*100               // to convert m to cm 
    189190 
    190191         
    191192        SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_MB 
    192193        Wave det_MB=data 
    193         Redimension/N=(npix,48)/E=1 det_MB               
     194//      Redimension/N=(npix,48)/E=1 det_MB               
    194195        Redimension/D det_MB 
    195196        SetScale/I x -npix/2,npix/2,"",det_MB 
     
    198199//      det_MB += 2 
    199200        wave tmpw=$"root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_MB:det_MB" 
    200         det_MB=tmpw 
    201         det_MB += 2 
     201//      det_MB=tmpw 
     202//      det_MB += 2 
    202203        Wave distance=distance 
    203         distance = 1030 
     204        distance = VCALC_getSDD("MB")*100               // to convert m to cm 
    204205 
    205206         
     
    207208        SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_ML 
    208209        Wave det_ML=data 
    209         Redimension/N=(48,npix)/E=1 det_ML               
     210//      Redimension/N=(48,npix)/E=1 det_ML               
    210211        Redimension/D det_ML 
    211212        SetScale/I x -ctr-48,-ctr,"",det_ML 
     
    214215//      det_ML += 2 
    215216        wave tmpw=$"root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_ML:det_ML" 
    216         det_ML=tmpw 
    217         det_ML += 2 
     217//      det_ML=tmpw 
     218//      det_ML += 2 
    218219        Wave distance=distance 
    219         distance = 1000 
     220        distance = VCALC_getSDD("ML")*100               // to convert m to cm 
    220221 
    221222                 
    222223        SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_MR 
    223224        Wave det_MR=data 
    224         Redimension/N=(48,npix)/E=1 det_MR               
     225//      Redimension/N=(48,npix)/E=1 det_MR               
    225226        Redimension/D det_MR 
    226227        SetScale/I x ctr,ctr+48,"",det_MR 
     
    228229//      det_MR +=2 
    229230        wave tmpw=$"root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_MR:det_MR" 
    230         det_MR=tmpw 
    231         det_MR += 2 
     231//      det_MR=tmpw 
     232//      det_MR += 2 
    232233        Wave distance=distance 
    233         distance = 1000 
     234        distance = VCALC_getSDD("MR")*100               // to convert m to cm 
    234235         
    235236         
     
    237238        SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FT 
    238239        Wave det_FT=data 
    239         Redimension/N=(npix,48)/E=1 det_FT               
     240//      Redimension/N=(npix,48)/E=1 det_FT               
    240241        Redimension/D det_FT 
    241242        SetScale/I x -npix/2,npix/2,"",det_FT 
    242243        SetScale/I y ctr,ctr+48,"",det_FT 
    243244        wave tmpw=$"root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_FT:det_FT" 
    244         det_FT=tmpw 
     245//      det_FT=tmpw 
    245246        Wave distance=distance 
    246         distance = 180 
     247        distance = VCALC_getSDD("FT")*100               // to convert m to cm 
    247248 
    248249 
    249250        SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FB 
    250251        Wave det_FB=data 
    251         Redimension/N=(npix,48)/E=1 det_FB               
     252//      Redimension/N=(npix,48)/E=1 det_FB               
    252253        Redimension/D det_FB 
    253254        SetScale/I x -npix/2,npix/2,"",det_FB 
    254255        SetScale/I y -ctr-48,-ctr,"",det_FB 
    255256        wave tmpw=$"root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_FB:det_FB" 
    256         det_FB=tmpw 
     257//      det_FB=tmpw 
    257258        Wave distance=distance 
    258         distance = 180 
     259        distance = VCALC_getSDD("FB")*100               // to convert m to cm 
    259260 
    260261                         
    261262        SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FL 
    262263        Wave det_FL=data 
    263         Redimension/N=(48,npix)/E=1 det_FL               
     264//      Redimension/N=(48,npix)/E=1 det_FL               
    264265        Redimension/D det_FL 
    265266        SetScale/I x -ctr-48,-ctr,"",det_FL 
    266267        SetScale/I y -npix/2,npix/2,"",det_FL 
    267268        wave tmpw=$"root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_FL:det_FL" 
    268         det_FL=tmpw 
     269//      det_FL=tmpw 
    269270        Wave distance=distance 
    270         distance = 150 
     271        distance = VCALC_getSDD("FL")*100               // to convert m to cm 
    271272 
    272273         
    273274        SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FR 
    274275        Wave det_FR=data 
    275         Redimension/N=(48,npix)/E=1 det_FR               
     276//      Redimension/N=(48,npix)/E=1 det_FR               
    276277        Redimension/D det_FR 
    277278        SetScale/I x ctr,ctr+48,"",det_FR 
    278279        SetScale/I y -npix/2,npix/2,"",det_FR 
    279280        wave tmpw=$"root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_FR:det_FR" 
    280         det_FR=tmpw 
     281//      det_FR=tmpw 
    281282        Wave distance=distance 
    282         distance = 150 
     283        distance = VCALC_getSDD("FR")*100               // to convert m to cm 
    283284 
    284285         
    285286// get rid of zeros 
    286         det_FL += 2 
    287         det_FR += 2 
    288         det_FT += 2 
    289         det_FB += 2 
     287//      det_FL += 2 
     288//      det_FR += 2 
     289//      det_FT += 2 
     290//      det_FB += 2 
    290291 
    291292 
     
    626627//    a separate function that will write and generate if needed, and use this in specific cases 
    627628//    only if I really have to force it. 
     629// 
     630// --Attributes are not currently saved. Fix this, maybe make it optional? See the help file for 
     631//  DemoAttributes(w) example under the HDF5SaveData operation 
    628632//       
    629633// -x change the /P=home to the user-defined data path (catPathName)             
     
    799803////////////////////////////// 
    800804 
     805 
     806 
     807 
     808//////// function to take VCALC information and  
     809// fill in the simulated information as needed to make a "fake" data file 
     810// 
    801811// TODO: 
    802 // -- this must be called as needed to force a re-read of the data from disk 
    803 //    "as needed" means that when an operation is done that needs to ensure 
    804 //     a fresh read from disk, it must take care of the kill. 
    805 // -- the ksBaseDFPath needs to be removed. It's currently pointing to RawVSANS, which is 
    806 //    really not used as intended anymore. 
    807 // 
    808 Function V_KillNamedDataFolder(fname) 
    809         String fname 
    810          
    811         Variable err=0 
    812          
    813         String folderStr = V_GetFileNameFromPathNoSemi(fname) 
    814         folderStr = V_RemoveDotExtension(folderStr) 
    815          
    816         KillDataFolder/Z $(ksBaseDFPath+folderStr) 
    817         err = V_flag 
    818          
    819         return(err) 
     812// -- identify all of the necessary bits to change 
     813// -- maybe want a panel to make it easier to decide what inputs to change in the file 
     814// -- decide if it's better to write wholesale, or as individual waves 
     815// 
     816Macro Copy_VCALC_to_VSANSFile() 
     817         
     818        String fileName = V_DoSaveFileDialog("pick the file to write to") 
     819        print fileName 
     820//       
     821        if(strlen(fileName) > 0) 
     822                writeVCALC_to_file(fileName) 
     823        endif 
     824End 
     825 
     826// 
     827// TODO -- fill this in as needed to get fake data that's different 
     828// 
     829Function writeVCALC_to_file(fileName) 
     830        String fileName 
     831 
     832// the wavelength 
     833//      Variable lam = V_getWavelength("VCALC")         //doesn't work, the corresponding folder in VCALC has not been defined 
     834        V_writeWavelength(fileName,VCALC_getWavelength()) 
     835         
     836// the front SDD (correct units) 
     837// the middle SDD (correct units) 
     838// the back SDD (correct units) 
     839         
     840// the detectors, all 9 + the correct SDD (that accounts for the offset of T/B panels 
     841        Variable ii,val 
     842        String detStr 
     843        for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
     844                detStr = StringFromList(ii, ksDetectorListAll, ";") 
     845                Duplicate/O $("root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_"+detStr+":det_"+detStr) tmpData 
     846                Redimension/I tmpData 
     847                tmpData = (tmpData ==   2147483647) ? 0 : tmpData               //the NaN "mask" in the sim data (T/B only)shows up as an ugly integer 
     848 
     849                V_writeDetectorData(fileName,detStr,tmpData) 
     850                val = VCALC_getTopBottomSDDOffset(detStr)/10 + VCALC_getSDD(detStr)*100         // make sure value is in cm 
     851                print val 
     852                V_writeDet_distance(fileName,detStr,val) 
     853        endfor 
     854         
     855// the calibration data for each detector 
     856 
     857// the dead time for each detector 
     858 
     859//? other detector geometry - lateral separation? 
     860 
     861 
     862// description of the sample 
     863 
     864// sample information 
     865// name, title, etc 
     866         
     867// fake the information about the count setup, so I have different numbers to read 
     868 
     869// ?? anything else that I'd like to see on the catalog - I could change them here to see different values 
     870// different collimation types? 
     871// 
     872 
     873        return(0) 
    820874end 
    821875 
    822 //given a filename of a SANS data filename of the form 
    823 // name.anything 
    824 //returns the name as a string without the ".fbdfasga" extension 
    825 // 
    826 // returns the input string if a "." can't be found (maybe it wasn't there) 
    827 Function/S V_RemoveDotExtension(item) 
    828         String item 
    829         String invalid = item   // 
    830         Variable num=-1 
    831          
    832         //find the "dot" 
    833         String runStr="" 
    834         Variable pos = strsearch(item,".",0) 
    835         if(pos == -1) 
    836                 //"dot" not found 
    837                 return (invalid) 
    838         else 
    839                 //found, get all of the characters preceeding it 
    840                 runStr = item[0,pos-1] 
    841                 return (runStr) 
    842         Endif 
    843 End 
    844  
    845 //returns a string containing filename (WITHOUT the ;vers) 
    846 //the input string is a full path to the file (Mac-style, still works on Win in IGOR) 
    847 //with the folders separated by colons 
    848 // 
    849 // called by MaskUtils.ipf, ProtocolAsPanel.ipf, WriteQIS.ipf 
    850 // 
    851 Function/S V_GetFileNameFromPathNoSemi(fullPath) 
    852         String fullPath 
    853          
    854         Variable offset1,offset2 
    855         String filename="" 
    856         //String PartialPath 
    857         offset1 = 0 
    858         do 
    859                 offset2 = StrSearch(fullPath, ":", offset1) 
    860                 if (offset2 == -1)                              // no more colons ? 
    861                         fileName = FullPath[offset1,strlen(FullPath) ] 
    862                         //PartialPath = FullPath[0, offset1-1] 
    863                         break 
    864                 endif 
    865                 offset1 = offset2+1 
    866         while (1) 
    867          
    868         //remove version number from name, if it's there - format should be: filename;N 
    869         filename =  StringFromList(0,filename,";")              //returns null if error 
    870          
    871         Return filename 
    872 End 
     876 
     877 
     878 
Note: See TracChangeset for help on using the changeset viewer.