Changeset 556 for sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS
- Timestamp:
- Sep 15, 2009 5:25:35 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/WriteQIS.ipf
r555 r556 860 860 861 861 862 //for writing out data (q-i-s) from the "type" folder, and including reduction information863 //if fullpath is a complete HD path:filename, no dialog will be presented864 //if fullpath is just a filename, the save dialog will be presented865 //if dialog = 1, a dialog will always be presented866 //867 // root:myGlobals:Protocols:gProtoStr is the name of the currently active protocol868 //869 Function WriteXMLWaves_W_Protocol(type,fullpath,dialog)870 String type,fullpath871 Variable dialog //=1 will present dialog for name872 873 Struct NISTXMLfile nf874 875 String destStr=""876 destStr = "root:Packages:NIST:"+type877 878 Variable refNum879 String formatStr = "%15.4g %15.4g %15.4g %15.4g %15.4g %15.4g\r\n"880 String fname,ave="C",hdrStr1="",hdrStr2=""881 Variable step=1882 883 //*****these waves MUST EXIST, or IGOR Pro will crash, with a type 2 error****884 WAVE intw=$(destStr + ":integersRead")885 WAVE rw=$(destStr + ":realsRead")886 WAVE/T textw=$(destStr + ":textRead")887 WAVE qvals =$(destStr + ":qval")888 WAVE inten=$(destStr + ":aveint")889 WAVE sig=$(destStr + ":sigave")890 WAVE qbar = $(destStr + ":QBar")891 WAVE sigmaq = $(destStr + ":SigmaQ")892 WAVE fsubs = $(destStr + ":fSubS")893 894 895 SVAR gProtoStr = root:myGlobals:Protocols:gProtoStr896 Wave/T proto=$("root:myGlobals:Protocols:"+gProtoStr)897 898 899 //check each wave900 If(!(WaveExists(intw)))901 Abort "intw DNExist BinaryWrite_W_Protocol()"902 Endif903 If(!(WaveExists(rw)))904 Abort "rw DNExist BinaryWrite_W_Protocol()"905 Endif906 If(!(WaveExists(textw)))907 Abort "textw DNExist BinaryWrite_W_Protocol()"908 Endif909 If(!(WaveExists(qvals)))910 Abort "qvals DNExist BinaryWrite_W_Protocol()"911 Endif912 If(!(WaveExists(inten)))913 Abort "inten DNExist BinaryWrite_W_Protocol()"914 Endif915 If(!(WaveExists(sig)))916 Abort "sig DNExist BinaryWrite_W_Protocol()"917 Endif918 If(!(WaveExists(qbar)))919 Abort "qbar DNExist BinaryWrite_W_Protocol()"920 Endif921 If(!(WaveExists(sigmaq)))922 Abort "sigmaq DNExist BinaryWrite_W_Protocol()"923 Endif924 If(!(WaveExists(fsubs)))925 Abort "fsubs DNExist BinaryWrite_W_Protocol()"926 Endif927 If(!(WaveExists(proto)))928 Abort "current protocol wave DNExist BinaryWrite_W_Protocol()"929 Endif930 931 if(dialog)932 PathInfo/S catPathName933 fullPath = DoSaveFileDialog("Save data as")934 If(cmpstr(fullPath,"")==0)935 //user cancel, don't write out a file936 Close/A937 Abort "no data file was written"938 Endif939 //Print "dialog fullpath = ",fullpath940 Endif941 942 SVAR samFiles = $("root:Packages:NIST:"+type+":fileList")943 //actually open the file here944 //Open refNum as fullpath945 946 //Data947 Wave nf.Q = qvals948 nf.unitsQ = "1/A"949 Wave nf.I = inten950 nf.unitsI = "1/cm"951 Wave nf.Idev = sig952 nf.unitsIdev = "1/cm"953 Wave nf.Qdev = sigmaq954 nf.unitsQdev = "1/A"955 Wave nf.Qmean = qbar956 nf.unitsQmean = "1/A"957 Wave nf.Shadowfactor = fSubS958 nf.unitsShadowfactor = "none"959 960 961 //write out the standard header information962 //fprintf refnum,"FILE: %s\t\t CREATED: %s\r\n",textw[0],textw[1]963 964 //AJJ to fix with sensible values965 nf.run = "Test"966 String acct = textw[3]967 nf.nameSASinstrument = acct[1,3]968 nf.SASnote = ""969 //970 nf.sample_ID = textw[6]971 nf.title = textw[6]972 nf.radiation = "neutron"973 nf.wavelength = rw[26]974 nf.unitswavelength = "A"975 nf.offset_angle = rw[19]976 nf.unitsoffset_angle = "cm"977 nf.SDD = rw[18]978 nf.unitsSDD = "m"979 nf.sample_transmission = rw[4]980 nf.sample_thickness = rw[5]981 nf.unitssample_thickness = "mm"982 983 nf.beamcenter_X = rw[16]984 nf.beamcenter_Y = rw[17]985 nf.unitsbeamcenter_X = "pixels"986 nf.unitsbeamcenter_Y = "pixels"987 nf.source_aperture = rw[23]988 nf.typesource_aperture = "pinhole"989 nf.unitssource_aperture = "mm"990 nf.sample_aperture = rw[24]991 nf.typesample_aperture = "pinhole"992 nf.unitssample_aperture = "mm"993 //nf.collimation_length = total length - rw[25]994 nf.wavelength_spread = rw[27]995 nf.unitswavelength_spread = "percent"996 //Do something with beamstop (rw[21])997 nf.detector_name = textW[9]998 // fprintf refnum,"MON CNT LAMBDA DET ANG DET DIST TRANS THICK AVE STEP\r\n"999 // fprintf refnum,hdrStr11000 1001 // fprintf refnum,"BCENT(X,Y) A1(mm) A2(mm) A1A2DIST(m) DL/L BSTOP(mm) DET_TYP \r\n"1002 // fprintf refnum,hdrStr21003 1004 //insert protocol information here1005 //-1 list of sample files1006 //0 - bkg1007 //1 - emp1008 //2 - div1009 //3 - mask1010 //4 - abs params c2-c51011 //5 - average params1012 nf.SASprocessnote = "SAM: "+samFiles+"\n"1013 nf.SASprocessnote += "BGD: "+proto[0]+"\n"1014 nf.SASprocessnote += "EMP: "+Proto[1]+"\n"1015 nf.SASprocessnote += "DIV: "+Proto[2]+"\n"1016 nf.SASprocessnote += "MASK: "+Proto[3]+"\n"1017 nf.SASprocessnote += "ABS Parameters (3-6): "+Proto[4]+"\n"1018 nf.SASprocessnote += "Average Choices: "+Proto[5]+"\n"1019 1020 nf.nameSASProcess = "NIST IGOR"1021 1022 //Close refnum1023 1024 writeNISTXML(fullpath, nf)1025 1026 SetDataFolder root: //(redundant)1027 1028 //write confirmation of write operation to history area1029 Print "Averaged XML File written: ", GetFileNameFromPathNoSemi(fullPath)1030 KillWaves/Z tempShortProto1031 Return(0)1032 End
Note: See TracChangeset
for help on using the changeset viewer.