1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | #pragma version=1.19 |
---|
3 | Constant IR2EversionNumber = 1.18 |
---|
4 | |
---|
5 | //*************************************************************************\ |
---|
6 | //* Copyright (c) 2005 - 2022, Argonne National Laboratory |
---|
7 | //* This file is distributed subject to a Software License Agreement found |
---|
8 | //* in the file LICENSE that is included with this distribution. |
---|
9 | //*************************************************************************/ |
---|
10 | |
---|
11 | //1.19 fix ASCII export of USAXS data which was exporting incorrect Q data. |
---|
12 | //1.18 added export of all data from current experiment using IR2E_ExportAllAsNexus(), for now sets dQ=0 for DSM data, sets dQl=slit length and dQw to dQ for SMR data. |
---|
13 | //1.17 fixed dQ USAXS data Nexus export which exported always SMR dQ. |
---|
14 | //1.16 add option to export ASCII with d, two theta or Q. Tested against Nika TTH, Q, and D data and works fine within precision errors. |
---|
15 | //1.15 add option to reduce output to single precision output (requested) |
---|
16 | //1.14 fix missign wwavelength if dsata are imported as ASII from Irena and exported again. |
---|
17 | //1.13 fix naming bug for Nexus which caused the names not being changed as needed, when Nexus was used. |
---|
18 | //1.12 fix extensions mess, force extesions, cannot make the old one to be remebered correctly... Too many options. |
---|
19 | //1.11 fix bug that GSAS-II data type was not updating/chaqnging output name as expected. |
---|
20 | //1.10 added export of xye data file for GSAS-II |
---|
21 | //1.09 added getHelp button calling to www manual |
---|
22 | //1.08 changes for panel scaling |
---|
23 | //1.07 fixed multiple data export with QRS |
---|
24 | //1.06 modified GUI to disable Export Data & notes on main panel, when Multiple data selection panel is opened. Confused users. Changeds call to pull up without initialization, if exists. |
---|
25 | // changed mode for Listbox to enable shift-click selection of range of data, use ctrl/cmd for one-by-one data selection |
---|
26 | //1.05 added in panel version control and added vertical scrolling |
---|
27 | //1.04 fixed Multiple data export which was broken by update to control procedures |
---|
28 | //1.03 fixed QRS data export which was not working due to eventCode missing in structure |
---|
29 | //1.02 removed all font and font size from panel definitions to enable user control |
---|
30 | //1.01 added license for ANL |
---|
31 | |
---|
32 | |
---|
33 | //This is tool to export any type of 2 - 3 column data we have x, y, and error (if exists) |
---|
34 | |
---|
35 | Function IR2E_UniversalDataExport() |
---|
36 | |
---|
37 | //check for panel if exists - pull up, if not create |
---|
38 | DoWindow UnivDataExportPanel |
---|
39 | if(V_Flag) |
---|
40 | DoWindow/F UnivDataExportPanel |
---|
41 | DoWIndow IR2E_MultipleDataSelectionPnl |
---|
42 | if(V_Flag) |
---|
43 | DoWindow/F IR2E_MultipleDataSelectionPnl |
---|
44 | endif |
---|
45 | else |
---|
46 | //initialize, as usually |
---|
47 | IR2E_InitUnivDataExport() |
---|
48 | NVAR ExportMultipleDataSets = root:Packages:IR2_UniversalDataExport:ExportMultipleDataSets |
---|
49 | ExportMultipleDataSets=0 //do not start in multiple data export, it does not set parameters well... |
---|
50 | IR2E_UnivDataExportPanel() |
---|
51 | ING2_AddScrollControl() |
---|
52 | IR1_UpdatePanelVersionNumber("UnivDataExportPanel", IR2EversionNumber,1) |
---|
53 | endif |
---|
54 | |
---|
55 | end |
---|
56 | //************************************************************************************************************ |
---|
57 | //************************************************************************************************************ |
---|
58 | //************************************************************************************************************ |
---|
59 | //************************************************************************************************************ |
---|
60 | |
---|
61 | Function IR2E_MainCheckVersion() |
---|
62 | DoWindow UnivDataExportPanel |
---|
63 | if(V_Flag) |
---|
64 | if(!IR1_CheckPanelVersionNumber("UnivDataExportPanel", IR2EversionNumber)) |
---|
65 | DoAlert /T="The ASCII Export panel was created by incorrect version of Irena " 1, "Export ASCII may need to be restarted to work properly. Restart now?" |
---|
66 | if(V_flag==1) |
---|
67 | KillWindow UnivDataExportPanel |
---|
68 | IR2E_UniversalDataExport() |
---|
69 | else //at least reinitialize the variables so we avoid major crashes... |
---|
70 | IR2E_InitUnivDataExport() |
---|
71 | endif |
---|
72 | endif |
---|
73 | endif |
---|
74 | end |
---|
75 | //************************************************************************************************************ |
---|
76 | //************************************************************************************************************ |
---|
77 | //************************************************************************************************************ |
---|
78 | //************************************************************************************************************ |
---|
79 | |
---|
80 | Function IR2E_UnivDataExportPanel() |
---|
81 | //PauseUpdate // building window... |
---|
82 | NewPanel /K=1 /W=(2.25,43.25,390,690) as "Universal data export tool" |
---|
83 | DoWindow/C UnivDataExportPanel |
---|
84 | |
---|
85 | string AllowedIrenaTypes="DSM_Int;M_DSM_Int;SMR_Int;M_SMR_Int;R_Int;" |
---|
86 | IR2C_AddDataControls("IR2_UniversalDataExport","UnivDataExportPanel",AllowedIrenaTypes,"AllCurrentlyAllowedTypes","","","","", 0,0) |
---|
87 | CheckBox UseQRSdata proc=IR2E_InputPanelCheckboxProc |
---|
88 | CheckBox UseIndra2Data proc=IR2E_InputPanelCheckboxProc |
---|
89 | CheckBox UseResults proc=IR2E_InputPanelCheckboxProc |
---|
90 | TitleBox MainTitle title="\Zr220Universal data export panel",pos={20,0},frame=0,fstyle=3, fixedSize=1,font= "Times New Roman", size={350,24},anchor=MC,fColor=(0,0,52224) |
---|
91 | TitleBox FakeLine1 title=" ",fixedSize=1,size={330,3},pos={16,181},frame=0,fColor=(0,0,52224), labelBack=(0,0,52224) |
---|
92 | TitleBox Info1 title="\Zr160Data input",pos={10,27},frame=0,fstyle=1, fixedSize=1,size={80,20},fColor=(0,0,52224) |
---|
93 | TitleBox Info2 title="\Zr160Preview Options:",pos={20,190},frame=0,fstyle=2, fixedSize=1,size={150,20},fColor=(0,0,52224) |
---|
94 | TitleBox Info3 title="\Zr160Output Options:",pos={20,320},frame=0,fstyle=2, fixedSize=0,size={20,15},fColor=(0,0,52224) |
---|
95 | TitleBox FakeLine1 title=" ",fixedSize=1,size={330,3},pos={16,307},frame=0,fColor=(0,0,52224), labelBack=(0,0,52224) |
---|
96 | |
---|
97 | CheckBox ExportMultipleDataSets,pos={100,160},size={225,14},proc=IR2E_UnivExpCheckboxProc,title="Export multiple data sets?" |
---|
98 | CheckBox ExportMultipleDataSets,variable= root:Packages:IR2_UniversalDataExport:ExportMultipleDataSets, help={"When checked the multiple data sets with same data can be exported"} |
---|
99 | |
---|
100 | Button GetHelp,pos={305,105},size={80,15},fColor=(65535,32768,32768), proc=IR2E_InputPanelButtonProc,title="Get Help", help={"Open www manual page for this tool"} |
---|
101 | CheckBox GraphDataCheckbox,pos={15,220},size={225,14},noproc,title="Display graph with data?" |
---|
102 | CheckBox GraphDataCheckbox,variable= root:Packages:IR2_UniversalDataExport:GraphData, help={"When checked the graph displaying data will be displayed"} |
---|
103 | CheckBox DisplayWaveNote,pos={15,250},size={225,14},noproc,title="Display notes about data?" |
---|
104 | CheckBox DisplayWaveNote,variable= root:Packages:IR2_UniversalDataExport:DisplayWaveNote, help={"When checked notebook with notes about data history will be displayed"} |
---|
105 | Button LoadAndGraphData, pos={100,280},size={180,20}, proc=IR2E_InputPanelButtonProc,title="Load data", help={"Load data into the tool, generate graph and display notes if checkboxes are checked."} |
---|
106 | |
---|
107 | //Nexus or ASCII? |
---|
108 | CheckBox ExportASCII,pos={10,340},size={190,14},proc=IR2E_UnivExportCheckProc,title="Export ASCII?", mode=1 |
---|
109 | CheckBox ExportASCII,variable= root:Packages:IR2_UniversalDataExport:ExportASCII, help={"When checked ASCII files will be created"} |
---|
110 | CheckBox ExportGSASxye,pos={130,340},size={190,14},proc=IR2E_UnivExportCheckProc,title="Export GSAS-II xye?", mode=1 |
---|
111 | CheckBox ExportGSASxye,variable= root:Packages:IR2_UniversalDataExport:ExportGSASxye, help={"When checked ASCII files for GSAS-II will be created"} |
---|
112 | CheckBox ExportCanSASNexus,pos={260,340},size={190,14},proc=IR2E_UnivExportCheckProc,title="Export NEXUS?", mode=1 |
---|
113 | CheckBox ExportCanSASNexus,variable= root:Packages:IR2_UniversalDataExport:ExportCanSASNexus, help={"When checked Nexus (canSAS for data) files will be created"} |
---|
114 | |
---|
115 | CheckBox ExportSingleCanSASFile,pos={15,360},size={190,14},proc=IR2E_UnivExportCheckProc,title="Export Single canSAS NEXUS (with multiple data)?" |
---|
116 | CheckBox ExportSingleCanSASFile,variable= root:Packages:IR2_UniversalDataExport:ExportSingleCanSASFile, help={"When checked Nexus (canSAS for data) files will be created"} |
---|
117 | |
---|
118 | CheckBox ASCIIExportQ,pos={10,360},size={190,14},proc=IR2E_UnivExportCheckProc,title="Use Q?", mode=1 |
---|
119 | CheckBox ASCIIExportQ,variable= root:Packages:IR2_UniversalDataExport:ASCIIExportQ, help={"When checked ASCII files will be exported with Q"} |
---|
120 | CheckBox ASCIIExportD,pos={130,360},size={190,14},proc=IR2E_UnivExportCheckProc,title="Use d?", mode=1 |
---|
121 | CheckBox ASCIIExportD,variable= root:Packages:IR2_UniversalDataExport:ASCIIExportD, help={"When checked ASCII files will be exported with d"} |
---|
122 | CheckBox ASCIIExportTTH,pos={260,360},size={190,14},proc=IR2E_UnivExportCheckProc,title="Use Two Theta?", mode=1 |
---|
123 | CheckBox ASCIIExportTTH,variable= root:Packages:IR2_UniversalDataExport:ASCIIExportTTH, help={"When checked ASCII files will be created with two theta"} |
---|
124 | |
---|
125 | |
---|
126 | CheckBox AttachWaveNote,pos={10,378},size={190,14},noproc,title="Attach notes about data?" |
---|
127 | CheckBox AttachWaveNote,variable= root:Packages:IR2_UniversalDataExport:AttachWaveNote, help={"When checked block of text with notes about data history will be attached before the data itself"} |
---|
128 | CheckBox reduceOutputPrecision,pos={220,378},size={190,14},noproc,title="Reduce precision?" |
---|
129 | CheckBox reduceOutputPrecision,variable= root:Packages:IR2_UniversalDataExport:reduceOutputPrecision, help={"When checked, data are converted to single precision (default is double precision)"} |
---|
130 | |
---|
131 | |
---|
132 | CheckBox UseFolderNameForOutput,pos={10,395},size={190,14},proc=IR2E_UnivExportCheckProc,title="Use Sample/Fldr name for output?" |
---|
133 | CheckBox UseFolderNameForOutput,variable= root:Packages:IR2_UniversalDataExport:UseFolderNameForOutput, help={"Use Folder name for output file name"} |
---|
134 | CheckBox UseYWaveNameForOutput,pos={220,395},size={190,14},proc=IR2E_UnivExportCheckProc,title="Use Ywv name for output?" |
---|
135 | CheckBox UseYWaveNameForOutput,variable= root:Packages:IR2_UniversalDataExport:UseYWaveNameForOutput, help={"Use Y wave name for output file name"} |
---|
136 | |
---|
137 | |
---|
138 | SetVariable CurrentlyLoadedDataName,limits={0,Inf,0},value= root:Packages:IR2_UniversalDataExport:CurrentlyLoadedDataName, noedit=1,noProc,frame=0 |
---|
139 | SetVariable CurrentlyLoadedDataName,pos={3,420},size={385,25},title="Loaded data:", help={"This is data set currently loaded in the tool. These data will be saved."},fstyle=1,labelBack=(65280,21760,0) |
---|
140 | |
---|
141 | SetVariable CurrentlySetOutputPath,limits={0,Inf,0},value= root:Packages:IR2_UniversalDataExport:CurrentlySetOutputPath, noedit=1,noProc,frame=0 |
---|
142 | SetVariable CurrentlySetOutputPath,pos={3,455},size={370,25},title="Export Folder:", help={"This is data folder outside Igor where the data will be saved."},fstyle=0 |
---|
143 | Button ExportOutputPath, pos={100,480},size={180,20}, proc=IR2E_InputPanelButtonProc,title="Set export folder:", help={"Select export folder where to save new ASCII data sets."} |
---|
144 | // Button ExportNexusFile, pos={100,492},size={180,20}, proc=IR2E_InputPanelButtonProc,title="Create/Find Nexus Output file", help={"Create output Nexus file name in above location."} |
---|
145 | |
---|
146 | SetVariable NewFileOutputName,limits={0,Inf,0},value= root:Packages:IR2_UniversalDataExport:NewFileOutputName,noProc,frame=1 |
---|
147 | SetVariable NewFileOutputName,pos={3,520},size={370,25},title="Export file name:", help={"This is name for new data file which will be created"},fstyle=1 |
---|
148 | SetVariable OutputNameExtension,limits={0,Inf,0},value= root:Packages:IR2_UniversalDataExport:OutputNameExtension,noProc,frame=1 |
---|
149 | SetVariable OutputNameExtension,pos={3,540},size={200,25},title="Export file extension:", help={"This is extension for new data file which will be created"},fstyle=1 |
---|
150 | SetVariable HeaderSeparator,limits={0,Inf,0},value= root:Packages:IR2_UniversalDataExport:HeaderSeparator,proc=IR2E_UnivExportToolSetVarProc,frame=1 |
---|
151 | SetVariable HeaderSeparator,pos={3,560},size={180,25},title="Header separator:", help={"This is symnol at the start of header line. Include here spaces if you want them..."},fstyle=1 |
---|
152 | // |
---|
153 | Button ExportData, pos={100,600},size={180,20}, proc=IR2E_InputPanelButtonProc,title="Export Data & Notes", help={"Save ASCII file with data and notes for these data"} |
---|
154 | IR2E_FixMainGUI() |
---|
155 | end |
---|
156 | //******************************************************************************************************************************* |
---|
157 | //this is override or IR2C procedure so it also updates GUI... |
---|
158 | Function IR2E_InputPanelCheckboxProc(CB_Struct) |
---|
159 | STRUCT WMCheckboxAction &CB_Struct |
---|
160 | |
---|
161 | IR2C_InputPanelCheckboxProc(CB_Struct) |
---|
162 | IR2E_FixMainGUI() |
---|
163 | end |
---|
164 | |
---|
165 | //******************************************************************************************************************************* |
---|
166 | Function IR2E_FixMainGUI() |
---|
167 | |
---|
168 | DoWIndow UnivDataExportPanel |
---|
169 | if(V_Flag) |
---|
170 | NVAR MultipleData=root:Packages:IR2_UniversalDataExport:ExportMultipleDataSets |
---|
171 | NVAR ExportCanSASNexus = root:Packages:IR2_UniversalDataExport:ExportCanSASNexus |
---|
172 | NVAR ExportASCII = root:Packages:IR2_UniversalDataExport:ExportASCII |
---|
173 | NVAR ExportGSASxye = root:Packages:IR2_UniversalDataExport:ExportGSASxye |
---|
174 | NVAR ExportSingleCanSASFile = root:Packages:IR2_UniversalDataExport:ExportSingleCanSASFile |
---|
175 | NVAR UseIndra2Data = root:Packages:IR2_UniversalDataExport:UseIndra2Data |
---|
176 | NVAR UseQRSdata = root:Packages:IR2_UniversalDataExport:UseQRSdata |
---|
177 | NVAR UseResults = root:Packages:IR2_UniversalDataExport:UseResults |
---|
178 | |
---|
179 | Button ExportData, win=UnivDataExportPanel, disable=2*MultipleData |
---|
180 | CheckBox AttachWaveNote,win=UnivDataExportPanel, disable=(ExportCanSASNexus || ExportGSASxye) |
---|
181 | SetVariable HeaderSeparator, win=UnivDataExportPanel, disable=!(ExportASCII) |
---|
182 | CheckBox UseYWaveNameForOutput, win=UnivDataExportPanel, disable=(ExportCanSASNexus&&ExportSingleCanSASFile) |
---|
183 | CheckBox UseFolderNameForOutput, win=UnivDataExportPanel, disable=(ExportCanSASNexus&&ExportSingleCanSASFile) |
---|
184 | CheckBox ExportSingleCanSASFile, win=UnivDataExportPanel, disable=(ExportASCII || ExportGSASxye) |
---|
185 | CheckBox reduceOutputPrecision, win=UnivDataExportPanel, disable=(ExportCanSASNexus || ExportGSASxye) |
---|
186 | CheckBox ASCIIExportQ, win=UnivDataExportPanel, disable=!(ExportASCII&&(UseIndra2Data||UseQRSdata)) |
---|
187 | CheckBox ASCIIExportD, win=UnivDataExportPanel, disable=!(ExportASCII&&(UseIndra2Data||UseQRSdata)) |
---|
188 | CheckBox ASCIIExportTTH, win=UnivDataExportPanel, disable=!(ExportASCII&&(UseIndra2Data||UseQRSdata)) |
---|
189 | endif |
---|
190 | end |
---|
191 | |
---|
192 | //******************************************************************************************************************************* |
---|
193 | //******************************************************************************************************************************* |
---|
194 | //******************************************************************************************************************************* |
---|
195 | Function IR2E_UnivExpCheckboxProc(CB_Struct) |
---|
196 | STRUCT WMCheckboxAction &CB_Struct |
---|
197 | |
---|
198 | // DoAlert 0,"Fix IR2E_UnivExpCheckboxProc" |
---|
199 | if(CB_Struct.EventCode==2) |
---|
200 | if(stringMatch(CB_Struct.ctrlName,"ExportMultipleDataSets")) |
---|
201 | if(CB_Struct.checked) |
---|
202 | |
---|
203 | IR2E_UpdateListOfAvailFiles() |
---|
204 | DoWindow IR2E_MultipleDataSelectionPnl |
---|
205 | if(!V_Flag) |
---|
206 | NewPanel/K=1 /W=(400,44,800,355) as "Multiple Data Export selection" |
---|
207 | DoWIndow/C IR2E_MultipleDataSelectionPnl |
---|
208 | SetDrawLayer UserBack |
---|
209 | SetDrawEnv fsize= 20,fstyle= 1,textrgb= (0,0,65535) |
---|
210 | DrawText 29,29,"Multiple Data Export selection" |
---|
211 | DrawText 10,255,"Configure Universal export tool panel options" |
---|
212 | DrawText 10,275,"Select multiple data above and export : " |
---|
213 | ListBox DataFolderSelection,pos={4,35},size={372,200}, mode=10, special={0,0,1 } //this will scale the width of column, users may need to slide right using slider at the bottom. |
---|
214 | ListBox DataFolderSelection,listWave=root:Packages:IR2_UniversalDataExport:ListOfAvailableData |
---|
215 | ListBox DataFolderSelection,selWave=root:Packages:IR2_UniversalDataExport:SelectionOfAvailableData |
---|
216 | |
---|
217 | Button UpdateData,pos={280,245},size={100,15},proc=IR2E_ButtonProc,title="Update list" |
---|
218 | Button UpdateData,fSize=10,fStyle=2 |
---|
219 | |
---|
220 | Button AllData,pos={4,285},size={100,15},proc=IR2E_ButtonProc,title="Select all data" |
---|
221 | Button AllData,fSize=10,fStyle=2 |
---|
222 | Button NoData,pos={120,285},size={100,15},proc=IR2E_ButtonProc,title="DeSelect all data" |
---|
223 | Button NoData,fSize=10,fStyle=2 |
---|
224 | Button ProcessAllData,pos={240,285},size={150,15},proc=IR2E_ButtonProc,title="Export selected data" |
---|
225 | Button ProcessAllData,fSize=10,fStyle=2 |
---|
226 | Button ProcessAllData fColor=(65535,16385,16385) |
---|
227 | else |
---|
228 | |
---|
229 | DoWindow/F IR2E_MultipleDataSelectionPnl |
---|
230 | |
---|
231 | endif |
---|
232 | AutoPositionWindow/M=0 /R=UnivDataExportPanel IR2E_MultipleDataSelectionPnl |
---|
233 | else |
---|
234 | KillWIndow/Z IR2E_MultipleDataSelectionPnl |
---|
235 | endif |
---|
236 | endif //end of ExportMultipleDataSets |
---|
237 | |
---|
238 | endif |
---|
239 | IR2E_FixMainGUI() |
---|
240 | End |
---|
241 | //************************************************************************************** |
---|
242 | //************************************************************************************** |
---|
243 | //************************************************************************************** |
---|
244 | //************************************************************************************** |
---|
245 | //************************************************************************************** |
---|
246 | |
---|
247 | |
---|
248 | |
---|
249 | Function IR2E_ButtonProc(ctrlName) : ButtonControl |
---|
250 | String ctrlName |
---|
251 | |
---|
252 | wave SelectionOfAvailableData=root:Packages:IR2_UniversalDataExport:SelectionOfAvailableData |
---|
253 | if(stringmatch(ctrlName,"AllData")) |
---|
254 | SelectionOfAvailableData=1 |
---|
255 | endif |
---|
256 | if(stringmatch(ctrlName,"NoData")) |
---|
257 | SelectionOfAvailableData=0 |
---|
258 | endif |
---|
259 | if(stringmatch(ctrlName,"UpdateData")) |
---|
260 | IR2E_UpdateListOfAvailFiles() |
---|
261 | endif |
---|
262 | if(stringmatch(ctrlName,"ProcessAllData")) |
---|
263 | IR2E_ExportMultipleFiles() |
---|
264 | print "Export of all data is DONE!" |
---|
265 | endif |
---|
266 | |
---|
267 | |
---|
268 | End |
---|
269 | |
---|
270 | //************************************************************************************** |
---|
271 | //************************************************************************************** |
---|
272 | //************************************************************************************** |
---|
273 | Function IR2E_ExportMultipleFiles() |
---|
274 | |
---|
275 | DFref oldDf= GetDataFolderDFR() |
---|
276 | |
---|
277 | setDataFolder root:Packages:IR2_UniversalDataExport |
---|
278 | |
---|
279 | NVAR UseQRSdata=root:Packages:IR2_UniversalDataExport:UseQRSData |
---|
280 | SVAR DataFolderName = root:Packages:IR2_UniversalDataExport:DataFolderName |
---|
281 | SVAR IntensityWaveName=root:Packages:IR2_UniversalDataExport:IntensityWaveName |
---|
282 | SVAR QWavename=root:Packages:IR2_UniversalDataExport:QWavename |
---|
283 | SVAR ErrorWaveName=root:Packages:IR2_UniversalDataExport:ErrorWaveName |
---|
284 | string StartFolderName = RemoveFromList(stringFromList(ItemsInList(DataFolderName , ":")-1,DataFolderName,":"), DataFolderName , ":") |
---|
285 | |
---|
286 | Wave/T ListOfAvailableData=root:Packages:IR2_UniversalDataExport:ListOfAvailableData |
---|
287 | Wave SelectionOfAvailableData=root:Packages:IR2_UniversalDataExport:SelectionOfAvailableData |
---|
288 | |
---|
289 | variable i |
---|
290 | |
---|
291 | For(i=0;i<numpnts(ListOfAvailableData);i+=1) |
---|
292 | if(!UseQRSdata) //just stuff in Folder name and go ahead... |
---|
293 | if(SelectionOfAvailableData[i]) |
---|
294 | DataFolderName = StartFolderName+ListOfAvailableData[i] |
---|
295 | if(!DataFolderExists(DataFolderName )) |
---|
296 | Abort "Problem with data folder definition. Please \"Update list\" and try again" |
---|
297 | endif |
---|
298 | IR2E_LoadDataInTool() |
---|
299 | DoUpdate |
---|
300 | sleep/S 1 |
---|
301 | IR2E_ExportTheData() |
---|
302 | endif |
---|
303 | else //we need to set all strings for qrs data... |
---|
304 | if(SelectionOfAvailableData[i]) |
---|
305 | DataFolderName = StartFolderName+ListOfAvailableData[i] |
---|
306 | if(!DataFolderExists(DataFolderName )) |
---|
307 | Abort "Problem with data folder definition. Please \"Update list\" and try again" |
---|
308 | endif |
---|
309 | //now for qrs we need to reload the other wave names... |
---|
310 | STRUCT WMPopupAction PU_Struct |
---|
311 | PU_Struct.ctrlName = "SelectDataFolder" |
---|
312 | PU_Struct.popNum=-1 |
---|
313 | PU_Struct.eventCode=2 |
---|
314 | PU_Struct.popStr=DataFolderName |
---|
315 | PU_Struct.win = "UnivDataExportPanel" |
---|
316 | //PopupMenu SelectDataFolder win=UnivDataExportPanel, popmatch=DataFolderName |
---|
317 | PopupMenu SelectDataFolder win=UnivDataExportPanel, popmatch=StringFromList(ItemsInList(DataFolderName,":")-1,DataFolderName,":") |
---|
318 | IR2C_PanelPopupControl(PU_Struct) |
---|
319 | IR2E_LoadDataInTool() |
---|
320 | DoUpdate |
---|
321 | sleep/S 1 |
---|
322 | IR2E_ExportTheData() |
---|
323 | endif |
---|
324 | endif |
---|
325 | |
---|
326 | endfor |
---|
327 | |
---|
328 | |
---|
329 | setDataFolder OldDF |
---|
330 | end |
---|
331 | //******************************************************************************************************************************* |
---|
332 | //******************************************************************************************************************************* |
---|
333 | //******************************************************************************************************************************* |
---|
334 | //******************************************************************************************************************************* |
---|
335 | //******************************************************************************************************************************* |
---|
336 | |
---|
337 | Function IR2E_UpdateListOfAvailFiles() |
---|
338 | |
---|
339 | DFref oldDf= GetDataFolderDFR() |
---|
340 | |
---|
341 | setDataFolder root:Packages:IR2_UniversalDataExport |
---|
342 | |
---|
343 | NVAR UseIndra2Data=root:Packages:IR2_UniversalDataExport:UseIndra2Data |
---|
344 | NVAR UseQRSdata=root:Packages:IR2_UniversalDataExport:UseQRSData |
---|
345 | NVAR UseResults = root:Packages:IR2_UniversalDataExport:UseResults |
---|
346 | NVAR UseSMRData = root:Packages:IR2_UniversalDataExport:UseSMRData |
---|
347 | // SVAR StartFolderName=root:Packages:IR2_UniversalDataExport:StartFolderName |
---|
348 | SVAR DataFolderName = root:Packages:IR2_UniversalDataExport:DataFolderName |
---|
349 | string StartFolderName = RemoveFromList(stringFromList(ItemsInList(DataFolderName , ":")-1,DataFolderName,":"), DataFolderName , ":") |
---|
350 | SVAR IntensityWaveName=root:Packages:IR2_UniversalDataExport:IntensityWaveName |
---|
351 | |
---|
352 | //string CurrentFolders=IR2S_GenStringOfFolders(StartFolderName,UseIndra2Data, UseQRSData,UseSMRData,1) |
---|
353 | string CurrentFolders |
---|
354 | IR2P_GenStringOfFolders(winNm="UnivDataExportPanel") |
---|
355 | SVAR RealLongListOfFolder = root:Packages:IR2_UniversalDataExport:RealLongListOfFolder //after 2/2013 update this is where the list is. |
---|
356 | CurrentFolders = RealLongListOfFolder |
---|
357 | //these are all folders with data... Now we need to check for results of different type... And clean up those which are not in the same subfolder... |
---|
358 | variable i, j |
---|
359 | string TempStr |
---|
360 | For(i=ItemsInList(CurrentFolders , ";")-1;i>=0;i-=1) //cleanup from other start folders... |
---|
361 | TempStr = StringFromList(i, CurrentFolders , ";") |
---|
362 | if(!stringmatch(TempStr, StartFolderName+"*" )) |
---|
363 | CurrentFolders = RemoveListItem(i, CurrentFolders , ";") |
---|
364 | endif |
---|
365 | endfor |
---|
366 | //now cleanup from different wave names... Valid only for Indra 2 data and results, not qrs data... |
---|
367 | if(UseIndra2Data || UseResults) |
---|
368 | For(i=ItemsInList(CurrentFolders , ";")-1;i>=0;i-=1) //cleanup from other start folders... |
---|
369 | TempStr = StringFromList(i, CurrentFolders , ";") |
---|
370 | if(UseIndra2Data) //check for Indra 2 data of the right kind... |
---|
371 | if(!stringmatch(IN2G_CreateListOfItemsInFolder(TempStr,2), "*"+IntensityWaveName+"*" )) |
---|
372 | CurrentFolders = RemoveListItem(i, CurrentFolders , ";") |
---|
373 | endif |
---|
374 | else //results... May need to modify later, this will manage only same generation results... |
---|
375 | if(!stringmatch(IN2G_CreateListOfItemsInFolder(TempStr,2), "*"+IntensityWaveName+"*" )) |
---|
376 | CurrentFolders = RemoveListItem(i, CurrentFolders , ";") |
---|
377 | endif |
---|
378 | endif |
---|
379 | endfor |
---|
380 | |
---|
381 | endif |
---|
382 | |
---|
383 | Wave/T ListOfAvailableData=root:Packages:IR2_UniversalDataExport:ListOfAvailableData |
---|
384 | Wave SelectionOfAvailableData=root:Packages:IR2_UniversalDataExport:SelectionOfAvailableData |
---|
385 | |
---|
386 | Redimension/N=(ItemsInList(CurrentFolders , ";")) ListOfAvailableData |
---|
387 | j=0 |
---|
388 | For(i=0;i<ItemsInList(CurrentFolders , ";");i+=1) |
---|
389 | TempStr = ReplaceString(StartFolderName, StringFromList(i, CurrentFolders , ";"),"") |
---|
390 | if(strlen(TempStr)>0) |
---|
391 | ListOfAvailableData[j] = tempStr |
---|
392 | j+=1 |
---|
393 | endif |
---|
394 | endfor |
---|
395 | Redimension/N=(Numpnts(ListOfAvailableData)) SelectionOfAvailableData |
---|
396 | SelectionOfAvailableData = 0 |
---|
397 | setDataFolder OldDF |
---|
398 | end |
---|
399 | |
---|
400 | //******************************************************************************************************************************* |
---|
401 | //******************************************************************************************************************************* |
---|
402 | //******************************************************************************************************************************* |
---|
403 | //******************************************************************************************************************************* |
---|
404 | //******************************************************************************************************************************* |
---|
405 | |
---|
406 | Function IR2E_UnivExportToolSetVarProc(ctrlName,varNum,varStr,varName) : SetVariableControl |
---|
407 | String ctrlName |
---|
408 | Variable varNum |
---|
409 | String varStr |
---|
410 | String varName |
---|
411 | |
---|
412 | if(cmpstr(ctrlName,"HeaderSeparator")==0) |
---|
413 | DoWindow ExportNoteDisplay |
---|
414 | if(V_Flag) |
---|
415 | KillWIndow/Z ExportNoteDisplay |
---|
416 | else |
---|
417 | abort |
---|
418 | endif |
---|
419 | |
---|
420 | DFref oldDf= GetDataFolderDFR() |
---|
421 | |
---|
422 | setDataFolder root:Packages:IR2_UniversalDataExport |
---|
423 | |
---|
424 | NVAR AttachWaveNote |
---|
425 | NVAR DisplayWaveNote |
---|
426 | NVAR UseFolderNameForOutput |
---|
427 | NVAR UseYWaveNameForOutput |
---|
428 | |
---|
429 | SVAR DataFolderName |
---|
430 | SVAR IntensityWaveName |
---|
431 | SVAR QWavename |
---|
432 | SVAR ErrorWaveName |
---|
433 | SVAR CurrentlyLoadedDataName |
---|
434 | SVAR CurrentlySetOutputPath |
---|
435 | SVAR NewFileOutputName |
---|
436 | SVAR HeaderSeparator |
---|
437 | |
---|
438 | |
---|
439 | Wave/Z tempY=$(DataFolderName+possiblyQUoteName(IntensityWaveName)) |
---|
440 | if(!WaveExists(tempY)) |
---|
441 | setDataFolder OldDf |
---|
442 | abort |
---|
443 | endif |
---|
444 | string OldNote |
---|
445 | String nb = "ExportNoteDisplay" |
---|
446 | variable i |
---|
447 | if(DisplayWaveNote) |
---|
448 | OldNote = note(TempY) +"Exported="+date()+" "+time()+";" |
---|
449 | NewNotebook/K=1/N=$nb/F=0/V=1/K=0/W=(300,270,700,530) as "Data Notes" |
---|
450 | Notebook $nb defaultTab=20, statusWidth=238, pageMargins={72,72,72,72} |
---|
451 | Notebook $nb font="Arial", fStyle=0, textRGB=(0,0,0) |
---|
452 | For(i=0;i<ItemsInList(OldNOte);i+=1) |
---|
453 | Notebook $nb text=HeaderSeparator + stringFromList(i,OldNote)+"\r" |
---|
454 | endfor |
---|
455 | endif |
---|
456 | setDataFolder OldDf |
---|
457 | endif |
---|
458 | |
---|
459 | End |
---|
460 | |
---|
461 | //******************************************************************************************************************************* |
---|
462 | //******************************************************************************************************************************* |
---|
463 | //******************************************************************************************************************************* |
---|
464 | //******************************************************************************************************************************* |
---|
465 | //******************************************************************************************************************************* |
---|
466 | |
---|
467 | Function IR2E_UnivExportCheckProc(ctrlName,checked) : CheckBoxControl |
---|
468 | String ctrlName |
---|
469 | Variable checked |
---|
470 | |
---|
471 | DFref oldDf= GetDataFolderDFR() |
---|
472 | |
---|
473 | setDataFolder root:Packages:IR2_UniversalDataExport |
---|
474 | |
---|
475 | NVAR UseFolderNameForOutput |
---|
476 | NVAR UseYWaveNameForOutput |
---|
477 | |
---|
478 | SVAR DataFolderName |
---|
479 | SVAR IntensityWaveName |
---|
480 | SVAR QWavename |
---|
481 | SVAR ErrorWaveName |
---|
482 | SVAR CurrentlyLoadedDataName |
---|
483 | SVAR CurrentlySetOutputPath |
---|
484 | SVAR NewFileOutputName |
---|
485 | NVAR ExportCanSASNexus = root:Packages:IR2_UniversalDataExport:ExportCanSASNexus |
---|
486 | NVAR ExportASCII = root:Packages:IR2_UniversalDataExport:ExportASCII |
---|
487 | NVAR ExportGSASxye = root:Packages:IR2_UniversalDataExport:ExportGSASxye |
---|
488 | NVAR ASCIIExportQ = root:Packages:IR2_UniversalDataExport:ASCIIExportQ |
---|
489 | NVAR ASCIIExportD = root:Packages:IR2_UniversalDataExport:ASCIIExportD |
---|
490 | NVAR ASCIIExportTTH = root:Packages:IR2_UniversalDataExport:ASCIIExportTTH |
---|
491 | |
---|
492 | SVAR OutputNameExtension = root:Packages:IR2_UniversalDataExport:OutputNameExtension |
---|
493 | if(stringMatch(ctrlName,"ASCIIExportQ")) |
---|
494 | if(checked) |
---|
495 | ASCIIExportQ = 1 |
---|
496 | ASCIIExportD = 0 |
---|
497 | ASCIIExportTTH = 0 |
---|
498 | endif |
---|
499 | endif |
---|
500 | if(stringMatch(ctrlName,"ASCIIExportD")) |
---|
501 | if(checked) |
---|
502 | ASCIIExportQ = 0 |
---|
503 | ASCIIExportD = 1 |
---|
504 | ASCIIExportTTH = 0 |
---|
505 | endif |
---|
506 | endif |
---|
507 | if(stringMatch(ctrlName,"ASCIIExportTTH")) |
---|
508 | if(checked) |
---|
509 | ASCIIExportQ = 0 |
---|
510 | ASCIIExportD = 0 |
---|
511 | ASCIIExportTTH = 1 |
---|
512 | endif |
---|
513 | endif |
---|
514 | |
---|
515 | |
---|
516 | if(stringMatch(ctrlName,"ExportASCII")) |
---|
517 | if(checked) |
---|
518 | ExportASCII = 1 |
---|
519 | ExportCanSASNexus = 0 |
---|
520 | ExportGSASxye = 0 |
---|
521 | OutputNameExtension = "dat" |
---|
522 | endif |
---|
523 | endif |
---|
524 | if(stringMatch(ctrlName,"ExportGSASxye")) |
---|
525 | if(checked) |
---|
526 | ExportGSASxye = 1 |
---|
527 | ExportASCII = 0 |
---|
528 | ExportCanSASNexus = 0 |
---|
529 | OutputNameExtension = "xye" |
---|
530 | endif |
---|
531 | endif |
---|
532 | if(stringMatch(ctrlName,"ExportCanSASNexus")) |
---|
533 | if(checked) |
---|
534 | ExportGSASxye =0 |
---|
535 | ExportASCII = 0 |
---|
536 | ExportCanSASNexus = 1 |
---|
537 | OutputNameExtension = "h5" |
---|
538 | endif |
---|
539 | if(ExportCanSASNexus) |
---|
540 | DoAlert /T="NXcanSAS Warning for slit smeared data" 0, "At this time NO software has been verified to be able to use slit smeared data. Export ONLY desmeared USAXS data, please." |
---|
541 | endif |
---|
542 | endif |
---|
543 | NVAR UseFolderNameForOutput = root:Packages:IR2_UniversalDataExport:UseFolderNameForOutput |
---|
544 | NVAR UseYWaveNameForOutput = root:Packages:IR2_UniversalDataExport:UseYWaveNameForOutput |
---|
545 | if(stringMatch(ctrlName,"UseFolderNameForOutput")) |
---|
546 | if(checked) |
---|
547 | UseFolderNameForOutput = 1 |
---|
548 | UseYWaveNameForOutput = 0 |
---|
549 | else |
---|
550 | UseFolderNameForOutput = 0 |
---|
551 | UseYWaveNameForOutput = 1 |
---|
552 | endif |
---|
553 | endif |
---|
554 | if(stringMatch(ctrlName,"UseYWaveNameForOutput")) |
---|
555 | if(checked) |
---|
556 | UseFolderNameForOutput = 0 |
---|
557 | UseYWaveNameForOutput = 1 |
---|
558 | else |
---|
559 | UseFolderNameForOutput = 1 |
---|
560 | UseYWaveNameForOutput = 0 |
---|
561 | endif |
---|
562 | endif |
---|
563 | if(cmpstr(ctrlName,"UseFolderNameForOutput")==0 || cmpstr(ctrlName,"UseYWaveNameForOutput")==0) |
---|
564 | |
---|
565 | NewFileOutputName = "" |
---|
566 | if(UseFolderNameForOutput) |
---|
567 | NewFileOutputName += IN2G_RemoveExtraQuote(StringFromList(ItemsInList(DataFolderName,":")-1,DataFolderName,":"),1,1) |
---|
568 | endif |
---|
569 | if(UseFolderNameForOutput && UseYWaveNameForOutput) |
---|
570 | NewFileOutputName += "_" |
---|
571 | endif |
---|
572 | if(UseYWaveNameForOutput) |
---|
573 | NewFileOutputName += IN2G_RemoveExtraQuote(IntensityWaveName,1,1) |
---|
574 | endif |
---|
575 | |
---|
576 | endif |
---|
577 | nVAR ExportSingleCanSASFile = root:Packages:IR2_UniversalDataExport:ExportSingleCanSASFile |
---|
578 | if(stringMatch(ctrlName,"ExportSingleCanSASFile")) |
---|
579 | if(checked) |
---|
580 | ExportSingleCanSASFile=1 |
---|
581 | DoALert 0, "Type in \"Export file name\" name of file. Make sure it is acceptable name for the OS. " |
---|
582 | else |
---|
583 | ExportSingleCanSASFile=0 |
---|
584 | endif |
---|
585 | endif |
---|
586 | |
---|
587 | |
---|
588 | |
---|
589 | IR2E_FixMainGUI() |
---|
590 | setDataFolder OldDf |
---|
591 | End |
---|
592 | |
---|
593 | //******************************************************************************************************************************* |
---|
594 | //******************************************************************************************************************************* |
---|
595 | //******************************************************************************************************************************* |
---|
596 | //******************************************************************************************************************************* |
---|
597 | //******************************************************************************************************************************* |
---|
598 | |
---|
599 | Function IR2E_InputPanelButtonProc(ctrlName) : ButtonControl |
---|
600 | String ctrlName |
---|
601 | |
---|
602 | DFref oldDf= GetDataFolderDFR() |
---|
603 | |
---|
604 | setDataFolder root:Packages:IR2_UniversalDataExport |
---|
605 | if(cmpstr(ctrlName,"LoadAndGraphData")==0) |
---|
606 | //here we load the data and create default values |
---|
607 | IR2E_LoadDataInTool() |
---|
608 | endif |
---|
609 | if(cmpstr(ctrlName,"ExportOutputPath")==0) |
---|
610 | //here we set output path and patch it in the string to be seen by user |
---|
611 | IR2E_ChangeExportPath() |
---|
612 | endif |
---|
613 | if(cmpstr(ctrlName,"ExportData")==0) |
---|
614 | //here we do whatever is apropriate... |
---|
615 | IR2E_ExportTheData() |
---|
616 | endif |
---|
617 | if(cmpstr(ctrlName,"GetHelp")==0) |
---|
618 | //Open www manual with the right page |
---|
619 | IN2G_OpenWebManual("Irena/ExportData.html") |
---|
620 | endif |
---|
621 | |
---|
622 | setDataFolder oldDF |
---|
623 | end |
---|
624 | //******************************************************************************************************************************* |
---|
625 | //******************************************************************************************************************************* |
---|
626 | //******************************************************************************************************************************* |
---|
627 | //******************************************************************************************************************************* |
---|
628 | //******************************************************************************************************************************* |
---|
629 | |
---|
630 | Function IR2E_ExportTheData() |
---|
631 | |
---|
632 | DFref oldDf= GetDataFolderDFR() |
---|
633 | |
---|
634 | setDataFolder root:Packages:IR2_UniversalDataExport |
---|
635 | |
---|
636 | NVAR AttachWaveNote |
---|
637 | NVAR GraphData |
---|
638 | NVAR DisplayWaveNote |
---|
639 | NVAR UseFolderNameForOutput |
---|
640 | NVAR UseYWaveNameForOutput |
---|
641 | NVAR reduceOutputPrecision |
---|
642 | |
---|
643 | SVAR DataFolderName |
---|
644 | SVAR IntensityWaveName |
---|
645 | SVAR QWavename |
---|
646 | SVAR ErrorWaveName |
---|
647 | SVAR CurrentlyLoadedDataName |
---|
648 | SVAR CurrentlySetOutputPath |
---|
649 | SVAR NewFileOutputName |
---|
650 | SVAR OutputNameExtension |
---|
651 | SVAR HeaderSeparator |
---|
652 | |
---|
653 | string UserSampleName=IN2G_ReturnUserSampleName(DataFolderName) |
---|
654 | |
---|
655 | NVAR ExportCanSASNexus |
---|
656 | NVAR ExportASCII |
---|
657 | NVAR ExportGSASxye |
---|
658 | NVAR ExportMultipleCanSASFiles |
---|
659 | NVAR ExportSingleCanSASFile |
---|
660 | |
---|
661 | NVAR UseIndra2Data=root:Packages:IR2_UniversalDataExport:UseIndra2Data |
---|
662 | NVAR UseQRSdata=root:Packages:IR2_UniversalDataExport:UseQRSdata |
---|
663 | NVAR UseResults=root:Packages:IR2_UniversalDataExport:UseResults |
---|
664 | NVAR UseSMRData=root:Packages:IR2_UniversalDataExport:UseSMRData |
---|
665 | |
---|
666 | NVAR ASCIIExportQ=root:Packages:IR2_UniversalDataExport:ASCIIExportQ |
---|
667 | NVAR ASCIIExportD=root:Packages:IR2_UniversalDataExport:ASCIIExportD |
---|
668 | NVAR ASCIIExportTTH=root:Packages:IR2_UniversalDataExport:ASCIIExportTTH |
---|
669 | |
---|
670 | |
---|
671 | Wave/Z TempY=$(DataFolderName+possiblyquoteName(IntensityWaveName)) |
---|
672 | Wave/Z TempX=$(DataFolderName+possiblyquoteName(QWavename)) |
---|
673 | Wave/Z TempE=$(DataFolderName+possiblyquoteName(ErrorWaveName)) |
---|
674 | if(!WaveExists(TempE)) |
---|
675 | Duplicate/Free TempX, TempE |
---|
676 | TempE = 0 |
---|
677 | endif |
---|
678 | if(UseIndra2Data) |
---|
679 | Wave/Z TempdX=$(DataFolderName+ReplaceString("Qvec", QWavename, "dQ")) |
---|
680 | elseif(UseQRSdata) |
---|
681 | Wave/Z TempdX=$(DataFolderName+possiblyquoteName(ReplaceString("s_", ErrorWaveName, "w_", 0,1))) |
---|
682 | else |
---|
683 | //no such thing for other options |
---|
684 | endif |
---|
685 | if(!WaveExists(TempdX)) |
---|
686 | Duplicate/Free TempE, tempdX |
---|
687 | tempdX = 0 |
---|
688 | endif |
---|
689 | |
---|
690 | if(!WaveExists(TempY) && !WaveExists(TempX)) |
---|
691 | abort |
---|
692 | endif |
---|
693 | variable HaveErrors=0 |
---|
694 | if(WaveExists(TempE)) |
---|
695 | HaveErrors=1 |
---|
696 | endif |
---|
697 | |
---|
698 | if(strlen(NewFileOutputName)==0) |
---|
699 | abort "Create output file name first, please" |
---|
700 | endif |
---|
701 | variable refnum |
---|
702 | string FinalOutputName, oldNote, OldNoteT1 |
---|
703 | variable wvlgth |
---|
704 | |
---|
705 | |
---|
706 | if(ExportASCII) //this is old ASCII method... |
---|
707 | //Check for existing file and manage on our own... |
---|
708 | FinalOutputName=NewFileOutputName |
---|
709 | if(strlen(OutputNameExtension)>0) |
---|
710 | FinalOutputName+="."+OutputNameExtension |
---|
711 | endif |
---|
712 | |
---|
713 | Open/Z=1 /R/P=IR2E_ExportPath refnum as FinalOutputName |
---|
714 | if(V_Flag==0) |
---|
715 | DoAlert 1, "The file with this name: "+FinalOutputName+ " in this location already exists, overwrite?" |
---|
716 | if(V_Flag!=1) |
---|
717 | abort |
---|
718 | endif |
---|
719 | close/A |
---|
720 | //user wants to delete the file |
---|
721 | OpenNotebook/V=0/P=IR2E_ExportPath/N=JunkNbk FinalOutputName |
---|
722 | DoWindow/D /K JunkNbk |
---|
723 | endif |
---|
724 | close/A |
---|
725 | Duplicate/O TempY, NoteTempY |
---|
726 | string OldNoteT=note(TempY) |
---|
727 | note/K NoteTempY |
---|
728 | note NoteTempY, OldNoteT+"Exported="+date()+" "+time()+";" |
---|
729 | make/T/O WaveNoteWave |
---|
730 | if (AttachWaveNote ||(ASCIIExportTTH&&(UseIndra2Data || UseQRSdata))) |
---|
731 | IN2G_PasteWnoteToWave("NoteTempY", WaveNoteWave,HeaderSeparator) |
---|
732 | Save/G/M="\r\n"/P=IR2E_ExportPath WaveNoteWave as FinalOutputName |
---|
733 | endif |
---|
734 | if( UseIndra2Data || UseQRSdata) //scattering data |
---|
735 | //lower precision if needed |
---|
736 | Duplicate/O TempY,Intensity |
---|
737 | if(HaveErrors) |
---|
738 | Duplicate/O TempE, Uncertainty |
---|
739 | endif |
---|
740 | if(reduceOutputPrecision) |
---|
741 | Redimension/S Qvector_A,Intensity |
---|
742 | if(HaveErrors) |
---|
743 | Redimension/S Uncertainty |
---|
744 | endif |
---|
745 | endif |
---|
746 | |
---|
747 | OldNoteT1=note(Intensity) |
---|
748 | wvlgth = NumberByKey("Nika_Wavelength", OldNoteT1 , "=", ";") |
---|
749 | if(numtype(wvlgth)!=0) |
---|
750 | wvlgth = NumberByKey("Wavelength", OldNoteT1 , "=", ";") |
---|
751 | if(numtype(wvlgth)!=0) |
---|
752 | Prompt wvlgth, "Wavelength not found, please, provide" |
---|
753 | DoPrompt "Provide wavelength is A", wvlgth |
---|
754 | if (V_Flag || numtype(wvlgth)!=0 || wvlgth<0.01) |
---|
755 | return -1 // User canceled |
---|
756 | endif |
---|
757 | endif |
---|
758 | endif |
---|
759 | |
---|
760 | //convert q tth or d into what is asked for... |
---|
761 | Duplicate/Free tempX, TempXConverted |
---|
762 | if(ASCIIExportQ) //user wants Q |
---|
763 | if(StringMatch(QWavename, "q_*") || StringMatch(QWavename, "'q_*")||StringMatch(QWavename, "*_Qvec")) //q wave |
---|
764 | TempXConverted = tempX |
---|
765 | elseif(StringMatch(QWavename, "d_*") || StringMatch(QWavename, "'d_*")) //d wave |
---|
766 | //q = 2pi/d |
---|
767 | TempXCOnverted = 2*pi / TempX |
---|
768 | else //Two theta wave, convert to Q |
---|
769 | //q = 4pi sin(theta)/lambda |
---|
770 | TempXConverted = 4*pi*sin(TempX/(2 * 180/pi)) / wvlgth |
---|
771 | endif |
---|
772 | Duplicate/O TempXConverted,Qvector_A |
---|
773 | if(HaveErrors) |
---|
774 | Save/A=2/G/W/M="\r\n"/P=IR2E_ExportPath Qvector_A,Intensity,Uncertainty as FinalOutputName |
---|
775 | else |
---|
776 | Save/A=2/G/W/M="\r\n"/P=IR2E_ExportPath Qvector_A,Intensity as FinalOutputName |
---|
777 | endif |
---|
778 | elseif(ASCIIExportD) //user wants d |
---|
779 | if(StringMatch(QWavename, "q_*") || StringMatch(QWavename, "'q_*")||StringMatch(QWavename, "*_Qvec")) //q wave |
---|
780 | //d = 2pi/q |
---|
781 | TempXConverted = 2*pi / TempX |
---|
782 | elseif(StringMatch(QWavename, "d_*") || StringMatch(QWavename, "'d_*")) //d wave |
---|
783 | TempXConverted = tempX |
---|
784 | else //Two theta wave, convert to d |
---|
785 | //q = 4pi sin(theta)/lambda |
---|
786 | //d = 2*pi/Q : 2pi/(4pi*sin(theta)/lambda) |
---|
787 | //TTH = 114.592 * asin((2*pi/D) * wvlgth /(4*pi)) |
---|
788 | //D = 2*pi/(4*pi)*sin(TTH/114.592)/wvlgth |
---|
789 | TempXConverted = 1/(2*sin(TempX/(2 * 180/pi))/ wvlgth) |
---|
790 | endif |
---|
791 | Duplicate/O TempXConverted,Dspacing_A |
---|
792 | if(HaveErrors) |
---|
793 | Save/A=2/G/W/M="\r\n"/P=IR2E_ExportPath Dspacing_A,Intensity,Uncertainty as FinalOutputName |
---|
794 | else |
---|
795 | Save/A=2/G/W/M="\r\n"/P=IR2E_ExportPath Dspacing_A,Intensity as FinalOutputName |
---|
796 | endif |
---|
797 | elseif(ASCIIExportTTH) //user wants Two Theta |
---|
798 | if(StringMatch(QWavename, "q_*") || StringMatch(QWavename, "'q_*")||StringMatch(QWavename, "*_Qvec")) //q wave |
---|
799 | //TwoTheta = 2* asin(q * lambda /4pi) |
---|
800 | TempXCOnverted = 114.592 * asin(TempX * wvlgth /(4*pi)) |
---|
801 | elseif(StringMatch(QWavename, "d_*") || StringMatch(QWavename, "'d_*")) //d wave |
---|
802 | //TwoTheta = 2* asin(q * lambda /4pi), Q = 2*pi/D |
---|
803 | TempXCOnverted = 114.592 * asin((2*pi/TempX) * wvlgth /(4*pi)) |
---|
804 | else //Two theta wave, convert to d |
---|
805 | TempXConverted = tempX |
---|
806 | endif |
---|
807 | Duplicate/O TempXConverted,TwoTheta_Deg |
---|
808 | if(HaveErrors) |
---|
809 | Save/A=2/G/W/M="\r\n"/P=IR2E_ExportPath TwoTheta_Deg,Intensity,Uncertainty as FinalOutputName |
---|
810 | else |
---|
811 | Save/A=2/G/W/M="\r\n"/P=IR2E_ExportPath TwoTheta_Deg,Intensity as FinalOutputName |
---|
812 | endif |
---|
813 | endif |
---|
814 | KillWaves/Z WaveNoteWave, NoteTempY, Qvector_A,Intensity,Uncertainty, Dspacing_A, TwoTheta_Deg |
---|
815 | else //results or other, no idea what x, y, e is... |
---|
816 | //lower precision if needed |
---|
817 | Duplicate/O TempX,Xdata |
---|
818 | Duplicate/O TempY,Ydata |
---|
819 | if(HaveErrors) |
---|
820 | Duplicate/O TempE, Uncertainty |
---|
821 | endif |
---|
822 | if(reduceOutputPrecision) |
---|
823 | Redimension/S Xdata,Ydata |
---|
824 | if(HaveErrors) |
---|
825 | Redimension/S Uncertainty |
---|
826 | endif |
---|
827 | endif |
---|
828 | if(HaveErrors) |
---|
829 | Save/A=2/G/W/M="\r\n"/P=IR2E_ExportPath Xdata,Ydata,Uncertainty as FinalOutputName |
---|
830 | else |
---|
831 | Save/A=2/G/W/M="\r\n"/P=IR2E_ExportPath Xdata,Ydata as FinalOutputName |
---|
832 | endif |
---|
833 | KillWaves/Z WaveNoteWave, NoteTempY, Xdata,Ydata,Uncertainty |
---|
834 | endif |
---|
835 | endif |
---|
836 | |
---|
837 | if(ExportGSASxye) //this is GSAS-II xye file... |
---|
838 | //Check for existing file and manage on our own... |
---|
839 | FinalOutputName=NewFileOutputName |
---|
840 | if(strlen(OutputNameExtension)>0) |
---|
841 | FinalOutputName+="."+OutputNameExtension |
---|
842 | endif |
---|
843 | |
---|
844 | Open/Z=1 /R/P=IR2E_ExportPath refnum as FinalOutputName |
---|
845 | if(V_Flag==0) |
---|
846 | DoAlert 1, "The file with this name: "+FinalOutputName+ " in this location already exists, overwrite?" |
---|
847 | if(V_Flag!=1) |
---|
848 | abort |
---|
849 | endif |
---|
850 | close/A |
---|
851 | //user wants to delete the file |
---|
852 | OpenNotebook/V=0/P=IR2E_ExportPath/N=JunkNbk FinalOutputName |
---|
853 | DoWindow/D /K JunkNbk |
---|
854 | endif |
---|
855 | close/A |
---|
856 | Duplicate TempY, NoteTempY |
---|
857 | OldNoteT1=note(TempY) |
---|
858 | note/K NoteTempY |
---|
859 | note NoteTempY, OldNoteT1+"Exported="+date()+" "+time()+";" |
---|
860 | wvlgth = NumberByKey("Nika_Wavelength", OldNoteT1 , "=", ";") |
---|
861 | if(numtype(wvlgth)!=0) |
---|
862 | wvlgth = NumberByKey("Wavelength", OldNoteT1 , "=", ";") |
---|
863 | if(numtype(wvlgth)!=0) |
---|
864 | Prompt wvlgth, "Wavelength not found, please, provide" |
---|
865 | DoPrompt "Provide wavelength is A", wvlgth |
---|
866 | if (V_Flag || numtype(wvlgth)!=0 || wvlgth<0.01) |
---|
867 | return -1 // User canceled |
---|
868 | endif |
---|
869 | endif |
---|
870 | endif |
---|
871 | //convert q or d into two theta as needed... |
---|
872 | Duplicate/Free tempX, TempXCOnverted |
---|
873 | if(StringMatch(QWavename, "q_*") || StringMatch(QWavename, "'q_*")||StringMatch(QWavename, "*_Qvec")) //q wave |
---|
874 | TempXCOnverted = 2 * 180/pi * asin(TempX * wvlgth /(4*pi)) |
---|
875 | elseif(StringMatch(QWavename, "d_*") || StringMatch(QWavename, "'d_*")) //d wave |
---|
876 | TempXCOnverted = 2 * 180/pi * (wvlgth / (2*TempX)) |
---|
877 | else //Two theta wave nothing needed... |
---|
878 | |
---|
879 | endif |
---|
880 | |
---|
881 | make/T/O WaveNoteWave |
---|
882 | if (1) |
---|
883 | IN2G_PasteWnoteToWave("NoteTempY",WaveNoteWave ,HeaderSeparator) |
---|
884 | InsertPoints 0, 2, WaveNoteWave |
---|
885 | InsertPoints numpnts(WaveNoteWave), 2, WaveNoteWave |
---|
886 | WaveNoteWave[0] = "/*" |
---|
887 | WaveNoteWave[1] = HeaderSeparator+"wavelength = "+num2str(wvlgth) |
---|
888 | WaveNoteWave[numpnts(WaveNoteWave)-2] = "# 2Theta Intensity Error" |
---|
889 | WaveNoteWave[numpnts(WaveNoteWave)-1] = "*/" |
---|
890 | Save/G/M="\r\n"/P=IR2E_ExportPath WaveNoteWave as FinalOutputName |
---|
891 | endif |
---|
892 | if(HaveErrors) |
---|
893 | Save/A=2/G/M="\r\n"/P=IR2E_ExportPath TempXCOnverted,TempY,TempE as FinalOutputName |
---|
894 | else |
---|
895 | Save/A=2/G/M="\r\n"/P=IR2E_ExportPath TempXCOnverted,TempY as FinalOutputName |
---|
896 | endif |
---|
897 | KillWaves/Z WaveNoteWave, NoteTempY |
---|
898 | endif |
---|
899 | |
---|
900 | variable SlitLength |
---|
901 | |
---|
902 | if(ExportCanSASNexus) //export Nexus... now assume this is data, not model results. |
---|
903 | if(UseIndra2Data || UseQRSdata) |
---|
904 | FinalOutputName=NewFileOutputName |
---|
905 | if(strlen(OutputNameExtension)>0) |
---|
906 | FinalOutputName+="."+OutputNameExtension |
---|
907 | else |
---|
908 | OutputNameExtension= "hdf" |
---|
909 | FinalOutputName+="."+"hdf" |
---|
910 | endif |
---|
911 | oldNote=note(TempY) |
---|
912 | if(UseSMRData || stringMatch(NameOfWave(TempX),"*SMR*")) |
---|
913 | SlitLength = NumberByKey("SlitLength", oldNote, "=", ";") |
---|
914 | else |
---|
915 | SlitLength = 0 |
---|
916 | endif |
---|
917 | PathInfo IR2E_ExportPath |
---|
918 | NEXUS_WriteNx1DCanSASdata(UserSampleName, S_path+FinalOutputName, TempY, TempE, TempX, TempdX, "", "Irena", oldNote, SlitLength) |
---|
919 | else //results, not canSAS Nexus export available |
---|
920 | Abort "Cannot export Results into the canSAS Nexus files" |
---|
921 | endif |
---|
922 | endif |
---|
923 | print "Saved data into : "+FinalOutputName |
---|
924 | end |
---|
925 | |
---|
926 | //******************************************************************************************************************************* |
---|
927 | //******************************************************************************************************************************* |
---|
928 | //******************************************************************************************************************************* |
---|
929 | //******************************************************************************************************************************* |
---|
930 | //******************************************************************************************************************************* |
---|
931 | |
---|
932 | Function IR2E_LoadDataInTool() |
---|
933 | |
---|
934 | KillWIndow/Z TempExportGraph |
---|
935 | KillWIndow/Z ExportNoteDisplay |
---|
936 | KillWaves/Z TempX, TampY, TempE |
---|
937 | |
---|
938 | |
---|
939 | DFref oldDf= GetDataFolderDFR() |
---|
940 | |
---|
941 | setDataFolder root:Packages:IR2_UniversalDataExport |
---|
942 | |
---|
943 | NVAR AttachWaveNote = root:Packages:IR2_UniversalDataExport:AttachWaveNote |
---|
944 | NVAR GraphData = root:Packages:IR2_UniversalDataExport:GraphData |
---|
945 | NVAR DisplayWaveNote = root:Packages:IR2_UniversalDataExport:DisplayWaveNote |
---|
946 | NVAR UseFolderNameForOutput = root:Packages:IR2_UniversalDataExport:UseFolderNameForOutput |
---|
947 | NVAR UseYWaveNameForOutput = root:Packages:IR2_UniversalDataExport:UseYWaveNameForOutput |
---|
948 | NVAR ExportCanSASNexus = root:Packages:IR2_UniversalDataExport:ExportCanSASNexus |
---|
949 | NVAR ExportASCII = root:Packages:IR2_UniversalDataExport:ExportASCII |
---|
950 | NVAR ExportMultipleCanSASFiles = root:Packages:IR2_UniversalDataExport:ExportMultipleCanSASFiles |
---|
951 | NVAR ExportSingleCanSASFile = root:Packages:IR2_UniversalDataExport:ExportSingleCanSASFile |
---|
952 | NVAR ExportGSASxye = root:Packages:IR2_UniversalDataExport:ExportGSASxye |
---|
953 | |
---|
954 | SVAR DataFolderName = root:Packages:IR2_UniversalDataExport:DataFolderName |
---|
955 | SVAR IntensityWaveName = root:Packages:IR2_UniversalDataExport:IntensityWaveName |
---|
956 | SVAR QWavename = root:Packages:IR2_UniversalDataExport:QWavename |
---|
957 | SVAR ErrorWaveName = root:Packages:IR2_UniversalDataExport:ErrorWaveName |
---|
958 | SVAR CurrentlyLoadedDataName = root:Packages:IR2_UniversalDataExport:CurrentlyLoadedDataName |
---|
959 | SVAR CurrentlySetOutputPath = root:Packages:IR2_UniversalDataExport:CurrentlySetOutputPath |
---|
960 | SVAR NewFileOutputName = root:Packages:IR2_UniversalDataExport:NewFileOutputName |
---|
961 | SVAR HeaderSeparator = root:Packages:IR2_UniversalDataExport:HeaderSeparator |
---|
962 | |
---|
963 | |
---|
964 | Wave/Z tempY=$(DataFolderName+possiblyquoteName(IntensityWaveName)) |
---|
965 | Wave/Z tempX=$(DataFolderName+possiblyquoteName(QWavename)) |
---|
966 | Wave/Z tempE=$(DataFolderName+possiblyquoteName(ErrorWaveName)) |
---|
967 | |
---|
968 | if(!WaveExists(tempY) && !WaveExists(tempX)) |
---|
969 | abort |
---|
970 | endif |
---|
971 | |
---|
972 | CurrentlyLoadedDataName = DataFolderName+IntensityWaveName |
---|
973 | |
---|
974 | if(GraphData) |
---|
975 | Display/K=1/W=(300,40,700,250) TempY vs TempX as "Preview of export data" |
---|
976 | DoWindow/C TempExportGraph |
---|
977 | ModifyGraph log=1 |
---|
978 | TextBox/C/N=text0 CurrentlyLoadedDataName |
---|
979 | IN2G_AutoAlignPanelAndGraph() |
---|
980 | endif |
---|
981 | string OldNote |
---|
982 | String nb = "ExportNoteDisplay" |
---|
983 | variable i |
---|
984 | if(DisplayWaveNote) |
---|
985 | OldNote = note(TempY) +"Exported="+date()+" "+time()+";" |
---|
986 | NewNotebook/K=1/N=$nb/F=0/V=1/K=0/W=(300,270,700,530) as "Data Notes" |
---|
987 | Notebook $nb defaultTab=20, statusWidth=238, pageMargins={72,72,72,72} |
---|
988 | Notebook $nb font="Arial", fSize=10, fStyle=0, textRGB=(0,0,0) |
---|
989 | For(i=0;i<ItemsInList(OldNOte);i+=1) |
---|
990 | Notebook $nb text=HeaderSeparator+ stringFromList(i,OldNote)+"\r" |
---|
991 | endfor |
---|
992 | AutopositionWindow/M=0 /R=TempExportGraph ExportNoteDisplay |
---|
993 | endif |
---|
994 | |
---|
995 | |
---|
996 | if(ExportASCII || ExportGSASxye ||(ExportCanSASNexus * !ExportSingleCanSASFile)) |
---|
997 | NewFileOutputName = "" |
---|
998 | if(UseFolderNameForOutput) |
---|
999 | NewFileOutputName += IN2G_ReturnUserSampleName(DataFolderName) |
---|
1000 | endif |
---|
1001 | if(UseFolderNameForOutput && UseYWaveNameForOutput) |
---|
1002 | NewFileOutputName += "_" |
---|
1003 | endif |
---|
1004 | if(UseYWaveNameForOutput) |
---|
1005 | NewFileOutputName += IN2G_RemoveExtraQuote(IntensityWaveName,1,1) |
---|
1006 | endif |
---|
1007 | endif |
---|
1008 | |
---|
1009 | setDataFolder oldDF |
---|
1010 | |
---|
1011 | end |
---|
1012 | //******************************************************************************************************************************* |
---|
1013 | //******************************************************************************************************************************* |
---|
1014 | //******************************************************************************************************************************* |
---|
1015 | //******************************************************************************************************************************* |
---|
1016 | //******************************************************************************************************************************* |
---|
1017 | |
---|
1018 | Function IR2E_ChangeExportPath() |
---|
1019 | |
---|
1020 | DFref oldDf= GetDataFolderDFR() |
---|
1021 | |
---|
1022 | setDataFolder root:Packages:IR2_UniversalDataExport |
---|
1023 | SVAR CurrentlySetOutputPath=root:Packages:IR2_UniversalDataExport:CurrentlySetOutputPath |
---|
1024 | NewPath/O/M="Select new output folder" IR2E_ExportPath |
---|
1025 | PathInfo IR2E_ExportPath |
---|
1026 | CurrentlySetOutputPath=S_Path |
---|
1027 | |
---|
1028 | setDataFolder oldDF |
---|
1029 | |
---|
1030 | end |
---|
1031 | |
---|
1032 | ///****************************************************************************************** |
---|
1033 | ///****************************************************************************************** |
---|
1034 | ///****************************************************************************************** |
---|
1035 | ///****************************************************************************************** |
---|
1036 | ///****************************************************************************************** |
---|
1037 | ///****************************************************************************************** |
---|
1038 | |
---|
1039 | |
---|
1040 | Function IR2E_InitUnivDataExport() |
---|
1041 | |
---|
1042 | |
---|
1043 | DFref oldDf= GetDataFolderDFR() |
---|
1044 | |
---|
1045 | setdatafolder root: |
---|
1046 | NewDataFolder/O/S root:Packages |
---|
1047 | NewDataFolder/O/S IR2_UniversalDataExport |
---|
1048 | |
---|
1049 | string ListOfVariables |
---|
1050 | string ListOfStrings |
---|
1051 | variable i |
---|
1052 | |
---|
1053 | //here define the lists of variables and strings needed, separate names by ;... |
---|
1054 | |
---|
1055 | ListOfVariables="UseIndra2Data;UseQRSdata;UseResults;UseSMRData;UseUserDefinedData;" |
---|
1056 | ListOfVariables+="AttachWaveNote;GraphData;DisplayWaveNote;UseFolderNameForOutput;UseYWaveNameForOutput;" |
---|
1057 | ListOfVariables+="ExportMultipleDataSets;ASCIIExportQ;ASCIIExportD;ASCIIExportTTH;" |
---|
1058 | ListOfVariables+="ExportCanSASNexus;ExportASCII;ExportGSASxye;" |
---|
1059 | ListOfVariables+="ExportMultipleCanSASFiles;ExportSingleCanSASFile;reduceOutputPrecision;" |
---|
1060 | |
---|
1061 | ListOfStrings="DataFolderName;IntensityWaveName;QWavename;ErrorWaveName;" |
---|
1062 | ListOfStrings+="CurrentlyLoadedDataName;CurrentlySetOutputPath;NewFileOutputName;" |
---|
1063 | |
---|
1064 | //and here we create them |
---|
1065 | for(i=0;i<itemsInList(ListOfVariables);i+=1) |
---|
1066 | IN2G_CreateItem("variable",StringFromList(i,ListOfVariables)) |
---|
1067 | endfor |
---|
1068 | |
---|
1069 | for(i=0;i<itemsInList(ListOfStrings);i+=1) |
---|
1070 | IN2G_CreateItem("string",StringFromList(i,ListOfStrings)) |
---|
1071 | endfor |
---|
1072 | |
---|
1073 | |
---|
1074 | make/O/T/N=0 ListOfAvailableData |
---|
1075 | make/O/N=0 SelectionOfAvailableData |
---|
1076 | |
---|
1077 | SVAR/Z OutputNameExtension |
---|
1078 | if(!SVAR_Exists(OutputNameExtension)) |
---|
1079 | string/G OutputNameExtension |
---|
1080 | OutputNameExtension="dat" |
---|
1081 | endif |
---|
1082 | SVAR/Z HeaderSeparator |
---|
1083 | if(!SVAR_Exists(HeaderSeparator)) |
---|
1084 | string/G HeaderSeparator |
---|
1085 | HeaderSeparator="# " |
---|
1086 | endif |
---|
1087 | //Ouptu path |
---|
1088 | PathInfo IR2E_ExportPath |
---|
1089 | if(!V_Flag) |
---|
1090 | PathInfo Igor |
---|
1091 | NewPath/Q IR2E_ExportPath S_Path |
---|
1092 | endif |
---|
1093 | PathInfo IR2E_ExportPath |
---|
1094 | SVAR CurrentlySetOutputPath |
---|
1095 | CurrentlySetOutputPath=S_Path |
---|
1096 | |
---|
1097 | SVAR NewFileOutputName |
---|
1098 | NewFileOutputName="" |
---|
1099 | SVAR CurrentlyLoadedDataName |
---|
1100 | CurrentlyLoadedDataName = "" |
---|
1101 | SVAR DataFolderName |
---|
1102 | DataFolderName="" |
---|
1103 | SVAR IntensityWaveName |
---|
1104 | IntensityWaveName="" |
---|
1105 | SVAR QWavename |
---|
1106 | QWavename="" |
---|
1107 | SVAR ErrorWaveName |
---|
1108 | ErrorWaveName="" |
---|
1109 | |
---|
1110 | NVAR UseFolderNameForOutput |
---|
1111 | NVAR UseYWaveNameForOutput |
---|
1112 | if(UseFolderNameForOutput+UseYWaveNameForOutput !=1) |
---|
1113 | UseFolderNameForOutput = 1 |
---|
1114 | UseYWaveNameForOutput = 0 |
---|
1115 | endif |
---|
1116 | |
---|
1117 | NVAR ExportASCII |
---|
1118 | NVAR ExportCanSASNexus |
---|
1119 | NVAR ExportGSASxye |
---|
1120 | if(ExportASCII + ExportCanSASNexus + ExportGSASxye !=1) |
---|
1121 | ExportASCII = 1 |
---|
1122 | ExportCanSASNexus= 0 |
---|
1123 | ExportGSASxye = 0 |
---|
1124 | endif |
---|
1125 | NVAR ASCIIExportQ |
---|
1126 | NVAR ASCIIExportD |
---|
1127 | NVAR ASCIIExportTTH |
---|
1128 | if(ASCIIExportQ+ASCIIExportD+ASCIIExportTTH !=1) |
---|
1129 | ASCIIExportQ =1 |
---|
1130 | ASCIIExportD = 0 |
---|
1131 | ASCIIExportTTH = 0 |
---|
1132 | endif |
---|
1133 | setDataFolder OldDf |
---|
1134 | |
---|
1135 | end |
---|
1136 | |
---|
1137 | //******************************************************************************************************************************* |
---|
1138 | //******************************************************************************************************************************* |
---|
1139 | //******************************************************************************************************************************* |
---|
1140 | //******************************************************************************************************************************* |
---|
1141 | //******************************************************************************************************************************* |
---|
1142 | |
---|
1143 | |
---|
1144 | |
---|
1145 | Function IR2E_ExportAllAsNexus() |
---|
1146 | //this function exports all USAXS, SAXS, and WAXS data in current experiment |
---|
1147 | //use standard export tool, but hide it from user... |
---|
1148 | IR2E_UniversalDataExport() |
---|
1149 | DoWIndow/hide=1 UnivDataExportPanel |
---|
1150 | NVAR UseIndra2data = root:Packages:IR2_UniversalDataExport:UseIndra2data |
---|
1151 | NVAR UseQRSdata = root:Packages:IR2_UniversalDataExport:UseQRSdata |
---|
1152 | NVAR UseResults = root:Packages:IR2_UniversalDataExport:UseResults |
---|
1153 | SVAR DataFolderName = root:Packages:IR2_UniversalDataExport:DataFolderName |
---|
1154 | SVAR IntensityWaveName=root:Packages:IR2_UniversalDataExport:IntensityWaveName |
---|
1155 | SVAR QWavename=root:Packages:IR2_UniversalDataExport:QWavename |
---|
1156 | SVAR ErrorWaveName=root:Packages:IR2_UniversalDataExport:ErrorWaveName |
---|
1157 | UseResults = 0 |
---|
1158 | UseQRSdata = 0 |
---|
1159 | UseIndra2data = 1 |
---|
1160 | string CurrentFoldersUSAXS=IR2P_GenStringOfFolders(winNm="UnivDataExportPanel", returnListOfFolders=1, forceReset=1) |
---|
1161 | CurrentFoldersUSAXS = GrepList(CurrentFoldersUSAXS, "---",1 , ";" ) |
---|
1162 | //now we have all folders with data. These could be either USAXS SMR, USAXS DSM, and we have separate list for QRS data. |
---|
1163 | //print CurrentFoldersUSAXS |
---|
1164 | //print CurrentFoldersQRS |
---|
1165 | //mneed to verify the file name and location are available, use name of current Igor experiment and its location, |
---|
1166 | //add _nxcansas to it. |
---|
1167 | string currentEXPName=IgorInfo(1) |
---|
1168 | PathInfo home |
---|
1169 | string FinalOutputName, oldNote, OldNoteT1, tempFldr |
---|
1170 | string UserSampleName |
---|
1171 | string HomePathStr=S_path |
---|
1172 | FinalOutputName = currentEXPName+"_nxcansas.h5" |
---|
1173 | //print HomePathStr |
---|
1174 | variable refnum, SlitLength |
---|
1175 | variable i |
---|
1176 | |
---|
1177 | Open/Z=1 /R/P=home refnum as FinalOutputName |
---|
1178 | if(V_Flag==0) |
---|
1179 | DoAlert 1, "The file with this name: "+FinalOutputName+ " already exists in "+HomePathStr+" , overwrite?" |
---|
1180 | if(V_Flag!=1) |
---|
1181 | abort |
---|
1182 | endif |
---|
1183 | close/A |
---|
1184 | //user wants to delete the file |
---|
1185 | DeleteFile /P=home FinalOutputName |
---|
1186 | else |
---|
1187 | DoAlert 1, "New file with this name: "+FinalOutputName+ " will be created in "+HomePathStr+", continue?" |
---|
1188 | if(V_Flag!=1) |
---|
1189 | abort |
---|
1190 | endif |
---|
1191 | close/A |
---|
1192 | endif |
---|
1193 | variable ExportUSAXS=1 |
---|
1194 | variable ExportSAXS=1 |
---|
1195 | variable ExportWAXS=1 |
---|
1196 | variable ExportOtherQRS=1 |
---|
1197 | Prompt ExportUSAXS, "Export USAXS?", popup, "Yes;No;" |
---|
1198 | Prompt ExportSAXS, "Export QRS in root:SAXS/SAS/ImportedSAS?", popup, "Yes;No;" |
---|
1199 | Prompt ExportWAXS, "Export QRS in root:WAXS/WAS/ImportedWAXS?", popup, "Yes;No;" |
---|
1200 | Prompt ExportOtherQRS, "Export QRS in other locations?", popup, "Yes;No;" |
---|
1201 | DoPrompt/HELP="Choose if these specific types of data should be exported" "Select which data will be exported", ExportUSAXS, ExportSAXS, ExportWAXS, ExportOtherQRS |
---|
1202 | if (V_Flag) |
---|
1203 | return -1 // User canceled |
---|
1204 | endif |
---|
1205 | // note, value of 2 = NO |
---|
1206 | // to preset the names, code is here: IR2E_ExportMultipleFiles() |
---|
1207 | //export USAXS data |
---|
1208 | SVAR FolderMatchStr = root:Packages:IrenaControlProcs:UnivDataExportPanel:FolderMatchStr |
---|
1209 | FolderMatchStr="" |
---|
1210 | UseResults = 0 |
---|
1211 | UseQRSdata = 0 |
---|
1212 | UseIndra2data = 1 |
---|
1213 | STRUCT WMPopupAction PU_Struct |
---|
1214 | if(ItemsInList(CurrentFoldersUSAXS, ";")>0 && ExportUSAXS==1) |
---|
1215 | For(i=0;i<ItemsInList(CurrentFoldersUSAXS, ";");i+=1) |
---|
1216 | tempFldr = StringFromList(i, CurrentFoldersUSAXS, ";") |
---|
1217 | DataFolderName = StringFromList(i, CurrentFoldersUSAXS, ";") |
---|
1218 | PU_Struct.ctrlName = "SelectDataFolder" |
---|
1219 | PU_Struct.popNum=-1 |
---|
1220 | PU_Struct.eventCode=2 |
---|
1221 | PU_Struct.popStr=DataFolderName |
---|
1222 | PU_Struct.win = "UnivDataExportPanel" |
---|
1223 | PopupMenu SelectDataFolder win=UnivDataExportPanel, popmatch=StringFromList(ItemsInList(DataFolderName,":")-1,DataFolderName,":") |
---|
1224 | IR2C_PanelPopupControl(PU_Struct) |
---|
1225 | Wave/Z TempY=$(tempFldr+possiblyquoteName(IntensityWaveName)) |
---|
1226 | Wave/Z TempX=$(tempFldr+possiblyquoteName(QWavename)) |
---|
1227 | Wave/Z TempE=$(tempFldr+possiblyquoteName(ErrorWaveName)) |
---|
1228 | Wave/Z TempdX=$(DataFolderName+ReplaceString("Qvec", QWavename, "dQ")) |
---|
1229 | if(!WaveExists(TempdX)) |
---|
1230 | Duplicate/Free TempE, tempdXLoc |
---|
1231 | tempdXLoc = 0 |
---|
1232 | else |
---|
1233 | Duplicate/Free TempdX, tempdXLoc |
---|
1234 | endif |
---|
1235 | oldNote=note(TempY) |
---|
1236 | if(stringMatch(NameOfWave(TempX),"*SMR*")) |
---|
1237 | SlitLength = NumberByKey("SlitLength", oldNote, "=", ";") |
---|
1238 | else |
---|
1239 | SlitLength = 0 |
---|
1240 | print "Did not export dQ data as this causes issues in sasView" |
---|
1241 | tempdXLoc = 0 |
---|
1242 | endif |
---|
1243 | UserSampleName=IN2G_ReturnUserSampleName(DataFolderName) |
---|
1244 | NEXUS_WriteNx1DCanSASdata(UserSampleName, HomePathStr+FinalOutputName, TempY, TempE, TempX, tempdXLoc, "", "Irena", oldNote, SlitLength) |
---|
1245 | endfor |
---|
1246 | endif |
---|
1247 | |
---|
1248 | UseResults = 0 |
---|
1249 | UseQRSdata = 1 |
---|
1250 | UseIndra2data = 0 |
---|
1251 | string CurrentFoldersQRS=IR2P_GenStringOfFolders(winNm="UnivDataExportPanel", returnListOfFolders=1, forceReset=1) |
---|
1252 | CurrentFoldersQRS = GrepList(CurrentFoldersQRS, "---",1 , ";" ) |
---|
1253 | string TempList ="" |
---|
1254 | string TempList2 = "" |
---|
1255 | if(ExportSAXS==1) |
---|
1256 | TempList += GrepList(CurrentFoldersQRS, ":SAXS:" ,0 )+GrepList(CurrentFoldersQRS, ":SAS:" ,0 )+GrepList(CurrentFoldersQRS, ":ImportedSAS:" ,0 ) |
---|
1257 | endif |
---|
1258 | if(ExportWAXS==1) |
---|
1259 | TempList += GrepList(CurrentFoldersQRS, ":WAXS:" ,0 )+GrepList(CurrentFoldersQRS, ":WAS:" ,0 )+GrepList(CurrentFoldersQRS, ":ImportedWAXS:" ,0 ) |
---|
1260 | endif |
---|
1261 | if(ExportOtherQRS==1) |
---|
1262 | TempList2 = GrepList(CurrentFoldersQRS, ":WAXS:" ,1 ) |
---|
1263 | TempList2 = GrepList(TempList2, ":SAXS:" ,1 ) |
---|
1264 | TempList2 = GrepList(TempList2, ":WAS:" ,1 ) |
---|
1265 | TempList2 = GrepList(TempList2, ":SAS:" ,1 ) |
---|
1266 | TempList2 = GrepList(TempList2, ":ImportedWAXS:" ,1 ) |
---|
1267 | TempList2 = GrepList(TempList2, ":ImportedSAS:" ,1 ) |
---|
1268 | endif |
---|
1269 | CurrentFoldersQRS = TempList + TempList2 |
---|
1270 | if(ItemsInList(CurrentFoldersQRS, ";")>0) |
---|
1271 | For(i=0;i<ItemsInList(CurrentFoldersQRS, ";");i+=1) |
---|
1272 | tempFldr = StringFromList(i, CurrentFoldersQRS, ";") |
---|
1273 | DataFolderName = StringFromList(i, CurrentFoldersQRS, ";") |
---|
1274 | PU_Struct.ctrlName = "SelectDataFolder" |
---|
1275 | PU_Struct.popNum=-1 |
---|
1276 | PU_Struct.eventCode=2 |
---|
1277 | PU_Struct.popStr=DataFolderName |
---|
1278 | PU_Struct.win = "UnivDataExportPanel" |
---|
1279 | PopupMenu SelectDataFolder win=UnivDataExportPanel, popmatch=StringFromList(ItemsInList(DataFolderName,":")-1,DataFolderName,":") |
---|
1280 | IR2C_PanelPopupControl(PU_Struct) |
---|
1281 | Wave/Z TempY=$(tempFldr+possiblyquoteName(IntensityWaveName)) |
---|
1282 | Wave/Z TempX=$(tempFldr+possiblyquoteName(QWavename)) |
---|
1283 | Wave/Z TempE=$(tempFldr+possiblyquoteName(ErrorWaveName)) |
---|
1284 | Wave/Z TempdX=$(DataFolderName+ReplaceString("Qvec", QWavename, "dQ")) |
---|
1285 | if(!WaveExists(TempdX)) |
---|
1286 | Duplicate/Free TempE, tempdX |
---|
1287 | tempdX = 0 |
---|
1288 | endif |
---|
1289 | oldNote=note(TempY) |
---|
1290 | SlitLength = 0 |
---|
1291 | UserSampleName=IN2G_ReturnUserSampleName(DataFolderName) |
---|
1292 | NEXUS_WriteNx1DCanSASdata(UserSampleName, HomePathStr+FinalOutputName, TempY, TempE, TempX, TempdX, "", "Irena", oldNote, SlitLength) |
---|
1293 | endfor |
---|
1294 | endif |
---|
1295 | |
---|
1296 | |
---|
1297 | DOwindow/K UnivDataExportPanel |
---|
1298 | print "Exported all data from current experiment in file:" +FinalOutputName |
---|
1299 | end |
---|
1300 | |
---|
1301 | |
---|
1302 | |
---|
1303 | //************************************************************************************************************ |
---|
1304 | //************************************************************************************************************ |
---|
1305 | //************************************************************************************************************ |
---|
1306 | //************************************************************************************************************ |
---|