Changeset 1180


Ignore:
Timestamp:
Jul 17, 2019 11:50:16 AM (3 years ago)
Author:
krzywon
Message:

VSANS 1D NXcanSAS writer store real meta data from file. Not fully tested/verified.

File:
1 edited

Legend:

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

    r1179 r1180  
    2020         
    2121        SetDataFolder $(pathStr+folderStr) 
    22          
    23         Make/T textw = {"","","","","","","","",""} 
    24         Make rw = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} 
    2522         
    2623        // Check fullpath and dialog 
     
    4542        EndIf 
    4643         
    47         String dataSetFolderParent,basestr 
    48          
    4944        SVAR gProtoStr = root:Packages:NIST:VSANS:Globals:Protocols:gProtoStr 
    50         Wave/T proto=$("root:Packages:NIST:VSANS:Globals:Protocols:"+gProtoStr)  
    51          
    52         SVAR samFiles = root:Packages:NIST:VSANS:Globals:Protocols:gSAM 
     45        Wave/T proto=$("root:Packages:NIST:VSANS:Globals:Protocols:"+gProtoStr) 
    5346         
    5447        //make sure the waves exist 
    55          
    5648        if(WaveExists(qw) == 0) 
    5749                Abort "q is missing" 
     
    8274        NewDataFolder/O/S $(parentBase) 
    8375         
    84          
    85         // 
    86         // FIXME: Replace textw and rw with actual data locations 
    87         // 
    88          
    89         Make/O/T/N=1 $(parentBase + ":title") = {textw[6]} 
     76        Make/O/T/N=1 $(parentBase + ":title") = {V_getTitle(folderStr)} 
    9077        CreateStrNxCansas(fileID,nxcansasBase,"","title",$(parentBase + ":title"),empty,empty) 
    91         Make/O/T/N=1 $(parentBase + ":run") = {textw[0]} 
     78        Make/O/T/N=1 $(parentBase + ":run") = {V_getExperiment_identifier(folderStr)} 
    9279        CreateStrNxCansas(fileID,nxcansasBase,"","run",$(parentBase + ":run"),empty,empty) 
    9380         
     
    9885        NewDataFolder/O/S $(dataBase) 
    9986        Make/O/T/N=5 $(dataBase + ":attr") = {"canSAS_class","signal","I_axes","NX_class","Q_indices", "timestamp"} 
    100         Make/O/T/N=5 $(dataBase + ":attrVals") = {"SASdata","I","Q","NXdata","0",textw[1]} 
     87        Make/O/T/N=5 $(dataBase + ":attrVals") = {"SASdata","I","Q","NXdata","0",V_getDataEndTime(folderStr)} 
    10188        CreateStrNxCansas(fileID,dataParent,"","",empty,$(dataBase + ":attr"),$(dataBase + ":attrVals")) 
    10289        // Create q entry 
     
    117104         
    118105        // Write all VSANS meta data 
    119         V_WriteMetaData(fileID,parentBase,nxcansasBase,proto,textw,rw) 
     106        V_WriteMetaData(fileID,parentBase,nxcansasBase,folderStr,proto) 
    120107         
    121108End 
     
    413400// 
    414401 
    415 Function V_WriteMetaData(fileID,base,parentBase,proto,textw,rw) 
    416         String base,parentBase 
     402Function V_WriteMetaData(fileID,base,parentBase,folderStr,proto) 
     403        String base,parentBase,folderStr 
    417404        Variable fileID 
    418         Wave/T proto,textw 
    419         Wave rw 
     405        Wave/T proto 
    420406         
    421407        // Define common attribute waves 
     
    436422        Make/O/T/N=5 $(instrumentBase + ":attrVals") = {"SASinstrument","NXinstrument"} 
    437423        CreateStrNxCansas(fileID,instrParent,"","",empty,$(instrumentBase + ":attr"),$(instrumentBase + ":attrVals")) 
     424        // Create SASinstrument name entry 
     425        Make/O/T/N=1 $(instrumentBase + ":name") = {V_getInstrumentName(folderStr)} 
     426        CreateStrNxCansas(fileID,instrParent,"","name",$(instrumentBase + ":name"),empty,empty) 
    438427         
    439428        // SASaperture 
     
    447436         
    448437        // Create SASaperture shape entry 
    449         Make/O/T/N=1 $(apertureBase + ":shape") = {"pinhole"}  
     438        Make/O/T/N=1 $(apertureBase + ":shape") = {V_getSampleAp_shape(folderStr)}  
    450439        CreateStrNxCansas(fileID,apertureParent,"sasaperture","shape",$(apertureBase + ":shape"),empty,empty) 
    451440        // Create SASaperture x_gap entry 
    452         Make/O/N=1 $(apertureBase + ":x_gap") = {rw[24]} 
     441        Make/O/N=1 $(apertureBase + ":x_gap") = {V_getSampleAp_height(folderStr)} 
    453442        CreateVarNxCansas(fileID,apertureParent,"sasaperture","x_gap",$(apertureBase + ":x_gap"),units,mm) 
    454443        // Create SASaperture y_gap entry 
    455         Make/O/N=1 $(apertureBase + ":y_gap") = {rw[24]} 
     444        Make/O/N=1 $(apertureBase + ":y_gap") = {V_getSampleAp_width(folderStr)} 
    456445        CreateVarNxCansas(fileID,apertureParent,"sasaperture","y_gap",$(apertureBase + ":y_gap"),units,mm) 
    457446         
     
    465454        CreateStrNxCansas(fileID,collimationParent,"","",empty,$(collimationBase + ":attr"),$(collimationBase + ":attrVals")) 
    466455        // Create SAScollimation distance entry 
    467         Make/O/N=1 $(collimationBase + ":distance") = {rw[25]} 
     456        Make/O/N=1 $(collimationBase + ":distance") = {V_getSourceAp_distance(folderStr)} 
    468457        CreateVarNxCansas(fileID,collimationParent,"sasaperture","distance",$(collimationBase + ":distance"),units,m) 
    469458         
    470         // SASdetector 
     459        // 
     460        // TODO: Create separate detector entry for each panel 
     461        // 
     462         
     463        // SASdetector - Front Top 
    471464        String detectorParent = instrParent + "sasdetector/" 
    472465        // Create SASdetector entry 
     
    477470        CreateStrNxCansas(fileID,detectorParent,"","",empty,$(detectorBase + ":attr"),$(detectorBase + ":attrVals")) 
    478471        // Create SASdetector name entry 
    479         Make/O/T/N=1 $(detectorBase + ":name") = {textw[9]} 
     472        Make/O/T/N=1 $(detectorBase + ":name") = {"FrontTop"} 
    480473        CreateStrNxCansas(fileID,detectorParent,"","name",$(detectorBase + ":name"),empty,empty) 
     474        // Create SASdetector type entry 
     475        Make/O/T/N=1 $(detectorBase + ":type") = {"He3 gas cylinder"} 
     476        CreateStrNxCansas(fileID,detectorParent,"","type",$(detectorBase + ":type"),empty,empty) 
    481477        // Create SASdetector distance entry 
    482         Make/O/N=1 $(detectorBase + ":SDD") = {rw[18]} 
    483         CreateVarNxCansas(fileID,detectorParent,"","SDD",$(detectorBase + ":SDD"),units,m) 
     478        Make/O/N=1 $(detectorBase + ":SDD") = {V_getDet_ActualDistance(folderStr,"FT")} 
     479        CreateVarNxCansas(fileID,detectorParent,"","SDD",$(detectorBase + ":SDD"),units,cm) 
    484480        // Create SASdetector beam_center_x entry 
    485         Make/O/N=1 $(detectorBase + ":beam_center_x") = {rw[16]} 
    486         CreateVarNxCansas(fileID,detectorParent,"","beam_center_x",$(detectorBase + ":beam_center_x"),units,pixel) 
     481        Make/O/N=1 $(detectorBase + ":beam_center_x") = {V_getDet_beam_center_x_mm(folderStr,"FT")} 
     482        CreateVarNxCansas(fileID,detectorParent,"","beam_center_x",$(detectorBase + ":beam_center_x"),units,mm) 
    487483        // Create SASdetector beam_center_y entry 
    488         Make/O/N=1 $(detectorBase + ":beam_center_y") = {rw[17]} 
    489         CreateVarNxCansas(fileID,detectorParent,"","beam_center_y",$(detectorBase + ":beam_center_y"),units,pixel) 
     484        Make/O/N=1 $(detectorBase + ":beam_center_y") = {V_getDet_beam_center_y_mm(folderStr,"FT")} 
     485        CreateVarNxCansas(fileID,detectorParent,"","beam_center_y",$(detectorBase + ":beam_center_y"),units,mm) 
    490486        // Create SASdetector x_pixel_size entry 
    491         Make/O/N=1 $(detectorBase + ":x_pixel_size") = {rw[10]} 
     487        Make/O/N=1 $(detectorBase + ":x_pixel_size") = {V_getDet_x_pixel_size(folderStr,"FT")} 
    492488        CreateVarNxCansas(fileID,detectorParent,"","x_pixel_size",$(detectorBase + ":x_pixel_size"),units,mm) 
    493489        // Create SASdetector y_pixel_size entry 
    494         Make/O/N=1 $(detectorBase + ":y_pixel_size") = {rw[13]} 
     490        Make/O/N=1 $(detectorBase + ":y_pixel_size") = {V_getDet_y_pixel_size(folderStr,"FT")} 
    495491        CreateVarNxCansas(fileID,detectorParent,"","y_pixel_size",$(detectorBase + ":y_pixel_size"),units,mm) 
    496492         
     
    504500        CreateStrNxCansas(fileID,sourceParent,"","",empty,$(sourceBase + ":attr"),$(sourceBase + ":attrVals")) 
    505501        // Create SASsource radiation entry 
    506         Make/O/T/N=1 $(sourceBase + ":radiation") = {"Reactor Neutron Source"} 
     502        Make/O/T/N=1 $(sourceBase + ":radiation") = {V_getSourceType(folderStr} 
    507503        CreateStrNxCansas(fileID,sourceParent,"","radiation",$(sourceBase + ":radiation"),empty,empty) 
    508504        // Create SASsource incident_wavelength entry 
    509         Make/O/N=1 $(sourceBase + ":incident_wavelength") = {rw[26]} 
     505        Make/O/N=1 $(sourceBase + ":incident_wavelength") = {V_getWavelength(folderStr)} 
    510506        CreateVarNxCansas(fileID,sourceParent,"","incident_wavelength",$(sourceBase + ":incident_wavelength"),units,angstrom) 
    511507        // Create SASsource incident_wavelength_spread entry 
    512         Make/O/N=1 $(sourceBase + ":incident_wavelength_spread") = {rw[27]} 
     508        Make/O/N=1 $(sourceBase + ":incident_wavelength_spread") = {V_getWavelength_spread(folderStr)} 
    513509        CreateVarNxCansas(fileID,sourceParent,"","incident_wavelength_spread",$(sourceBase + ":incident_wavelength_spread"),units,angstrom) 
     510         
     511        // SASsample 
     512        String sampleParent = parentBase + "sassample/" 
     513        // Create SASsample entry 
     514        String sampleBase = base + ":sassample" 
     515        NewDataFolder/O/S $(sampleBase) 
     516        Make/O/T/N=5 $(sampleBase + ":attr") = {"canSAS_class","NX_class"} 
     517        Make/O/T/N=5 $(sampleBase + ":attrVals") = {"SASsample","NXsample"} 
     518        CreateStrNxCansas(fileID,sampleParent,"","",empty,$(sampleBase + ":attr"),$(sampleBase + ":attrVals")) 
     519        // Create SASsample name entry 
     520        Make/O/T/N=1 $(sampleBase + ":name") = {V_getSampleDescription(folderStr)} 
     521        CreateStrNxCansas(fileID,sampleParent,"","name",$(sampleBase + ":name"),empty,empty) 
     522        // Create SASsample thickness entry 
     523        Make/O/N=1 $(sampleBase + ":thickness") = {V_getSampleThickness(folderStr)} 
     524        CreateVarNxCansas(fileID,sampleParent,"","thickness",$(sampleBase + ":thickness"),units,cm) 
     525        // Create SASsample transmission entry 
     526        Make/O/N=1 $(sampleBase + ":transmission") = {V_getSampleTransmission(folderStr)} 
     527        CreateVarNxCansas(fileID,sampleParent,"","transmission",$(sampleBase + ":transmission"),empty,empty) 
    514528         
    515529        // SASprocess 
     
    550564        Make/O/T/N=1 $(processBase + ":note") = {processNote} 
    551565        CreateStrNxCansas(fileID,processParent,"","note",$(processBase + ":note"),empty,empty) 
    552          
    553         // SASsample 
    554         String sampleParent = parentBase + "sassample/" 
    555         // Create SASsample entry 
    556         String sampleBase = base + ":sassample" 
    557         NewDataFolder/O/S $(sampleBase) 
    558         Make/O/T/N=5 $(sampleBase + ":attr") = {"canSAS_class","NX_class"} 
    559         Make/O/T/N=5 $(sampleBase + ":attrVals") = {"SASsample","NXsample"} 
    560         CreateStrNxCansas(fileID,sampleParent,"","",empty,$(sampleBase + ":attr"),$(sampleBase + ":attrVals")) 
    561         // Create SASsample name entry 
    562         Make/O/T/N=1 $(sampleBase + ":name") = {textw[6]} 
    563         CreateStrNxCansas(fileID,sampleParent,"","name",$(sampleBase + ":name"),empty,empty) 
    564         // Create SASsample thickness entry 
    565         Make/O/N=1 $(sampleBase + ":thickness") = {rw[5]} 
    566         CreateVarNxCansas(fileID,sampleParent,"","thickness",$(sampleBase + ":thickness"),units,cm) 
    567         // Create SASsample transmission entry 
    568         Make/O/N=1 $(sampleBase + ":transmission") = {rw[4]} 
    569         CreateVarNxCansas(fileID,sampleParent,"","transmission",$(sampleBase + ":transmission"),empty,empty) 
    570566End 
    571567         
Note: See TracChangeset for help on using the changeset viewer.