Ignore:
Timestamp:
Jun 18, 2019 10:46:02 AM (4 years ago)
Author:
krzywon
Message:

Fix final issues with USANS data and copy changes to Demsmeared writer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/branches/nxcansas_writer/NCNR_User_Procedures/Reduction/USANS/WriteUSANSNXcanSAS.ipf

    r1173 r1174  
    9494        NewDataFolder/O/S $(parentBase) 
    9595         
    96         // 
    97         // FIXME: Get useful title - For now, sending empty string 
    98         // 
    99          
    100         Make/T/N=1 $(parentBase + ":title") = {""} //StringByKey("LABEL",note(inten),":",";")} 
     96        Make/T/N=1 $(parentBase + ":title") = {StringByKey("LABEL",note(inten),":",";")} 
    10197        CreateStrNxCansas(fileID,nxcansasBase,"","title",$(parentBase + ":title"),empty,empty) 
    102          
    103         // 
    104         // TODO: Any way to programatically get the old filename? 
    105         // 
    106          
    107         Make/T/N=1 $(parentBase + ":run") = {""} 
     98        Make/T/N=1 $(parentBase + ":run") = {StringByKey("FILE",note(inten),":",";")} 
    10899        CreateStrNxCansas(fileID,nxcansasBase,"","run",$(parentBase + ":run"),empty,empty) 
    109100         
     
    156147         
    157148        Variable fileID 
    158         String destStr="" 
    159         destStr = USANSFolder+":DSM" 
     149        String destStr=USANSFolder+":DSM" 
    160150        String dateStr=date()+" "+time() 
    161151 
     
    167157        sPrintf nxcansasBase,"/sasentry%d/",sasentry // HDF5 base path for all 
    168158         
    169         KillDataFolder/Z $base 
     159        NewDataFolder/O/S $(base) 
    170160         
    171161        // Define common attribute waves 
    172         Make/T/N=1 empty = {""} 
    173         Make/T/N=1 units = {"units"} 
    174         Make/T/N=1 m = {"m"} 
    175         Make/T/N=1 mm = {"mm"} 
    176         Make/T/N=1 cm = {"cm"} 
    177         Make/T/N=1 angstrom = {"A"} 
    178         Make/T/N=1 inv_cm = {"1/cm"} 
    179         Make/T/N=1 inv_angstrom = {"1/A"} 
     162        Make/O/T/N=1 empty = {""} 
     163        Make/O/T/N=1 units = {"units"} 
     164        Make/O/T/N=1 m = {"m"} 
     165        Make/O/T/N=1 mm = {"mm"} 
     166        Make/O/T/N=1 cm = {"cm"} 
     167        Make/O/T/N=1 angstrom = {"A"} 
     168        Make/O/T/N=1 inv_cm = {"1/cm"} 
     169        Make/O/T/N=1 inv_angstrom = {"1/A"} 
    180170         
    181171        Variable refNum,integer,realval 
    182          
    183         //*****these waves MUST EXIST, or IGOR Pro will crash, with a type 2 error**** 
    184         WAVE qvals =$(destStr + "Q_dsm") 
    185         WAVE inten=$(destStr + "I_dsm") 
    186         WAVE sig=$(destStr + "S_dsm") 
    187172                 
    188173        if(dialog || stringmatch(fullpath, "")) 
     
    192177        Endif 
    193178         
     179        if(!fileID) 
     180                abort "Unable to create file at " + fullpath + "." 
     181        else 
     182                //*****these waves MUST EXIST, or IGOR Pro will crash, with a type 2 error**** 
     183                WAVE qvals =$(destStr + "Q_dsm") 
     184                WAVE inten=$(destStr + "I_dsm") 
     185                WAVE sig=$(destStr + "S_dsm") 
     186        endif 
     187         
    194188        //check each wave 
    195189        If(!(WaveExists(qvals))) 
     
    203197        Endif 
    204198         
    205         //Use the evil extra column for the resolution "information". Should probably switch to using slit_length in collimation. 
     199        Duplicate/O Q_dsm,res1,res2,res3 
     200        res3 = 1                // "fake" beamstop shadowing 
     201        res1 /= 100             //make the sigmaQ so small that there is no smearing 
     202         
    206203        //write out partial set? 
    207204        Duplicate/O qvals,tq,ti,te 
     
    215212        endif 
    216213         
    217         Make/N= (numpnts(dumWave)) dQw = 0 
     214        //Use the evil extra column for the resolution "information". Should probably switch to using slit_length in collimation. 
     215        Duplicate/O qvals,dumWave 
     216        dumWave = dQv 
     217         
     218        Make/O/N= (numpnts(dumWave)) dQw = 0 
    218219         
    219220        // Run Name and title 
    220221        NewDataFolder/O/S $(parentBase) 
     222         
    221223        Make/T/N=1 $(parentBase + ":title") = {StringByKey("LABEL",note(inten),":",";")} 
    222224        CreateStrNxCansas(fileID,nxcansasBase,"","title",$(parentBase + ":title"),empty,empty) 
    223         Make/T/N=1 $(parentBase + ":run") = {""} 
     225        Make/T/N=1 $(parentBase + ":run") = {StringByKey("FILE",note(inten),":",";")} 
    224226        CreateStrNxCansas(fileID,nxcansasBase,"","run",$(parentBase + ":run"),empty,empty) 
    225227         
     
    235237        NewDataFolder/O/S $(dataBase + ":q") 
    236238        Make/T/N=2 $(dataBase + ":q:attr") = {"units","resolutions"} 
    237         Make/T/N=2 $(dataBase + ":q:attrVals") = {"1/angstrom","dQ"} 
     239        Make/T/N=2 $(dataBase + ":q:attrVals") = {"1/A","Qdev"} 
    238240        CreateVarNxCansas(fileID,dataParent,"sasdata","Q",tq,$(dataBase + ":q:attr"),$(dataBase + ":q:attrVals")) 
    239241        // Create i entry 
     
    245247        CreateVarNxCansas(fileID,dataParent,"sasdata","Idev",te,units,inv_cm) 
    246248        // Create qdev entry 
    247         CreateVarNxCansas(fileID,dataParent,"sasdata","dQl",dumWave,units,inv_angstrom) 
    248         CreateVarNxCansas(fileID,dataParent,"sasdata","dQw",res1,units,inv_angstrom) 
     249        CreateVarNxCansas(fileID,dataParent,"sasdata","Qdev",res1,units,inv_angstrom) 
    249250        CreateVarNxCansas(fileID,dataParent,"sasdata","Qmean",res2,units,inv_angstrom) 
    250  
    251         // Write USANS meta data 
    252         WriteUSANSNXcanSASMetaData(fileID,"SMEARED",parentBase,nxcansasBase,dateStr) 
     251        CreateVarNxCansas(fileID,dataParent,"sasdata","Shadowfactor",res3,units,empty) 
     252         
     253        // Write the meta data to the file 
     254        WriteUSANSNXcanSASMetaData(fileID,"DSM",parentBase,nxcansasBase,dateStr) 
    253255         
    254256        //write confirmation of write operation to history area 
     
    262264        endif 
    263265         
    264 End      
     266End 
    265267 
    266268Function WriteUSANSNXcanSASMetaData(fileID,type,parentBase,nxcansasBase,dateStr) 
     
    270272        // tailor the output given the type of data written out... 
    271273        SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder 
     274        String destStr=USANSFolder+":"+type 
     275        WAVE inten = $(destStr + ":DetCts") 
    272276        WAVE inten_EMP=$(USANSFolder+":EMP:DetCts") 
    273277        String samStr="",empStr="",samLabelStr="",paramStr="",empLevStr="",bkgLevStr="" 
     
    296300                        pkStr += "EMP PEAK ANGLE: "+num2str(QpkFromNote("EMP")) 
    297301                        break 
    298                 case "SMEARED": 
     302                case "DSM": 
    299303                        samStr = "SMEARED FILES: "+StringByKey("FILE",note(inten),":",";") 
    300304                        empStr = "EMP FILES: "+StringByKey("FILE",note(inten_EMP),":",";")       
     
    318322        endswitch 
    319323 
    320         processNote = samStr+"\n"+dateStr+"\n"+samLabelStr+"\n"+empStr+"\n"+paramStr+"\n"+pkStr+"\n" 
     324        processNote = samStr+"\n"+dateStr+"\n"+empStr+"\n"+paramStr+"\n"+pkStr+"\n" 
    321325        processNote += empLevStr + " ; "+bkglevStr+"\n" 
    322326         
     
    396400        CreateStrNxCansas(fileID,sampleParent,"","",empty,$(sampleBase + ":attr"),$(sampleBase + ":attrVals")) 
    397401        // Create SASsample name entry 
    398          
    399         // 
    400         // FIXME: reinstate sample name once format is correct (same as title) 
    401         // 
    402          
    403402        Make/O/T/N=1 $(sampleBase + ":name") = {StringByKey("LABEL",note(inten),":",";")} 
    404403        CreateStrNxCansas(fileID,sampleParent,"","name",$(sampleBase + ":name"),empty,empty) 
     
    412411        // SASProcess 
    413412        String processParent = nxcansasBase + "sasprocess/" 
    414         // Create SASsample entry 
     413        // Create SASProcess entry 
    415414        String processBase = parentBase + ":sasprocess" 
    416415        NewDataFolder/O/S $(processBase) 
     
    418417        Make/O/T/N=2 $(processBase + ":attrVals") = {"SASprocess","NXprocess"} 
    419418        CreateStrNxCansas(fileID,processParent,"","",empty,$(processBase + ":attr"),$(processBase + ":attrVals")) 
    420         // Create SASsample name entry 
     419        // Create SASProcess name entry 
    421420        Make/O/T/N=1 $(processBase + ":name") = {"NIST IGOR"} 
    422421        CreateStrNxCansas(fileID,processParent,"","name",$(processBase + ":name"),empty,empty) 
    423         // Create SASsample thickness entry 
     422        // Create SASProcess note entry 
    424423        Make/O/T/N=1 $(processBase + ":processnote") = {processNote} 
    425424        CreateStrNxCansas(fileID,processParent,"","note",$(processBase + ":processnote"),empty,empty) 
Note: See TracChangeset for help on using the changeset viewer.