1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | #pragma version=5.0 |
---|
3 | #pragma IgorVersion=6.1 |
---|
4 | |
---|
5 | //************************** |
---|
6 | // |
---|
7 | // Vers. 1.2 092101 |
---|
8 | // Vers. 5.0 29MAR07 - branched from main reduction to split out facility |
---|
9 | // specific calls |
---|
10 | // |
---|
11 | // functions for reading raw data files from the VAX |
---|
12 | // - RAW data files are read into the RAW folder - integer data from the detector |
---|
13 | // is decompressed and given the proper orientation |
---|
14 | // - header information is placed into real,integer, or text waves in the order they appear |
---|
15 | // in the file header |
---|
16 | // |
---|
17 | // Work data (DIV File) is read into the DIV folder |
---|
18 | // |
---|
19 | //***************************** |
---|
20 | |
---|
21 | //simple, main entry procedure that will load a RAW sans data file (not a work file) |
---|
22 | //into the RAW dataFolder. It is up to the calling procedure to display the file |
---|
23 | // |
---|
24 | // called by MainPanel.ipf and ProtocolAsPanel.ipf |
---|
25 | // |
---|
26 | Function LoadRawSANSData(msgStr) |
---|
27 | String msgStr |
---|
28 | |
---|
29 | String filename="" |
---|
30 | |
---|
31 | //each routine is responsible for checking the current (displayed) data folder |
---|
32 | //selecting it, and returning to root when done |
---|
33 | PathInfo/S catPathName //should set the next dialog to the proper path... |
---|
34 | //get the filename, then read it in |
---|
35 | filename = PromptForPath(msgStr) //in SANS_Utils.ipf |
---|
36 | //check for cancel from dialog |
---|
37 | if(strlen(filename)==0) |
---|
38 | //user cancelled, abort |
---|
39 | SetDataFolder root: |
---|
40 | DoAlert 0, "No file selected, action aborted" |
---|
41 | return(1) |
---|
42 | Endif |
---|
43 | |
---|
44 | ReadHeaderAndData(filename) //this is the full Path+file |
---|
45 | |
---|
46 | Return(0) |
---|
47 | End |
---|
48 | |
---|
49 | |
---|
50 | //function that does the guts of reading the binary data file |
---|
51 | //fname is the full path:name;vers required to open the file |
---|
52 | // |
---|
53 | // The final root:RAW:data wave is the real |
---|
54 | //neutron counts and can be directly operated on |
---|
55 | // |
---|
56 | // header information is put into three waves: integersRead, realsRead, and textRead |
---|
57 | // logicals in the header are currently skipped, since they are no use in the |
---|
58 | // data reduction process. |
---|
59 | // |
---|
60 | // The output is the three R/T/I waves that are filled at least with minimal values |
---|
61 | // and the detector data loaded into an array named "data" |
---|
62 | // |
---|
63 | // see documentation for the expected information in each element of the R/T/I waves |
---|
64 | // and the minimum set of information. These waves can be increased in length so that |
---|
65 | // more information can be accessed as needed (propagating changes...) |
---|
66 | // |
---|
67 | // called by multiple .ipfs (when the file name is known) |
---|
68 | // |
---|
69 | // |
---|
70 | // THIS FUNCTION DOES NOT NEED TO BE MODIFIED. ONLY THE DATA ACCESSORS NEED TO BE CONSTRUCTED |
---|
71 | // |
---|
72 | Function ReadHeaderAndData(fname) |
---|
73 | String fname |
---|
74 | //this function is for reading in RAW data only, so it will always put data in RAW folder |
---|
75 | String curPath = "root:Packages:NIST:RAW:" |
---|
76 | SetDataFolder curPath //use the full path, so it will always work |
---|
77 | Variable/G root:Packages:NIST:RAW:gIsLogScale = 0 //initial state is linear, keep this in RAW folder |
---|
78 | |
---|
79 | Variable refNum,integer,realval,ii |
---|
80 | String sansfname,textstr,v0 |
---|
81 | |
---|
82 | Make/O/D/N=23 $"root:Packages:NIST:RAW:IntegersRead" |
---|
83 | Make/O/D/N=52 $"root:Packages:NIST:RAW:RealsRead" |
---|
84 | Make/O/T/N=11 $"root:Packages:NIST:RAW:TextRead" |
---|
85 | Make/O/N=7 $"root:Packages:NIST:RAW:LogicalsRead" |
---|
86 | |
---|
87 | Wave intw=$"root:Packages:NIST:RAW:IntegersRead" |
---|
88 | Wave realw=$"root:Packages:NIST:RAW:RealsRead" |
---|
89 | Wave/T textw=$"root:Packages:NIST:RAW:TextRead" |
---|
90 | Wave logw=$"root:Packages:NIST:RAW:LogicalsRead" |
---|
91 | |
---|
92 | // FILL IN 3 ARRAYS WITH HEADER INFORMATION FOR LATER USE |
---|
93 | // THESE ARE JUST THE MINIMALLY NECESSARY VALUES |
---|
94 | |
---|
95 | // filename as stored in the file header |
---|
96 | Open/R refNum as fname |
---|
97 | //skip first two bytes (VAX record length markers, not needed here) |
---|
98 | // FSetPos refNum, 2 |
---|
99 | //read the next 21 bytes as characters (fname) |
---|
100 | |
---|
101 | |
---|
102 | |
---|
103 | for (ii=0;ii<2;ii+=1) |
---|
104 | FReadLine refNum,textstr |
---|
105 | sscanf textstr,"%s",v0 |
---|
106 | |
---|
107 | endfor |
---|
108 | |
---|
109 | Close refnum |
---|
110 | |
---|
111 | textw[0]= v0 |
---|
112 | |
---|
113 | // print "function read raw used" |
---|
114 | |
---|
115 | // date and time of collection |
---|
116 | textw[1]= getFileCreationDate(fname) |
---|
117 | |
---|
118 | // run type identifier (this is a reader for RAW data) |
---|
119 | textw[2]= "RAW" |
---|
120 | |
---|
121 | // user account identifier (currently used only for NCNR-specific operations) |
---|
122 | textw[3]= getFileInstrument(fname) |
---|
123 | |
---|
124 | // sample label |
---|
125 | textw[6]= getSampleLabel(fname) |
---|
126 | |
---|
127 | // identifier of detector type, useful for setting detector constants |
---|
128 | //(currently used only for NCNR-specific operations) |
---|
129 | textw[9]= "" |
---|
130 | |
---|
131 | |
---|
132 | |
---|
133 | //total counting time in seconds |
---|
134 | intw[2] = getCountTime(fname) |
---|
135 | |
---|
136 | |
---|
137 | // total monitor count |
---|
138 | realw[0] = getMonitorCount(fname) |
---|
139 | |
---|
140 | // total detector count |
---|
141 | realw[2] = getDetCount(fname) |
---|
142 | |
---|
143 | // attenuator number (NCNR-specific, your stub returns 0) |
---|
144 | // may also be used to hold attenuator transmission (< 1) |
---|
145 | realw[3] = getAttenNumber(fname) |
---|
146 | |
---|
147 | // sample transmission |
---|
148 | realw[4] = getSampleTrans(fname) |
---|
149 | |
---|
150 | //sample thickness (cm) |
---|
151 | realw[5] = getSampleThickness(fname) |
---|
152 | |
---|
153 | // following 6 values are for non-linear spatial corrections to a detector (RC timing) |
---|
154 | // these values are set for a detctor that has a linear correspondence between |
---|
155 | // pixel number and real-space distance |
---|
156 | // 10 and 13 are the X and Y pixel dimensions, respectively (in mm!) |
---|
157 | //(11,12 and 13,14 are set to values for a linear response, as from a new Ordela detector) |
---|
158 | realw[10] = getDetectorPixelXSize(fname) |
---|
159 | realw[11] = 10000 |
---|
160 | realw[12] = 0 |
---|
161 | realw[13] = getDetectorPixelYSize(fname) |
---|
162 | realw[14] = 10000 |
---|
163 | realw[15] = 0 |
---|
164 | |
---|
165 | // beam center X,Y on the detector (in units of pixel coordinates (1,N)) |
---|
166 | realw[16] = getBeamXPos(fname) |
---|
167 | realw[17] = getBeamYPos(fname) |
---|
168 | |
---|
169 | // sample to detector distance (meters) |
---|
170 | realw[18] = getSDD(fname) |
---|
171 | |
---|
172 | // detector physical width (right now assumes square...) (in cm) |
---|
173 | realw[20] = 102 |
---|
174 | |
---|
175 | // beam stop diameter (assumes circular) (in mm) |
---|
176 | realw[21] = getBSDiameter(fname) |
---|
177 | |
---|
178 | // source aperture diameter (mm) |
---|
179 | realw[23] = getSourceApertureDiam(fname) |
---|
180 | |
---|
181 | // sample aperture diameter (mm) |
---|
182 | realw[24] = getSampleApertureDiam(fname) |
---|
183 | |
---|
184 | // source aperture to sample aperture distance |
---|
185 | realw[25] = getSourceToSampleDist(fname) |
---|
186 | |
---|
187 | // wavelength (A) |
---|
188 | realw[26] = getWavelength(fname) |
---|
189 | |
---|
190 | // wavelength spread (FWHM) |
---|
191 | realw[27] = getWavelengthSpread(fname) |
---|
192 | |
---|
193 | realw[52] = getreactorpower(fname) |
---|
194 | |
---|
195 | // beam stop X-position (motor reading, approximate cm from zero position) |
---|
196 | // currently NCNR-specific use to identify transmission measurements |
---|
197 | // you return 0 |
---|
198 | realw[37] = 0 |
---|
199 | |
---|
200 | |
---|
201 | // the actual data array, dimensions are set as globals in |
---|
202 | // InitFacilityGlobals() |
---|
203 | NVAR XPix = root:myGlobals:gNPixelsX |
---|
204 | NVAR YPix = root:myGlobals:gNPixelsX |
---|
205 | |
---|
206 | SetDataFolder curPath |
---|
207 | |
---|
208 | Make/D/O/N=(XPix,YPix) $"root:Packages:NIST:RAW:data" |
---|
209 | WAVE data=$"root:Packages:NIST:RAW:data" |
---|
210 | |
---|
211 | // fill the data array with the detector values |
---|
212 | getDetectorData(fname,data) |
---|
213 | |
---|
214 | Setdatafolder curpath |
---|
215 | |
---|
216 | Duplicate/O data $"root:Packages:NIST:RAW:linear_data" // data is "fresh" and linear scale, so copy it now |
---|
217 | |
---|
218 | //keep a string with the filename in the RAW folder |
---|
219 | String/G root:Packages:NIST:RAW:fileList = textw[0] |
---|
220 | |
---|
221 | Setdatafolder root: |
---|
222 | |
---|
223 | |
---|
224 | Return 0 |
---|
225 | |
---|
226 | End |
---|
227 | |
---|
228 | //**************** |
---|
229 | //main entry procedure for reading a "WORK.DIV" file |
---|
230 | //displays a quick image of the file, to check that it's correct |
---|
231 | //data is deposited in root:DIV data folder |
---|
232 | // |
---|
233 | // local, just for testing |
---|
234 | // |
---|
235 | Proc ReadWork_DIV() |
---|
236 | |
---|
237 | String fname = PromptForPath("Select detector sensitivity file") |
---|
238 | ReadHeaderAndWork("DIV",fname) //puts what is read in work.div |
---|
239 | |
---|
240 | String waveStr = "root:Packages:NIST:DIV:data" |
---|
241 | NewImage/F/K=1/S=2 $waveStr |
---|
242 | ModifyImage '' ctab= {*,*,YellowHot,0} |
---|
243 | |
---|
244 | String/G root:Packages:NIST:DIV:fileList = "WORK.DIV" |
---|
245 | |
---|
246 | SetDataFolder root: //(redundant) |
---|
247 | End |
---|
248 | |
---|
249 | |
---|
250 | |
---|
251 | |
---|
252 | /////////DIV file created with NIST reduction so has the VAX format.... painful |
---|
253 | // |
---|
254 | // Detector sensitivity files have the same header structure as RAW SANS data |
---|
255 | // as NCNR, just with a different data array (real, rather than integer data) |
---|
256 | // |
---|
257 | // So for your facility, make this reader specific to the format of whatever |
---|
258 | // file you use for a pixel-by-pixel division of the raw detector data |
---|
259 | // to correct for non-uniform sensitivities of the detector. This is typically a |
---|
260 | // measurement of water, plexiglas, or another uniform scattering sample. |
---|
261 | // |
---|
262 | // The data must be normalized to a mean value of 1 |
---|
263 | // |
---|
264 | // called from ProtocolAsPanel.ipf |
---|
265 | // |
---|
266 | // type is "DIV" on input |
---|
267 | Function ReadHeaderAndWork(type,fname) |
---|
268 | String type,fname |
---|
269 | |
---|
270 | //type is the desired folder to read the workfile to |
---|
271 | //this data will NOT be automatically displayed |
---|
272 | // gDataDisplayType is unchanged |
---|
273 | |
---|
274 | String cur_folder = type |
---|
275 | String curPath = "root:Packages:NIST:"+cur_folder |
---|
276 | SetDataFolder curPath //use the full path, so it will always work |
---|
277 | |
---|
278 | Variable refNum,integer,realval |
---|
279 | String sansfname,textstr |
---|
280 | Variable/G $(curPath + ":gIsLogScale") = 0 //initial state is linear, keep this in DIV folder |
---|
281 | |
---|
282 | Make/O/D/N=23 $(curPath + ":IntegersRead") |
---|
283 | Make/O/D/N=52 $(curPath + ":RealsRead") |
---|
284 | Make/O/T/N=11 $(curPath + ":TextRead") |
---|
285 | |
---|
286 | WAVE intw=$(curPath + ":IntegersRead") |
---|
287 | WAVE realw=$(curPath + ":RealsRead") |
---|
288 | WAVE/T textw=$(curPath + ":TextRead") |
---|
289 | |
---|
290 | // the actual data array, dimensions are set as globals inÊ |
---|
291 | // InitFacilityGlobals() |
---|
292 | NVAR XPix = root:myGlobals:gNPixelsX |
---|
293 | NVAR YPix = root:myGlobals:gNPixelsX |
---|
294 | |
---|
295 | Make/O/D/N=(XPix,YPix) $(curPath + ":data") |
---|
296 | WAVE data = $(curPath + ":data") |
---|
297 | |
---|
298 | Make/O/D/N=(XPix,YPix) $(curPath + ":linear_data") |
---|
299 | WAVE linear_data = $(curPath + ":linear_data") |
---|
300 | |
---|
301 | // (1) |
---|
302 | // fill in your reader for the header here so that intw, realw, and textW are filled in |
---|
303 | // -- these are not really needed at all, so skip them for now |
---|
304 | // a simple duplication of some other data may be sufficient |
---|
305 | if(exists("root:Packages:NIST:raw:realsread") == 1) |
---|
306 | Duplicate/O $("root:Packages:NIST:raw:realsread"),$(curPath+ ":realsread") |
---|
307 | Duplicate/O $("root:Packages:NIST:raw:integersread"),$(curPath+ ":integersread") |
---|
308 | Duplicate/O/T $("root:Packages:NIST:raw:Textread"),$(curPath+ ":Textread") |
---|
309 | endif |
---|
310 | |
---|
311 | //(2) |
---|
312 | // then fill in a reader for the data array that will DIVIDE your data |
---|
313 | // to get the corrected values. |
---|
314 | |
---|
315 | //here you load in your file, you're already in the DIV folder |
---|
316 | LoadWave/O fname //since fname is the full path |
---|
317 | |
---|
318 | String loadedStr = StringFromList(0,S_waveNames,";") //then name of the wave loaded |
---|
319 | |
---|
320 | // data loaded should be named "linear_data" (this is set in the DIV writer) |
---|
321 | Duplicate/O linear_data,data // folder is in linear scale in its as-loaded state, so both are linear |
---|
322 | |
---|
323 | //keep a string with the filename in the DIV folder |
---|
324 | String/G $(curPath + ":fileList") = textw[0] |
---|
325 | |
---|
326 | //return the data folder to root |
---|
327 | SetDataFolder root: |
---|
328 | |
---|
329 | Return(0) |
---|
330 | End |
---|
331 | |
---|
332 | |
---|
333 | ///// ASC FORMAT READER ////// |
---|
334 | ///// FOR WORKFILE MATH PANEL ////// |
---|
335 | // |
---|
336 | //function to read in the ASC output of SANS reduction |
---|
337 | // currently the file has 20 header lines, followed by a single column |
---|
338 | // of 16384 values, Data is written by row, starting with Y=1 and X=(1->128) |
---|
339 | // |
---|
340 | //returns 0 if read was ok |
---|
341 | //returns 1 if there was an error |
---|
342 | // |
---|
343 | // called by WorkFileUtils.ipf |
---|
344 | // |
---|
345 | // |
---|
346 | // If the ASC data was generated by the NCNR data writer, then |
---|
347 | // NOTHING NEEDS TO BE CHANGED HERE |
---|
348 | // |
---|
349 | Function ReadASCData(fname,destPath) |
---|
350 | String fname, destPath |
---|
351 | //this function is for reading in ASCII data so put data in user-specified folder |
---|
352 | SetDataFolder "root:Packages:NIST:"+destPath |
---|
353 | |
---|
354 | NVAR pixelsX = root:myGlobals:gNPixelsX |
---|
355 | NVAR pixelsY = root:myGlobals:gNPixelsY |
---|
356 | Variable refNum=0,ii,p1,p2,tot,num=pixelsX,numHdrLines=220 ///waas 20 for NIST |
---|
357 | String str="" |
---|
358 | //data is initially linear scale |
---|
359 | Variable/G :gIsLogScale=0 |
---|
360 | Make/O/T/N=(numHdrLines) hdrLines |
---|
361 | Make/O/D/N=(pixelsX*pixelsY) data //,linear_data |
---|
362 | |
---|
363 | //full filename and path is now passed in... |
---|
364 | //actually open the file |
---|
365 | // SetDataFolder destPath |
---|
366 | Open/R/Z refNum as fname // /Z flag means I must handle open errors |
---|
367 | if(refnum==0) //FNF error, get out |
---|
368 | DoAlert 0,"Could not find file: "+fname |
---|
369 | Close/A |
---|
370 | SetDataFolder root: |
---|
371 | return(1) |
---|
372 | endif |
---|
373 | if(V_flag!=0) |
---|
374 | DoAlert 0,"File open error: V_flag="+num2Str(V_Flag) |
---|
375 | Close/A |
---|
376 | SetDataFolder root: |
---|
377 | return(1) |
---|
378 | Endif |
---|
379 | // |
---|
380 | for(ii=0;ii<numHdrLines;ii+=1) //read (or skip) 18 header lines |
---|
381 | FReadLine refnum,str |
---|
382 | hdrLines[ii]=str |
---|
383 | endfor |
---|
384 | // |
---|
385 | Close refnum |
---|
386 | |
---|
387 | // SetDataFolder destPath |
---|
388 | |
---|
389 | //loadwave /A=tempGBwave/L={0, start, numrow, 0, numcol}/N/G/D/O/E=1/K=1 |
---|
390 | |
---|
391 | |
---|
392 | LoadWave/Q/G/D/N=temp fName |
---|
393 | Wave/Z temp0=temp0 |
---|
394 | data=temp0 |
---|
395 | Redimension/N=(pixelsX,pixelsY) data //,linear_data |
---|
396 | |
---|
397 | //linear_data = data |
---|
398 | |
---|
399 | KillWaves/Z temp0 |
---|
400 | |
---|
401 | //return the data folder to root |
---|
402 | SetDataFolder root: |
---|
403 | |
---|
404 | Return(0) |
---|
405 | End |
---|
406 | |
---|
407 | // fills the "default" fake header so that the SANS Reduction machinery does not have to be altered |
---|
408 | // pay attention to what is/not to be trusted due to "fake" information. |
---|
409 | // uses what it can from the header lines from the ASC file (hdrLines wave) |
---|
410 | // |
---|
411 | // destFolder is of the form "myGlobals:WorkMath:AAA" |
---|
412 | // |
---|
413 | // |
---|
414 | // called by WorkFileUtils.ipf |
---|
415 | // |
---|
416 | // If the ASC data was generated by the NCNR data writer, then |
---|
417 | // NOTHING NEEDS TO BE CHANGED HERE |
---|
418 | // |
---|
419 | Function FillFakeHeader_ASC(destFolder) |
---|
420 | String destFolder |
---|
421 | Make/O/D/N=23 $("root:Packages:NIST:"+destFolder+":IntegersRead") |
---|
422 | Make/O/D/N=52 $("root:Packages:NIST:"+destFolder+":RealsRead") |
---|
423 | Make/O/T/N=11 $("root:Packages:NIST:"+destFolder+":TextRead") |
---|
424 | |
---|
425 | Wave intw=$("root:Packages:NIST:"+destFolder+":IntegersRead") |
---|
426 | Wave realw=$("root:Packages:NIST:"+destFolder+":RealsRead") |
---|
427 | Wave/T textw=$("root:Packages:NIST:"+destFolder+":TextRead") |
---|
428 | |
---|
429 | //Put in appropriate "fake" values |
---|
430 | //parse values as needed from headerLines |
---|
431 | Wave/T hdr=$("root:Packages:NIST:"+destFolder+":hdrLines") |
---|
432 | Variable monCt,lam,offset,sdd,trans,thick |
---|
433 | Variable xCtr,yCtr,a1,a2,a1a2Dist,dlam,bsDiam |
---|
434 | String detTyp="" |
---|
435 | String tempStr="",formatStr="",junkStr="" |
---|
436 | formatStr = "%g %g %g %g %g %g" |
---|
437 | tempStr=hdr[3] |
---|
438 | sscanf tempStr, formatStr, monCt,lam,offset,sdd,trans,thick |
---|
439 | // Print monCt,lam,offset,sdd,trans,thick,avStr,step |
---|
440 | formatStr = "%g %g %g %g %g %g %g %s" |
---|
441 | tempStr=hdr[5] |
---|
442 | sscanf tempStr,formatStr,xCtr,yCtr,a1,a2,a1a2Dist,dlam,bsDiam,detTyp |
---|
443 | // Print xCtr,yCtr,a1,a2,a1a2Dist,dlam,bsDiam,detTyp |
---|
444 | |
---|
445 | realw[16]=xCtr //xCtr(pixels) |
---|
446 | realw[17]=yCtr //yCtr (pixels) |
---|
447 | realw[18]=sdd //SDD (m) |
---|
448 | realw[26]=lam //wavelength (A) |
---|
449 | // |
---|
450 | // necessary values |
---|
451 | realw[10]=8 //detector calibration constants, needed for averaging |
---|
452 | realw[11]=10000 |
---|
453 | realw[12]=0 |
---|
454 | realw[13]=8 |
---|
455 | realw[14]=10000 |
---|
456 | realw[15]=0 |
---|
457 | // |
---|
458 | // used in the resolution calculation, ONLY here to keep the routine from crashing |
---|
459 | realw[20]=102 //det size |
---|
460 | realw[27]=dlam //delta lambda |
---|
461 | realw[21]=bsDiam //BS size |
---|
462 | realw[23]=a1 //A1 |
---|
463 | realw[24]=a2 //A2 |
---|
464 | realw[25]=a1a2Dist //A1A2 distance |
---|
465 | realw[4]=trans //trans |
---|
466 | realw[3]=0 //atten |
---|
467 | realw[5]=thick //thick |
---|
468 | // |
---|
469 | // |
---|
470 | realw[0]=monCt //def mon cts |
---|
471 | |
---|
472 | // fake values to get valid deadtime and detector constants |
---|
473 | // |
---|
474 | textw[9]=detTyp+" " //6 characters 4+2 spaces |
---|
475 | textw[3]="[NGxSANS00]" //11 chars, NGx will return default values for atten trans, deadtime... |
---|
476 | |
---|
477 | //set the string values |
---|
478 | formatStr="FILE: %s CREATED: %s" |
---|
479 | sscanf hdr[0],formatStr,tempStr,junkStr |
---|
480 | // Print tempStr |
---|
481 | // Print junkStr |
---|
482 | String/G $("root:Packages:NIST:"+destFolder+":fileList") = tempStr |
---|
483 | textw[0] = tempStr //filename |
---|
484 | textw[1] = junkStr //run date-time |
---|
485 | |
---|
486 | //file label = hdr[1] |
---|
487 | tempStr = hdr[1] |
---|
488 | tempStr = tempStr[0,strlen(tempStr)-2] //clean off the last LF |
---|
489 | // Print tempStr |
---|
490 | textW[6] = tempStr //sample label |
---|
491 | |
---|
492 | return(0) |
---|
493 | End |
---|
494 | |
---|
495 | |
---|
496 | ///////// ACCESSORS FOR WRITING DATA TO HEADER ///////// |
---|
497 | ///// |
---|
498 | |
---|
499 | // Write* routines all must: |
---|
500 | // (1) open file "fname". fname is a full file path and name to the file on disk |
---|
501 | // (2) write the specified value to the header at the correct location in the file |
---|
502 | // (3) close the file |
---|
503 | |
---|
504 | //sample transmission (0<T<=1) |
---|
505 | Function WriteTransmissionToHeader(fname,trans) |
---|
506 | String fname |
---|
507 | Variable trans |
---|
508 | |
---|
509 | // your writer here |
---|
510 | |
---|
511 | WriteReal(fname,trans,5589) //I will define at position 10 lines position 1 by myself |
---|
512 | |
---|
513 | // 16 bites between numbers and 81 per line |
---|
514 | |
---|
515 | return(0) |
---|
516 | End |
---|
517 | |
---|
518 | //whole transmission is NCNR-specific right now |
---|
519 | // leave this stub empty |
---|
520 | Function WriteWholeTransToHeader(fname,trans) |
---|
521 | String fname |
---|
522 | Variable trans |
---|
523 | |
---|
524 | // do nothing for now |
---|
525 | WriteReal(fname,trans,6885) /// //I will define at position last lines position 1 by myself |
---|
526 | |
---|
527 | return(0) |
---|
528 | End |
---|
529 | |
---|
530 | //box sum counts is a real value |
---|
531 | // used for transmission calculation module |
---|
532 | Function WriteBoxCountsToHeader(fname,counts) |
---|
533 | String fname |
---|
534 | Variable counts |
---|
535 | |
---|
536 | // do nothing if not using NCNR Transmission module |
---|
537 | |
---|
538 | WriteReal(fname,counts,6868) |
---|
539 | |
---|
540 | ////I will define at position 2 lines before the end and last position by myself |
---|
541 | |
---|
542 | |
---|
543 | return(0) |
---|
544 | End |
---|
545 | |
---|
546 | //beam stop X-position |
---|
547 | // used for transmission module to manually tag transmission files |
---|
548 | Function WriteBSXPosToHeader(fname,xpos) |
---|
549 | String fname |
---|
550 | Variable xpos |
---|
551 | |
---|
552 | // do nothing if not using NCNR Transmission module |
---|
553 | |
---|
554 | WriteReal(fname,xpos,5119) ////should do it for ypos for ILL ....NEED TO REMEMBER HERE |
---|
555 | /// line 4 column 2 |
---|
556 | |
---|
557 | return(0) |
---|
558 | End |
---|
559 | |
---|
560 | //sample thickness in cm |
---|
561 | Function WriteThicknessToHeader(fname,num) |
---|
562 | String fname |
---|
563 | Variable num |
---|
564 | |
---|
565 | // your code here |
---|
566 | |
---|
567 | WriteReal(fname,num,5508) //define at 9 lines column 1 just above transmission by myself |
---|
568 | |
---|
569 | return(0) |
---|
570 | End |
---|
571 | |
---|
572 | //beam center X pixel location (detector coordinates) |
---|
573 | Function WriteBeamCenterXToHeader(fname,num) |
---|
574 | String fname |
---|
575 | Variable num |
---|
576 | |
---|
577 | // your code here |
---|
578 | |
---|
579 | // pos (1) on line 71 => 70 lines x 81 char |
---|
580 | WriteReal(fname,num*10,5670) |
---|
581 | |
---|
582 | /// line 11 column 1 |
---|
583 | |
---|
584 | return(0) |
---|
585 | End |
---|
586 | |
---|
587 | //beam center Y pixel location (detector coordinates) |
---|
588 | Function WriteBeamCenterYToHeader(fname,num) |
---|
589 | String fname |
---|
590 | Variable num |
---|
591 | |
---|
592 | // your code here |
---|
593 | |
---|
594 | WriteReal(fname,num*10,5686) |
---|
595 | |
---|
596 | /// line 11 column 2 |
---|
597 | |
---|
598 | return(0) |
---|
599 | End |
---|
600 | |
---|
601 | //attenuator number (not its transmission) |
---|
602 | // if your beam attenuation is indexed in some way, use that number here |
---|
603 | // if not, write a 1 to the file here as a default |
---|
604 | // |
---|
605 | Function WriteAttenNumberToHeader(fname,num) |
---|
606 | String fname |
---|
607 | Variable num |
---|
608 | |
---|
609 | // your code here, default of 1 |
---|
610 | WriteReal(fname,num,5799) |
---|
611 | |
---|
612 | /// line 12 column 4 |
---|
613 | |
---|
614 | return(0) |
---|
615 | End |
---|
616 | |
---|
617 | |
---|
618 | Function WritereactorpowerToHeader(fname,num) |
---|
619 | String fname |
---|
620 | Variable num |
---|
621 | |
---|
622 | // your code here, default of 1 |
---|
623 | WriteReal(fname,num,6204) |
---|
624 | |
---|
625 | /// line 12 column 4 |
---|
626 | |
---|
627 | return(0) |
---|
628 | End |
---|
629 | |
---|
630 | |
---|
631 | |
---|
632 | |
---|
633 | |
---|
634 | |
---|
635 | |
---|
636 | |
---|
637 | // total monitor count during data collection |
---|
638 | Function WriteMonitorCountToHeader(fname,num) |
---|
639 | String fname |
---|
640 | Variable num |
---|
641 | |
---|
642 | // your code here |
---|
643 | |
---|
644 | WriteReal(fname,num,4924) |
---|
645 | |
---|
646 | /// line 1 column 5 |
---|
647 | |
---|
648 | return(0) |
---|
649 | End |
---|
650 | |
---|
651 | //total detector count |
---|
652 | Function WriteDetectorCountToHeader(fname,num) |
---|
653 | String fname |
---|
654 | Variable num |
---|
655 | |
---|
656 | // your code here |
---|
657 | |
---|
658 | WriteReal(fname,num,4908) |
---|
659 | |
---|
660 | /// line 1 column 4 |
---|
661 | |
---|
662 | return(0) |
---|
663 | End |
---|
664 | |
---|
665 | //transmission detector count |
---|
666 | // (currently unused in data reduction) |
---|
667 | Function WriteTransDetCountToHeader(fname,num) |
---|
668 | String fname |
---|
669 | Variable num |
---|
670 | |
---|
671 | // do nothing for now |
---|
672 | |
---|
673 | return(0) |
---|
674 | End |
---|
675 | |
---|
676 | //wavelength (Angstroms) |
---|
677 | Function WriteWavelengthToHeader(fname,num) |
---|
678 | String fname |
---|
679 | Variable num |
---|
680 | |
---|
681 | // your code here |
---|
682 | WriteReal(fname,num,5703) |
---|
683 | |
---|
684 | // line 11 column 3 |
---|
685 | |
---|
686 | return(0) |
---|
687 | End |
---|
688 | |
---|
689 | //wavelength spread (FWHM) |
---|
690 | Function WriteWavelengthDistrToHeader(fname,num) |
---|
691 | String fname |
---|
692 | Variable num |
---|
693 | |
---|
694 | // your code here |
---|
695 | |
---|
696 | WriteReal(fname,num,5719) |
---|
697 | |
---|
698 | // line 11 column 4 |
---|
699 | |
---|
700 | return(0) |
---|
701 | End |
---|
702 | |
---|
703 | //temperature of the sample (C) |
---|
704 | Function WriteTemperatureToHeader(fname,num) |
---|
705 | String fname |
---|
706 | Variable num |
---|
707 | |
---|
708 | // your code here |
---|
709 | |
---|
710 | WriteReal(fname,num,5347) |
---|
711 | |
---|
712 | // line 7 column 1 |
---|
713 | |
---|
714 | return(0) |
---|
715 | End |
---|
716 | |
---|
717 | //magnetic field (Oe) |
---|
718 | Function WriteMagnFieldToHeader(fname,num) |
---|
719 | String fname |
---|
720 | Variable num |
---|
721 | |
---|
722 | // your code here |
---|
723 | |
---|
724 | return(0) |
---|
725 | End |
---|
726 | |
---|
727 | //Source Aperture diameter (millimeters) |
---|
728 | Function WriteSourceApDiamToHeader(fname,num) |
---|
729 | String fname |
---|
730 | Variable num |
---|
731 | |
---|
732 | // your code here |
---|
733 | // WriteReal(fname,num,5348) |
---|
734 | WriteReal(fname,num,6027) ///4*81 = 324 |
---|
735 | |
---|
736 | // line 15 colum 3 |
---|
737 | |
---|
738 | return(0) |
---|
739 | End |
---|
740 | |
---|
741 | //Sample Aperture diameter (millimeters) |
---|
742 | Function WriteSampleApDiamToHeader(fname,num) |
---|
743 | String fname |
---|
744 | Variable num |
---|
745 | |
---|
746 | //your code here |
---|
747 | WriteReal(fname,num,6043) |
---|
748 | |
---|
749 | // line 15 colum 4 |
---|
750 | |
---|
751 | return(0) |
---|
752 | End |
---|
753 | |
---|
754 | //Source aperture to sample aperture distance (meters) |
---|
755 | Function WriteSrcToSamDistToHeader(fname,num) |
---|
756 | String fname |
---|
757 | Variable num |
---|
758 | |
---|
759 | // your code here |
---|
760 | WriteReal(fname,num,5784) //it is collimation at ILL |
---|
761 | |
---|
762 | |
---|
763 | return(0) |
---|
764 | End |
---|
765 | |
---|
766 | //lateral detector offset (centimeters) |
---|
767 | Function WriteDetectorOffsetToHeader(fname,num) |
---|
768 | String fname |
---|
769 | Variable num |
---|
770 | |
---|
771 | //your code here |
---|
772 | |
---|
773 | WriteReal(fname,10*num,5849) |
---|
774 | |
---|
775 | |
---|
776 | |
---|
777 | // line 13 column 2 |
---|
778 | |
---|
779 | return(0) |
---|
780 | End |
---|
781 | |
---|
782 | //beam stop diameter (millimeters) |
---|
783 | Function WriteBeamStopDiamToHeader(fname,num) |
---|
784 | String fname |
---|
785 | Variable num |
---|
786 | |
---|
787 | // your code here |
---|
788 | WriteReal(fname,num,6059) |
---|
789 | |
---|
790 | //line 15 column 5 |
---|
791 | |
---|
792 | return(0) |
---|
793 | End |
---|
794 | |
---|
795 | //sample to detector distance (meters) |
---|
796 | Function WriteSDDToHeader(fname,num) |
---|
797 | String fname |
---|
798 | Variable num |
---|
799 | |
---|
800 | //your code here |
---|
801 | //WriteReal(fname,num,5152) |
---|
802 | |
---|
803 | |
---|
804 | WriteReal(fname,num,5265) |
---|
805 | |
---|
806 | // line 4 column 4 |
---|
807 | |
---|
808 | // real calculated distance line 6 colunm1 |
---|
809 | |
---|
810 | return(0) |
---|
811 | End |
---|
812 | |
---|
813 | // physical dimension of detector x-pixel (mm) |
---|
814 | Function WriteDetPixelXToHeader(fname,num) |
---|
815 | String fname |
---|
816 | Variable num |
---|
817 | |
---|
818 | //your code here |
---|
819 | WriteReal(fname,num,5735) |
---|
820 | |
---|
821 | // line 11 column 5 |
---|
822 | |
---|
823 | return(0) |
---|
824 | end |
---|
825 | |
---|
826 | // physical dimension of detector y-pixel (mm) |
---|
827 | Function WriteDetPixelYToHeader(fname,num) |
---|
828 | String fname |
---|
829 | Variable num |
---|
830 | |
---|
831 | //your code here |
---|
832 | WriteReal(fname,num,5752) |
---|
833 | |
---|
834 | return(0) |
---|
835 | end |
---|
836 | |
---|
837 | // sample label string |
---|
838 | Function WriteSamLabelToHeader(fname,str) |
---|
839 | String fname,str |
---|
840 | |
---|
841 | // your code here |
---|
842 | // WriteText(fname," ",2075) // need to write in 30 bites no more.... |
---|
843 | |
---|
844 | Variable numChars=30 |
---|
845 | String blankStr="" |
---|
846 | blankStr = PadString(blankStr, numChars, 0x20) |
---|
847 | WriteText(fname,blankStr,2075) |
---|
848 | |
---|
849 | if(strlen(str)>numChars) |
---|
850 | str = str[0,numchars-1] |
---|
851 | endif |
---|
852 | |
---|
853 | WriteText(fname,str,2075) //// need to change that in order to erase the title and write a new one |
---|
854 | |
---|
855 | return(0) |
---|
856 | End |
---|
857 | |
---|
858 | // total counting time (stored here as seconds/10??) |
---|
859 | Function WriteCountTimeToHeader(fname,num) |
---|
860 | String fname |
---|
861 | Variable num |
---|
862 | |
---|
863 | // your code here |
---|
864 | // WriteReal(fname,num,4894) |
---|
865 | WriteReal(fname,10*num,4892) |
---|
866 | |
---|
867 | |
---|
868 | |
---|
869 | return(0) |
---|
870 | End |
---|
871 | |
---|
872 | |
---|
873 | |
---|
874 | //////// ACCESSORS FOR READING DATA FROM THE HEADER ////////////// |
---|
875 | // |
---|
876 | // read specific bits of information from the header |
---|
877 | // each of these operations MUST take care of open/close on their own |
---|
878 | // |
---|
879 | // fname is the full path and filname to the file on disk |
---|
880 | // return values are either strings or real values as appropriate |
---|
881 | // |
---|
882 | ////// |
---|
883 | |
---|
884 | |
---|
885 | // function that reads in the 2D detector data and fills the array |
---|
886 | // data[nx][ny] with the data values |
---|
887 | // fname is the full name and path to the data file for opening and closing |
---|
888 | // |
---|
889 | // |
---|
890 | Function getDetectorData(fname,data) |
---|
891 | String fname |
---|
892 | Wave data |
---|
893 | |
---|
894 | |
---|
895 | // your reader here |
---|
896 | |
---|
897 | // value = getRealValueFromHeader_2(fname,60,28,5,1,3) // data start at 60+58 lines |
---|
898 | ReadILLData2(fname,data) |
---|
899 | |
---|
900 | return (0) |
---|
901 | End |
---|
902 | |
---|
903 | // file suffix (NCNR data file name specific) |
---|
904 | // return null string |
---|
905 | Function/S getSuffix(fname) |
---|
906 | String fname |
---|
907 | |
---|
908 | String suffix = getStringFromHeader(fname,9341,6) |
---|
909 | |
---|
910 | // replace the leading space w/ "0" |
---|
911 | suffix = ReplaceString(" ",suffix,"0") |
---|
912 | |
---|
913 | return(suffix) //// file suffix (6 characters @ byte 9341) |
---|
914 | End |
---|
915 | |
---|
916 | // associated file suffix (for transmission) |
---|
917 | // NCNR Transmission calculation specific |
---|
918 | // return null string |
---|
919 | Function/S getAssociatedFileSuffix(fname) |
---|
920 | String fname |
---|
921 | |
---|
922 | string str |
---|
923 | |
---|
924 | str= getStringFromHeader(fname,9350,6) |
---|
925 | |
---|
926 | // replace leading space(s) w/zero |
---|
927 | str = ReplaceString(" ", str, "0" ) |
---|
928 | // print str |
---|
929 | |
---|
930 | return(str) // 6 characters @ byte 9350 |
---|
931 | End |
---|
932 | |
---|
933 | // sample label |
---|
934 | Function/S getSampleLabel(fname) |
---|
935 | String fname |
---|
936 | |
---|
937 | String str |
---|
938 | |
---|
939 | // your code, returning str |
---|
940 | str = (getStringFromHeader(fname,2075,30)) /// 25*81 + 50////+51 30 lines before the end |
---|
941 | |
---|
942 | |
---|
943 | return(str) |
---|
944 | End |
---|
945 | |
---|
946 | // file creation date |
---|
947 | Function/S getFileCreationDate(fname) |
---|
948 | String fname |
---|
949 | |
---|
950 | String str |
---|
951 | |
---|
952 | // your code, returning str |
---|
953 | |
---|
954 | str = (getStringFromHeader(fname,2106,50)) //324 +12 |
---|
955 | |
---|
956 | return(str) |
---|
957 | End |
---|
958 | |
---|
959 | |
---|
960 | Function/S getFileInstrument(fname) |
---|
961 | String fname |
---|
962 | |
---|
963 | String str |
---|
964 | |
---|
965 | // your code, returning str |
---|
966 | |
---|
967 | str = (getStringFromHeader(fname,324,3)) //324 +12 |
---|
968 | |
---|
969 | return(str) |
---|
970 | End |
---|
971 | |
---|
972 | |
---|
973 | //reactor power |
---|
974 | Function getReactorpower(fname) |
---|
975 | String fname |
---|
976 | |
---|
977 | Variable value |
---|
978 | |
---|
979 | // your code returning value |
---|
980 | |
---|
981 | // value = getRealValueFromHeader_2(fname,60,28,5,1,5) // |
---|
982 | |
---|
983 | value = getRealValueFromHeader(fname,83) |
---|
984 | |
---|
985 | // print value |
---|
986 | |
---|
987 | return(value) |
---|
988 | end |
---|
989 | |
---|
990 | |
---|
991 | |
---|
992 | |
---|
993 | |
---|
994 | //monitor count |
---|
995 | Function getMonitorCount(fname) |
---|
996 | String fname |
---|
997 | |
---|
998 | Variable value |
---|
999 | |
---|
1000 | // your code returning value |
---|
1001 | |
---|
1002 | // value = getRealValueFromHeader_2(fname,60,28,5,1,5) // |
---|
1003 | |
---|
1004 | value = getRealValueFromHeader(fname,4) |
---|
1005 | |
---|
1006 | // print value |
---|
1007 | |
---|
1008 | return(value) |
---|
1009 | end |
---|
1010 | |
---|
1011 | //saved monitor count |
---|
1012 | // NCNR specific for pre-processed data, never used |
---|
1013 | // return 0 |
---|
1014 | Function getSavMon(fname) |
---|
1015 | String fname |
---|
1016 | |
---|
1017 | Variable value |
---|
1018 | |
---|
1019 | // your code returning value |
---|
1020 | |
---|
1021 | return(0) |
---|
1022 | end |
---|
1023 | |
---|
1024 | //total detector count |
---|
1025 | Function getDetCount(fname) |
---|
1026 | String fname |
---|
1027 | |
---|
1028 | Variable value |
---|
1029 | |
---|
1030 | // your code returning value |
---|
1031 | |
---|
1032 | // value = getRealValueFromHeader_2(fname,60,28,5,1,4) |
---|
1033 | |
---|
1034 | value = getRealValueFromHeader(fname,3) |
---|
1035 | |
---|
1036 | return(value) |
---|
1037 | end |
---|
1038 | |
---|
1039 | //Attenuator number, return 1 if your attenuators are not |
---|
1040 | // indexed by number |
---|
1041 | Function getAttenNumber(fname) |
---|
1042 | String fname |
---|
1043 | |
---|
1044 | Variable value |
---|
1045 | |
---|
1046 | // your code returning value |
---|
1047 | |
---|
1048 | // value = getRealValueFromHeader_2(fname,60,28,5,56,4) |
---|
1049 | |
---|
1050 | value = getRealValueFromHeader(fname,58) |
---|
1051 | |
---|
1052 | return(value) |
---|
1053 | end |
---|
1054 | |
---|
1055 | //transmission |
---|
1056 | Function getSampleTrans(fname) |
---|
1057 | String fname |
---|
1058 | |
---|
1059 | Variable value |
---|
1060 | |
---|
1061 | // your code returning value |
---|
1062 | |
---|
1063 | value = getRealValueFromHeader(fname,45) |
---|
1064 | |
---|
1065 | return(value) |
---|
1066 | end |
---|
1067 | |
---|
1068 | //box counts from stored transmission calculation |
---|
1069 | // return 0 if not using NCNR transmission module |
---|
1070 | Function getBoxCounts(fname) |
---|
1071 | String fname |
---|
1072 | |
---|
1073 | Variable value |
---|
1074 | |
---|
1075 | // your code returning value |
---|
1076 | value = getRealValueFromHeader(fname,124) |
---|
1077 | |
---|
1078 | return(value) |
---|
1079 | end |
---|
1080 | |
---|
1081 | //whole detector trasmission |
---|
1082 | // return 0 if not using NCNR transmission module |
---|
1083 | Function getSampleTransWholeDetector(fname) |
---|
1084 | String fname |
---|
1085 | |
---|
1086 | Variable value |
---|
1087 | |
---|
1088 | // your code returning value |
---|
1089 | |
---|
1090 | return(value) |
---|
1091 | end |
---|
1092 | |
---|
1093 | //SampleThickness in centimeters |
---|
1094 | Function getSampleThickness(fname) |
---|
1095 | String fname |
---|
1096 | |
---|
1097 | Variable value |
---|
1098 | |
---|
1099 | // your code returning value |
---|
1100 | value = getRealValueFromHeader(fname,40) //mm |
---|
1101 | |
---|
1102 | return(value) |
---|
1103 | end |
---|
1104 | |
---|
1105 | //Sample Rotation Angle (degrees) |
---|
1106 | Function getSampleRotationAngle(fname) |
---|
1107 | String fname |
---|
1108 | |
---|
1109 | Variable value |
---|
1110 | |
---|
1111 | // your code returning value |
---|
1112 | value = getRealValueFromHeader(fname,64) |
---|
1113 | |
---|
1114 | return(value) |
---|
1115 | end |
---|
1116 | |
---|
1117 | //temperature (C) |
---|
1118 | Function getTemperature(fname) |
---|
1119 | String fname |
---|
1120 | |
---|
1121 | Variable value |
---|
1122 | |
---|
1123 | // your code returning value |
---|
1124 | |
---|
1125 | // value = getRealValueFromHeader_2(fname,60,28,5,7,1) |
---|
1126 | |
---|
1127 | value = getRealValueFromHeader(fname,30) |
---|
1128 | |
---|
1129 | return(value) |
---|
1130 | end |
---|
1131 | |
---|
1132 | //field strength (Oe) |
---|
1133 | Function getFieldStrength(fname) |
---|
1134 | String fname |
---|
1135 | |
---|
1136 | Variable value |
---|
1137 | |
---|
1138 | // your code returning value |
---|
1139 | |
---|
1140 | return(value) |
---|
1141 | end |
---|
1142 | |
---|
1143 | //center of beam xPos in pixel coordinates |
---|
1144 | Function getBeamXPos(fname) |
---|
1145 | String fname |
---|
1146 | |
---|
1147 | Variable value |
---|
1148 | |
---|
1149 | // your code returning value |
---|
1150 | // value = getRealValueFromHeader(fname,14) //Lionel |
---|
1151 | value = getRealValueFromHeader(fname,50)/10 //SRK |
---|
1152 | |
---|
1153 | return(value) |
---|
1154 | end |
---|
1155 | |
---|
1156 | //center of beam Y pos in pixel coordinates |
---|
1157 | Function getBeamYPos(fname) |
---|
1158 | String fname |
---|
1159 | |
---|
1160 | Variable value |
---|
1161 | |
---|
1162 | // your code returning value |
---|
1163 | // value = getRealValueFromHeader(fname,15) //Lionel |
---|
1164 | value = getRealValueFromHeader(fname,51)/10 //SRK |
---|
1165 | |
---|
1166 | return(value) |
---|
1167 | end |
---|
1168 | |
---|
1169 | //sample to detector distance (meters) |
---|
1170 | Function getSDD(fname) |
---|
1171 | String fname |
---|
1172 | |
---|
1173 | Variable value |
---|
1174 | |
---|
1175 | // your code returning value |
---|
1176 | // value = getRealValueFromHeader_2(fname,60,28,5,4,4) |
---|
1177 | // value = getRealValueFromHeader(fname,18) detector distance but need to add the offset due to the table |
---|
1178 | |
---|
1179 | value = getRealValueFromHeader(fname,25) |
---|
1180 | |
---|
1181 | |
---|
1182 | return(value) |
---|
1183 | end |
---|
1184 | |
---|
1185 | //lateral detector offset (centimeters) |
---|
1186 | Function getDetectorOffset(fname) |
---|
1187 | String fname |
---|
1188 | |
---|
1189 | Variable value |
---|
1190 | |
---|
1191 | // your code returning value |
---|
1192 | // value = getRealValueFromHeader_2(fname,60,28,5,13,2) |
---|
1193 | value = getRealValueFromHeader(fname,61) |
---|
1194 | |
---|
1195 | return(value/10) // need in cm ILL write in mm |
---|
1196 | end |
---|
1197 | |
---|
1198 | //Beamstop diameter (millimeters) |
---|
1199 | Function getBSDiameter(fname) |
---|
1200 | String fname |
---|
1201 | |
---|
1202 | Variable value |
---|
1203 | |
---|
1204 | // your code returning value |
---|
1205 | |
---|
1206 | // value = getRealValueFromHeader_2(fname,60,28,5,15,5) |
---|
1207 | value = getRealValueFromHeader(fname,74) |
---|
1208 | |
---|
1209 | return(value) |
---|
1210 | end |
---|
1211 | |
---|
1212 | //source aperture diameter (millimeters) |
---|
1213 | Function getSourceApertureDiam(fname) |
---|
1214 | String fname |
---|
1215 | |
---|
1216 | Variable value |
---|
1217 | |
---|
1218 | // your code returning value |
---|
1219 | |
---|
1220 | value = 52 |
---|
1221 | |
---|
1222 | return(value) |
---|
1223 | end |
---|
1224 | |
---|
1225 | //sample aperture diameter (millimeters) |
---|
1226 | Function getSampleApertureDiam(fname) |
---|
1227 | String fname |
---|
1228 | |
---|
1229 | Variable value |
---|
1230 | |
---|
1231 | // your code returning value |
---|
1232 | // value = getRealValueFromHeader_2(fname,60,28,5,15,3) |
---|
1233 | value = getRealValueFromHeader(fname,73) |
---|
1234 | |
---|
1235 | if(value == 0) //in case no aperture size was written to raw data file |
---|
1236 | value = 10 |
---|
1237 | endif |
---|
1238 | |
---|
1239 | return(value) |
---|
1240 | end |
---|
1241 | |
---|
1242 | //source AP to Sample AP distance (meters) |
---|
1243 | Function getSourceToSampleDist(fname) |
---|
1244 | String fname |
---|
1245 | |
---|
1246 | Variable value |
---|
1247 | |
---|
1248 | // your code returning value |
---|
1249 | |
---|
1250 | // value = getRealValueFromHeader_2(fname,60,28,5,12,3) |
---|
1251 | |
---|
1252 | value = getRealValueFromHeader(fname,57) |
---|
1253 | |
---|
1254 | return(value) |
---|
1255 | end |
---|
1256 | |
---|
1257 | //wavelength (Angstroms) |
---|
1258 | Function getWavelength(fname) |
---|
1259 | String fname |
---|
1260 | |
---|
1261 | Variable value |
---|
1262 | |
---|
1263 | // your code returning value |
---|
1264 | // value = getRealValueFromHeader_2(fname,60,28,5,11,3) |
---|
1265 | value = getRealValueFromHeader(fname,52) |
---|
1266 | |
---|
1267 | return(value) |
---|
1268 | end |
---|
1269 | |
---|
1270 | //wavelength spread (FWHM) |
---|
1271 | Function getWavelengthSpread(fname) |
---|
1272 | String fname |
---|
1273 | |
---|
1274 | Variable value |
---|
1275 | |
---|
1276 | // your code returning value |
---|
1277 | value = getRealValueFromHeader(fname,53) |
---|
1278 | |
---|
1279 | |
---|
1280 | return(value) |
---|
1281 | end |
---|
1282 | |
---|
1283 | // physical x-dimension of a detector pixel, in mm |
---|
1284 | Function getDetectorPixelXSize(fname) |
---|
1285 | String fname |
---|
1286 | |
---|
1287 | Variable value |
---|
1288 | |
---|
1289 | // your code here returning value |
---|
1290 | // value = getRealValueFromHeader_2(fname,60,28,5,11,5) |
---|
1291 | value = getRealValueFromHeader(fname,54) |
---|
1292 | |
---|
1293 | return(value) |
---|
1294 | end |
---|
1295 | |
---|
1296 | // physical y-dimension of a detector pixel, in mm |
---|
1297 | Function getDetectorPixelYSize(fname) |
---|
1298 | String fname |
---|
1299 | |
---|
1300 | Variable value |
---|
1301 | |
---|
1302 | // your code here returning value |
---|
1303 | // value = getRealValueFromHeader_2(fname,60,28,5,12,1) |
---|
1304 | value = getRealValueFromHeader(fname,55) |
---|
1305 | |
---|
1306 | return(value) |
---|
1307 | end |
---|
1308 | |
---|
1309 | //transmission detector count (unused, return 0) |
---|
1310 | // |
---|
1311 | Function getTransDetectorCounts(fname) |
---|
1312 | String fname |
---|
1313 | |
---|
1314 | Variable value |
---|
1315 | |
---|
1316 | // your code returning value |
---|
1317 | |
---|
1318 | return(0) |
---|
1319 | end |
---|
1320 | |
---|
1321 | |
---|
1322 | //total count time (seconds) |
---|
1323 | // stored here as (s/10), so multiply by 10 ? |
---|
1324 | Function getCountTime(fname) |
---|
1325 | String fname |
---|
1326 | |
---|
1327 | Variable value |
---|
1328 | |
---|
1329 | // your code returning value |
---|
1330 | |
---|
1331 | // value = getRealValueFromHeader_2(fname,60,28,5,1,3) /// line 1 col 3 |
---|
1332 | |
---|
1333 | value = getRealValueFromHeader(fname,2)/10 |
---|
1334 | |
---|
1335 | return(value) |
---|
1336 | end |
---|
1337 | |
---|
1338 | |
---|
1339 | //reads the wavelength from a reduced data file (not very reliable) |
---|
1340 | // - does not work with NSORTed files |
---|
1341 | // - only used in FIT/RPA (which itself is almost NEVER used...) |
---|
1342 | // |
---|
1343 | // DOES NOT NEED TO BE CHANGED IF USING NCNR DATA WRITER |
---|
1344 | Function GetLambdaFromReducedData(tempName) |
---|
1345 | String tempName |
---|
1346 | |
---|
1347 | String junkString |
---|
1348 | Variable lambdaFromFile, fileVar |
---|
1349 | lambdaFromFile = 6.0 |
---|
1350 | Open/R/P=catPathName fileVar as tempName |
---|
1351 | FReadLine fileVar, junkString |
---|
1352 | FReadLine fileVar, junkString |
---|
1353 | FReadLine fileVar, junkString |
---|
1354 | if(strsearch(LowerStr(junkString),"lambda",0) != -1) |
---|
1355 | FReadLine/N=11 fileVar, junkString |
---|
1356 | FReadLine/N=10 fileVar, junkString |
---|
1357 | lambdaFromFile = str2num(junkString) |
---|
1358 | endif |
---|
1359 | Close fileVar |
---|
1360 | |
---|
1361 | return(lambdaFromFile) |
---|
1362 | End |
---|
1363 | |
---|
1364 | ///// TRANSMISSION RELATED FUNCTIONS //////// |
---|
1365 | //box coordinate are returned by reference |
---|
1366 | // |
---|
1367 | // box to sum over is bounded (x1,y1) to (x2,y2) |
---|
1368 | // |
---|
1369 | // this function returns the bounding coordinates as stored in |
---|
1370 | // the header |
---|
1371 | // |
---|
1372 | // if not using the NCNR Transmission module, this function default to |
---|
1373 | // returning 0000, and no changes needed |
---|
1374 | // |
---|
1375 | // filename is the full path:name to the file |
---|
1376 | Function getXYBoxFromFile(filename,x1,x2,y1,y2) |
---|
1377 | String filename |
---|
1378 | Variable &x1,&x2,&y1,&y2 |
---|
1379 | |
---|
1380 | // return your bounding box coordinates or default values of 0 |
---|
1381 | x1=getRealValueFromHeader(filename,120) |
---|
1382 | x2=getRealValueFromHeader(filename,121) |
---|
1383 | y1=getRealValueFromHeader(filename,122) |
---|
1384 | y2=getRealValueFromHeader(filename,123) |
---|
1385 | |
---|
1386 | // print "in get", x1,x2,y1,y2 |
---|
1387 | |
---|
1388 | return(0) |
---|
1389 | End |
---|
1390 | |
---|
1391 | // Writes the coordinates of the box to the header after user input |
---|
1392 | // |
---|
1393 | // box to sum over bounded (x1,y1) to (x2,y2) |
---|
1394 | // |
---|
1395 | // if not using the NCNR Transmission module, this function is null |
---|
1396 | // |
---|
1397 | // filename as passed in is a full path:filename |
---|
1398 | // |
---|
1399 | Function WriteXYBoxToHeader(filename,x1,x2,y1,y2) |
---|
1400 | String filename |
---|
1401 | Variable x1,x2,y1,y2 |
---|
1402 | |
---|
1403 | // your code to write bounding box to the header, or nothing |
---|
1404 | |
---|
1405 | WriteReal(filename,x1,6804) |
---|
1406 | WriteReal(filename,x2,6820) |
---|
1407 | WriteReal(filename,y1,6836) |
---|
1408 | WriteReal(filename,y2,6852) |
---|
1409 | |
---|
1410 | // use the last full line and the 4 first numbers |
---|
1411 | |
---|
1412 | // print "in write",x1,x2,y1,y2 |
---|
1413 | |
---|
1414 | // should start at 120 for read and line 25 |
---|
1415 | |
---|
1416 | /// 84 *81 |
---|
1417 | |
---|
1418 | return(0) |
---|
1419 | End |
---|
1420 | |
---|
1421 | // for transmission calculation, writes an NCNR-specific alphanumeric identifier |
---|
1422 | // (suffix of the data file) |
---|
1423 | // |
---|
1424 | // if not using the NCNR Transmission module, this function is null |
---|
1425 | Function WriteAssocFileSuffixToHeader(fname,suffix) |
---|
1426 | String fname,suffix |
---|
1427 | |
---|
1428 | // replace leading space(s) w/zero |
---|
1429 | suffix = ReplaceString(" ", suffix, "0" ) |
---|
1430 | |
---|
1431 | suffix = suffix[0,5] //limit to 6 characters |
---|
1432 | |
---|
1433 | WriteText(fname,suffix,9350) |
---|
1434 | |
---|
1435 | |
---|
1436 | return(0) |
---|
1437 | end |
---|
1438 | |
---|
1439 | Function/S getStringFromHeader(fname,start,num) |
---|
1440 | String fname //full path:name |
---|
1441 | Variable start,num //starting byte and number of characters to read |
---|
1442 | |
---|
1443 | String str |
---|
1444 | Variable refnum |
---|
1445 | Open/R refNum as fname |
---|
1446 | FSetPos refNum,start |
---|
1447 | FReadLine/N=(num) refNum,str |
---|
1448 | Close refnum |
---|
1449 | |
---|
1450 | return(str) |
---|
1451 | End |
---|
1452 | |
---|
1453 | Function getRealValueFromHeader(fname,start) |
---|
1454 | String fname |
---|
1455 | Variable start |
---|
1456 | Variable numLinesLoaded = 0,firstchar,countTime |
---|
1457 | variable refnum |
---|
1458 | Variable v1,v2,v3,v4,v5,v6,v7,v8,v9,v0,ii,valuesread,result |
---|
1459 | String buffer |
---|
1460 | Make/O/D/N=128 TemporaryHeader |
---|
1461 | // Make/O/D/N=(128) data |
---|
1462 | |
---|
1463 | Open/R refNum as fname //if fname is "", a dialog will be presented |
---|
1464 | if(refnum==0) |
---|
1465 | return(1) //user cancelled |
---|
1466 | endif |
---|
1467 | |
---|
1468 | //skip the next 10 lines |
---|
1469 | For(ii=0;ii<60;ii+=1) |
---|
1470 | FReadLine refnum,buffer |
---|
1471 | EndFor |
---|
1472 | |
---|
1473 | // read in the whole header |
---|
1474 | For (ii=60;ii<188;ii+=1) |
---|
1475 | |
---|
1476 | numlinesloaded = ii-60 |
---|
1477 | FReadLine refNum,buffer //assume a 2nd line is there, w/16 values |
---|
1478 | sscanf buffer,"%g %g %g %g %g ",v0,v1,v2,v3,v4 |
---|
1479 | valuesRead = V_flag |
---|
1480 | // print valuesRead |
---|
1481 | |
---|
1482 | // print buffer |
---|
1483 | |
---|
1484 | //valuesRead = V_flag |
---|
1485 | // print ii,refnum,v0,v1,v2,v3,v4,v5,v6,v7,v8,v9 |
---|
1486 | // print buffer |
---|
1487 | |
---|
1488 | TemporaryHeader[5*numlinesloaded] = v0 |
---|
1489 | TemporaryHeader[5*numlinesloaded+1] = v1 //monitor |
---|
1490 | TemporaryHeader[5*numlinesloaded+2] = v2 |
---|
1491 | TemporaryHeader[5*numlinesloaded+3] = v3 |
---|
1492 | TemporaryHeader[5*numlinesloaded+4] = v4 |
---|
1493 | Endfor |
---|
1494 | |
---|
1495 | Close refNum |
---|
1496 | result= TemporaryHeader[start] |
---|
1497 | // KillWaves/Z TemporaryHeader |
---|
1498 | |
---|
1499 | return (result) |
---|
1500 | End |
---|
1501 | |
---|
1502 | //Function getRealValueFromHeader_1(fname,start) |
---|
1503 | // String fname |
---|
1504 | // Variable start |
---|
1505 | // |
---|
1506 | // String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=1/W=1/Q" |
---|
1507 | // |
---|
1508 | // GBLoadStr += "/S="+num2str(start)+"/U=10" + "\"" + fname + "\"" |
---|
1509 | // Execute GBLoadStr |
---|
1510 | // Wave w=$"tempGBWave0" |
---|
1511 | // |
---|
1512 | // return(w[0]) |
---|
1513 | //End |
---|
1514 | |
---|
1515 | //Function getRealValueFromHeader_2(fname,start,numrow,numcol,rowbit,colbit) |
---|
1516 | // String fname |
---|
1517 | // Variable start,numcol,numrow,colbit,rowbit |
---|
1518 | // variable result |
---|
1519 | // make /O/D/N=(numrow) w0,w1,w2,w3,w4 |
---|
1520 | // Make/O/D/N=(numrow,numcol) dataread |
---|
1521 | // |
---|
1522 | // |
---|
1523 | // loadwave /A=tempGBwave/L={0, start, numrow, 0, numcol}/N/G/D/O/K=1 fname |
---|
1524 | // |
---|
1525 | // Wave/Z tempGBwave0=tempGBwave0 |
---|
1526 | // Wave/Z tempGBwave1=tempGBwave1 |
---|
1527 | // Wave/Z tempGBwave2=tempGBwave2 |
---|
1528 | // Wave/Z tempGBwave3=tempGBwave3 |
---|
1529 | // Wave/Z tempGBwave4=tempGBwave4 |
---|
1530 | // |
---|
1531 | // |
---|
1532 | // w0=tempGBWave0 |
---|
1533 | // w1=tempGBWave1 |
---|
1534 | // w2=tempGBWave2 |
---|
1535 | // w3=tempGBWave3 |
---|
1536 | // w4=tempGBWave4 |
---|
1537 | // |
---|
1538 | ///// redimension could use that to redimension dataread in only one colunm... but will see later.. |
---|
1539 | // |
---|
1540 | // |
---|
1541 | // |
---|
1542 | // KillWaves/Z tempGBwave0,tempGBwave1,tempGBwave3,tempGBwave2,tempGBwave4 |
---|
1543 | // /// Make/O/D/N=(numrow,numcol),wres |
---|
1544 | // |
---|
1545 | // dataread[][0] = w0[p] |
---|
1546 | // dataread[][1] = w1[p] |
---|
1547 | // dataread[][2] = w2[p] |
---|
1548 | // dataread[][3] = w3[p] |
---|
1549 | // dataread[][4] = w4[p] |
---|
1550 | // |
---|
1551 | //KillWaves/Z w0,w1,w2,w3,w4 |
---|
1552 | // |
---|
1553 | //// wave wres = $"tempGBwave" +num2str(linebit-1) |
---|
1554 | // result = dataread[rowbit-1][colbit-1] |
---|
1555 | // |
---|
1556 | // return(result) |
---|
1557 | //End |
---|
1558 | |
---|
1559 | |
---|
1560 | //Function ReadILLData(fname) |
---|
1561 | // String fname |
---|
1562 | // |
---|
1563 | // NVAR pixelsX = root:myGlobals:gNPixelsX |
---|
1564 | // NVAR pixelsY = root:myGlobals:gNPixelsY |
---|
1565 | // Variable refNum=0,ii,p1,p2,tot,num=pixelsX,numHdrLines=118 ///waas 20 for NIST |
---|
1566 | // String str="" |
---|
1567 | // //data is initially linear scale |
---|
1568 | // Variable/G :gIsLogScale=0 |
---|
1569 | // Make/O/T/N=(numHdrLines) hdrLines |
---|
1570 | // Make/O/D/N=(pixelsX*pixelsY) data |
---|
1571 | // Make/O/D/N=(1638,10) datahelp //,linear_data |
---|
1572 | // |
---|
1573 | // //full filename and path is now passed in... |
---|
1574 | // //actually open the file |
---|
1575 | //// SetDataFolder destPath |
---|
1576 | // Open/R/Z refNum as fname // /Z flag means I must handle open errors |
---|
1577 | // if(refnum==0) //FNF error, get out |
---|
1578 | // DoAlert 0,"Could not find file: "+fname |
---|
1579 | // Close/A |
---|
1580 | // SetDataFolder root: |
---|
1581 | // return(1) |
---|
1582 | // endif |
---|
1583 | // if(V_flag!=0) |
---|
1584 | // DoAlert 0,"File open error: V_flag="+num2Str(V_Flag) |
---|
1585 | // Close/A |
---|
1586 | // SetDataFolder root: |
---|
1587 | // return(1) |
---|
1588 | // Endif |
---|
1589 | // // |
---|
1590 | // for(ii=0;ii<numHdrLines;ii+=1) //read (or skip) 18 header lines |
---|
1591 | // FReadLine refnum,str |
---|
1592 | // hdrLines[ii]=str |
---|
1593 | // endfor |
---|
1594 | // // |
---|
1595 | // Close refnum |
---|
1596 | // |
---|
1597 | //// SetDataFolder destPath |
---|
1598 | // |
---|
1599 | //// loadwave /A=tempt/L={0, 118, 1638, 1, 10}/N/J/D/O/E=1/K=1 fname |
---|
1600 | // |
---|
1601 | //loadwave /A=tempt/L={0, 0, 1638, 0, 10}/N/G/D/O/E=1/K=1 fname |
---|
1602 | // |
---|
1603 | //Wave/Z tempt0=tempt0 |
---|
1604 | // Wave/Z tempt1=tempt1 |
---|
1605 | // Wave/Z tempt2=tempt2 |
---|
1606 | // Wave/Z tempt3=tempt3 |
---|
1607 | // Wave/Z tempt4=tempt4 |
---|
1608 | // Wave/Z tempt5=tempt5 |
---|
1609 | // Wave/Z tempt6=tempt6 |
---|
1610 | // Wave/Z tempt7=tempt7 |
---|
1611 | // Wave/Z tempt8=tempt8 |
---|
1612 | // Wave/Z tempt9=tempt9 |
---|
1613 | // |
---|
1614 | // |
---|
1615 | // |
---|
1616 | // |
---|
1617 | // datahelp[][0]=tempt0[p] |
---|
1618 | // datahelp[][1]=tempt1[p] |
---|
1619 | // datahelp[][2]=tempt2[p] |
---|
1620 | // datahelp[][3]=tempt3[p] |
---|
1621 | // datahelp[][4]=tempt4[p] |
---|
1622 | // datahelp[][5]=tempt5[p] |
---|
1623 | // datahelp[][6]=tempt6[p] |
---|
1624 | // datahelp[][7]=tempt7[p] |
---|
1625 | // datahelp[][8]=tempt8[p] |
---|
1626 | // datahelp[][9]=tempt9[p] |
---|
1627 | // |
---|
1628 | // Killwaves/Z tempt1,tempt2,tempt3,tempt4,tempt0,tempt5,tempt6,tempt7,tempt8,tempt9 |
---|
1629 | // |
---|
1630 | /////////////Wave/Z tempt0=tempt0 |
---|
1631 | /////data=tempt |
---|
1632 | // |
---|
1633 | // |
---|
1634 | // Redimension/N=(pixelsX,pixelsY) datahelp |
---|
1635 | // |
---|
1636 | // |
---|
1637 | //// LoadWave/Q/J/D/E=1/V={" " ,"non",1,1}/N=temp fName |
---|
1638 | //// Wave/Z temp0=temp0 |
---|
1639 | //// data=temp0 |
---|
1640 | //// Redimension/N=(pixelsX,pixelsY) data //,linear_data |
---|
1641 | // |
---|
1642 | // //linear_data = data |
---|
1643 | // |
---|
1644 | // KillWaves/Z temp0 |
---|
1645 | // |
---|
1646 | // //return the data folder to root |
---|
1647 | // SetDataFolder root: |
---|
1648 | // |
---|
1649 | // Return(0) |
---|
1650 | //End |
---|
1651 | |
---|
1652 | |
---|
1653 | |
---|
1654 | Function ReadILLData2(fname,data) |
---|
1655 | String fname |
---|
1656 | wave data |
---|
1657 | |
---|
1658 | Variable numLinesLoaded = 0,firstchar,countTime |
---|
1659 | variable refnum |
---|
1660 | Variable v1,v2,v3,v4,v5,v6,v7,v8,v9,v0,ii,valuesread |
---|
1661 | String buffer |
---|
1662 | Make/O/D/N=16384 Dataline //temporary storage |
---|
1663 | |
---|
1664 | Open/R refNum as fname //if fname is "", a dialog will be presented |
---|
1665 | if(refnum==0) |
---|
1666 | return(1) //user cancelled |
---|
1667 | endif |
---|
1668 | |
---|
1669 | //skip the next 10 lines |
---|
1670 | For(ii=0;ii<118;ii+=1) |
---|
1671 | FReadLine refnum,buffer |
---|
1672 | EndFor |
---|
1673 | |
---|
1674 | For (ii=118;ii<1757;ii+=1) |
---|
1675 | numlinesloaded = ii-118 |
---|
1676 | FReadLine refNum,buffer //assume a 2nd line is there, w/16 values |
---|
1677 | sscanf buffer,"%g %g %g %g %g %g %g %g %g %g",v0,v1,v2,v3,v4,v5,v6,v7,v8,v9 |
---|
1678 | valuesRead = V_flag |
---|
1679 | // print valuesRead |
---|
1680 | // buffer |
---|
1681 | //valuesRead = V_flag |
---|
1682 | // print ii,refnum,v0,v1,v2,v3,v4,v5,v6,v7,v8,v9 |
---|
1683 | // print buffer |
---|
1684 | |
---|
1685 | if(ii == 1756) |
---|
1686 | dataline[10*numlinesloaded] = v0 //last line has only four values |
---|
1687 | dataline[10*numlinesloaded+1] = v1 |
---|
1688 | dataline[10*numlinesloaded+2] = v2 |
---|
1689 | dataline[10*numlinesloaded+3] = v3 |
---|
1690 | else |
---|
1691 | dataline[10*numlinesloaded] = v0 //reading in 10 values per line |
---|
1692 | dataline[10*numlinesloaded+1] = v1 |
---|
1693 | dataline[10*numlinesloaded+2] = v2 |
---|
1694 | dataline[10*numlinesloaded+3] = v3 |
---|
1695 | dataline[10*numlinesloaded+4] = v4 |
---|
1696 | dataline[10*numlinesloaded+5] = v5 |
---|
1697 | dataline[10*numlinesloaded+6] = v6 |
---|
1698 | dataline[10*numlinesloaded+7] = v7 |
---|
1699 | dataline[10*numlinesloaded+8] = v8 |
---|
1700 | dataline[10*numlinesloaded+9] = v9 |
---|
1701 | endif |
---|
1702 | Endfor |
---|
1703 | |
---|
1704 | Close refNum |
---|
1705 | |
---|
1706 | data = dataline |
---|
1707 | redimension /N=(128,128) data |
---|
1708 | |
---|
1709 | // Killwaves/Z dataline |
---|
1710 | |
---|
1711 | return (0) |
---|
1712 | |
---|
1713 | end |
---|
1714 | |
---|
1715 | // Write* routines all must: |
---|
1716 | // (1) open file "fname". fname is a full file path and name to the file on disk |
---|
1717 | // (2) write the specified value to the header at the correct location in the file |
---|
1718 | // (3) close the file |
---|
1719 | |
---|
1720 | // |
---|
1721 | // ILL header values are 16 characters: one space followed by 15 bytes of the value, in scientific notation (pos 2 is the sign, last 4 are "e(+-)XX" ) |
---|
1722 | // SRK - May 2008 |
---|
1723 | Function WriteReal(path,value,start) |
---|
1724 | string path |
---|
1725 | variable value,start |
---|
1726 | |
---|
1727 | variable refnum |
---|
1728 | |
---|
1729 | String valStr |
---|
1730 | sprintf valStr, " %14e",value |
---|
1731 | // print valstr, strlen(valStr) |
---|
1732 | |
---|
1733 | Open/A/T= "????" refnum as path |
---|
1734 | |
---|
1735 | FStatus refnum |
---|
1736 | FSetPos refnum, start |
---|
1737 | FBinWrite refNum, valStr |
---|
1738 | FSetpos refnum,V_logEOF // correct length is 142317 total bytes |
---|
1739 | |
---|
1740 | Close refnum |
---|
1741 | |
---|
1742 | return (0) |
---|
1743 | |
---|
1744 | end |
---|
1745 | |
---|
1746 | |
---|
1747 | Function/S PromptForPathtest(msgStr) |
---|
1748 | String msgStr |
---|
1749 | String fullPath |
---|
1750 | Variable refnum |
---|
1751 | |
---|
1752 | //this just asks for the filename, doesn't open the file |
---|
1753 | Open/D/R/T="????"/M=(msgStr) refNum |
---|
1754 | fullPath = S_FileName //fname is the full path |
---|
1755 | // Print refnum,fullPath |
---|
1756 | |
---|
1757 | //null string is returned in S_FileName if user cancelled, and is passed back to calling function |
---|
1758 | Return(fullPath) |
---|
1759 | End |
---|
1760 | |
---|
1761 | |
---|
1762 | /// !!!! Make sure the text string is the correct LENGTH before sending it here!!! |
---|
1763 | // SRK - May 2008 |
---|
1764 | Function WriteText(path,str,start) |
---|
1765 | string path,str |
---|
1766 | variable start |
---|
1767 | |
---|
1768 | variable refnum |
---|
1769 | |
---|
1770 | Open/A/T= "????TEXT" refnum as path |
---|
1771 | |
---|
1772 | FStatus refnum |
---|
1773 | FSetPos refnum, start |
---|
1774 | FBinWrite/F=0 refnum, str //native object format (character) |
---|
1775 | FSetPos refnum,V_logEOF |
---|
1776 | |
---|
1777 | Close refnum |
---|
1778 | |
---|
1779 | return (0) |
---|
1780 | |
---|
1781 | end |
---|
1782 | ////// OCT 2009, facility specific bits from ProDiv() |
---|
1783 | //"type" is the data folder that has the corrected, patched, and normalized DIV data array |
---|
1784 | // |
---|
1785 | // the header of this file is rather unimportant. Filling in a title at least would be helpful/ |
---|
1786 | // |
---|
1787 | Function Write_DIV_File(type) |
---|
1788 | String type |
---|
1789 | |
---|
1790 | // should have the linear display..... |
---|
1791 | ConvertFolderToLogScale(type) |
---|
1792 | |
---|
1793 | // Your file writing function here. Don't try to duplicate the VAX binary format... |
---|
1794 | |
---|
1795 | SetDataFolder $("root:Packages:NIST:"+type) |
---|
1796 | Save/C linear_data as "plex.DIV" |
---|
1797 | |
---|
1798 | SetDataFolder root: |
---|
1799 | return(0) |
---|
1800 | End |
---|
1801 | |
---|
1802 | ////// OCT 2009, facility specific bits from MonteCarlo functions() |
---|
1803 | //"type" is the data folder that has the data array that is to be (re)written as a full |
---|
1804 | // data file, as if it was a raw data file |
---|
1805 | // |
---|
1806 | // not really necessary |
---|
1807 | // |
---|
1808 | Function/S Write_RawData_File(type,fullpath,dialog) |
---|
1809 | String type,fullpath |
---|
1810 | Variable dialog //=1 will present dialog for name |
---|
1811 | |
---|
1812 | // Your file writing function here. Don't try to duplicate the VAX binary format... |
---|
1813 | Print "Write_RawData_File stub" |
---|
1814 | |
---|
1815 | return(fullPath) |
---|
1816 | End |
---|