Changeset 1183


Ignore:
Timestamp:
Jul 18, 2019 10:11:37 AM (3 years ago)
Author:
krzywon
Message:

Successfully output 1D VSANS data in NXcanSAS format.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/branches/nxcansas_writer/NCNR_User_Procedures/Reduction/VSANS/V_Write_VSANS_NXcanSAS.ipf

    r1182 r1183  
    1313        String/G base = "root:V_NXcanSAS_file" 
    1414         
     15        NewDataFolder/O/S $(base) 
     16         
    1517        SetDataFolder $(pathStr+folderStr) 
    16          
    17         Print "Starting the process of writing to NXcanSAS files" 
    1818         
    1919        // Check fullpath and dialog 
     
    2525        if(!fileID) 
    2626                abort "Unable to create file at " + saveName + "." 
    27         else 
    28                 Variable sasentry = NumVarOrDefault("root:Packages:NIST:gSASEntryNumber", 1) 
    29                 sPrintf parentBase,"%s:sasentry%d",base,sasentry // Igor memory base path for all 
    30                 sPrintf nxcansasBase,"/sasentry%d/",sasentry // HDF5 base path for all 
    31  
    32                 Wave qw = tmp_q 
    33                 Wave iw = tmp_i 
    34                 Wave sw = tmp_s 
    35                 Wave sigQ = tmp_sq 
    36                 Wave qbar = tmp_qb 
    37                 Wave fs = tmp_fs 
    3827        EndIf 
     28         
     29        Variable sasentry = NumVarOrDefault("root:Packages:NIST:gSASEntryNumber", 1) 
     30        sPrintf parentBase,"%s:sasentry%d",base,sasentry // Igor memory base path for all 
     31        sPrintf nxcansasBase,"/sasentry%d/",sasentry // HDF5 base path for all 
     32 
     33        Wave qw = tmp_q 
     34        Wave iw = tmp_i 
     35        Wave sw = tmp_s 
     36        Wave sigQ = tmp_sq 
     37        Wave qbar = tmp_qb 
     38        Wave fs = tmp_fs 
    3939         
    4040        SVAR gProtoStr = root:Packages:NIST:VSANS:Globals:Protocols:gProtoStr 
     
    6969        // Run Name and title 
    7070        NewDataFolder/O/S $(parentBase) 
    71          
    7271        Make/O/T/N=1 $(parentBase + ":title") = {V_getTitle(folderStr)} 
    7372        CreateStrNxCansas(fileID,nxcansasBase,"","title",$(parentBase + ":title"),empty,empty) 
    7473        Make/O/T/N=1 $(parentBase + ":run") = {V_getExperiment_identifier(folderStr)} 
    7574        CreateStrNxCansas(fileID,nxcansasBase,"","run",$(parentBase + ":run"),empty,empty) 
    76          
    77         Print "Writing VSANS 1D Data in NXcanSAS format" 
    7875         
    7976        // SASData 
     
    10097        CreateVarNxCansas(fileID,dataParent,"sasdata","Qdev",sigQ,units,inv_angstrom) 
    10198        CreateVarNxCansas(fileID,dataParent,"sasdata","Qmean",qbar,units,inv_angstrom) 
    102          
    103         Print "Writing VSANS Meta Data in NXcanSAS format" 
    10499         
    105100        // Write all VSANS meta data 
     
    450445        Make/O/T/N=5 $(apertureBase + ":attrVals") = {"SASaperture","NXaperture"} 
    451446        CreateStrNxCansas(fileID,apertureParent,"","",empty,$(apertureBase + ":attr"),$(apertureBase + ":attrVals")) 
    452          
    453447        // Create SASaperture shape entry 
    454448        Make/O/T/N=1 $(apertureBase + ":shape") = {V_getSampleAp_shape(folderStr)}  
     
    532526        Make/O/N=1 $(detectorBase + ":y_pixel_size") = {V_getDet_y_pixel_size(folderStr,"FB")} 
    533527        CreateVarNxCansas(fileID,detectorParent,"","y_pixel_size",$(detectorBase + ":y_pixel_size"),units,mm)    
    534                  
     528         
    535529        // SASdetector - Front Left 
    536530        detectorParent = instrParent + "sasdetector3/" 
     
    562556        Make/O/N=1 $(detectorBase + ":y_pixel_size") = {V_getDet_y_pixel_size(folderStr,"FL")} 
    563557        CreateVarNxCansas(fileID,detectorParent,"","y_pixel_size",$(detectorBase + ":y_pixel_size"),units,mm) 
    564                  
     558         
    565559        // SASdetector - Front Right 
    566560        detectorParent = instrParent + "sasdetector4/" 
     
    592586        Make/O/N=1 $(detectorBase + ":y_pixel_size") = {V_getDet_y_pixel_size(folderStr,"FR")} 
    593587        CreateVarNxCansas(fileID,detectorParent,"","y_pixel_size",$(detectorBase + ":y_pixel_size"),units,mm) 
    594                  
     588         
    595589        // SASdetector - Middle Top 
    596590        detectorParent = instrParent + "sasdetector5/" 
     
    622616        Make/O/N=1 $(detectorBase + ":y_pixel_size") = {V_getDet_y_pixel_size(folderStr,"MT")} 
    623617        CreateVarNxCansas(fileID,detectorParent,"","y_pixel_size",$(detectorBase + ":y_pixel_size"),units,mm) 
    624                          
     618         
    625619        // SASdetector - Middle Bottom 
    626620        detectorParent = instrParent + "sasdetector6/" 
     
    652646        Make/O/N=1 $(detectorBase + ":y_pixel_size") = {V_getDet_y_pixel_size(folderStr,"MB")} 
    653647        CreateVarNxCansas(fileID,detectorParent,"","y_pixel_size",$(detectorBase + ":y_pixel_size"),units,mm) 
    654                          
     648         
    655649        // SASdetector - Middle Left 
    656650        detectorParent = instrParent + "sasdetector7/" 
     
    682676        Make/O/N=1 $(detectorBase + ":y_pixel_size") = {V_getDet_y_pixel_size(folderStr,"ML")} 
    683677        CreateVarNxCansas(fileID,detectorParent,"","y_pixel_size",$(detectorBase + ":y_pixel_size"),units,mm) 
    684                          
     678         
    685679        // SASdetector - Middle Right 
    686680        detectorParent = instrParent + "sasdetector8/" 
     
    712706        Make/O/N=1 $(detectorBase + ":y_pixel_size") = {V_getDet_y_pixel_size(folderStr,"MR")} 
    713707        CreateVarNxCansas(fileID,detectorParent,"","y_pixel_size",$(detectorBase + ":y_pixel_size"),units,mm) 
    714                          
    715         // SASdetector - Back High Res 
    716         detectorParent = instrParent + "sasdetector9/" 
    717         // Create SASdetector entry 
    718         detectorBase = instrumentBase + ":sasdetector9" 
    719         NewDataFolder/O/S $(detectorBase) 
    720         Make/O/T/N=5 $(detectorBase + ":attr") = {"canSAS_class","NX_class"} 
    721         Make/O/T/N=5 $(detectorBase + ":attrVals") = {"SASdetector","NXdetector"} 
    722         CreateStrNxCansas(fileID,detectorParent,"","",empty,$(detectorBase + ":attr"),$(detectorBase + ":attrVals")) 
    723         // Create SASdetector name entry 
    724         Make/O/T/N=1 $(detectorBase + ":name") = {"HighResolutionBack"} 
    725         CreateStrNxCansas(fileID,detectorParent,"","name",$(detectorBase + ":name"),empty,empty) 
    726         // Create SASdetector type entry 
    727         Make/O/T/N=1 $(detectorBase + ":type") = {"He3 gas cylinder"} 
    728         CreateStrNxCansas(fileID,detectorParent,"","type",$(detectorBase + ":type"),empty,empty) 
    729         // Create SASdetector distance entry 
    730         Make/O/N=1 $(detectorBase + ":SDD") = {V_getDet_ActualDistance(folderStr,"B")} 
    731         CreateVarNxCansas(fileID,detectorParent,"","SDD",$(detectorBase + ":SDD"),units,cm) 
    732         // Create SASdetector beam_center_x entry 
    733         Make/O/N=1 $(detectorBase + ":beam_center_x") = {V_getDet_beam_center_x_mm(folderStr,"B")} 
    734         CreateVarNxCansas(fileID,detectorParent,"","beam_center_x",$(detectorBase + ":beam_center_x"),units,mm) 
    735         // Create SASdetector beam_center_y entry 
    736         Make/O/N=1 $(detectorBase + ":beam_center_y") = {V_getDet_beam_center_y_mm(folderStr,"B")} 
    737         CreateVarNxCansas(fileID,detectorParent,"","beam_center_y",$(detectorBase + ":beam_center_y"),units,mm) 
    738         // Create SASdetector x_pixel_size entry 
    739         Make/O/N=1 $(detectorBase + ":x_pixel_size") = {V_getDet_x_pixel_size(folderStr,"B")} 
    740         CreateVarNxCansas(fileID,detectorParent,"","x_pixel_size",$(detectorBase + ":x_pixel_size"),units,mm) 
    741         // Create SASdetector y_pixel_size entry 
    742         Make/O/N=1 $(detectorBase + ":y_pixel_size") = {V_getDet_y_pixel_size(folderStr,"B")} 
    743         CreateVarNxCansas(fileID,detectorParent,"","y_pixel_size",$(detectorBase + ":y_pixel_size"),units,mm) 
     708         
     709        NVAR ignoreBack = root:Packages:NIST:VSANS:Globals:gIgnoreDetB 
     710        if(ignoreBack == 0)      
     711                // SASdetector - Back High Res 
     712                detectorParent = instrParent + "sasdetector9/" 
     713                // Create SASdetector entry 
     714                detectorBase = instrumentBase + ":sasdetector9" 
     715                NewDataFolder/O/S $(detectorBase) 
     716                Make/O/T/N=5 $(detectorBase + ":attr") = {"canSAS_class","NX_class"} 
     717                Make/O/T/N=5 $(detectorBase + ":attrVals") = {"SASdetector","NXdetector"} 
     718                CreateStrNxCansas(fileID,detectorParent,"","",empty,$(detectorBase + ":attr"),$(detectorBase + ":attrVals")) 
     719                // Create SASdetector name entry 
     720                Make/O/T/N=1 $(detectorBase + ":name") = {"HighResolutionBack"} 
     721                CreateStrNxCansas(fileID,detectorParent,"","name",$(detectorBase + ":name"),empty,empty) 
     722                // Create SASdetector type entry 
     723                Make/O/T/N=1 $(detectorBase + ":type") = {"He3 gas cylinder"} 
     724                CreateStrNxCansas(fileID,detectorParent,"","type",$(detectorBase + ":type"),empty,empty) 
     725                // Create SASdetector distance entry 
     726                Make/O/N=1 $(detectorBase + ":SDD") = {V_getDet_ActualDistance(folderStr,"B")} 
     727                CreateVarNxCansas(fileID,detectorParent,"","SDD",$(detectorBase + ":SDD"),units,cm) 
     728                // Create SASdetector beam_center_x entry 
     729                Make/O/N=1 $(detectorBase + ":beam_center_x") = {V_getDet_beam_center_x_mm(folderStr,"B")} 
     730                CreateVarNxCansas(fileID,detectorParent,"","beam_center_x",$(detectorBase + ":beam_center_x"),units,mm) 
     731                // Create SASdetector beam_center_y entry 
     732                Make/O/N=1 $(detectorBase + ":beam_center_y") = {V_getDet_beam_center_y_mm(folderStr,"B")} 
     733                CreateVarNxCansas(fileID,detectorParent,"","beam_center_y",$(detectorBase + ":beam_center_y"),units,mm) 
     734                // Create SASdetector x_pixel_size entry 
     735                Make/O/N=1 $(detectorBase + ":x_pixel_size") = {V_getDet_x_pixel_size(folderStr,"B")} 
     736                CreateVarNxCansas(fileID,detectorParent,"","x_pixel_size",$(detectorBase + ":x_pixel_size"),units,mm) 
     737                // Create SASdetector y_pixel_size entry 
     738                Make/O/N=1 $(detectorBase + ":y_pixel_size") = {V_getDet_y_pixel_size(folderStr,"B")} 
     739                CreateVarNxCansas(fileID,detectorParent,"","y_pixel_size",$(detectorBase + ":y_pixel_size"),units,mm) 
     740        EndIf 
    744741         
    745742        // SASsource 
     
    760757        Make/O/N=1 $(sourceBase + ":incident_wavelength_spread") = {V_getWavelength_spread(folderStr)} 
    761758        CreateVarNxCansas(fileID,sourceParent,"","incident_wavelength_spread",$(sourceBase + ":incident_wavelength_spread"),units,angstrom) 
    762          
     759 
    763760        // SASsample 
    764761        String sampleParent = parentBase + "sassample/" 
     
    774771        // Create SASsample thickness entry 
    775772        Make/O/N=1 $(sampleBase + ":thickness") = {V_getSampleThickness(folderStr)} 
    776         CreateVarNxCansas(fileID,sampleParent,"","thickness",$(sampleBase + ":thickness"),units,cm) 
     773        CreateVarNxCansas(fileID,sampleParent,"","thickness",$(sampleBase + ":thickness"),units,mm) 
    777774        // Create SASsample transmission entry 
    778775        Make/O/N=1 $(sampleBase + ":transmission") = {V_getSampleTransmission(folderStr)} 
     
    803800        sPrintf processNote,"%sEnd Trim Points: %s\r\n",processNote,ProtoStr8 
    804801        sPrintf processNote,"%sCOLLIMATION=%s\r\n",processNote,proto[9] 
     802        // Create SASprocess entry 
    805803        String processParent = parentBase + "sasprocess/" 
    806         // Create SASprocess entry 
    807804        String processBase = base + ":sasprocess" 
    808805        NewDataFolder/O/S $(processBase) 
     
    814811        CreateStrNxCansas(fileID,processParent,"","name",$(processBase + ":name"),empty,empty) 
    815812        // Create SASprocess note entry 
    816         Make/O/T/N=1 $(processBase + ":note") = {processNote} 
    817         CreateStrNxCansas(fileID,processParent,"","note",$(processBase + ":note"),empty,empty) 
     813         
     814        // 
     815        // TODO: Reinstate SASprocess.note when I figure out why it won't save 
     816        // 
     817         
     818        //Make/O/T/N=1 $(processBase + ":note") = {processNote} 
     819        //CreateStrNxCansas(fileID,processParent,"","note",$(processBase + ":note"),empty,empty) 
     820         
    818821End 
    819822         
Note: See TracChangeset for help on using the changeset viewer.