source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Write.ipf @ 1246

Last change on this file since 1246 was 1242, checked in by srkline, 3 years ago

updating the IgorVersion? pragma to v7.0 for all files to be consistent.

File size: 193.1 KB
Line 
1#pragma rtGlobals=3             // Use modern global access method and strict wave access.
2#pragma IgorVersion = 7.00
3
4
5// Start to build up and test the r/w accessors for VSANS
6// (SANS has a template, VSANS does not, so just start from scratch here, since the
7// file structure will be different)
8//
9//
10
11//////////// WRITE FUNCTIONS ////////////////////
12//
13// Each of the individual write functions have both the "write" and "kill" function
14// calls explicitly in each named function to allow flexibility during real implementation.
15// The calls could be streamlined, but writing this way allows for individualized kill/nokill, depending
16// on the details of what is actually being written out, and the possibility of changing the
17// particular "Write" routine, if specific changes need to be made to match the data type (int, fp, etc).
18// Currently, I don't know all of the data types, or what is important in the HDF structure.
19// NOV 2015
20//
21
22
23//////////////////////////////////////////////
24//////////////////////////////////
25// for TESTING of the get functions - to quickly access and see if there are errors
26//
27// -- not sure how to test the string functions -- can't seem to get a FUNCREF to a string function
28// to work -- maybe it's not alllowed?
29//
30// -- also, now I have get_functions that take a detStr input with the detector information, so that the
31//    functions didn't need to be repeated
32//
33//      -- Not sure how to test the "write" functions. writing the wrong data type to the wrong data field will be a disaster
34//    Writing odd, dummy values will also be a mess - no way to know if I'm doing anything correctly
35//
36Function proto_V_write_FP(str)
37        String str
38        return(0)
39end
40Function proto_V_write_FP2(str,str2)
41        String str,str2
42        return(0)
43end
44//Function proto_V_write_STR(str)
45//      String str
46//      return("")
47//end
48
49Function Test_V_write_FP(str,fname)
50        String str,fname
51       
52        Variable ii,num
53        String list,item
54       
55       
56        list=FunctionList(str,";","NPARAMS:1,VALTYPE:1") //,VALTYPE:1 gives real return values, not strings
57//      Print list
58        num = ItemsInlist(list)
59       
60       
61        for(ii=0;ii<num;ii+=1)
62                item = StringFromList(ii, list , ";")
63                FUNCREF proto_V_write_FP f = $item
64                Print item ," = ", f(fname)
65        endfor
66       
67        return(0)
68end
69
70Function Test_V_write_FP2(str,fname,detStr)
71        String str,fname,detStr
72       
73        Variable ii,num
74        String list,item
75       
76       
77        list=FunctionList(str,";","NPARAMS:2,VALTYPE:1") //,VALTYPE:1 gives real return values, not strings
78//      Print list
79        num = ItemsInlist(list)
80       
81       
82        for(ii=0;ii<num;ii+=1)
83                item = StringFromList(ii, list , ";")
84                FUNCREF proto_V_write_FP2 f = $item
85                Print item ," = ", f(fname,detStr)
86        endfor
87       
88        return(0)
89end
90
91Function Test_V_write_STR(str,fname)
92        String str,fname
93       
94        Variable ii,num
95        String list,item,strToEx
96       
97       
98        list=FunctionList(str,";","NPARAMS:1,VALTYPE:4")
99//      Print list
100        num = ItemsInlist(list)
101       
102       
103        for(ii=0;ii<num;ii+=1)
104                item = StringFromList(ii, list , ";")
105        //      FUNCREF proto_V_write_STR f = $item
106                printf "%s = ",item
107                sprintf strToEx,"Print %s(\"%s\")",item,fname
108                Execute strToEx
109//              print strToEx
110//              Print item ," = ", f(fname)
111        endfor
112       
113        return(0)
114end
115
116Function Test_V_write_STR2(str,fname,detStr)
117        String str,fname,detStr
118       
119        Variable ii,num
120        String list,item,strToEx
121       
122       
123        list=FunctionList(str,";","NPARAMS:2,VALTYPE:4")
124//      Print list
125        num = ItemsInlist(list)
126       
127       
128        for(ii=0;ii<num;ii+=1)
129                item = StringFromList(ii, list , ";")
130        //      FUNCREF proto_V_write_STR f = $item
131                printf "%s = ",item
132                sprintf strToEx,"Print %s(\"%s\",\"%s\")",item,fname,detStr
133                Execute strToEx
134//              print strToEx
135//              Print item ," = ", f(fname)
136        endfor
137       
138        return(0)
139end
140///////////////////////////////////////
141
142
143//////////////////////////////////////////////
144
145
146///////////////////////
147//
148// *These are the specific bits of information to retrieve (or write) to the data file
149// *These functions use the path to the file as input, and each has the specific
150//   path to the variable srting, or wave hard-coded into the access function
151// *They call the generic worker functions to get the values, either from the local copy if present,
152//   or the full file is loaded.
153//
154// *Since the path is the important bit, these are written as get/write pairs to make it easier to
155//   keep up with any changes in path
156//
157//
158// TODO -- verify the paths, and add more as needed
159// TODO -- for all of the String functions -- "num" does nothing right now -
160//         -- if it ever does, or needs to, a lot of locations will need to be corrected
161//
162
163
164//////// TOP LEVEL
165//////// TOP LEVEL
166//////// TOP LEVEL
167
168//// nexus version used for definitions
169//Function V_writeNeXus_version(fname,str)
170//      String fname,str
171//     
172////    String path = "entry:NeXus_version"     
173//     
174//      Make/O/T/N=1 tmpTW
175//      String groupName = "/entry"     //     
176//      String varName = "NeXus_version"
177//      tmpTW[0] = str //
178//
179//      variable err
180//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
181//      if(err)
182//              Print "HDF write err = ",err
183//      endif
184//     
185//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
186////    err = V_KillNamedDataFolder(fname)
187////    if(err)
188////            Print "DataFolder kill err = ",err
189////    endif
190//             
191//      return(err)
192//End
193
194// TODO -- not mine, added somewhere by Nexus writer?
195// data collection time (! this is the true counting time??)
196Function V_writeCollectionTime(fname,val)
197        String fname
198        Variable val
199       
200//      String path = "entry:collection_time"   
201       
202        Make/O/D/N=1 wTmpWrite
203//      Make/O/R/N=1 wTmpWrite
204        String groupName = "/entry"     
205        String varName = "collection_time"
206        wTmpWrite[0] = val
207
208        variable err
209        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
210        if(err)
211                Print "HDF write err = ",err
212        endif
213        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
214//      err = V_KillNamedDataFolder(fname)
215//      if(err)
216//              Print "DataFolder kill err = ",err
217//      endif
218        return(err)
219End
220
221// fname is a local WORK folder
222Function V_putCollectionTime(fname,val)
223        String fname
224        Variable val
225
226//root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:beam_center_x
227        String path = "root:Packages:NIST:VSANS:"+fname+":"
228        path += "entry:collection_time"
229       
230        Wave/Z w = $path
231        if(waveExists(w) == 0)
232                return(1)
233        else
234        w[0] = val
235                return(0)
236        endif
237
238End
239
240// data directory where data files are stored (for user access, not archive)
241Function V_writeData_directory(fname,str)
242        String fname,str
243       
244//      String path = "entry:data_directory"   
245
246        Make/O/T/N=1 tmpTW
247        String groupName = "/entry"     //     
248        String varName = "data_directory"
249        tmpTW[0] = str //
250
251        variable err
252        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
253        if(err)
254                Print "HDF write err = ",err
255        endif
256       
257        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
258//      err = V_KillNamedDataFolder(fname)
259//      if(err)
260//              Print "DataFolder kill err = ",err
261//      endif
262               
263        return(err)
264End
265
266// Base class of Nexus definition (=NXsas)
267Function V_writeNexusDefinition(fname,str)
268        String fname,str
269       
270//      String path = "entry:definition"       
271
272        Make/O/T/N=1 tmpTW
273        String groupName = "/entry"     //     
274        String varName = "definition"
275        tmpTW[0] = str //
276
277        variable err
278        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
279        if(err)
280                Print "HDF write err = ",err
281        endif
282       
283        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
284//      err = V_KillNamedDataFolder(fname)
285//      if(err)
286//              Print "DataFolder kill err = ",err
287//      endif
288               
289        return(err)
290End
291
292// TODO -- not mine, added somewhere by Nexus writer?
293// data collection duration (may include pauses, other "dead" time)
294Function V_writeDataDuration(fname,val)
295        String fname
296        Variable val
297       
298        String path = "entry:duration" 
299       
300        Make/O/D/N=1 wTmpWrite
301//      Make/O/R/N=1 wTmpWrite
302        String groupName = "/entry"     
303        String varName = "duration"
304        wTmpWrite[0] = val
305
306        variable err
307        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
308        if(err)
309                Print "HDF write err = ",err
310        endif
311        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
312//      err = V_KillNamedDataFolder(fname)
313//      if(err)
314//              Print "DataFolder kill err = ",err
315//      endif
316        return(err)
317End
318
319// TODO -- not mine, added somewhere by Nexus writer?
320// data collection end time
321Function V_writeDataEndTime(fname,str)
322        String fname,str
323       
324//      String path = "entry:end_time" 
325
326        Make/O/T/N=1 tmpTW
327        String groupName = "/entry"     //     
328        String varName = "end_time"
329        tmpTW[0] = str //
330
331        variable err
332        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
333        if(err)
334                Print "HDF write err = ",err
335        endif
336       
337        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
338//      err = V_KillNamedDataFolder(fname)
339//      if(err)
340//              Print "DataFolder kill err = ",err
341//      endif
342               
343        return(err)
344End
345
346// experiment description
347Function V_writeExperiment_description(fname,str)
348        String fname,str
349       
350//      String path = "entry:experiment_description"   
351
352        Make/O/T/N=1 tmpTW
353        String groupName = "/entry"     //     
354        String varName = "experiment_description"
355        tmpTW[0] = str //
356
357        variable err
358        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
359        if(err)
360                Print "HDF write err = ",err
361        endif
362       
363        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
364//      err = V_KillNamedDataFolder(fname)
365//      if(err)
366//              Print "DataFolder kill err = ",err
367//      endif
368               
369        return(err)
370End
371
372// experiment identifier? used only by NICE?
373Function V_writeExperiment_identifier(fname,str)
374        String fname,str
375       
376//      String path = "entry:experiment_identifier"     
377
378        Make/O/T/N=1 tmpTW
379        String groupName = "/entry"     //     
380        String varName = "experiment_identifier"
381        tmpTW[0] = str //
382
383        variable err
384        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
385        if(err)
386                Print "HDF write err = ",err
387        endif
388       
389        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
390//      err = V_KillNamedDataFolder(fname)
391//      if(err)
392//              Print "DataFolder kill err = ",err
393//      endif
394               
395        return(err)
396End
397
398// name of facility = NCNR
399Function V_writeFacility(fname,str)
400        String fname,str
401       
402//      String path = "entry:facility" 
403
404        Make/O/T/N=1 tmpTW
405        String groupName = "/entry"     //     
406        String varName = "facility"
407        tmpTW[0] = str //
408
409        variable err
410        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
411        if(err)
412                Print "HDF write err = ",err
413        endif
414       
415        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
416//      err = V_KillNamedDataFolder(fname)
417//      if(err)
418//              Print "DataFolder kill err = ",err
419//      endif
420               
421        return(err)
422End
423
424
425// file name
426Function V_writeFile_name(fname,str)
427        String fname,str
428       
429//      String path = "entry:file_name"
430
431        Make/O/T/N=1 tmpTW
432        String groupName = "/entry"     //     
433        String varName = "file_name"
434        tmpTW[0] = str //
435
436        variable err
437        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
438        if(err)
439                Print "HDF write err = ",err
440        endif
441       
442        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
443//      err = V_KillNamedDataFolder(fname)
444//      if(err)
445//              Print "DataFolder kill err = ",err
446//      endif
447               
448        return(err)
449End
450
451       
452//// file write time (what is this??)
453//// TODO - figure out if this is supposed to be an integer or text (ISO)
454//Function V_writeFileWriteTime(fname,val)
455//      String fname
456//      Variable val
457//     
458//      String path = "entry:file_time"
459//     
460//      Make/O/D/N=1 wTmpWrite
461////    Make/O/R/N=1 wTmpWrite
462//      String groupName = "/entry"     
463//      String varName = "file_time"
464//      wTmpWrite[0] = val
465//
466//      variable err
467//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
468//      if(err)
469//              Print "HDF write err = ",err
470//      endif
471//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
472////    err = V_KillNamedDataFolder(fname)
473////    if(err)
474////            Print "DataFolder kill err = ",err
475////    endif
476//      return(err)
477//End
478               
479//
480Function V_writeHDF_version(fname,str)
481        String fname,str
482       
483//      String path = "entry:hdf_version"       
484
485        Make/O/T/N=1 tmpTW
486        String groupName = "/entry"     //     
487        String varName = "hdf_version"
488        tmpTW[0] = str //
489
490        variable err
491        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
492        if(err)
493                Print "HDF write err = ",err
494        endif
495       
496        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
497//      err = V_KillNamedDataFolder(fname)
498//      if(err)
499//              Print "DataFolder kill err = ",err
500//      endif
501               
502        return(err)
503End
504
505// TODO -- not mine, added somewhere by Nexus writer?
506Function V_writeProgram_name(fname,str)
507        String fname,str
508       
509//      String path = "entry:program_name"     
510
511        Make/O/T/N=1 tmpTW
512        String groupName = "/entry"     //     
513        String varName = "program_name"
514        tmpTW[0] = str //
515
516        variable err
517        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
518        if(err)
519                Print "HDF write err = ",err
520        endif
521       
522        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
523//      err = V_KillNamedDataFolder(fname)
524//      if(err)
525//              Print "DataFolder kill err = ",err
526//      endif
527               
528        return(err)
529End
530
531// TODO -- not mine, added somewhere by Nexus writer?
532// data collection start time
533Function V_writeDataStartTime(fname,str)
534        String fname,str
535       
536//      String path = "entry:start_time"       
537
538        Make/O/T/N=1 tmpTW
539        String groupName = "/entry"     //     
540        String varName = "start_time"
541        tmpTW[0] = str //
542
543        variable err
544        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
545        if(err)
546                Print "HDF write err = ",err
547        endif
548       
549        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
550//      err = V_KillNamedDataFolder(fname)
551//      if(err)
552//              Print "DataFolder kill err = ",err
553//      endif
554               
555        return(err)
556End
557               
558// title of experiment
559Function V_writeTitle(fname,str)
560        String fname,str
561       
562//      String path = "entry:title"     
563
564        Make/O/T/N=1 tmpTW
565        String groupName = "/entry"     //     
566        String varName = "title"
567        tmpTW[0] = str //
568
569        variable err
570        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
571        if(err)
572                Print "HDF write err = ",err
573        endif
574       
575        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
576//      err = V_KillNamedDataFolder(fname)
577//      if(err)
578//              Print "DataFolder kill err = ",err
579//      endif
580               
581        return(err)
582end
583       
584       
585               
586////////// USER
587////////// USER
588////////// USER
589
590// list of user names
591// DONE -- currently not written out to data file??
592Function V_writeUserNames(fname,str)
593        String fname,str
594       
595//      String path = "entry:user:name"
596
597        Make/O/T/N=1 tmpTW
598        String groupName = "/entry/user"        //     
599        String varName = "name"
600        tmpTW[0] = str //
601
602        variable err
603        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
604        if(err)
605                Print "HDF write err = ",err
606        endif
607       
608        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
609//      err = V_KillNamedDataFolder(fname)
610//      if(err)
611//              Print "DataFolder kill err = ",err
612//      endif
613               
614        return(err)
615end
616
617
618//////// CONTROL
619//////// CONTROL
620//////// CONTROL
621
622// TODO -- for the control section, document each of the fields
623//
624Function V_writeCount_end(fname,str)
625        String fname,str
626       
627//      String path = "entry:control:count_end"
628
629        Make/O/T/N=1 tmpTW
630        String groupName = "/entry/control"     //     
631        String varName = "count_end"
632        tmpTW[0] = str //
633
634        variable err
635        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
636        if(err)
637                Print "HDF write err = ",err
638        endif
639       
640        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
641//      err = V_KillNamedDataFolder(fname)
642//      if(err)
643//              Print "DataFolder kill err = ",err
644//      endif
645               
646        return(err)
647end
648
649Function V_writeCount_start(fname,str)
650        String fname,str
651       
652//      String path = "entry:control:count_start"       
653
654        Make/O/T/N=1 tmpTW
655        String groupName = "/entry/control"     //     
656        String varName = "count_start"
657        tmpTW[0] = str //
658
659        variable err
660        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
661        if(err)
662                Print "HDF write err = ",err
663        endif
664       
665        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
666//      err = V_KillNamedDataFolder(fname)
667//      if(err)
668//              Print "DataFolder kill err = ",err
669//      endif
670               
671        return(err)
672end
673
674
675Function V_writeCount_time(fname,val)
676        String fname
677        Variable val
678       
679//      String path = "entry:control:count_time"       
680       
681        Make/O/D/N=1 wTmpWrite
682//      Make/O/R/N=1 wTmpWrite
683        String groupName = "/entry/control"     
684        String varName = "count_time"
685        wTmpWrite[0] = val
686
687        variable err
688        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
689        if(err)
690                Print "HDF write err = ",err
691        endif
692        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
693//      err = V_KillNamedDataFolder(fname)
694//      if(err)
695//              Print "DataFolder kill err = ",err
696//      endif
697        return(err)
698end
699
700// fname is a local WORK folder
701Function V_putCount_time(fname,val)
702        String fname
703        Variable val
704
705//root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:beam_center_x
706        String path = "root:Packages:NIST:VSANS:"+fname+":"
707        path += "entry:control:count_time"
708       
709        Wave/Z w = $path
710        if(waveExists(w) == 0)
711                return(1)
712        else
713        w[0] = val
714                return(0)
715        endif
716
717End
718
719Function V_writeCount_time_preset(fname,val)
720        String fname
721        Variable val
722       
723//      String path = "entry:control:count_time_preset"
724       
725        Make/O/D/N=1 wTmpWrite
726//      Make/O/R/N=1 wTmpWrite
727        String groupName = "/entry/control"     
728        String varName = "count_time_preset"
729        wTmpWrite[0] = val
730
731        variable err
732        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
733        if(err)
734                Print "HDF write err = ",err
735        endif
736        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
737//      err = V_KillNamedDataFolder(fname)
738//      if(err)
739//              Print "DataFolder kill err = ",err
740//      endif
741        return(err)
742end
743
744
745Function V_writeDetector_counts(fname,val)
746        String fname
747        Variable val
748       
749//      String path = "entry:control:detector_counts"
750       
751        Make/O/D/N=1 wTmpWrite
752//      Make/O/R/N=1 wTmpWrite
753        String groupName = "/entry/control"     
754        String varName = "detector_counts"
755        wTmpWrite[0] = val
756
757        variable err
758        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
759        if(err)
760                Print "HDF write err = ",err
761        endif
762        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
763//      err = V_KillNamedDataFolder(fname)
764//      if(err)
765//              Print "DataFolder kill err = ",err
766//      endif
767        return(err)
768end
769
770// fname is a local WORK folder
771Function V_putDetector_counts(fname,val)
772        String fname
773        Variable val
774
775//root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:beam_center_x
776        String path = "root:Packages:NIST:VSANS:"+fname+":"
777        path += "entry:control:detector_counts"
778       
779        Wave/Z w = $path
780        if(waveExists(w) == 0)
781                return(1)
782        else
783        w[0] = val
784                return(0)
785        endif
786
787End
788
789Function V_writeDetector_preset(fname,val)
790        String fname
791        Variable val
792       
793//      String path = "entry:control:detector_preset"   
794       
795        Make/O/D/N=1 wTmpWrite
796//      Make/O/R/N=1 wTmpWrite
797        String groupName = "/entry/control"     
798        String varName = "detector_preset"
799        wTmpWrite[0] = val
800
801        variable err
802        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
803        if(err)
804                Print "HDF write err = ",err
805        endif
806        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
807//      err = V_KillNamedDataFolder(fname)
808//      if(err)
809//              Print "DataFolder kill err = ",err
810//      endif
811        return(err)
812end
813
814// integer value
815Function V_writeIntegral(fname,val)
816        String fname
817        Variable val
818       
819//      String path = "entry:control:integral"
820       
821        Make/O/I/N=1 wTmpWrite
822//      Make/O/R/N=1 wTmpWrite
823        String groupName = "/entry/control"     
824        String varName = "integral"
825        wTmpWrite[0] = val
826
827        variable err
828        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
829        if(err)
830                Print "HDF write err = ",err
831        endif
832        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
833//      err = V_KillNamedDataFolder(fname)
834//      if(err)
835//              Print "DataFolder kill err = ",err
836//      endif
837        return(err)
838end
839
840// control mode for data acquisition, "timer"
841Function V_writeControlMode(fname,str)
842        String fname,str
843       
844//      String path = "entry:control:mode"     
845
846        Make/O/T/N=1 tmpTW
847        String groupName = "/entry/control"     //     
848        String varName = "mode"
849        tmpTW[0] = str //
850
851        variable err
852        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
853        if(err)
854                Print "HDF write err = ",err
855        endif
856       
857        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
858//      err = V_KillNamedDataFolder(fname)
859//      if(err)
860//              Print "DataFolder kill err = ",err
861//      endif
862               
863        return(err)
864End
865
866//monitor count
867// integer value
868Function V_writeControlMonitorCount(fname,val)
869        String fname
870        Variable val
871       
872//      String path = "entry:control:monitor_counts"   
873       
874        Make/O/I/N=1 wTmpWrite
875//      Make/O/R/N=1 wTmpWrite
876        String groupName = "/entry/control"     
877        String varName = "monitor_counts"
878        wTmpWrite[0] = val
879
880        variable err
881        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
882        if(err)
883                Print "HDF write err = ",err
884        endif
885        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
886//      err = V_KillNamedDataFolder(fname)
887//      if(err)
888//              Print "DataFolder kill err = ",err
889//      endif
890        return(err)
891end
892
893// fname is a local WORK folder
894Function V_putControlMonitorCount(fname,val)
895        String fname
896        Variable val
897
898//root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:beam_center_x
899        String path = "root:Packages:NIST:VSANS:"+fname+":"
900        path += "entry:control:monitor_counts"
901       
902        Wave/Z w = $path
903        if(waveExists(w) == 0)
904                return(1)
905        else
906        w[0] = val
907                return(0)
908        endif
909
910End
911
912//integer value
913Function V_writeControlMonitor_preset(fname,val)
914        String fname
915        Variable val
916       
917//      String path = "entry:control:monitor_preset"
918       
919        Make/O/I/N=1 wTmpWrite
920//      Make/O/R/N=1 wTmpWrite
921        String groupName = "/entry/control"     
922        String varName = "monitor_preset"
923        wTmpWrite[0] = val
924
925        variable err
926        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
927        if(err)
928                Print "HDF write err = ",err
929        endif
930        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
931//      err = V_KillNamedDataFolder(fname)
932//      if(err)
933//              Print "DataFolder kill err = ",err
934//      endif
935        return(err)
936end
937
938Function V_writeControlPreset(fname,str)
939        String fname,str
940       
941//      String path = "entry:control:preset"
942               
943        Make/O/T/N=1 tmpTW
944        String groupName = "/entry/control"     
945        String varName = "preset"
946        tmpTW[0] = str //
947
948        variable err
949        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
950        if(err)
951                Print "HDF write err = ",err
952        endif
953        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
954//      err = V_KillNamedDataFolder(fname)
955//      if(err)
956//              Print "DataFolder kill err = ",err
957//      endif
958        return(err)
959end
960
961
962
963
964
965//////// INSTRUMENT
966//////// INSTRUMENT
967//////// INSTRUMENT
968
969Function V_writeLocalContact(fname,str)
970        String fname,str
971
972//      String path = "entry:instrument:local_contact"
973
974        Make/O/T/N=1 tmpTW
975        String groupName = "/entry/instrument"  //     
976        String varName = "local_contact"
977        tmpTW[0] = str //
978
979        variable err
980        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
981        if(err)
982                Print "HDF write err = ",err
983        endif
984       
985        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
986//      err = V_KillNamedDataFolder(fname)
987//      if(err)
988//              Print "DataFolder kill err = ",err
989//      endif
990               
991        return(err)
992End
993
994Function V_writeInstrumentName(fname,str)
995        String fname,str
996
997//      String path = "entry:instrument:name"
998
999        Make/O/T/N=1 tmpTW
1000        String groupName = "/entry/instrument"  //     
1001        String varName = "name"
1002        tmpTW[0] = str //
1003
1004        variable err
1005        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1006        if(err)
1007                Print "HDF write err = ",err
1008        endif
1009       
1010        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1011//      err = V_KillNamedDataFolder(fname)
1012//      if(err)
1013//              Print "DataFolder kill err = ",err
1014//      endif
1015               
1016        return(err)
1017End
1018
1019Function V_writeInstrumentType(fname,str)
1020        String fname,str
1021
1022//      String path = "entry:instrument:type"
1023
1024        Make/O/T/N=1 tmpTW
1025        String groupName = "/entry/instrument"  //     
1026        String varName = "type"
1027        tmpTW[0] = str //
1028
1029        variable err
1030        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1031        if(err)
1032                Print "HDF write err = ",err
1033        endif
1034       
1035        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1036//      err = V_KillNamedDataFolder(fname)
1037//      if(err)
1038//              Print "DataFolder kill err = ",err
1039//      endif
1040               
1041        return(err)
1042End
1043
1044////// INSTRUMENT/ATTENUATOR
1045// TODO - verify the format of how these are written out to the file
1046//
1047
1048// transmission value for the attenuator in the beam
1049// use this, but if something wrong, the tables are present
1050Function V_writeAttenuator_transmission(fname,val)
1051        String fname
1052        Variable val
1053       
1054//      String path = "entry:instrument:attenuator:attenuator_transmission"     
1055       
1056        Make/O/D/N=1 wTmpWrite
1057//      Make/O/R/N=1 wTmpWrite
1058        String groupName = "/entry/instrument/attenuator"       
1059        String varName = "attenuator_transmission"
1060        wTmpWrite[0] = val
1061
1062        variable err
1063        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1064        if(err)
1065                Print "HDF write err = ",err
1066        endif
1067        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1068//      err = V_KillNamedDataFolder(fname)
1069//      if(err)
1070//              Print "DataFolder kill err = ",err
1071//      endif
1072        return(err)
1073end
1074
1075// transmission value (error) for the attenuator in the beam
1076// use this, but if something wrong, the tables are present
1077Function V_writeAttenuator_trans_err(fname,val)
1078        String fname
1079        Variable val
1080       
1081//      String path = "entry:instrument:attenuator:attenuator_transmission_error"       
1082       
1083        Make/O/D/N=1 wTmpWrite
1084//      Make/O/R/N=1 wTmpWrite
1085        String groupName = "/entry/instrument/attenuator"       
1086        String varName = "attenuator_transmission_error"
1087        wTmpWrite[0] = val
1088
1089        variable err
1090        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1091        if(err)
1092                Print "HDF write err = ",err
1093        endif
1094        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1095//      err = V_KillNamedDataFolder(fname)
1096//      if(err)
1097//              Print "DataFolder kill err = ",err
1098//      endif
1099        return(err)
1100end
1101
1102// desired thickness of attenuation
1103Function V_writeAttenuator_desiredThick(fname,val)
1104        String fname
1105        Variable val
1106       
1107//      String path = "entry:instrument:attenuator:attenuator_transmission_error"       
1108       
1109        Make/O/D/N=1 wTmpWrite
1110//      Make/O/R/N=1 wTmpWrite
1111        String groupName = "/entry/instrument/attenuator"       
1112        String varName = "desired_thickness"
1113        wTmpWrite[0] = val
1114
1115        variable err
1116        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1117        if(err)
1118                Print "HDF write err = ",err
1119        endif
1120        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1121//      err = V_KillNamedDataFolder(fname)
1122//      if(err)
1123//              Print "DataFolder kill err = ",err
1124//      endif
1125        return(err)
1126end
1127
1128
1129// distance from the attenuator to the sample (units??)
1130Function V_writeAttenDistance(fname,val)
1131        String fname
1132        Variable val
1133       
1134//      String path = "entry:instrument:attenuator:distance"   
1135       
1136        Make/O/D/N=1 wTmpWrite
1137//      Make/O/R/N=1 wTmpWrite
1138        String groupName = "/entry/instrument/attenuator"       
1139        String varName = "distance"
1140        wTmpWrite[0] = val
1141
1142        variable err
1143        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1144        if(err)
1145                Print "HDF write err = ",err
1146        endif
1147        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1148//      err = V_KillNamedDataFolder(fname)
1149//      if(err)
1150//              Print "DataFolder kill err = ",err
1151//      endif
1152        return(err)
1153end
1154
1155
1156// table of the attenuation factor error
1157Function V_writeAttenIndex_table_err(fname,inW)
1158        String fname
1159        Wave inW
1160       
1161//      String path = "entry:instrument:attenuator:index_table"
1162       
1163        Duplicate/O inW wTmpWrite       
1164// then use redimension as needed to cast the wave to write to the specified type
1165// see WaveType for the proper codes
1166//      Redimension/T=() wTmpWrite
1167// -- May also need to check the dimension(s) before writing (don't trust the input)
1168        String groupName = "/entry/instrument/attenuator"       
1169        String varName = "index_error_table"
1170
1171        variable err
1172        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1173        if(err)
1174                Print "HDF write err = ",err
1175        endif
1176        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1177//      err = V_KillNamedDataFolder(fname)
1178//      if(err)
1179//              Print "DataFolder kill err = ",err
1180//      endif
1181        return(err)
1182end
1183
1184// table of the attenuation factor
1185Function V_writeAttenIndex_table(fname,inW)
1186        String fname
1187        Wave inW
1188       
1189//      String path = "entry:instrument:attenuator:index_table"
1190       
1191        Duplicate/O inW wTmpWrite       
1192// then use redimension as needed to cast the wave to write to the specified type
1193// see WaveType for the proper codes
1194//      Redimension/T=() wTmpWrite
1195// -- May also need to check the dimension(s) before writing (don't trust the input)
1196        String groupName = "/entry/instrument/attenuator"       
1197        String varName = "index_table"
1198
1199        variable err
1200        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1201        if(err)
1202                Print "HDF write err = ",err
1203        endif
1204        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1205//      err = V_KillNamedDataFolder(fname)
1206//      if(err)
1207//              Print "DataFolder kill err = ",err
1208//      endif
1209        return(err)
1210end
1211
1212
1213//// status "in or out"
1214//Function V_writeAttenStatus(fname,str)
1215//      String fname,str
1216//
1217////    String path = "entry:instrument:attenuator:status"
1218//
1219//      Make/O/T/N=1 tmpTW
1220//      String groupName = "/entry/instrument/attenuator"       //     
1221//      String varName = "status"
1222//      tmpTW[0] = str //
1223//
1224//      variable err
1225//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1226//      if(err)
1227//              Print "HDF write err = ",err
1228//      endif
1229//     
1230//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1231////    err = V_KillNamedDataFolder(fname)
1232////    if(err)
1233////            Print "DataFolder kill err = ",err
1234////    endif
1235//             
1236//      return(err)
1237//End
1238
1239//// number of attenuators actually dropped in
1240//// an integer value
1241Function V_writeAtten_num_dropped(fname,val)
1242        String fname
1243        Variable val
1244       
1245//      String path = "entry:instrument:attenuator:thickness"   
1246       
1247        Make/O/I/N=1 wTmpWrite
1248//      Make/O/R/N=1 wTmpWrite
1249        String groupName = "/entry/instrument/attenuator"       
1250        String varName = "num_atten_dropped"
1251        wTmpWrite[0] = val
1252
1253        variable err
1254        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1255        if(err)
1256                Print "HDF write err = ",err
1257        endif
1258        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1259//      err = V_KillNamedDataFolder(fname)
1260//      if(err)
1261//              Print "DataFolder kill err = ",err
1262//      endif
1263        return(err)
1264end
1265
1266// thickness of the attenuator (PMMA) - units??
1267Function V_writeAttenThickness(fname,val)
1268        String fname
1269        Variable val
1270       
1271//      String path = "entry:instrument:attenuator:thickness"   
1272       
1273        Make/O/D/N=1 wTmpWrite
1274//      Make/O/R/N=1 wTmpWrite
1275        String groupName = "/entry/instrument/attenuator"       
1276        String varName = "thickness"
1277        wTmpWrite[0] = val
1278
1279        variable err
1280        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1281        if(err)
1282                Print "HDF write err = ",err
1283        endif
1284        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1285//      err = V_KillNamedDataFolder(fname)
1286//      if(err)
1287//              Print "DataFolder kill err = ",err
1288//      endif
1289        return(err)
1290end
1291
1292
1293// type of material for the atteunator
1294Function V_writeAttenType(fname,str)
1295        String fname,str
1296
1297//      String path = "entry:instrument:attenuator:type"
1298
1299        Make/O/T/N=1 tmpTW
1300        String groupName = "/entry/instrument/attenuator"       //     
1301        String varName = "type"
1302        tmpTW[0] = str //
1303
1304        variable err
1305        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1306        if(err)
1307                Print "HDF write err = ",err
1308        endif
1309       
1310        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1311//      err = V_KillNamedDataFolder(fname)
1312//      if(err)
1313//              Print "DataFolder kill err = ",err
1314//      endif
1315               
1316        return(err)
1317End
1318
1319
1320
1321
1322////// INSTRUMENT/BEAM
1323//
1324Function V_writeAnalyzer_depth(fname,val)
1325        String fname
1326        Variable val
1327       
1328//      String path = "entry:instrument:beam:analyzer:depth"
1329
1330        Make/O/D/N=1 wTmpWrite
1331//      Make/O/R/N=1 wTmpWrite
1332        String groupName = "/entry/instrument/beam/analyzer"   
1333        String varName = "depth"
1334        wTmpWrite[0] = val
1335
1336        variable err
1337        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1338        if(err)
1339                Print "HDF write err = ",err
1340        endif
1341        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1342//      err = V_KillNamedDataFolder(fname)
1343//      if(err)
1344//              Print "DataFolder kill err = ",err
1345//      endif
1346        return(err)
1347end
1348
1349Function V_writeAnalyzer_direction(fname,str)
1350        String fname,str
1351
1352//      String path = "entry:instrument:beam:analyzer:direction"
1353
1354        Make/O/T/N=1 tmpTW
1355        String groupName = "/entry/instrument/beam/analyzer"    //     
1356        String varName = "direction"
1357        tmpTW[0] = str //
1358
1359        variable err
1360        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1361        if(err)
1362                Print "HDF write err = ",err
1363        endif
1364       
1365        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1366//      err = V_KillNamedDataFolder(fname)
1367//      if(err)
1368//              Print "DataFolder kill err = ",err
1369//      endif
1370               
1371        return(err)
1372End
1373
1374Function V_writeAnalyzer_height(fname,val)
1375        String fname
1376        Variable val
1377       
1378//      String path = "entry:instrument:beam:analyzer:height"   
1379
1380        Make/O/D/N=1 wTmpWrite
1381//      Make/O/R/N=1 wTmpWrite
1382        String groupName = "/entry/instrument/beam/analyzer"   
1383        String varName = "height"
1384        wTmpWrite[0] = val
1385
1386        variable err
1387        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1388        if(err)
1389                Print "HDF write err = ",err
1390        endif
1391        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1392//      err = V_KillNamedDataFolder(fname)
1393//      if(err)
1394//              Print "DataFolder kill err = ",err
1395//      endif
1396        return(err)
1397end
1398
1399// ?? TODO is this equivalent to "status" -- is this 0|1 ??
1400Function V_writeAnalyzer_inBeam(fname,val)
1401        String fname
1402        Variable val
1403       
1404//      String path = "entry:instrument:beam:analyzer:inBeam"   
1405
1406        Make/O/D/N=1 wTmpWrite
1407//      Make/O/R/N=1 wTmpWrite
1408        String groupName = "/entry/instrument/beam/analyzer"   
1409        String varName = "inBeam"
1410        wTmpWrite[0] = val
1411
1412        variable err
1413        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1414        if(err)
1415                Print "HDF write err = ",err
1416        endif
1417        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1418//      err = V_KillNamedDataFolder(fname)
1419//      if(err)
1420//              Print "DataFolder kill err = ",err
1421//      endif
1422        return(err)
1423end
1424
1425Function V_writeAnalyzer_innerDiameter(fname,val)
1426        String fname
1427        Variable val
1428       
1429//      String path = "entry:instrument:beam:analyzer:innerDiameter"   
1430
1431        Make/O/D/N=1 wTmpWrite
1432//      Make/O/R/N=1 wTmpWrite
1433        String groupName = "/entry/instrument/beam/analyzer"   
1434        String varName = "innerDiameter"
1435        wTmpWrite[0] = val
1436
1437        variable err
1438        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1439        if(err)
1440                Print "HDF write err = ",err
1441        endif
1442        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1443//      err = V_KillNamedDataFolder(fname)
1444//      if(err)
1445//              Print "DataFolder kill err = ",err
1446//      endif
1447        return(err)
1448end
1449
1450// one of the most important
1451Function V_writeAnalyzer_name(fname,str)
1452        String fname,str
1453
1454//      String path = "entry:instrument:beam:analyzer:name"
1455
1456        Make/O/T/N=1 tmpTW
1457        String groupName = "/entry/instrument/beam/analyzer"    //     
1458        String varName = "name"
1459        tmpTW[0] = str //
1460
1461        variable err
1462        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1463        if(err)
1464                Print "HDF write err = ",err
1465        endif
1466       
1467        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1468//      err = V_KillNamedDataFolder(fname)
1469//      if(err)
1470//              Print "DataFolder kill err = ",err
1471//      endif
1472               
1473        return(err)
1474End
1475
1476Function V_writeAnalyzer_opacityAt1Ang(fname,val)
1477        String fname
1478        Variable val
1479       
1480//      String path = "entry:instrument:beam:analyzer:opacityAt1Ang"   
1481
1482        Make/O/D/N=1 wTmpWrite
1483//      Make/O/R/N=1 wTmpWrite
1484        String groupName = "/entry/instrument/beam/analyzer"   
1485        String varName = "opacityAt1Ang"
1486        wTmpWrite[0] = val
1487
1488        variable err
1489        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1490        if(err)
1491                Print "HDF write err = ",err
1492        endif
1493        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1494//      err = V_KillNamedDataFolder(fname)
1495//      if(err)
1496//              Print "DataFolder kill err = ",err
1497//      endif
1498        return(err)
1499end
1500
1501Function V_writeAna_opacityAt1Ang_err(fname,val)
1502        String fname
1503        Variable val
1504       
1505//      String path = "entry:instrument:beam:analyzer:opacityAt1AngStd"
1506
1507        Make/O/D/N=1 wTmpWrite
1508//      Make/O/R/N=1 wTmpWrite
1509        String groupName = "/entry/instrument/beam/analyzer"   
1510        String varName = "opacityAt1AngStd"
1511        wTmpWrite[0] = val
1512
1513        variable err
1514        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1515        if(err)
1516                Print "HDF write err = ",err
1517        endif
1518        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1519//      err = V_KillNamedDataFolder(fname)
1520//      if(err)
1521//              Print "DataFolder kill err = ",err
1522//      endif
1523        return(err)
1524end
1525
1526Function V_writeAnalyzer_outerDiameter(fname,val)
1527        String fname
1528        Variable val
1529       
1530//      String path = "entry:instrument:beam:analyzer:outerDiameter"   
1531
1532        Make/O/D/N=1 wTmpWrite
1533//      Make/O/R/N=1 wTmpWrite
1534        String groupName = "/entry/instrument/beam/analyzer"   
1535        String varName = "outerDiameter"
1536        wTmpWrite[0] = val
1537
1538        variable err
1539        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1540        if(err)
1541                Print "HDF write err = ",err
1542        endif
1543        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1544//      err = V_KillNamedDataFolder(fname)
1545//      if(err)
1546//              Print "DataFolder kill err = ",err
1547//      endif
1548        return(err)
1549end
1550
1551Function V_writeAnalyzer_shape(fname,str)
1552        String fname,str
1553
1554//      String path = "entry:instrument:beam:analyzer:shape"
1555
1556        Make/O/T/N=1 tmpTW
1557        String groupName = "/entry/instrument/beam/analyzer"    //     
1558        String varName = "shape"
1559        tmpTW[0] = str //
1560
1561        variable err
1562        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1563        if(err)
1564                Print "HDF write err = ",err
1565        endif
1566       
1567        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1568//      err = V_KillNamedDataFolder(fname)
1569//      if(err)
1570//              Print "DataFolder kill err = ",err
1571//      endif
1572               
1573        return(err)
1574End
1575
1576Function V_writeAnalyzer_tE(fname,val)
1577        String fname
1578        Variable val
1579               
1580//      String path = "entry:instrument:beam:analyzer:tE"       
1581
1582        Make/O/D/N=1 wTmpWrite
1583//      Make/O/R/N=1 wTmpWrite
1584        String groupName = "/entry/instrument/beam/analyzer"   
1585        String varName = "tE"
1586        wTmpWrite[0] = val
1587
1588        variable err
1589        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1590        if(err)
1591                Print "HDF write err = ",err
1592        endif
1593        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1594//      err = V_KillNamedDataFolder(fname)
1595//      if(err)
1596//              Print "DataFolder kill err = ",err
1597//      endif
1598        return(err)
1599end
1600
1601Function V_writeAnalyzer_tE_err(fname,val)
1602        String fname
1603        Variable val
1604       
1605//      String path = "entry:instrument:beam:analyzer:tEStd"   
1606
1607        Make/O/D/N=1 wTmpWrite
1608//      Make/O/R/N=1 wTmpWrite
1609        String groupName = "/entry/instrument/beam/analyzer"   
1610        String varName = "tEStd"
1611        wTmpWrite[0] = val
1612
1613        variable err
1614        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1615        if(err)
1616                Print "HDF write err = ",err
1617        endif
1618        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1619//      err = V_KillNamedDataFolder(fname)
1620//      if(err)
1621//              Print "DataFolder kill err = ",err
1622//      endif
1623        return(err)
1624end
1625
1626Function V_writeAnalyzer_type(fname,str)
1627        String fname,str
1628
1629//      String path = "entry:instrument:beam:analyzer:type"
1630
1631        Make/O/T/N=1 tmpTW
1632        String groupName = "/entry/instrument/beam/analyzer"    //     
1633        String varName = "type"
1634        tmpTW[0] = str //
1635
1636        variable err
1637        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1638        if(err)
1639                Print "HDF write err = ",err
1640        endif
1641       
1642        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1643//      err = V_KillNamedDataFolder(fname)
1644//      if(err)
1645//              Print "DataFolder kill err = ",err
1646//      endif
1647               
1648        return(err)
1649End
1650
1651
1652Function V_writeAnalyzer_width(fname,val)
1653        String fname
1654        Variable val
1655       
1656//      String path = "entry:instrument:beam:analyzer:width"   
1657
1658        Make/O/D/N=1 wTmpWrite
1659//      Make/O/R/N=1 wTmpWrite
1660        String groupName = "/entry/instrument/beam/analyzer"   
1661        String varName = "width"
1662        wTmpWrite[0] = val
1663
1664        variable err
1665        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1666        if(err)
1667                Print "HDF write err = ",err
1668        endif
1669        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1670//      err = V_KillNamedDataFolder(fname)
1671//      if(err)
1672//              Print "DataFolder kill err = ",err
1673//      endif
1674        return(err)
1675end
1676
1677
1678
1679
1680
1681// instrument/beam/chopper (data folder)
1682Function V_writeChopperAngular_opening(fname,val)
1683        String fname
1684        Variable val
1685       
1686//      String path = "entry:instrument:beam:chopper:angular_opening"
1687       
1688        Make/O/D/N=1 wTmpWrite
1689//      Make/O/R/N=1 wTmpWrite
1690        String groupName = "/entry/instrument/beam/chopper"     
1691        String varName = "angular_opening"
1692        wTmpWrite[0] = val
1693
1694        variable err
1695        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1696        if(err)
1697                Print "HDF write err = ",err
1698        endif
1699        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1700//      err = V_KillNamedDataFolder(fname)
1701//      if(err)
1702//              Print "DataFolder kill err = ",err
1703//      endif
1704        return(err)
1705end
1706
1707Function V_writeChopDistance_from_sample(fname,val)
1708        String fname
1709        Variable val
1710       
1711//      String path = "entry:instrument:beam:chopper:distance_from_sample"
1712       
1713        Make/O/D/N=1 wTmpWrite
1714//      Make/O/R/N=1 wTmpWrite
1715        String groupName = "/entry/instrument/beam/chopper"     
1716        String varName = "distance_from_sample"
1717        wTmpWrite[0] = val
1718
1719        variable err
1720        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1721        if(err)
1722                Print "HDF write err = ",err
1723        endif
1724        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1725//      err = V_KillNamedDataFolder(fname)
1726//      if(err)
1727//              Print "DataFolder kill err = ",err
1728//      endif
1729        return(err)
1730end
1731
1732Function V_writeChopDistance_from_source(fname,val)
1733        String fname
1734        Variable val
1735       
1736//      String path = "entry:instrument:beam:chopper:distance_from_source"     
1737       
1738        Make/O/D/N=1 wTmpWrite
1739//      Make/O/R/N=1 wTmpWrite
1740        String groupName = "/entry/instrument/beam/chopper"     
1741        String varName = "distance_from_source"
1742        wTmpWrite[0] = val
1743
1744        variable err
1745        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1746        if(err)
1747                Print "HDF write err = ",err
1748        endif
1749        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1750//      err = V_KillNamedDataFolder(fname)
1751//      if(err)
1752//              Print "DataFolder kill err = ",err
1753//      endif
1754        return(err)
1755end
1756
1757Function V_writeChopperDuty_cycle(fname,val)
1758        String fname
1759        Variable val
1760       
1761//      String path = "entry:instrument:beam:chopper:duty_cycle"       
1762       
1763        Make/O/D/N=1 wTmpWrite
1764//      Make/O/R/N=1 wTmpWrite
1765        String groupName = "/entry/instrument/beam/chopper"     
1766        String varName = "duty_cycle"
1767        wTmpWrite[0] = val
1768
1769        variable err
1770        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1771        if(err)
1772                Print "HDF write err = ",err
1773        endif
1774        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1775//      err = V_KillNamedDataFolder(fname)
1776//      if(err)
1777//              Print "DataFolder kill err = ",err
1778//      endif
1779        return(err)
1780end
1781
1782Function V_writeChopperRotation_speed(fname,val)
1783        String fname
1784        Variable val
1785       
1786//      String path = "entry:instrument:beam:chopper:rotation_speed"   
1787       
1788        Make/O/D/N=1 wTmpWrite
1789//      Make/O/R/N=1 wTmpWrite
1790        String groupName = "/entry/instrument/beam/chopper"     
1791        String varName = "rotation_speed"
1792        wTmpWrite[0] = val
1793
1794        variable err
1795        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1796        if(err)
1797                Print "HDF write err = ",err
1798        endif
1799        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1800//      err = V_KillNamedDataFolder(fname)
1801//      if(err)
1802//              Print "DataFolder kill err = ",err
1803//      endif
1804        return(err)
1805end
1806
1807// integer value
1808Function V_writeChopperSlits(fname,val)
1809        String fname
1810        Variable val
1811       
1812//      String path = "entry:instrument:beam:chopper:slits"     
1813       
1814        Make/O/I/N=1 wTmpWrite
1815//      Make/O/R/N=1 wTmpWrite
1816        String groupName = "/entry/instrument/beam/chopper"     
1817        String varName = "slits"
1818        wTmpWrite[0] = val
1819
1820        variable err
1821        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1822        if(err)
1823                Print "HDF write err = ",err
1824        endif
1825        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1826//      err = V_KillNamedDataFolder(fname)
1827//      if(err)
1828//              Print "DataFolder kill err = ",err
1829//      endif
1830        return(err)
1831end
1832
1833Function V_writeChopperstatus(fname,str)
1834        String fname,str
1835
1836//      String path = "entry:instrument:beam:chopper:status"
1837
1838        Make/O/T/N=1 tmpTW
1839        String groupName = "/entry/instrument/beam/chopper"     //     
1840        String varName = "status"
1841        tmpTW[0] = str //
1842
1843        variable err
1844        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1845        if(err)
1846                Print "HDF write err = ",err
1847        endif
1848       
1849        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1850//      err = V_KillNamedDataFolder(fname)
1851//      if(err)
1852//              Print "DataFolder kill err = ",err
1853//      endif
1854               
1855        return(err)
1856End
1857
1858Function V_writeChoppertype(fname,str)
1859        String fname,str
1860
1861//      String path = "entry:instrument:beam:chopper:type"
1862
1863        Make/O/T/N=1 tmpTW
1864        String groupName = "/entry/instrument/beam/chopper"     //     
1865        String varName = "type"
1866        tmpTW[0] = str //
1867
1868        variable err
1869        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1870        if(err)
1871                Print "HDF write err = ",err
1872        endif
1873       
1874        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1875//      err = V_KillNamedDataFolder(fname)
1876//      if(err)
1877//              Print "DataFolder kill err = ",err
1878//      endif
1879               
1880        return(err)
1881End
1882
1883
1884///////////////
1885// instrument/beam/flipperPolarizer (data folder)
1886// this is upstream, after the supermirror but before the sample
1887//
1888Function V_writeflipperPol_Direction(fname,str)
1889        String fname,str
1890
1891//      String path = "entry:instrument:beam:flipperPolarizer:direction"
1892
1893        Make/O/T/N=1 tmpTW
1894        String groupName = "/entry/instrument/beam/flipperPolarizer"    //     
1895        String varName = "direction"
1896        tmpTW[0] = str //
1897
1898        variable err
1899        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1900        if(err)
1901                Print "HDF write err = ",err
1902        endif
1903       
1904        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1905//      err = V_KillNamedDataFolder(fname)
1906//      if(err)
1907//              Print "DataFolder kill err = ",err
1908//      endif
1909               
1910        return(err)
1911End
1912
1913Function V_writeflipperPolarizer_inBeam(fname,val)
1914        String fname
1915        Variable val
1916       
1917//      String path = "entry:instrument:beam:flipperPolarizer:inBeam"   
1918
1919        Make/O/D/N=1 wTmpWrite
1920//      Make/O/R/N=1 wTmpWrite
1921        String groupName = "/entry/instrument/beam/flipperPolarizer"   
1922        String varName = "inBeam"
1923        wTmpWrite[0] = val
1924
1925        variable err
1926        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1927        if(err)
1928                Print "HDF write err = ",err
1929        endif
1930        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1931//      err = V_KillNamedDataFolder(fname)
1932//      if(err)
1933//              Print "DataFolder kill err = ",err
1934//      endif
1935        return(err)
1936end
1937
1938Function V_writeflipperPolarizer_Type(fname,str)
1939        String fname,str
1940
1941//      String path = "entry:instrument:beam:flipperPolarizer:type"
1942        Make/O/T/N=1 tmpTW
1943        String groupName = "/entry/instrument/beam/flipperPolarizer"    //     
1944        String varName = "type"
1945        tmpTW[0] = str //
1946
1947        variable err
1948        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1949        if(err)
1950                Print "HDF write err = ",err
1951        endif
1952       
1953        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1954//      err = V_KillNamedDataFolder(fname)
1955//      if(err)
1956//              Print "DataFolder kill err = ",err
1957//      endif
1958               
1959        return(err)
1960End
1961
1962
1963
1964
1965//////////
1966//// instrument/beam/flipper (data folder)
1967//Function V_writeFlipperDriving_current(fname,val)
1968//      String fname
1969//      Variable val
1970//     
1971////    String path = "entry:instrument:beam:flipper:driving_current"   
1972//     
1973//      Make/O/D/N=1 wTmpWrite
1974////    Make/O/R/N=1 wTmpWrite
1975//      String groupName = "/entry/instrument/beam/flipper"     
1976//      String varName = "driving_current"
1977//      wTmpWrite[0] = val
1978//
1979//      variable err
1980//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1981//      if(err)
1982//              Print "HDF write err = ",err
1983//      endif
1984//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1985////    err = V_KillNamedDataFolder(fname)
1986////    if(err)
1987////            Print "DataFolder kill err = ",err
1988////    endif
1989//      return(err)
1990//end
1991//
1992//Function V_writeFlipperFrequency(fname,val)
1993//      String fname
1994//      Variable val
1995//     
1996////    String path = "entry:instrument:beam:flipper:frequency"
1997//     
1998//      Make/O/D/N=1 wTmpWrite
1999////    Make/O/R/N=1 wTmpWrite
2000//      String groupName = "/entry/instrument/beam/flipper"     
2001//      String varName = "frequency"
2002//      wTmpWrite[0] = val
2003//
2004//      variable err
2005//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2006//      if(err)
2007//              Print "HDF write err = ",err
2008//      endif
2009//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2010////    err = V_KillNamedDataFolder(fname)
2011////    if(err)
2012////            Print "DataFolder kill err = ",err
2013////    endif
2014//      return(err)
2015//end
2016//
2017//Function V_writeFlipperstatus(fname,str)
2018//      String fname,str
2019//
2020////    String path = "entry:instrument:beam:flipper:status"
2021//
2022//      Make/O/T/N=1 tmpTW
2023//      String groupName = "/entry/instrument/beam/flipper"     //     
2024//      String varName = "status"
2025//      tmpTW[0] = str //
2026//
2027//      variable err
2028//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2029//      if(err)
2030//              Print "HDF write err = ",err
2031//      endif
2032//     
2033//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2034////    err = V_KillNamedDataFolder(fname)
2035////    if(err)
2036////            Print "DataFolder kill err = ",err
2037////    endif
2038//             
2039//      return(err)
2040//End
2041//
2042//Function V_writeFlipperTransmitted_power(fname,val)
2043//      String fname
2044//      Variable val
2045//     
2046////    String path = "entry:instrument:beam:flipper:transmitted_power"
2047//
2048//      Make/O/D/N=1 wTmpWrite
2049////    Make/O/R/N=1 wTmpWrite
2050//      String groupName = "/entry/instrument/beam/flipper"     
2051//      String varName = "transmitted_power"
2052//      wTmpWrite[0] = val
2053//
2054//      variable err
2055//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2056//      if(err)
2057//              Print "HDF write err = ",err
2058//      endif
2059//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2060////    err = V_KillNamedDataFolder(fname)
2061////    if(err)
2062////            Print "DataFolder kill err = ",err
2063////    endif
2064//      return(err)
2065//end
2066//
2067//Function V_writeFlipperWaveform(fname,str)
2068//      String fname,str
2069//
2070////    String path = "entry:instrument:beam:flipper:waveform"
2071//
2072//      Make/O/T/N=1 tmpTW
2073//      String groupName = "/entry/instrument/beam/flipper"     //     
2074//      String varName = "waveform"
2075//      tmpTW[0] = str //
2076//
2077//      variable err
2078//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2079//      if(err)
2080//              Print "HDF write err = ",err
2081//      endif
2082//     
2083//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2084////    err = V_KillNamedDataFolder(fname)
2085////    if(err)
2086////            Print "DataFolder kill err = ",err
2087////    endif
2088//             
2089//      return(err)
2090//End
2091
2092
2093
2094// instrument/beam/monochromator (data folder)
2095Function V_writeMonochromatorType(fname,str)
2096        String fname,str
2097
2098//      String path = "entry:instrument:beam:monochromator:type"
2099
2100        Make/O/T/N=1 tmpTW
2101        String groupName = "/entry/instrument/beam/monochromator"       //     
2102        String varName = "type"
2103        tmpTW[0] = str //
2104
2105        variable err
2106        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2107        if(err)
2108                Print "HDF write err = ",err
2109        endif
2110       
2111        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2112//      err = V_KillNamedDataFolder(fname)
2113//      if(err)
2114//              Print "DataFolder kill err = ",err
2115//      endif
2116               
2117        return(err)
2118End
2119
2120Function V_writeWavelength(fname,val)
2121        String fname
2122        Variable val
2123       
2124//      String path = "entry:instrument:beam:monochromator:wavelength" 
2125       
2126        Make/O/D/N=1 wTmpWrite
2127//      Make/O/R/N=1 wTmpWrite
2128        String groupName = "/entry/instrument/beam/monochromator"       
2129        String varName = "wavelength"
2130        wTmpWrite[0] = val
2131
2132        variable err
2133        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2134        if(err)
2135                Print "HDF write err = ",err
2136        endif
2137        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2138//      err = V_KillNamedDataFolder(fname)
2139//      if(err)
2140//              Print "DataFolder kill err = ",err
2141//      endif
2142        return(err)
2143end
2144
2145Function V_writeWavelength_spread(fname,val)
2146        String fname
2147        Variable val
2148       
2149//      String path = "entry:instrument:beam:monochromator:wavelength_spread"   
2150       
2151        Make/O/D/N=1 wTmpWrite
2152//      Make/O/R/N=1 wTmpWrite
2153        String groupName = "/entry/instrument/beam/monochromator"       
2154        String varName = "wavelength_spread"
2155        wTmpWrite[0] = val
2156
2157        variable err
2158        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2159        if(err)
2160                Print "HDF write err = ",err
2161        endif
2162        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2163//      err = V_KillNamedDataFolder(fname)
2164//      if(err)
2165//              Print "DataFolder kill err = ",err
2166//      endif
2167        return(err)
2168end
2169
2170
2171
2172
2173
2174
2175// instrument/beam/monochromator/crystal (data folder)
2176//
2177Function V_writeCrystalDistance(fname,val)
2178        String fname
2179        Variable val
2180       
2181//      String path = "entry:instrument:beam:monochromator:crystal:distance"   
2182       
2183        Make/O/D/N=1 wTmpWrite
2184//      Make/O/R/N=1 wTmpWrite
2185        String groupName = "/entry/instrument/beam/monochromator/crystal"       
2186        String varName = "distance"
2187        wTmpWrite[0] = val
2188
2189        variable err
2190        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2191        if(err)
2192                Print "HDF write err = ",err
2193        endif
2194        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2195//      err = V_KillNamedDataFolder(fname)
2196//      if(err)
2197//              Print "DataFolder kill err = ",err
2198//      endif
2199        return(err)
2200end
2201
2202Function V_writeCrystalEnergy(fname,val)
2203        String fname
2204        Variable val
2205       
2206//      String path = "entry:instrument:beam:monochromator:crystal:energy"     
2207       
2208        Make/O/D/N=1 wTmpWrite
2209//      Make/O/R/N=1 wTmpWrite
2210        String groupName = "/entry/instrument/beam/monochromator/crystal"       
2211        String varName = "energy"
2212        wTmpWrite[0] = val
2213
2214        variable err
2215        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2216        if(err)
2217                Print "HDF write err = ",err
2218        endif
2219        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2220//      err = V_KillNamedDataFolder(fname)
2221//      if(err)
2222//              Print "DataFolder kill err = ",err
2223//      endif
2224        return(err)
2225end
2226
2227Function V_writeCrystalHoriz_apert(fname,val)
2228        String fname
2229        Variable val
2230       
2231//      String path = "entry:instrument:beam:monochromator:crystal:horizontal_aperture"
2232       
2233        Make/O/D/N=1 wTmpWrite
2234//      Make/O/R/N=1 wTmpWrite
2235        String groupName = "/entry/instrument/beam/monochromator/crystal"       
2236        String varName = "horizontal_aperture"
2237        wTmpWrite[0] = val
2238
2239        variable err
2240        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2241        if(err)
2242                Print "HDF write err = ",err
2243        endif
2244        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2245//      err = V_KillNamedDataFolder(fname)
2246//      if(err)
2247//              Print "DataFolder kill err = ",err
2248//      endif
2249        return(err)
2250end
2251
2252Function V_writeCrystalHoriz_curvature(fname,val)
2253        String fname
2254        Variable val
2255       
2256//      String path = "entry:instrument:beam:monochromator:crystal:horizontal_curvature"       
2257       
2258        Make/O/D/N=1 wTmpWrite
2259//      Make/O/R/N=1 wTmpWrite
2260        String groupName = "/entry/instrument/beam/monochromator/crystal"       
2261        String varName = "horizontal_curvature"
2262        wTmpWrite[0] = val
2263
2264        variable err
2265        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2266        if(err)
2267                Print "HDF write err = ",err
2268        endif
2269        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2270//      err = V_KillNamedDataFolder(fname)
2271//      if(err)
2272//              Print "DataFolder kill err = ",err
2273//      endif
2274        return(err)
2275end
2276
2277Function V_writeCrystalLattice_parameter(fname,val)
2278        String fname
2279        Variable val
2280       
2281//      String path = "entry:instrument:beam:monochromator:crystal:lattice_parameter"   
2282       
2283        Make/O/D/N=1 wTmpWrite
2284//      Make/O/R/N=1 wTmpWrite
2285        String groupName = "/entry/instrument/beam/monochromator/crystal"       
2286        String varName = "lattice_parameter"
2287        wTmpWrite[0] = val
2288
2289        variable err
2290        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2291        if(err)
2292                Print "HDF write err = ",err
2293        endif
2294        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2295//      err = V_KillNamedDataFolder(fname)
2296//      if(err)
2297//              Print "DataFolder kill err = ",err
2298//      endif
2299        return(err)
2300end
2301
2302
2303Function V_writeCrystalReflection(fname,val)
2304        String fname
2305        Variable val
2306       
2307//      String path = "entry:instrument:beam:monochromator:crystal:reflection" 
2308       
2309        Make/O/D/N=1 wTmpWrite
2310//      Make/O/R/N=1 wTmpWrite
2311        String groupName = "/entry/instrument/beam/monochromator/crystal"       
2312        String varName = "reflection"
2313        wTmpWrite[0] = val
2314
2315        variable err
2316        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2317        if(err)
2318                Print "HDF write err = ",err
2319        endif
2320        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2321//      err = V_KillNamedDataFolder(fname)
2322//      if(err)
2323//              Print "DataFolder kill err = ",err
2324//      endif
2325        return(err)
2326end
2327
2328Function V_writeCrystalRotation(fname,val)
2329        String fname
2330        Variable val
2331       
2332//      String path = "entry:instrument:beam:monochromator:crystal:rotation"   
2333       
2334        Make/O/D/N=1 wTmpWrite
2335//      Make/O/R/N=1 wTmpWrite
2336        String groupName = "/entry/instrument/beam/monochromator/crystal"       
2337        String varName = "rotation"
2338        wTmpWrite[0] = val
2339
2340        variable err
2341        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2342        if(err)
2343                Print "HDF write err = ",err
2344        endif
2345        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2346//      err = V_KillNamedDataFolder(fname)
2347//      if(err)
2348//              Print "DataFolder kill err = ",err
2349//      endif
2350        return(err)
2351end
2352
2353Function V_writeCrystalStatus(fname,str)
2354        String fname,str
2355
2356//      String path = "entry:instrument:beam:monochromator:crystal:status"
2357
2358        Make/O/T/N=1 tmpTW
2359        String groupName = "/entry/instrument/beam/monochromator/crystal"       //     
2360        String varName = "status"
2361        tmpTW[0] = str //
2362
2363        variable err
2364        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2365        if(err)
2366                Print "HDF write err = ",err
2367        endif
2368       
2369        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2370//      err = V_KillNamedDataFolder(fname)
2371//      if(err)
2372//              Print "DataFolder kill err = ",err
2373//      endif
2374               
2375        return(err)
2376End
2377
2378Function V_writeCrystalVertical_aperture(fname,val)
2379        String fname
2380        Variable val
2381       
2382//      String path = "entry:instrument:beam:monochromator:crystal:vertical_aperture"   
2383       
2384        Make/O/D/N=1 wTmpWrite
2385//      Make/O/R/N=1 wTmpWrite
2386        String groupName = "/entry/instrument/beam/monochromator/crystal"       
2387        String varName = "vertical_aperture"
2388        wTmpWrite[0] = val
2389
2390        variable err
2391        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2392        if(err)
2393                Print "HDF write err = ",err
2394        endif
2395        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2396//      err = V_KillNamedDataFolder(fname)
2397//      if(err)
2398//              Print "DataFolder kill err = ",err
2399//      endif
2400        return(err)
2401end
2402
2403Function V_writeCrystalVertical_curv(fname,val)
2404        String fname
2405        Variable val
2406       
2407//      String path = "entry:instrument:beam:monochromator:crystal:vertical_curvature" 
2408       
2409        Make/O/D/N=1 wTmpWrite
2410//      Make/O/R/N=1 wTmpWrite
2411        String groupName = "/entry/instrument/beam/monochromator/crystal"       
2412        String varName = "vertical_curvature"
2413        wTmpWrite[0] = val
2414
2415        variable err
2416        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2417        if(err)
2418                Print "HDF write err = ",err
2419        endif
2420        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2421//      err = V_KillNamedDataFolder(fname)
2422//      if(err)
2423//              Print "DataFolder kill err = ",err
2424//      endif
2425        return(err)
2426end
2427
2428Function V_writeCrystalWavelength(fname,val)
2429        String fname
2430        Variable val
2431       
2432//      String path = "entry:instrument:beam:monochromator:crystal:wavelength" 
2433       
2434        Make/O/D/N=1 wTmpWrite
2435//      Make/O/R/N=1 wTmpWrite
2436        String groupName = "/entry/instrument/beam/monochromator/crystal"       
2437        String varName = "wavelength"
2438        wTmpWrite[0] = val
2439
2440        variable err
2441        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2442        if(err)
2443                Print "HDF write err = ",err
2444        endif
2445        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2446//      err = V_KillNamedDataFolder(fname)
2447//      if(err)
2448//              Print "DataFolder kill err = ",err
2449//      endif
2450        return(err)
2451end
2452
2453Function V_writeCrystalWavelength_spread(fname,val)
2454        String fname
2455        Variable val
2456       
2457//      String path = "entry:instrument:beam:monochromator:crystal:wavelength_spread"   
2458       
2459        Make/O/D/N=1 wTmpWrite
2460//      Make/O/R/N=1 wTmpWrite
2461        String groupName = "/entry/instrument/beam/monochromator/crystal"       
2462        String varName = "wavelength_spread"
2463        wTmpWrite[0] = val
2464
2465        variable err
2466        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2467        if(err)
2468                Print "HDF write err = ",err
2469        endif
2470        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2471//      err = V_KillNamedDataFolder(fname)
2472//      if(err)
2473//              Print "DataFolder kill err = ",err
2474//      endif
2475        return(err)
2476end
2477
2478Function V_writeCrystalWavevector(fname,val)
2479        String fname
2480        Variable val
2481       
2482//      String path = "entry:instrument:beam:monochromator:crystal:wavevector" 
2483       
2484        Make/O/D/N=1 wTmpWrite
2485//      Make/O/R/N=1 wTmpWrite
2486        String groupName = "/entry/instrument/beam/monochromator/crystal"       
2487        String varName = "wavevector"
2488        wTmpWrite[0] = val
2489
2490        variable err
2491        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2492        if(err)
2493                Print "HDF write err = ",err
2494        endif
2495        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2496//      err = V_KillNamedDataFolder(fname)
2497//      if(err)
2498//              Print "DataFolder kill err = ",err
2499//      endif
2500        return(err)
2501end
2502
2503////////////
2504// instrument/beam/monochromator/velocity_selector (data folder)
2505Function V_writeVSDistance(fname,val)
2506        String fname
2507        Variable val
2508       
2509//      String path = "entry:instrument:beam:monochromator:velocity_selector:distance" 
2510       
2511        Make/O/D/N=1 wTmpWrite
2512//      Make/O/R/N=1 wTmpWrite
2513        String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     
2514        String varName = "distance"
2515        wTmpWrite[0] = val
2516
2517        variable err
2518        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2519        if(err)
2520                Print "HDF write err = ",err
2521        endif
2522        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2523//      err = V_KillNamedDataFolder(fname)
2524//      if(err)
2525//              Print "DataFolder kill err = ",err
2526//      endif
2527        return(err)
2528end
2529
2530Function V_writeVSRotation_speed(fname,val)
2531        String fname
2532        Variable val
2533       
2534//      String path = "entry:instrument:beam:monochromator:velocity_selector:rotation_speed"   
2535       
2536        Make/O/D/N=1 wTmpWrite
2537//      Make/O/R/N=1 wTmpWrite
2538        String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     
2539        String varName = "rotation_speed"
2540        wTmpWrite[0] = val
2541
2542        variable err
2543        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2544        if(err)
2545                Print "HDF write err = ",err
2546        endif
2547        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2548//      err = V_KillNamedDataFolder(fname)
2549//      if(err)
2550//              Print "DataFolder kill err = ",err
2551//      endif
2552        return(err)
2553end
2554
2555Function V_writeVelSelStatus(fname,str)
2556        String fname,str
2557
2558//      String path = "entry:instrument:beam:monochromator:velocity_selector:status"
2559
2560        Make/O/T/N=1 tmpTW
2561        String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     //     
2562        String varName = "status"
2563        tmpTW[0] = str //
2564
2565        variable err
2566        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2567        if(err)
2568                Print "HDF write err = ",err
2569        endif
2570       
2571        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2572//      err = V_KillNamedDataFolder(fname)
2573//      if(err)
2574//              Print "DataFolder kill err = ",err
2575//      endif
2576               
2577        return(err)
2578End
2579
2580Function V_writeVSTable_parameters(fname,inW)
2581        String fname
2582        Wave inW
2583       
2584//      String path = "entry:instrument:beam:monochromator:velocity_selector:table"     
2585
2586        Duplicate/O inW wTmpWrite       
2587// then use redimension as needed to cast the wave to write to the specified type
2588// see WaveType for the proper codes
2589//      Redimension/T=() wTmpWrite
2590// -- May also need to check the dimension(s) before writing (don't trust the input)
2591        String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     
2592        String varName = "table_parameters"
2593
2594        variable err
2595        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2596        if(err)
2597                Print "HDF write err = ",err
2598        endif
2599        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2600//      err = V_KillNamedDataFolder(fname)
2601//      if(err)
2602//              Print "DataFolder kill err = ",err
2603//      endif
2604        return(err)
2605end
2606
2607//// DONE - this does not exist for VSANS - per JGB 4/2016
2608//Function V_writeVS_tilt(fname,val)
2609//      String fname
2610//      Variable val
2611//     
2612////    String path = "entry:instrument:beam:monochromator:velocity_selector:vs_tilt"   
2613//     
2614//      Make/O/D/N=1 wTmpWrite
2615////    Make/O/R/N=1 wTmpWrite
2616//      String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     
2617//      String varName = "vs_tilt"
2618//      wTmpWrite[0] = val
2619//
2620//      variable err
2621//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2622//      if(err)
2623//              Print "HDF write err = ",err
2624//      endif
2625//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2626////    err = V_KillNamedDataFolder(fname)
2627////    if(err)
2628////            Print "DataFolder kill err = ",err
2629////    endif
2630//      return(err)
2631//end
2632
2633Function V_writeVSWavelength(fname,val)
2634        String fname
2635        Variable val
2636       
2637//      String path = "entry:instrument:beam:monochromator:velocity_selector:wavelength"       
2638       
2639        Make/O/D/N=1 wTmpWrite
2640//      Make/O/R/N=1 wTmpWrite
2641        String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     
2642        String varName = "wavelength"
2643        wTmpWrite[0] = val
2644
2645        variable err
2646        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2647        if(err)
2648                Print "HDF write err = ",err
2649        endif
2650        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2651//      err = V_KillNamedDataFolder(fname)
2652//      if(err)
2653//              Print "DataFolder kill err = ",err
2654//      endif
2655        return(err)
2656end
2657
2658Function V_writeVSWavelength_spread(fname,val)
2659        String fname
2660        Variable val
2661       
2662//      String path = "entry:instrument:beam:monochromator:velocity_selector:wavelength_spread"
2663       
2664        Make/O/D/N=1 wTmpWrite
2665//      Make/O/R/N=1 wTmpWrite
2666        String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     
2667        String varName = "wavelength_spread"
2668        wTmpWrite[0] = val
2669
2670        variable err
2671        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2672        if(err)
2673                Print "HDF write err = ",err
2674        endif
2675        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2676//      err = V_KillNamedDataFolder(fname)
2677//      if(err)
2678//              Print "DataFolder kill err = ",err
2679//      endif
2680        return(err)
2681end
2682
2683// instrument/beam/monochromator/white_beam (data folder)
2684Function V_writeWhiteBeamStatus(fname,str)
2685        String fname,str
2686
2687//      String path = "entry:instrument:beam:monochromator:white_beam:status"
2688
2689        Make/O/T/N=1 tmpTW
2690        String groupName = "/entry/instrument/beam/monochromator/white_beam"    //     
2691        String varName = "status"
2692        tmpTW[0] = str //
2693
2694        variable err
2695        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2696        if(err)
2697                Print "HDF write err = ",err
2698        endif
2699       
2700        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2701//      err = V_KillNamedDataFolder(fname)
2702//      if(err)
2703//              Print "DataFolder kill err = ",err
2704//      endif
2705               
2706        return(err)
2707End
2708
2709Function V_writeWhiteBeamWavelength(fname,val)
2710        String fname
2711        Variable val
2712       
2713//      String path = "entry:instrument:beam:monochromator:white_beam:wavelength"       
2714       
2715        Make/O/D/N=1 wTmpWrite
2716//      Make/O/R/N=1 wTmpWrite
2717        String groupName = "/entry/instrument/beam/monochromator/white_beam"   
2718        String varName = "wavelength"
2719        wTmpWrite[0] = val
2720
2721        variable err
2722        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2723        if(err)
2724                Print "HDF write err = ",err
2725        endif
2726        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2727//      err = V_KillNamedDataFolder(fname)
2728//      if(err)
2729//              Print "DataFolder kill err = ",err
2730//      endif
2731        return(err)
2732end
2733
2734Function V_writeWhiteBeamWavel_spread(fname,val)
2735        String fname
2736        Variable val
2737       
2738//      String path = "entry:instrument:beam:monochromator:white_beam:wavelength_spread"       
2739       
2740        Make/O/D/N=1 wTmpWrite
2741//      Make/O/R/N=1 wTmpWrite
2742        String groupName = "/entry/instrument/beam/monochromator/white_beam"   
2743        String varName = "wavelength_spread"
2744        wTmpWrite[0] = val
2745
2746        variable err
2747        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2748        if(err)
2749                Print "HDF write err = ",err
2750        endif
2751        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2752//      err = V_KillNamedDataFolder(fname)
2753//      if(err)
2754//              Print "DataFolder kill err = ",err
2755//      endif
2756        return(err)
2757end
2758
2759// instrument/beam/superMirror (data folder)
2760// This is the upstream polarizer. There are no other choices for polarizer on VSANS
2761Function V_writePolarizerComposition(fname,str)
2762        String fname,str
2763
2764//      String path = "entry:instrument:beam:superMirror:composition"
2765
2766        Make/O/T/N=1 tmpTW
2767        String groupName = "/entry/instrument/beam/superMirror" //     
2768        String varName = "composition"
2769        tmpTW[0] = str //
2770
2771        variable err
2772        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2773        if(err)
2774                Print "HDF write err = ",err
2775        endif
2776       
2777        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2778//      err = V_KillNamedDataFolder(fname)
2779//      if(err)
2780//              Print "DataFolder kill err = ",err
2781//      endif
2782               
2783        return(err)
2784End
2785
2786Function V_writePolarizerEfficiency(fname,val)
2787        String fname
2788        Variable val
2789       
2790//      String path = "entry:instrument:beam:superMirror:efficiency"   
2791       
2792        Make/O/D/N=1 wTmpWrite
2793//      Make/O/R/N=1 wTmpWrite
2794        String groupName = "/entry/instrument/beam/superMirror"
2795        String varName = "efficiency"
2796        wTmpWrite[0] = val
2797
2798        variable err
2799        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2800        if(err)
2801                Print "HDF write err = ",err
2802        endif
2803        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2804//      err = V_KillNamedDataFolder(fname)
2805//      if(err)
2806//              Print "DataFolder kill err = ",err
2807//      endif
2808        return(err)
2809end
2810
2811Function V_writePolarizerState(fname,str)
2812        String fname,str
2813
2814//      String path = "entry:instrument:beam:superMirror:state"
2815
2816        Make/O/T/N=1 tmpTW
2817        String groupName = "/entry/instrument/beam/superMirror" //     
2818        String varName = "state"
2819        tmpTW[0] = str //
2820
2821        variable err
2822        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2823        if(err)
2824                Print "HDF write err = ",err
2825        endif
2826       
2827        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2828//      err = V_KillNamedDataFolder(fname)
2829//      if(err)
2830//              Print "DataFolder kill err = ",err
2831//      endif
2832               
2833        return(err)
2834End
2835
2836//Function V_writePolarizerType(fname,str)
2837//      String fname,str
2838//
2839////    String path = "entry:instrument:beam:polarizer:type"
2840//
2841//      Make/O/T/N=1 tmpTW
2842//      String groupName = "/entry/instrument/beam/polarizer"   //     
2843//      String varName = "type"
2844//      tmpTW[0] = str //
2845//
2846//      variable err
2847//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2848//      if(err)
2849//              Print "HDF write err = ",err
2850//      endif
2851//     
2852//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2853////    err = V_KillNamedDataFolder(fname)
2854////    if(err)
2855////            Print "DataFolder kill err = ",err
2856////    endif
2857//             
2858//      return(err)
2859//End
2860//
2861//// instrument/beam/polarizer_analyzer (data folder)
2862//// integer value
2863//Function V_writePolAnaCell_index(fname,val)
2864//      String fname
2865//      Variable val
2866//
2867////    String path = "entry:instrument:beam:polarizer_analyzer:cell_index"
2868//     
2869//      Make/O/I/N=1 wTmpWrite
2870////    Make/O/R/N=1 wTmpWrite
2871//      String groupName = "/entry/instrument/beam/polarizer_analyzer" 
2872//      String varName = "cell_index"
2873//      wTmpWrite[0] = val
2874//
2875//      variable err
2876//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2877//      if(err)
2878//              Print "HDF write err = ",err
2879//      endif
2880//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2881////    err = V_KillNamedDataFolder(fname)
2882////    if(err)
2883////            Print "DataFolder kill err = ",err
2884////    endif
2885//      return(err)
2886//End
2887//
2888//Function V_writePolAnaCell_name(fname,str)
2889//      String fname,str
2890//
2891////    String path = "entry:instrument:beam:polarizer_analyzer:cell_name"
2892//
2893//      Make/O/T/N=1 tmpTW
2894//      String groupName = "/entry/instrument/beam/polarizer_analyzer"  //     
2895//      String varName = "cell_name"
2896//      tmpTW[0] = str //
2897//
2898//      variable err
2899//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2900//      if(err)
2901//              Print "HDF write err = ",err
2902//      endif
2903//     
2904//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2905////    err = V_KillNamedDataFolder(fname)
2906////    if(err)
2907////            Print "DataFolder kill err = ",err
2908////    endif
2909//             
2910//      return(err)
2911//End
2912//
2913//Function V_writePolAnaCell_parameters(fname,inW)
2914//      String fname
2915//      Wave inW
2916//
2917////    String path = "entry:instrument:beam:polarizer_analyzer:cell_parameters"
2918//
2919//      Duplicate/O inW wTmpWrite       
2920//// then use redimension as needed to cast the wave to write to the specified type
2921//// see WaveType for the proper codes
2922////    Redimension/T=() wTmpWrite
2923//// -- May also need to check the dimension(s) before writing (don't trust the input)
2924//      String groupName = "/entry/instrument//beam/polarizer_analyzer"
2925//      String varName = "cell_parameters"
2926//
2927//      variable err
2928//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2929//      if(err)
2930//              Print "HDF write err = ",err
2931//      endif
2932//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2933////    err = V_KillNamedDataFolder(fname)
2934////    if(err)
2935////            Print "DataFolder kill err = ",err
2936////    endif
2937//      return(err)
2938//End
2939//
2940//Function V_writePolAnaGuideFieldCur_1(fname,val)
2941//      String fname
2942//      Variable val
2943//
2944////    String path = "entry:instrument:beam:polarizer_analyzer:guide_field_current_1"
2945//     
2946//      Make/O/D/N=1 wTmpWrite
2947////    Make/O/R/N=1 wTmpWrite
2948//      String groupName = "/entry/instrument/beam/polarizer_analyzer" 
2949//      String varName = "guide_field_current_1"
2950//      wTmpWrite[0] = val
2951//
2952//      variable err
2953//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2954//      if(err)
2955//              Print "HDF write err = ",err
2956//      endif
2957//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2958////    err = V_KillNamedDataFolder(fname)
2959////    if(err)
2960////            Print "DataFolder kill err = ",err
2961////    endif
2962//      return(err)
2963//End
2964//
2965//Function V_writePolAnaGuideFieldCur_2(fname,val)
2966//      String fname
2967//      Variable val
2968//
2969////    String path = "entry:instrument:beam:polarizer_analyzer:guide_field_current_2"
2970//     
2971//      Make/O/D/N=1 wTmpWrite
2972////    Make/O/R/N=1 wTmpWrite
2973//      String groupName = "/entry/instrument/beam/polarizer_analyzer" 
2974//      String varName = "guide_field_current_2"
2975//      wTmpWrite[0] = val
2976//
2977//      variable err
2978//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2979//      if(err)
2980//              Print "HDF write err = ",err
2981//      endif
2982//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2983////    err = V_KillNamedDataFolder(fname)
2984////    if(err)
2985////            Print "DataFolder kill err = ",err
2986////    endif
2987//      return(err)
2988//End
2989//
2990//Function V_writePolAnaSolenoid_current(fname,val)
2991//      String fname
2992//      Variable val
2993//
2994////    String path = "entry:instrument:beam:polarizer_analyzer:solenoid_current"
2995//     
2996//      Make/O/D/N=1 wTmpWrite
2997////    Make/O/R/N=1 wTmpWrite
2998//      String groupName = "/entry/instrument/beam/polarizer_analyzer" 
2999//      String varName = "solenoid_current"
3000//      wTmpWrite[0] = val
3001//
3002//      variable err
3003//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3004//      if(err)
3005//              Print "HDF write err = ",err
3006//      endif
3007//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3008////    err = V_KillNamedDataFolder(fname)
3009////    if(err)
3010////            Print "DataFolder kill err = ",err
3011////    endif
3012//      return(err)
3013//End
3014//
3015//Function V_writePolAnaStatus(fname,str)
3016//      String fname,str
3017//
3018////    String path = "entry:instrument:beam:polarizer_analyzer:status"
3019//
3020//      Make/O/T/N=1 tmpTW
3021//      String groupName = "/entry/instrument/beam/polarizer_analyzer"  //     
3022//      String varName = "status"
3023//      tmpTW[0] = str //
3024//
3025//      variable err
3026//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3027//      if(err)
3028//              Print "HDF write err = ",err
3029//      endif
3030//     
3031//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3032////    err = V_KillNamedDataFolder(fname)
3033////    if(err)
3034////            Print "DataFolder kill err = ",err
3035////    endif
3036//             
3037//      return(err)
3038//End
3039
3040
3041
3042
3043                                       
3044/////// INSTRUMENT/BEAM MONITORS
3045
3046//beam_monitor_low (data folder)
3047// integer value
3048Function V_writeBeamMonLowData(fname,val)
3049        String fname
3050        Variable val
3051
3052//      String path = "entry:instrument:beam_monitor_low:data"
3053       
3054        Make/O/I/N=1 wTmpWrite
3055//      Make/O/R/N=1 wTmpWrite
3056        String groupName = "/entry/instrument/beam_monitor_low"
3057        String varName = "data"
3058        wTmpWrite[0] = val
3059
3060        variable err
3061        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3062        if(err)
3063                Print "HDF write err = ",err
3064        endif
3065        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3066//      err = V_KillNamedDataFolder(fname)
3067//      if(err)
3068//              Print "DataFolder kill err = ",err
3069//      endif
3070        return(err)
3071End
3072
3073Function V_writeBeamMonLowDistance(fname,val)
3074        String fname
3075        Variable val
3076
3077//      String path = "entry:instrument:beam_monitor_low:distance"
3078       
3079        Make/O/D/N=1 wTmpWrite
3080//      Make/O/R/N=1 wTmpWrite
3081        String groupName = "/entry/instrument/beam_monitor_low"
3082        String varName = "distance"
3083        wTmpWrite[0] = val
3084
3085        variable err
3086        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3087        if(err)
3088                Print "HDF write err = ",err
3089        endif
3090        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3091//      err = V_KillNamedDataFolder(fname)
3092//      if(err)
3093//              Print "DataFolder kill err = ",err
3094//      endif
3095        return(err)
3096End
3097
3098Function V_writeBeamMonLowEfficiency(fname,val)
3099        String fname
3100        Variable val
3101
3102//      String path = "entry:instrument:beam_monitor_low:efficiency"
3103       
3104        Make/O/D/N=1 wTmpWrite
3105//      Make/O/R/N=1 wTmpWrite
3106        String groupName = "/entry/instrument/beam_monitor_low"
3107        String varName = "efficiency"
3108        wTmpWrite[0] = val
3109
3110        variable err
3111        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3112        if(err)
3113                Print "HDF write err = ",err
3114        endif
3115        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3116//      err = V_KillNamedDataFolder(fname)
3117//      if(err)
3118//              Print "DataFolder kill err = ",err
3119//      endif
3120        return(err)
3121End
3122
3123Function V_writeBeamMonLowSaved_count(fname,val)
3124        String fname
3125        Variable val
3126
3127//      String path = "entry:instrument:beam_monitor_low:saved_count"
3128       
3129        Make/O/D/N=1 wTmpWrite
3130//      Make/O/R/N=1 wTmpWrite
3131        String groupName = "/entry/instrument/beam_monitor_low"
3132        String varName = "saved_count"
3133        wTmpWrite[0] = val
3134
3135        variable err
3136        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3137        if(err)
3138                Print "HDF write err = ",err
3139        endif
3140        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3141//      err = V_KillNamedDataFolder(fname)
3142//      if(err)
3143//              Print "DataFolder kill err = ",err
3144//      endif
3145        return(err)
3146End
3147
3148Function V_writeBeamMonLowType(fname,str)
3149        String fname,str
3150
3151//      String path = "entry:instrument:beam_monitor_low:type"
3152
3153        Make/O/T/N=1 tmpTW
3154        String groupName = "/entry/instrument/beam_monitor_low" //     
3155        String varName = "type"
3156        tmpTW[0] = str //
3157
3158        variable err
3159        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3160        if(err)
3161                Print "HDF write err = ",err
3162        endif
3163       
3164        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3165//      err = V_KillNamedDataFolder(fname)
3166//      if(err)
3167//              Print "DataFolder kill err = ",err
3168//      endif
3169               
3170        return(err)
3171End
3172
3173//beam_monitor_norm (data folder)
3174// integer value
3175Function V_writeBeamMonNormData(fname,val)
3176        String fname
3177        Variable val
3178
3179//      String path = "entry:instrument:beam_monitor_norm:data"
3180       
3181        Make/O/I/N=1 wTmpWrite
3182//      Make/O/R/N=1 wTmpWrite
3183        String groupName = "/entry/instrument/beam_monitor_norm"       
3184        String varName = "data"
3185        wTmpWrite[0] = val
3186
3187        variable err
3188        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3189        if(err)
3190                Print "HDF write err = ",err
3191        endif
3192        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3193//      err = V_KillNamedDataFolder(fname)
3194//      if(err)
3195//              Print "DataFolder kill err = ",err
3196//      endif
3197        return(err)
3198End
3199
3200// fname is a local WORK folder
3201Function V_putBeamMonNormData(fname,val)
3202        String fname
3203        Variable val
3204
3205        String path = "root:Packages:NIST:VSANS:"+fname+":"
3206        path += "entry:instrument:beam_monitor_norm:data"
3207       
3208        Wave/Z w = $path
3209        if(waveExists(w) == 0)
3210                return(1)
3211        else
3212        w[0] = val
3213                return(0)
3214        endif
3215
3216End
3217
3218
3219Function V_writeBeamMonNormDistance(fname,val)
3220        String fname
3221        Variable val
3222
3223//      String path = "entry:instrument:beam_monitor_norm:distance"
3224       
3225        Make/O/D/N=1 wTmpWrite
3226//      Make/O/R/N=1 wTmpWrite
3227        String groupName = "/entry/instrument/beam_monitor_norm"       
3228        String varName = "distance"
3229        wTmpWrite[0] = val
3230
3231        variable err
3232        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3233        if(err)
3234                Print "HDF write err = ",err
3235        endif
3236        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3237//      err = V_KillNamedDataFolder(fname)
3238//      if(err)
3239//              Print "DataFolder kill err = ",err
3240//      endif
3241        return(err)
3242End
3243
3244Function V_writeBeamMonNormEfficiency(fname,val)
3245        String fname
3246        Variable val
3247
3248//      String path = "entry:instrument:beam_monitor_norm:efficiency"
3249       
3250        Make/O/D/N=1 wTmpWrite
3251//      Make/O/R/N=1 wTmpWrite
3252        String groupName = "/entry/instrument/beam_monitor_norm"       
3253        String varName = "efficiency"
3254        wTmpWrite[0] = val
3255
3256        variable err
3257        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3258        if(err)
3259                Print "HDF write err = ",err
3260        endif
3261        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3262//      err = V_KillNamedDataFolder(fname)
3263//      if(err)
3264//              Print "DataFolder kill err = ",err
3265//      endif
3266        return(err)
3267End
3268
3269
3270Function V_writeBeamMonNormSaved_count(fname,val)
3271        String fname
3272        Variable val
3273
3274//      String path = "entry:instrument:beam_monitor_norm:saved_count"
3275       
3276        Make/O/D/N=1 wTmpWrite
3277//      Make/O/R/N=1 wTmpWrite
3278        String groupName = "/entry/instrument/beam_monitor_norm"       
3279        String varName = "saved_count"
3280        wTmpWrite[0] = val
3281
3282        variable err
3283        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3284        if(err)
3285                Print "HDF write err = ",err
3286        endif
3287        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3288//      err = V_KillNamedDataFolder(fname)
3289//      if(err)
3290//              Print "DataFolder kill err = ",err
3291//      endif
3292        return(err)
3293End
3294
3295// fname is a local WORK folder
3296Function V_putBeamMonNormSaved_count(fname,val)
3297        String fname
3298        Variable val
3299
3300        String path = "root:Packages:NIST:VSANS:"+fname+":"
3301        path += "entry:instrument:beam_monitor_norm:saved_count"
3302       
3303        Wave/Z w = $path
3304        if(waveExists(w) == 0)
3305                return(1)
3306        else
3307        w[0] = val
3308                return(0)
3309        endif
3310
3311End
3312
3313
3314
3315Function V_writeBeamMonNormType(fname,str)
3316        String fname,str
3317
3318//      String path = "entry:instrument:beam_monitor_norm:type"
3319
3320        Make/O/T/N=1 tmpTW
3321        String groupName = "/entry/instrument/beam_monitor_norm"        //     
3322        String varName = "type"
3323        tmpTW[0] = str //
3324
3325        variable err
3326        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3327        if(err)
3328                Print "HDF write err = ",err
3329        endif
3330       
3331        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3332//      err = V_KillNamedDataFolder(fname)
3333//      if(err)
3334//              Print "DataFolder kill err = ",err
3335//      endif
3336               
3337        return(err)
3338End
3339
3340
3341//beam_stop C2 (data folder)
3342Function V_writeBeamStopC2Description(fname,str)
3343        String fname,str
3344
3345//      String path = "entry:instrument:beam_stop:description"
3346
3347        Make/O/T/N=1 tmpTW
3348        String groupName = "/entry/instrument/beam_stop_C2"     //     
3349        String varName = "description"
3350        tmpTW[0] = str //
3351
3352        variable err
3353        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3354        if(err)
3355                Print "HDF write err = ",err
3356        endif
3357       
3358        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3359//      err = V_KillNamedDataFolder(fname)
3360//      if(err)
3361//              Print "DataFolder kill err = ",err
3362//      endif
3363               
3364        return(err)
3365End
3366
3367Function V_writeBeamStopC2Dist_to_det(fname,val)
3368        String fname
3369        Variable val
3370
3371//      String path = "entry:instrument:beam_stop:distance_to_detector"
3372       
3373        Make/O/D/N=1 wTmpWrite
3374//      Make/O/R/N=1 wTmpWrite
3375        String groupName = "/entry/instrument/beam_stop_C2"     
3376        String varName = "distance_to_detector"
3377        wTmpWrite[0] = val
3378
3379        variable err
3380        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3381        if(err)
3382                Print "HDF write err = ",err
3383        endif
3384        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3385//      err = V_KillNamedDataFolder(fname)
3386//      if(err)
3387//              Print "DataFolder kill err = ",err
3388//      endif
3389        return(err)
3390End
3391
3392// is this the index of which size beam stop is in position?
3393// integer value
3394Function V_writeBeamStopC2num_stop(fname,val)
3395        String fname
3396        Variable val
3397
3398//      String path = "entry:instrument:beam_stop:distance_to_detector"
3399       
3400        Make/O/I/N=1 wTmpWrite
3401//      Make/O/R/N=1 wTmpWrite
3402        String groupName = "/entry/instrument/beam_stop_C2"     
3403        String varName = "num_beamstops"
3404        wTmpWrite[0] = val
3405
3406        variable err
3407        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3408        if(err)
3409                Print "HDF write err = ",err
3410        endif
3411        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3412//      err = V_KillNamedDataFolder(fname)
3413//      if(err)
3414//              Print "DataFolder kill err = ",err
3415//      endif
3416        return(err)
3417End
3418
3419Function V_writeBeamStopC2_x_pos(fname,val)
3420        String fname
3421        Variable val
3422
3423//      String path = "entry:instrument:beam_stop:x0"
3424       
3425        Make/O/D/N=1 wTmpWrite
3426//      Make/O/R/N=1 wTmpWrite
3427        String groupName = "/entry/instrument/beam_stop_C2"     
3428        String varName = "x_pos"
3429        wTmpWrite[0] = val
3430
3431        variable err
3432        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3433        if(err)
3434                Print "HDF write err = ",err
3435        endif
3436        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3437//      err = V_KillNamedDataFolder(fname)
3438//      if(err)
3439//              Print "DataFolder kill err = ",err
3440//      endif
3441        return(err)
3442End
3443
3444Function V_writeBeamStopC2_y_pos(fname,val)
3445        String fname
3446        Variable val
3447
3448//      String path = "entry:instrument:beam_stop:y0"
3449       
3450        Make/O/D/N=1 wTmpWrite
3451//      Make/O/R/N=1 wTmpWrite
3452        String groupName = "/entry/instrument/beam_stop_C2"     
3453        String varName = "y_pos"
3454        wTmpWrite[0] = val
3455
3456        variable err
3457        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3458        if(err)
3459                Print "HDF write err = ",err
3460        endif
3461        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3462//      err = V_KillNamedDataFolder(fname)
3463//      if(err)
3464//              Print "DataFolder kill err = ",err
3465//      endif
3466        return(err)
3467End
3468
3469
3470// beam stop C2 (shape)
3471Function V_writeBeamStopC2_height(fname,val)
3472        String fname
3473        Variable val
3474
3475//      String path = "entry:instrument:beam_stop:y0"
3476       
3477        Make/O/D/N=1 wTmpWrite
3478//      Make/O/R/N=1 wTmpWrite
3479        String groupName = "/entry/instrument/beam_stop_C2/shape"       
3480        String varName = "height"
3481        wTmpWrite[0] = val
3482
3483        variable err
3484        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3485        if(err)
3486                Print "HDF write err = ",err
3487        endif
3488        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3489//      err = V_KillNamedDataFolder(fname)
3490//      if(err)
3491//              Print "DataFolder kill err = ",err
3492//      endif
3493        return(err)
3494End
3495
3496Function V_writeBeamStopC2_shape(fname,str)
3497        String fname,str
3498
3499//      String path = "entry:instrument:beam_stop:description"
3500
3501        Make/O/T/N=1 tmpTW
3502        String groupName = "/entry/instrument/beam_stop_C2/shape"       //     
3503        String varName = "shape"
3504        tmpTW[0] = str //
3505
3506        variable err
3507        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3508        if(err)
3509                Print "HDF write err = ",err
3510        endif
3511       
3512        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3513//      err = V_KillNamedDataFolder(fname)
3514//      if(err)
3515//              Print "DataFolder kill err = ",err
3516//      endif
3517               
3518        return(err)
3519End
3520
3521// this is diameter if shape=CIRCLE
3522Function V_writeBeamStopC2_size(fname,val)
3523        String fname
3524        Variable val
3525
3526//      String path = "entry:instrument:beam_stop:y0"
3527       
3528        Make/O/D/N=1 wTmpWrite
3529//      Make/O/R/N=1 wTmpWrite
3530        String groupName = "/entry/instrument/beam_stop_C2/shape"       
3531        String varName = "size"
3532        wTmpWrite[0] = val
3533
3534        variable err
3535        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3536        if(err)
3537                Print "HDF write err = ",err
3538        endif
3539        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3540//      err = V_KillNamedDataFolder(fname)
3541//      if(err)
3542//              Print "DataFolder kill err = ",err
3543//      endif
3544        return(err)
3545End
3546
3547Function V_writeBeamStopC2_width(fname,val)
3548        String fname
3549        Variable val
3550
3551//      String path = "entry:instrument:beam_stop:y0"
3552       
3553        Make/O/D/N=1 wTmpWrite
3554//      Make/O/R/N=1 wTmpWrite
3555        String groupName = "/entry/instrument/beam_stop_C2/shape"       
3556        String varName = "width"
3557        wTmpWrite[0] = val
3558
3559        variable err
3560        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3561        if(err)
3562                Print "HDF write err = ",err
3563        endif
3564        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3565//      err = V_KillNamedDataFolder(fname)
3566//      if(err)
3567//              Print "DataFolder kill err = ",err
3568//      endif
3569        return(err)
3570End
3571
3572// beam stop C3 (data folder)
3573Function V_writeBeamStopC3Description(fname,str)
3574        String fname,str
3575
3576//      String path = "entry:instrument:beam_stop:description"
3577
3578        Make/O/T/N=1 tmpTW
3579        String groupName = "/entry/instrument/beam_stop_C3"     //     
3580        String varName = "description"
3581        tmpTW[0] = str //
3582
3583        variable err
3584        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3585        if(err)
3586                Print "HDF write err = ",err
3587        endif
3588       
3589        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3590//      err = V_KillNamedDataFolder(fname)
3591//      if(err)
3592//              Print "DataFolder kill err = ",err
3593//      endif
3594               
3595        return(err)
3596End
3597
3598Function V_writeBeamStopC3Dist_to_det(fname,val)
3599        String fname
3600        Variable val
3601
3602//      String path = "entry:instrument:beam_stop:distance_to_detector"
3603       
3604        Make/O/D/N=1 wTmpWrite
3605//      Make/O/R/N=1 wTmpWrite
3606        String groupName = "/entry/instrument/beam_stop_C3"     
3607        String varName = "distance_to_detector"
3608        wTmpWrite[0] = val
3609
3610        variable err
3611        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3612        if(err)
3613                Print "HDF write err = ",err
3614        endif
3615        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3616//      err = V_KillNamedDataFolder(fname)
3617//      if(err)
3618//              Print "DataFolder kill err = ",err
3619//      endif
3620        return(err)
3621End
3622
3623// integer value
3624Function V_writeBeamStopC3num_stop(fname,val)
3625        String fname
3626        Variable val
3627
3628//      String path = "entry:instrument:beam_stop:distance_to_detector"
3629       
3630        Make/O/I/N=1 wTmpWrite
3631//      Make/O/R/N=1 wTmpWrite
3632        String groupName = "/entry/instrument/beam_stop_C3"     
3633        String varName = "num_beamstops"
3634        wTmpWrite[0] = val
3635
3636        variable err
3637        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3638        if(err)
3639                Print "HDF write err = ",err
3640        endif
3641        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3642//      err = V_KillNamedDataFolder(fname)
3643//      if(err)
3644//              Print "DataFolder kill err = ",err
3645//      endif
3646        return(err)
3647End
3648
3649Function V_writeBeamStopC3_x_pos(fname,val)
3650        String fname
3651        Variable val
3652
3653//      String path = "entry:instrument:beam_stop:x0"
3654       
3655        Make/O/D/N=1 wTmpWrite
3656//      Make/O/R/N=1 wTmpWrite
3657        String groupName = "/entry/instrument/beam_stop_C3"     
3658        String varName = "x_pos"
3659        wTmpWrite[0] = val
3660
3661        variable err
3662        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3663        if(err)
3664                Print "HDF write err = ",err
3665        endif
3666        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3667//      err = V_KillNamedDataFolder(fname)
3668//      if(err)
3669//              Print "DataFolder kill err = ",err
3670//      endif
3671        return(err)
3672End
3673
3674Function V_writeBeamStopC3_y_pos(fname,val)
3675        String fname
3676        Variable val
3677
3678//      String path = "entry:instrument:beam_stop:y0"
3679       
3680        Make/O/D/N=1 wTmpWrite
3681//      Make/O/R/N=1 wTmpWrite
3682        String groupName = "/entry/instrument/beam_stop_C3"     
3683        String varName = "y_pos"
3684        wTmpWrite[0] = val
3685
3686        variable err
3687        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3688        if(err)
3689                Print "HDF write err = ",err
3690        endif
3691        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3692//      err = V_KillNamedDataFolder(fname)
3693//      if(err)
3694//              Print "DataFolder kill err = ",err
3695//      endif
3696        return(err)
3697End
3698
3699
3700// beam stop C3 (shape)
3701Function V_writeBeamStopC3_height(fname,val)
3702        String fname
3703        Variable val
3704
3705//      String path = "entry:instrument:beam_stop:y0"
3706       
3707        Make/O/D/N=1 wTmpWrite
3708//      Make/O/R/N=1 wTmpWrite
3709        String groupName = "/entry/instrument/beam_stop_C3/shape"       
3710        String varName = "height"
3711        wTmpWrite[0] = val
3712
3713        variable err
3714        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3715        if(err)
3716                Print "HDF write err = ",err
3717        endif
3718        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3719//      err = V_KillNamedDataFolder(fname)
3720//      if(err)
3721//              Print "DataFolder kill err = ",err
3722//      endif
3723        return(err)
3724End
3725
3726Function V_writeBeamStopC3_shape(fname,str)
3727        String fname,str
3728
3729//      String path = "entry:instrument:beam_stop:description"
3730
3731        Make/O/T/N=1 tmpTW
3732        String groupName = "/entry/instrument/beam_stop_C3/shape"       //     
3733        String varName = "shape"
3734        tmpTW[0] = str //
3735
3736        variable err
3737        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3738        if(err)
3739                Print "HDF write err = ",err
3740        endif
3741       
3742        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3743//      err = V_KillNamedDataFolder(fname)
3744//      if(err)
3745//              Print "DataFolder kill err = ",err
3746//      endif
3747               
3748        return(err)
3749End
3750
3751// this is diameter if shape=CIRCLE
3752Function V_writeBeamStopC3_size(fname,val)
3753        String fname
3754        Variable val
3755
3756//      String path = "entry:instrument:beam_stop:y0"
3757       
3758        Make/O/D/N=1 wTmpWrite
3759//      Make/O/R/N=1 wTmpWrite
3760        String groupName = "/entry/instrument/beam_stop_C3/shape"       
3761        String varName = "size"
3762        wTmpWrite[0] = val
3763
3764        variable err
3765        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3766        if(err)
3767                Print "HDF write err = ",err
3768        endif
3769        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3770//      err = V_KillNamedDataFolder(fname)
3771//      if(err)
3772//              Print "DataFolder kill err = ",err
3773//      endif
3774        return(err)
3775End
3776
3777Function V_writeBeamStopC3_width(fname,val)
3778        String fname
3779        Variable val
3780
3781//      String path = "entry:instrument:beam_stop:y0"
3782       
3783        Make/O/D/N=1 wTmpWrite
3784//      Make/O/R/N=1 wTmpWrite
3785        String groupName = "/entry/instrument/beam_stop_C3/shape"       
3786        String varName = "width"
3787        wTmpWrite[0] = val
3788
3789        variable err
3790        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3791        if(err)
3792                Print "HDF write err = ",err
3793        endif
3794        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3795//      err = V_KillNamedDataFolder(fname)
3796//      if(err)
3797//              Print "DataFolder kill err = ",err
3798//      endif
3799        return(err)
3800End
3801
3802
3803
3804//// INSTRUMENT/COLLIMATOR
3805//collimator (data folder) -- this is a TEXT field
3806Function V_writeNumberOfGuides(fname,str)
3807        String fname,str
3808
3809//      String path = "entry:instrument:collimator:number_guides"
3810
3811        Make/O/T/N=1 tmpTW
3812        String groupName = "/entry/instrument/collimator"       
3813        String varName = "number_guides"
3814        tmpTW[0] = str //
3815
3816        variable err
3817        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3818        if(err)
3819                Print "HDF write err = ",err
3820        endif
3821       
3822        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3823//      err = V_KillNamedDataFolder(fname)
3824//      if(err)
3825//              Print "DataFolder kill err = ",err
3826//      endif
3827               
3828        return(err)
3829End
3830
3831
3832//                              geometry (data folder)
3833//                                      shape (data folder)
3834Function V_writeGuideShape(fname,str)
3835        String fname,str
3836
3837//      String path = "entry:instrument:collimator:geometry:shape:shape"
3838
3839        Make/O/T/N=1 tmpTW
3840        String groupName = "/entry/instrument/collimator/geometry/shape"        //     
3841        String varName = "shape"
3842        tmpTW[0] = str //
3843
3844        variable err
3845        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3846        if(err)
3847                Print "HDF write err = ",err
3848        endif
3849       
3850        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3851//      err = V_KillNamedDataFolder(fname)
3852//      if(err)
3853//              Print "DataFolder kill err = ",err
3854//      endif
3855               
3856        return(err)
3857End
3858
3859// TODO -- this may need to be a wave to properly describe the dimensions
3860Function V_writeGuideSize(fname,val)
3861        String fname
3862        Variable val
3863
3864//      String path = "entry:instrument:collimator:geometry:shape:size"
3865       
3866        Make/O/D/N=1 wTmpWrite
3867//      Make/O/R/N=1 wTmpWrite
3868        String groupName = "/entry/instrument/collimator/geometry/shape"       
3869        String varName = "size"
3870        wTmpWrite[0] = val
3871
3872        variable err
3873        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3874        if(err)
3875                Print "HDF write err = ",err
3876        endif
3877        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3878//      err = V_KillNamedDataFolder(fname)
3879//      if(err)
3880//              Print "DataFolder kill err = ",err
3881//      endif
3882        return(err)
3883End
3884
3885//                      converging_pinholes (data folder)
3886Function V_writeConvPinholeStatus(fname,str)
3887        String fname,str
3888
3889//      String path = "entry:instrument:converging_pinholes:status"
3890
3891        Make/O/T/N=1 tmpTW
3892        String groupName = "/entry/instrument/converging_pinholes"      //     
3893        String varName = "status"
3894        tmpTW[0] = str //
3895
3896        variable err
3897        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3898        if(err)
3899                Print "HDF write err = ",err
3900        endif
3901       
3902        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3903//      err = V_KillNamedDataFolder(fname)
3904//      if(err)
3905//              Print "DataFolder kill err = ",err
3906//      endif
3907               
3908        return(err)
3909End
3910
3911//                      converging_slits (not used)
3912
3913
3914
3915
3916
3917
3918////// INSTRUMENT/DETECTORS
3919//                      detector_B (data folder)
3920//
3921// only defined for the "B" detector, and may not be necessary?
3922// TODO -- write to return an ARRAY
3923Function V_writeDet_cal_x(fname,detStr,inW)
3924        String fname,detStr
3925        Wave inW
3926
3927        if(cmpstr(detStr,"B") == 0)
3928//              String path = "entry:instrument:detector_"+detStr+":CALX"
3929               
3930                Duplicate/O inW wTmpWrite       
3931        // then use redimension as needed to cast the wave to write to the specified type
3932        // see WaveType for the proper codes
3933        //      Redimension/T=() wTmpWrite
3934        // -- May also need to check the dimension(s) before writing (don't trust the input)
3935                String groupName = "/entry/instrument/detector_"+detStr
3936                String varName = "cal_x"
3937
3938                variable err
3939                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3940                if(err)
3941                        Print "HDF write err = ",err
3942                endif
3943                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3944//              err = V_KillNamedDataFolder(fname)
3945//              if(err)
3946//                      Print "DataFolder kill err = ",err
3947//              endif
3948                return(err)
3949        else
3950                return(0)
3951        endif
3952End
3953
3954// only defined for the "B" detector, and may not be necessary?
3955// TODO -- write to return an ARRAY
3956Function V_writeDet_cal_y(fname,detStr,inW)
3957        String fname,detStr
3958        Wave inW
3959
3960        if(cmpstr(detStr,"B") == 0)
3961//              String path = "entry:instrument:detector_"+detStr+":CALY"
3962
3963                Duplicate/O inW wTmpWrite       
3964        // then use redimension as needed to cast the wave to write to the specified type
3965        // see WaveType for the proper codes
3966        //      Redimension/T=() wTmpWrite
3967        // -- May also need to check the dimension(s) before writing (don't trust the input)
3968                String groupName = "/entry/instrument/detector_"+detStr
3969                String varName = "cal_y"
3970
3971                variable err
3972                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3973                if(err)
3974                        Print "HDF write err = ",err
3975                endif
3976                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3977//              err = V_KillNamedDataFolder(fname)
3978//              if(err)
3979//                      Print "DataFolder kill err = ",err
3980//              endif
3981                return(err)
3982        else
3983                return(0)
3984        endif
3985End
3986
3987// TODO -- write and X and Y version of this. Pixels are not square
3988// so the FHWM will be different in each direction. May need to return
3989// "dummy" value for "B" detector if pixels there are square
3990Function V_writeDet_pixel_fwhm_x(fname,detStr,val)
3991        String fname,detStr
3992        Variable val
3993
3994//      String path = "entry:instrument:detector_"+detStr+":pixel_fwhm_x"
3995       
3996        Make/O/D/N=1 wTmpWrite
3997//      Make/O/R/N=1 wTmpWrite
3998        String groupName = "/entry/instrument/detector_"+detStr
3999        String varName = "pixel_fwhm_x"
4000        wTmpWrite[0] = val
4001
4002        variable err
4003        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4004        if(err)
4005                Print "HDF write err = ",err
4006        endif
4007        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4008//      err = V_KillNamedDataFolder(fname)
4009//      if(err)
4010//              Print "DataFolder kill err = ",err
4011//      endif
4012        return(err)
4013End
4014
4015
4016// TODO -- write and X and Y version of this. Pixels are not square
4017// so the FHWM will be different in each direction. May need to return
4018// "dummy" value for "B" detector if pixels there are square
4019Function V_writeDet_pixel_fwhm_y(fname,detStr,val)
4020        String fname,detStr
4021        Variable val
4022
4023//      String path = "entry:instrument:detector_"+detStr+":pixel_fwhm_y"
4024       
4025        Make/O/D/N=1 wTmpWrite
4026//      Make/O/R/N=1 wTmpWrite
4027        String groupName = "/entry/instrument/detector_"+detStr
4028        String varName = "pixel_fwhm_y"
4029        wTmpWrite[0] = val
4030
4031        variable err
4032        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4033        if(err)
4034                Print "HDF write err = ",err
4035        endif
4036        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4037//      err = V_KillNamedDataFolder(fname)
4038//      if(err)
4039//              Print "DataFolder kill err = ",err
4040//      endif
4041        return(err)
4042End
4043
4044// integer value
4045Function V_writeDet_pixel_num_x(fname,detStr,val)
4046        String fname,detStr
4047        Variable val
4048
4049//      String path = "entry:instrument:detector_"+detStr+":pixel_nnum_x"
4050       
4051        Make/O/I/N=1 wTmpWrite
4052//      Make/O/R/N=1 wTmpWrite
4053        String groupName = "/entry/instrument/detector_"+detStr
4054        String varName = "pixel_num_x"
4055        wTmpWrite[0] = val
4056
4057        variable err
4058        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4059        if(err)
4060                Print "HDF write err = ",err
4061        endif
4062        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4063//      err = V_KillNamedDataFolder(fname)
4064//      if(err)
4065//              Print "DataFolder kill err = ",err
4066//      endif
4067        return(err)
4068End
4069
4070// integer value
4071Function V_writeDet_pixel_num_y(fname,detStr,val)
4072        String fname,detStr
4073        Variable val
4074
4075//      String path = "entry:instrument:detector_"+detStr+":pixel_num_y"
4076       
4077        Make/O/I/N=1 wTmpWrite
4078//      Make/O/R/N=1 wTmpWrite
4079        String groupName = "/entry/instrument/detector_"+detStr
4080        String varName = "pixel_num_y"
4081        wTmpWrite[0] = val
4082
4083        variable err
4084        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4085        if(err)
4086                Print "HDF write err = ",err
4087        endif
4088        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4089//      err = V_KillNamedDataFolder(fname)
4090//      if(err)
4091//              Print "DataFolder kill err = ",err
4092//      endif
4093        return(err)
4094End
4095
4096//// only defined for the "B" detector, and only to satisfy NXsas
4097//Function V_writeDet_azimuthalAngle(fname,detStr,val)
4098//      String fname,detStr
4099//      Variable val
4100//
4101//      if(cmpstr(detStr,"B") == 0)
4102////            String path = "entry:instrument:detector_"+detStr+":azimuthal_angle"
4103//     
4104//              Make/O/D/N=1 wTmpWrite
4105//      //      Make/O/R/N=1 wTmpWrite
4106//              String groupName = "/entry/instrument/detector_"+detStr
4107//              String varName = "azimuthal_angle"
4108//              wTmpWrite[0] = val
4109//
4110//              variable err
4111//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4112//              if(err)
4113//                      Print "HDF write err = ",err
4114//              endif
4115//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4116////            err = V_KillNamedDataFolder(fname)
4117////            if(err)
4118////                    Print "DataFolder kill err = ",err
4119////            endif
4120//              return(err)
4121//      else
4122//              return(0)
4123//      endif
4124//End
4125
4126Function V_writeDet_beam_center_x(fname,detStr,val)
4127        String fname,detStr
4128        Variable val
4129
4130//      String path = "entry:instrument:detector_"+detStr+":beam_center_x"
4131       
4132        Make/O/D/N=1 wTmpWrite
4133//      Make/O/R/N=1 wTmpWrite
4134        String groupName = "/entry/instrument/detector_"+detStr
4135        String varName = "beam_center_x"
4136        wTmpWrite[0] = val
4137
4138        variable err
4139        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4140        if(err)
4141                Print "HDF write err = ",err
4142        endif
4143        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4144//      err = V_KillNamedDataFolder(fname)
4145//      if(err)
4146//              Print "DataFolder kill err = ",err
4147//      endif
4148        return(err)
4149End
4150
4151// fname is a local WORK folder
4152Function V_putDet_beam_center_x(fname,detStr,val)
4153        String fname,detStr
4154        Variable val
4155
4156//root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:beam_center_x
4157        String path = "root:Packages:NIST:VSANS:"+fname+":"
4158        path += "entry:instrument:detector_"+detStr+":beam_center_x"
4159       
4160        Wave/Z w = $path
4161        if(waveExists(w) == 0)
4162                return(1)
4163        else
4164        w[0] = val
4165                return(0)
4166        endif
4167
4168End
4169
4170// fname is a local WORK folder
4171Function V_putDet_beam_center_x_pix(fname,detStr,val)
4172        String fname,detStr
4173        Variable val
4174
4175//root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:beam_center_x_pix
4176        String path = "root:Packages:NIST:VSANS:"+fname+":"
4177        path += "entry:instrument:detector_"+detStr+":beam_center_x_pix"
4178       
4179        Wave/Z w = $path
4180        if(waveExists(w) == 0)
4181                return(1)
4182        else
4183        w[0] = val
4184                return(0)
4185        endif
4186
4187End
4188
4189Function V_writeDet_beam_center_y(fname,detStr,val)
4190        String fname,detStr
4191        Variable val
4192
4193//      String path = "entry:instrument:detector_"+detStr+":beam_center_y"
4194       
4195        Make/O/D/N=1 wTmpWrite
4196//      Make/O/R/N=1 wTmpWrite
4197        String groupName = "/entry/instrument/detector_"+detStr
4198        String varName = "beam_center_y"
4199        wTmpWrite[0] = val
4200
4201        variable err
4202        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4203        if(err)
4204                Print "HDF write err = ",err
4205        endif
4206        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4207//      err = V_KillNamedDataFolder(fname)
4208//      if(err)
4209//              Print "DataFolder kill err = ",err
4210//      endif
4211        return(err)
4212End
4213
4214
4215// fname is a local WORK folder
4216Function V_putDet_beam_center_y(fname,detStr,val)
4217        String fname,detStr
4218        Variable val
4219
4220//root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:beam_center_y
4221        String path = "root:Packages:NIST:VSANS:"+fname+":"
4222        path += "entry:instrument:detector_"+detStr+":beam_center_y"
4223       
4224        Wave/Z w = $path
4225        if(waveExists(w) == 0)
4226                return(1)
4227        else
4228        w[0] = val
4229                return(0)
4230        endif
4231
4232End
4233
4234// fname is a local WORK folder
4235Function V_putDet_beam_center_y_pix(fname,detStr,val)
4236        String fname,detStr
4237        Variable val
4238
4239//root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:beam_center_y_pix
4240        String path = "root:Packages:NIST:VSANS:"+fname+":"
4241        path += "entry:instrument:detector_"+detStr+":beam_center_y_pix"
4242       
4243        Wave/Z w = $path
4244        if(waveExists(w) == 0)
4245                return(1)
4246        else
4247        w[0] = val
4248                return(0)
4249        endif
4250
4251End
4252
4253// TODO -- write this function to return a WAVE with the data
4254// either as a wave reference, or as an input parameter
4255Function V_writeDetectorData(fname,detStr,inW)
4256        String fname,detStr
4257        Wave inW
4258
4259//      String path = "entry:instrument:detector_"+detStr+":data"
4260       
4261        Duplicate/O inW wTmpWrite       
4262// then use redimension as needed to cast the wave to write to the specified type
4263// see WaveType for the proper codes
4264//      Redimension/T=() wTmpWrite
4265// -- May also need to check the dimension(s) before writing (don't trust the input)
4266        String groupName = "/entry/instrument/detector_"+detStr
4267        String varName = "data"
4268
4269        variable err
4270        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4271        if(err)
4272                Print "HDF write err = ",err
4273        endif
4274        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4275//      err = V_KillNamedDataFolder(fname)
4276//      if(err)
4277//              Print "DataFolder kill err = ",err
4278//      endif
4279        return(err)
4280End
4281
4282
4283
4284/////////////////////////
4285
4286
4287// TODO -- write this function to return a WAVE with the data
4288// either as a wave reference, or as an input parameter
4289// ALSO -- the "B" deadtime will be a single value (probably)
4290//  but the tube banks will be 1D arrays of values, one per tube
4291Function V_writeDetector_deadtime(fname,detStr,inW)
4292        String fname,detStr
4293        Wave inW
4294
4295//      String path = "entry:instrument:detector_"+detStr+":dead_time"
4296        if(cmpstr(detStr,"B") == 0)
4297                DoAlert 0,"Bad call to V_writeDetector_deadtime"
4298                return(0)
4299        else
4300
4301                Duplicate/O inW wTmpWrite       
4302        // then use redimension as needed to cast the wave to write to the specified type
4303        // see WaveType for the proper codes
4304        //      Redimension/T=() wTmpWrite
4305        // -- May also need to check the dimension(s) before writing (don't trust the input)
4306                String groupName = "/entry/instrument/detector_"+detStr
4307                String varName = "dead_time"
4308       
4309                variable err
4310                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4311                if(err)
4312                        Print "HDF write err = ",err
4313                endif
4314                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4315        //      err = V_KillNamedDataFolder(fname)
4316        //      if(err)
4317        //              Print "DataFolder kill err = ",err
4318        //      endif
4319                return(err)
4320        endif
4321End
4322
4323// dead time, a single value, only for detB
4324Function V_writeDetector_deadtime_B(fname,detStr,val)
4325        String fname,detStr
4326        variable val
4327
4328//      String path = "entry:instrument:detector_"+detStr+":dead_time"
4329        if(cmpstr(detStr,"B") == 0)
4330       
4331                Make/O/D/N=1 wTmpWrite
4332        //      Make/O/R/N=1 wTmpWrite
4333                String groupName = "/entry/instrument/detector_"+detStr
4334                String varName = "dead_time"
4335                wTmpWrite[0] = val
4336       
4337                variable err
4338                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4339                if(err)
4340                        Print "HDF write err = ",err
4341                endif
4342                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4343        //      err = V_KillNamedDataFolder(fname)
4344        //      if(err)
4345        //              Print "DataFolder kill err = ",err
4346        //      endif
4347       
4348                return(err)     
4349        else
4350                DoAlert 0,"Bad call to V_writeDetector_deadtime_B"
4351                return(0)
4352        endif
4353End
4354
4355// high res detector gain, a single value, only for detB
4356Function V_writeDetector_highResGain(fname,detStr,val)
4357        String fname,detStr
4358        variable val
4359
4360//      String path = "entry:instrument:detector_"+detStr+":highResGain"
4361        if(cmpstr(detStr,"B") == 0)
4362       
4363                Make/O/D/N=1 wTmpWrite
4364        //      Make/O/R/N=1 wTmpWrite
4365                String groupName = "/entry/instrument/detector_"+detStr
4366                String varName = "highResGain"
4367                wTmpWrite[0] = val
4368       
4369                variable err
4370                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4371                if(err)
4372                        Print "HDF write err = ",err
4373                endif
4374                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4375        //      err = V_KillNamedDataFolder(fname)
4376        //      if(err)
4377        //              Print "DataFolder kill err = ",err
4378        //      endif
4379       
4380                return(err)     
4381        else
4382                DoAlert 0,"Bad call to V_writeDetector_highResGain"
4383                return(0)
4384        endif
4385End
4386
4387
4388Function V_writeDetDescription(fname,detStr,str)
4389        String fname,detStr,str
4390
4391//      String path = "entry:instrument:detector_"+detStr+":description"
4392
4393        Make/O/T/N=1 tmpTW
4394        String groupName = "/entry/instrument/detector_"+detStr //     
4395        String varName = "description"
4396        tmpTW[0] = str //
4397
4398        variable err
4399        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4400        if(err)
4401                Print "HDF write err = ",err
4402        endif
4403       
4404        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4405//      err = V_KillNamedDataFolder(fname)
4406//      if(err)
4407//              Print "DataFolder kill err = ",err
4408//      endif
4409               
4410        return(err)
4411End
4412
4413Function V_writeDet_distance(fname,detStr,val)
4414        String fname,detStr
4415        variable val
4416
4417//      String path = "entry:instrument:detector_"+detStr+":distance"
4418       
4419        Make/O/D/N=1 wTmpWrite
4420//      Make/O/R/N=1 wTmpWrite
4421        String groupName = "/entry/instrument/detector_"+detStr
4422        String varName = "distance"
4423        wTmpWrite[0] = val
4424
4425        variable err
4426        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4427        if(err)
4428                Print "HDF write err = ",err
4429        endif
4430        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4431//      err = V_KillNamedDataFolder(fname)
4432//      if(err)
4433//              Print "DataFolder kill err = ",err
4434//      endif
4435        return(err)
4436End
4437
4438//// only defined for the "B" detector, and only to satisfy NXsas
4439//Function V_writeDet_equatorial_angle(fname,detStr,val)
4440//      String fname,detStr
4441//      variable val
4442//
4443//      if(cmpstr(detStr,"B") == 0)
4444////            String path = "entry:instrument:detector_"+detStr+":equatorial_angle"
4445//     
4446//              Make/O/D/N=1 wTmpWrite
4447//      //      Make/O/R/N=1 wTmpWrite
4448//              String groupName = "/entry/instrument/detector_"+detStr
4449//              String varName = "equatorial_angle"
4450//              wTmpWrite[0] = val
4451//
4452//              variable err
4453//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4454//              if(err)
4455//                      Print "HDF write err = ",err
4456//              endif
4457//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4458////            err = V_KillNamedDataFolder(fname)
4459////            if(err)
4460////                    Print "DataFolder kill err = ",err
4461////            endif
4462//              return(err)
4463//      else
4464//              return(0)
4465//      endif
4466//End
4467
4468Function V_writeDetEventFileName(fname,detStr,str)
4469        String fname,detStr,str
4470
4471//      String path = "entry:instrument:detector_"+detStr+":event_file_name"
4472
4473        Make/O/T/N=1 tmpTW
4474        String groupName = "/entry/instrument/detector_"+detStr //     
4475        String varName = "event_file_name"
4476        tmpTW[0] = str //
4477
4478        variable err
4479        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4480        if(err)
4481                Print "HDF write err = ",err
4482        endif
4483       
4484        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4485//      err = V_KillNamedDataFolder(fname)
4486//      if(err)
4487//              Print "DataFolder kill err = ",err
4488//      endif
4489               
4490        return(err)
4491End
4492
4493Function V_writeDet_IntegratedCount(fname,detStr,val)
4494        String fname,detStr
4495        Variable val
4496
4497//      String path = "entry:instrument:detector_"+detStr+":integrated_count"
4498       
4499        Make/O/D/N=1 wTmpWrite
4500//      Make/O/R/N=1 wTmpWrite
4501        String groupName = "/entry/instrument/detector_"+detStr
4502        String varName = "integrated_count"
4503        wTmpWrite[0] = val
4504
4505        variable err
4506        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4507        if(err)
4508                Print "HDF write err = ",err
4509        endif
4510        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4511//      err = V_KillNamedDataFolder(fname)
4512//      if(err)
4513//              Print "DataFolder kill err = ",err
4514//      endif
4515        return(err)
4516End
4517
4518// fname is a local WORK folder
4519Function V_putDet_IntegratedCount(fname,detStr,val)
4520        String fname,detStr
4521        Variable val
4522
4523//root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:beam_center_x
4524        String path = "root:Packages:NIST:VSANS:"+fname+":"
4525        path += "entry:instrument:detector_"+detStr+":integrated_count"
4526       
4527        Wave/Z w = $path
4528        if(waveExists(w) == 0)
4529                return(1)
4530        else
4531        w[0] = val
4532                return(0)
4533        endif
4534
4535End
4536
4537// this is only written for B and L/R detectors
4538Function V_writeDet_LateralOffset(fname,detStr,val)
4539        String fname,detStr
4540        Variable val
4541
4542//      String path = "entry:instrument:detector_"+detStr+":lateral_offset"
4543
4544        if(cmpstr(detStr,"FT") == 0 || cmpstr(detStr,"FB") == 0)
4545                return(0)
4546        endif
4547        if(cmpstr(detStr,"MT") == 0 || cmpstr(detStr,"MB") == 0)
4548                return(0)
4549        endif   
4550               
4551        Make/O/D/N=1 wTmpWrite
4552//      Make/O/R/N=1 wTmpWrite
4553        String groupName = "/entry/instrument/detector_"+detStr
4554        String varName = "lateral_offset"
4555        wTmpWrite[0] = val
4556
4557        variable err
4558        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4559        if(err)
4560                Print "HDF write err = ",err
4561        endif
4562        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4563//      err = V_KillNamedDataFolder(fname)
4564//      if(err)
4565//              Print "DataFolder kill err = ",err
4566//      endif
4567        return(err)
4568End
4569
4570
4571// this is only written for T/B detectors
4572Function V_writeDet_VerticalOffset(fname,detStr,val)
4573        String fname,detStr
4574        Variable val
4575
4576//      String path = "entry:instrument:detector_"+detStr+":vertical_offset"
4577
4578        if(cmpstr(detStr,"B") == 0)
4579                return(0)
4580        endif
4581        if(cmpstr(detStr,"FR") == 0 || cmpstr(detStr,"FL") == 0)
4582                return(0)
4583        endif
4584        if(cmpstr(detStr,"MR") == 0 || cmpstr(detStr,"ML") == 0)
4585                return(0)
4586        endif   
4587               
4588        Make/O/D/N=1 wTmpWrite
4589//      Make/O/R/N=1 wTmpWrite
4590        String groupName = "/entry/instrument/detector_"+detStr
4591        String varName = "vertical_offset"
4592        wTmpWrite[0] = val
4593
4594        variable err
4595        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4596        if(err)
4597                Print "HDF write err = ",err
4598        endif
4599        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4600//      err = V_KillNamedDataFolder(fname)
4601//      if(err)
4602//              Print "DataFolder kill err = ",err
4603//      endif
4604        return(err)
4605End
4606
4607
4608// TODO - be sure that this is defined correctly
4609// -- it needs to exist in the data file, and only for TB detector panels
4610Function V_writeDet_TBSetback(fname,detStr,val)
4611        String fname,detStr
4612        Variable val
4613
4614//      String path = "entry:instrument:detector_"+detStr+":setback"
4615       
4616        if(cmpstr(detStr,"B") == 0)
4617                return(0)
4618        endif
4619        if(cmpstr(detStr,"FR") == 0 || cmpstr(detStr,"FL") == 0)
4620                return(0)
4621        endif
4622        if(cmpstr(detStr,"MR") == 0 || cmpstr(detStr,"ML") == 0)
4623                return(0)
4624        endif   
4625       
4626        Make/O/D/N=1 wTmpWrite
4627//      Make/O/R/N=1 wTmpWrite
4628        String groupName = "/entry/instrument/detector_"+detStr
4629        String varName = "setback"
4630        wTmpWrite[0] = val
4631
4632        variable err
4633        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4634        if(err)
4635                Print "HDF write err = ",err
4636        endif
4637        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4638//      err = V_KillNamedDataFolder(fname)
4639//      if(err)
4640//              Print "DataFolder kill err = ",err
4641//      endif
4642        return(err)
4643End
4644
4645// gap when panels are "touching"
4646// units are mm
4647// writes panel gap for detector panel specified
4648// does not write anything if "B" is passed (no such field for this detector)
4649//
4650Function V_writeDet_panel_gap(fname,detStr,val)
4651        String fname,detStr
4652        Variable val
4653
4654        if(cmpstr(detStr,"B") == 0)
4655                return(0)
4656        endif
4657       
4658//      String path = "entry:instrument:detector_"+detStr+":panel_gap"
4659
4660        Make/O/D/N=1 wTmpWrite
4661//      Make/O/R/N=1 wTmpWrite
4662        String groupName = "/entry/instrument/detector_"+detStr
4663        String varName = "panel_gap"
4664        wTmpWrite[0] = val
4665
4666        variable err
4667        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4668        if(err)
4669                Print "HDF write err = ",err
4670        endif
4671        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4672//      err = V_KillNamedDataFolder(fname)
4673//      if(err)
4674//              Print "DataFolder kill err = ",err
4675//      endif
4676        return(err)
4677End
4678
4679
4680
4681//// only defined for the "B" detector, and only to satisfy NXsas
4682//Function V_writeDet_polar_angle(fname,detStr,val)
4683//      String fname,detStr
4684//      Variable val
4685//
4686//      if(cmpstr(detStr,"B") == 0)
4687////            String path = "entry:instrument:detector_"+detStr+":polar_angle"
4688//     
4689//              Make/O/D/N=1 wTmpWrite
4690//      //      Make/O/R/N=1 wTmpWrite
4691//              String groupName = "/entry/instrument/detector_"+detStr
4692//              String varName = "polar_angle"
4693//              wTmpWrite[0] = val
4694//
4695//              variable err
4696//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4697//              if(err)
4698//                      Print "HDF write err = ",err
4699//              endif
4700//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4701////            err = V_KillNamedDataFolder(fname)
4702////            if(err)
4703////                    Print "DataFolder kill err = ",err
4704////            endif
4705//              return(err)
4706//      else
4707//              return(0)
4708//      endif
4709//End
4710
4711//// only defined for the "B" detector, and only to satisfy NXsas
4712//Function V_writeDet_rotational_angle(fname,detStr,val)
4713//      String fname,detStr
4714//      Variable val
4715//
4716//      if(cmpstr(detStr,"B") == 0)
4717////            String path = "entry:instrument:detector_"+detStr+":rotational_angle"
4718//     
4719//              Make/O/D/N=1 wTmpWrite
4720//      //      Make/O/R/N=1 wTmpWrite
4721//              String groupName = "/entry/instrument/detector_"+detStr
4722//              String varName = "rotational_angle"
4723//              wTmpWrite[0] = val
4724//
4725//              variable err
4726//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4727//              if(err)
4728//                      Print "HDF write err = ",err
4729//              endif
4730//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4731////            err = V_KillNamedDataFolder(fname)
4732////            if(err)
4733////                    Print "DataFolder kill err = ",err
4734////            endif
4735//              return(err)
4736//      else
4737//              return(0)
4738//      endif
4739//End
4740
4741Function V_writeDetSettings(fname,detStr,str)
4742        String fname,detStr,str
4743
4744//      String path = "entry:instrument:detector_"+detStr+":settings"
4745
4746        Make/O/T/N=1 tmpTW
4747        String groupName = "/entry/instrument/detector_"+detStr //     
4748        String varName = "settings"
4749        tmpTW[0] = str //
4750
4751        variable err
4752        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4753        if(err)
4754                Print "HDF write err = ",err
4755        endif
4756       
4757        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4758//      err = V_KillNamedDataFolder(fname)
4759//      if(err)
4760//              Print "DataFolder kill err = ",err
4761//      endif
4762               
4763        return(err)
4764End
4765
4766//// really has no meaning at all
4767//Function V_writeDet_size(fname,detStr,val)
4768//      String fname,detStr
4769//      Variable val
4770//
4771////    String path = "entry:instrument:detector_"+detStr+":size"
4772//     
4773//      Make/O/D/N=1 wTmpWrite
4774////    Make/O/R/N=1 wTmpWrite
4775//      String groupName = "/entry/instrument/detector_"+detStr
4776//      String varName = "size"
4777//      wTmpWrite[0] = val
4778//
4779//      variable err
4780//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4781//      if(err)
4782//              Print "HDF write err = ",err
4783//      endif
4784//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4785////    err = V_KillNamedDataFolder(fname)
4786////    if(err)
4787////            Print "DataFolder kill err = ",err
4788////    endif
4789//      return(err)
4790//End
4791
4792//Function V_writeDetType(fname,detStr,str)
4793//      String fname,detStr,str
4794//
4795////    String path = "entry:instrument:detector_"+detStr+":type"
4796//
4797//      Make/O/T/N=1 tmpTW
4798//      String groupName = "/entry/instrument/detector_"+detStr //     
4799//      String varName = "type"
4800//      tmpTW[0] = str //
4801//
4802//      variable err
4803//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4804//      if(err)
4805//              Print "HDF write err = ",err
4806//      endif
4807//     
4808//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4809////    err = V_KillNamedDataFolder(fname)
4810////    if(err)
4811////            Print "DataFolder kill err = ",err
4812////    endif
4813//             
4814//      return(err)
4815//End
4816
4817Function V_writeDet_x_pixel_size(fname,detStr,val)
4818        String fname,detStr
4819        Variable val
4820
4821//      String path = "entry:instrument:detector_"+detStr+":x_pixel_size"
4822       
4823        Make/O/D/N=1 wTmpWrite
4824//      Make/O/R/N=1 wTmpWrite
4825        String groupName = "/entry/instrument/detector_"+detStr
4826        String varName = "x_pixel_size"
4827        wTmpWrite[0] = val
4828
4829        variable err
4830        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4831        if(err)
4832                Print "HDF write err = ",err
4833        endif
4834        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4835//      err = V_KillNamedDataFolder(fname)
4836//      if(err)
4837//              Print "DataFolder kill err = ",err
4838//      endif
4839        return(err)
4840End
4841
4842Function V_writeDet_y_pixel_size(fname,detStr,val)
4843        String fname,detStr
4844        Variable val
4845
4846//      String path = "entry:instrument:detector_"+detStr+":y_pixel_size"
4847       
4848        Make/O/D/N=1 wTmpWrite
4849//      Make/O/R/N=1 wTmpWrite
4850        String groupName = "/entry/instrument/detector_"+detStr
4851        String varName = "y_pixel_size"
4852        wTmpWrite[0] = val
4853
4854        variable err
4855        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4856        if(err)
4857                Print "HDF write err = ",err
4858        endif
4859        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4860//      err = V_KillNamedDataFolder(fname)
4861//      if(err)
4862//              Print "DataFolder kill err = ",err
4863//      endif
4864        return(err)
4865End
4866
4867/////////                       detector_FB (data folder) + ALL other PANEL DETECTORS
4868
4869// integer value
4870Function V_writeDet_numberOfTubes(fname,detStr,val)
4871        String fname,detStr
4872        Variable val
4873
4874//      String path = "entry:instrument:detector_"+detStr+":number_of_tubes"
4875        if(cmpstr(detStr,"B") == 0)
4876                return(0)
4877        else
4878       
4879                Make/O/I/N=1 wTmpWrite
4880        //      Make/O/R/N=1 wTmpWrite
4881                String groupName = "/entry/instrument/detector_"+detStr
4882                String varName = "number_of_tubes"
4883                wTmpWrite[0] = val
4884
4885                variable err
4886                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4887                if(err)
4888                        Print "HDF write err = ",err
4889                endif
4890                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4891//              err = V_KillNamedDataFolder(fname)
4892//              if(err)
4893//                      Print "DataFolder kill err = ",err
4894//              endif
4895                return(err)
4896        endif
4897End
4898
4899// deleted from definition
4900//Function V_writeDetPanelSeparation(fname,detStr,val)
4901//      String fname,detStr
4902//      Variable val
4903//
4904////    String path = "entry:instrument:detector_"+detStr+":separation"
4905//      if(cmpstr(detStr,"B") == 0)
4906//              return(0)
4907//      else
4908//     
4909//              Make/O/D/N=1 wTmpWrite
4910//      //      Make/O/R/N=1 wTmpWrite
4911//              String groupName = "/entry/instrument/detector_"+detStr
4912//              String varName = "separation"
4913//              wTmpWrite[0] = val
4914//
4915//              variable err
4916//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4917//              if(err)
4918//                      Print "HDF write err = ",err
4919//              endif
4920//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4921////            err = V_KillNamedDataFolder(fname)
4922////            if(err)
4923////                    Print "DataFolder kill err = ",err
4924////            endif
4925//              return(err)
4926//      endif
4927//End
4928
4929// TODO -- write this function to return a WAVE with the data
4930// either as a wave reference, or as an input parameter
4931Function V_writeDetTube_spatialCalib(fname,detStr,inW)
4932        String fname,detStr
4933        Wave inW
4934
4935//      String path = "entry:instrument:detector_"+detStr+":spatial_calibration"
4936
4937        if(cmpstr(detStr,"B") == 0)
4938                return(0)
4939        else
4940                Duplicate/O inW wTmpWrite       
4941        // then use redimension as needed to cast the wave to write to the specified type
4942        // see WaveType for the proper codes
4943        //      Redimension/T=() wTmpWrite
4944        // -- May also need to check the dimension(s) before writing (don't trust the input)
4945                String groupName = "/entry/instrument/detector_"+detStr
4946                String varName = "spatial_calibration"
4947
4948                variable err
4949                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4950                if(err)
4951                        Print "HDF write err = ",err
4952                endif
4953                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4954//              err = V_KillNamedDataFolder(fname)
4955//              if(err)
4956//                      Print "DataFolder kill err = ",err
4957//              endif
4958                return(err)
4959        endif
4960End
4961
4962//// TODO -- be clear on how this is defined.
4963//Function V_writeDet_tubeIndex(fname,detStr,val)
4964//      String fname,detStr
4965//      Variable val
4966//
4967////    String path = "entry:instrument:detector_"+detStr+":tube_index"
4968//      if(cmpstr(detStr,"B") == 0)
4969//              return(0)
4970//      else
4971//     
4972//              Make/O/D/N=1 wTmpWrite
4973//      //      Make/O/R/N=1 wTmpWrite
4974//              String groupName = "/entry/instrument/detector_"+detStr
4975//              String varName = "tube_index"
4976//              wTmpWrite[0] = val
4977//
4978//              variable err
4979//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4980//              if(err)
4981//                      Print "HDF write err = ",err
4982//              endif
4983//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4984////            err = V_KillNamedDataFolder(fname)
4985////            if(err)
4986////                    Print "DataFolder kill err = ",err
4987////            endif
4988//              return(err)
4989//      endif
4990//End
4991
4992Function V_writeDet_tubeOrientation(fname,detStr,str)
4993        String fname,detStr,str
4994
4995//      String path = "entry:instrument:detector_"+detStr+":tube_orientation"
4996
4997        if(cmpstr(detStr,"B") == 0)
4998                return(0)
4999        else
5000                Make/O/T/N=1 tmpTW
5001                String groupName = "/entry/instrument/detector_"+detStr //     
5002                String varName = "tube_orientation"
5003                tmpTW[0] = str //
5004
5005                variable err
5006                err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5007                if(err)
5008                        Print "HDF write err = ",err
5009                endif
5010       
5011                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5012//              err = V_KillNamedDataFolder(fname)
5013//              if(err)
5014//                      Print "DataFolder kill err = ",err
5015//              endif
5016               
5017                return(err)
5018
5019        endif
5020End
5021
5022// TODO -- be clear on how this is defined. Units?
5023Function V_writeDet_tubeWidth(fname,detStr,val)
5024        String fname,detStr
5025        Variable val
5026
5027//      String path = "entry:instrument:detector_"+detStr+":tube_width"
5028        if(cmpstr(detStr,"B") == 0)
5029                return(0)
5030        else
5031       
5032                Make/O/D/N=1 wTmpWrite
5033        //      Make/O/R/N=1 wTmpWrite
5034                String groupName = "/entry/instrument/detector_"+detStr
5035                String varName = "tube_width"
5036                wTmpWrite[0] = val
5037
5038                variable err
5039                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5040                if(err)
5041                        Print "HDF write err = ",err
5042                endif
5043                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5044//              err = V_KillNamedDataFolder(fname)
5045//              if(err)
5046//                      Print "DataFolder kill err = ",err
5047//              endif
5048                return(err)
5049        endif
5050End
5051
5052//////////////////////
5053
5054// INSTRUMENT/LENSES    /APERTURES
5055//  lenses (data folder)
5056
5057Function V_writeLensCurvature(fname,val)
5058        String fname
5059        Variable val
5060
5061//      String path = "entry:instrument:lenses:curvature"
5062       
5063        Make/O/D/N=1 wTmpWrite
5064//      Make/O/R/N=1 wTmpWrite
5065        String groupName = "/entry/instrument/lenses"
5066        String varName = "curvature"
5067        wTmpWrite[0] = val
5068
5069        variable err
5070        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5071        if(err)
5072                Print "HDF write err = ",err
5073        endif
5074        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5075//      err = V_KillNamedDataFolder(fname)
5076//      if(err)
5077//              Print "DataFolder kill err = ",err
5078//      endif
5079        return(err)
5080End
5081
5082Function V_writeLensesFocusType(fname,str)
5083        String fname,str
5084
5085//      String path = "entry:instrument:lenses:focus_type"
5086
5087        Make/O/T/N=1 tmpTW
5088        String groupName = "/entry/instrument/lenses"
5089        String varName = "focus_type"
5090        tmpTW[0] = str //
5091
5092        variable err
5093        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5094        if(err)
5095                Print "HDF write err = ",err
5096        endif
5097       
5098        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5099//      err = V_KillNamedDataFolder(fname)
5100//      if(err)
5101//              Print "DataFolder kill err = ",err
5102//      endif
5103               
5104        return(err)
5105End
5106
5107Function V_writeLensDistance(fname,val)
5108        String fname
5109        Variable val
5110
5111//      String path = "entry:instrument:lenses:lens_distance"
5112       
5113        Make/O/D/N=1 wTmpWrite
5114//      Make/O/R/N=1 wTmpWrite
5115        String groupName = "/entry/instrument/lenses"
5116        String varName = "lens_distance"
5117        wTmpWrite[0] = val
5118
5119        variable err
5120        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5121        if(err)
5122                Print "HDF write err = ",err
5123        endif
5124        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5125//      err = V_KillNamedDataFolder(fname)
5126//      if(err)
5127//              Print "DataFolder kill err = ",err
5128//      endif
5129        return(err)
5130End
5131
5132Function V_writeLensGeometry(fname,str)
5133        String fname,str
5134
5135//      String path = "entry:instrument:lenses:lens_geometry"
5136
5137        Make/O/T/N=1 tmpTW
5138        String groupName = "/entry/instrument/lenses"
5139        String varName = "lens_geometry"
5140        tmpTW[0] = str //
5141
5142        variable err
5143        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5144        if(err)
5145                Print "HDF write err = ",err
5146        endif
5147       
5148        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5149//      err = V_KillNamedDataFolder(fname)
5150//      if(err)
5151//              Print "DataFolder kill err = ",err
5152//      endif
5153               
5154        return(err)
5155End
5156
5157Function V_writeLensMaterial(fname,str)
5158        String fname,str
5159
5160//      String path = "entry:instrument:lenses:lens_material"
5161
5162        Make/O/T/N=1 tmpTW
5163        String groupName = "/entry/instrument/lenses"
5164        String varName = "lens_material"
5165        tmpTW[0] = str //
5166
5167        variable err
5168        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5169        if(err)
5170                Print "HDF write err = ",err
5171        endif
5172       
5173        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5174//      err = V_KillNamedDataFolder(fname)
5175//      if(err)
5176//              Print "DataFolder kill err = ",err
5177//      endif
5178               
5179        return(err)
5180End
5181
5182// integer value
5183Function V_writeNumber_of_Lenses(fname,val)
5184        String fname
5185        Variable val
5186
5187//      String path = "entry:instrument:lenses:number_of_lenses"
5188       
5189        Make/O/I/N=1 wTmpWrite
5190//      Make/O/R/N=1 wTmpWrite
5191        String groupName = "/entry/instrument/lenses"
5192        String varName = "number_of_lenses"
5193        wTmpWrite[0] = val
5194
5195        variable err
5196        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5197        if(err)
5198                Print "HDF write err = ",err
5199        endif
5200        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5201//      err = V_KillNamedDataFolder(fname)
5202//      if(err)
5203//              Print "DataFolder kill err = ",err
5204//      endif
5205        return(err)
5206End
5207
5208// integer value
5209Function V_writeNumber_of_prisms(fname,val)
5210        String fname
5211        Variable val
5212
5213//      String path = "entry:instrument:lenses:number_of_prisms"
5214       
5215        Make/O/I/N=1 wTmpWrite
5216//      Make/O/R/N=1 wTmpWrite
5217        String groupName = "/entry/instrument/lenses"
5218        String varName = "number_of_prisms"
5219        wTmpWrite[0] = val
5220
5221        variable err
5222        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5223        if(err)
5224                Print "HDF write err = ",err
5225        endif
5226        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5227//      err = V_KillNamedDataFolder(fname)
5228//      if(err)
5229//              Print "DataFolder kill err = ",err
5230//      endif
5231        return(err)
5232End
5233
5234Function V_writePrism_distance(fname,val)
5235        String fname
5236        Variable val
5237
5238//      String path = "entry:instrument:lenses:prism_distance"
5239       
5240        Make/O/D/N=1 wTmpWrite
5241//      Make/O/R/N=1 wTmpWrite
5242        String groupName = "/entry/instrument/lenses"
5243        String varName = "prism_distance"
5244        wTmpWrite[0] = val
5245
5246        variable err
5247        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5248        if(err)
5249                Print "HDF write err = ",err
5250        endif
5251        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5252//      err = V_KillNamedDataFolder(fname)
5253//      if(err)
5254//              Print "DataFolder kill err = ",err
5255//      endif
5256        return(err)
5257End
5258
5259Function V_writePrismMaterial(fname,str)
5260        String fname,str
5261
5262//      String path = "entry:instrument:lenses:prism_material"
5263
5264        Make/O/T/N=1 tmpTW
5265        String groupName = "/entry/instrument/lenses"
5266        String varName = "prism_material"
5267        tmpTW[0] = str //
5268
5269        variable err
5270        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5271        if(err)
5272                Print "HDF write err = ",err
5273        endif
5274       
5275        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5276//      err = V_KillNamedDataFolder(fname)
5277//      if(err)
5278//              Print "DataFolder kill err = ",err
5279//      endif
5280               
5281        return(err)
5282End
5283
5284// status of lens/prism = lens | prism | both | out
5285Function V_writeLensPrismStatus(fname,str)
5286        String fname,str
5287
5288//      String path = "entry:instrument:lenses:status"
5289
5290        Make/O/T/N=1 tmpTW
5291        String groupName = "/entry/instrument/lenses"
5292        String varName = "status"
5293        tmpTW[0] = str //
5294
5295        variable err
5296        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5297        if(err)
5298                Print "HDF write err = ",err
5299        endif
5300       
5301        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5302//      err = V_KillNamedDataFolder(fname)
5303//      if(err)
5304//              Print "DataFolder kill err = ",err
5305//      endif
5306               
5307        return(err)
5308End
5309       
5310
5311///////  sample_aperture (1) (data folder)
5312// this is the INTERNAL sample aperture
5313Function V_writeSampleAp_Description(fname,str)
5314        String fname,str
5315
5316//      String path = "entry:instrument:sample_aperture:description"
5317
5318        Make/O/T/N=1 tmpTW
5319        String groupName = "/entry/instrument/sample_aperture"
5320        String varName = "description"
5321        tmpTW[0] = str //
5322
5323        variable err
5324        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5325        if(err)
5326                Print "HDF write err = ",err
5327        endif
5328       
5329        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5330//      err = V_KillNamedDataFolder(fname)
5331//      if(err)
5332//              Print "DataFolder kill err = ",err
5333//      endif
5334               
5335        return(err)
5336End
5337
5338Function V_writeSampleAp_distance(fname,val)
5339        String fname
5340        Variable val
5341
5342//      String path = "entry:instrument:sample_aperture:distance"
5343       
5344        Make/O/D/N=1 wTmpWrite
5345//      Make/O/R/N=1 wTmpWrite
5346        String groupName = "/entry/instrument/sample_aperture"
5347        String varName = "distance"
5348        wTmpWrite[0] = val
5349
5350        variable err
5351        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5352        if(err)
5353                Print "HDF write err = ",err
5354        endif
5355        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5356//      err = V_KillNamedDataFolder(fname)
5357//      if(err)
5358//              Print "DataFolder kill err = ",err
5359//      endif
5360        return(err)
5361End
5362
5363//      sample_apertuer/shape (data folder)
5364Function V_writeSampleAp_height(fname,val)
5365        String fname
5366        Variable val
5367
5368//      String path = "entry:instrument:sample_aperture:distance"
5369       
5370        Make/O/D/N=1 wTmpWrite
5371//      Make/O/R/N=1 wTmpWrite
5372        String groupName = "/entry/instrument/sample_aperture/shape"
5373        String varName = "height"
5374        wTmpWrite[0] = val
5375
5376        variable err
5377        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5378        if(err)
5379                Print "HDF write err = ",err
5380        endif
5381        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5382//      err = V_KillNamedDataFolder(fname)
5383//      if(err)
5384//              Print "DataFolder kill err = ",err
5385//      endif
5386        return(err)
5387End
5388
5389Function V_writeSampleAp_shape(fname,str)
5390        String fname,str
5391
5392//      String path = "entry:instrument:sample_aperture:shape:shape"
5393
5394        Make/O/T/N=1 tmpTW
5395        String groupName = "/entry/instrument/sample_aperture/shape"
5396        String varName = "shape"
5397        tmpTW[0] = str //
5398
5399        variable err
5400        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5401        if(err)
5402                Print "HDF write err = ",err
5403        endif
5404       
5405        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5406//      err = V_KillNamedDataFolder(fname)
5407//      if(err)
5408//              Print "DataFolder kill err = ",err
5409//      endif
5410               
5411        return(err)
5412End
5413
5414Function V_writeSampleAp_size(fname,str)
5415        String fname,str
5416
5417//      String path = "entry:instrument:sample_aperture:shape:shape"
5418
5419        Make/O/T/N=1 tmpTW
5420        String groupName = "/entry/instrument/sample_aperture/shape"
5421        String varName = "size"
5422        tmpTW[0] = str //
5423
5424        variable err
5425        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5426        if(err)
5427                Print "HDF write err = ",err
5428        endif
5429       
5430        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5431//      err = V_KillNamedDataFolder(fname)
5432//      if(err)
5433//              Print "DataFolder kill err = ",err
5434//      endif
5435               
5436        return(err)
5437End
5438
5439Function V_writeSampleAp_width(fname,val)
5440        String fname
5441        Variable val
5442
5443//      String path = "entry:instrument:sample_aperture:distance"
5444       
5445        Make/O/D/N=1 wTmpWrite
5446//      Make/O/R/N=1 wTmpWrite
5447        String groupName = "/entry/instrument/sample_aperture/shape"
5448        String varName = "width"
5449        wTmpWrite[0] = val
5450
5451        variable err
5452        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5453        if(err)
5454                Print "HDF write err = ",err
5455        endif
5456        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5457//      err = V_KillNamedDataFolder(fname)
5458//      if(err)
5459//              Print "DataFolder kill err = ",err
5460//      endif
5461        return(err)
5462End
5463
5464///////  sample_aperture_2 (data folder)
5465// sample aperture (2) is the external aperture, which may or may not be present
5466
5467Function V_writeSampleAp2_Description(fname,str)
5468        String fname,str
5469
5470//      String path = "entry:instrument:sample_aperture_2:description"
5471
5472        Make/O/T/N=1 tmpTW
5473        String groupName = "/entry/instrument/sample_aperture_2"
5474        String varName = "description"
5475        tmpTW[0] = str //
5476
5477        variable err
5478        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5479        if(err)
5480                Print "HDF write err = ",err
5481        endif
5482       
5483        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5484//      err = V_KillNamedDataFolder(fname)
5485//      if(err)
5486//              Print "DataFolder kill err = ",err
5487//      endif
5488               
5489        return(err)
5490End
5491
5492Function V_writeSampleAp2_distance(fname,val)
5493        String fname
5494        Variable val
5495
5496//      String path = "entry:instrument:sample_aperture_2:distance"
5497       
5498        Make/O/D/N=1 wTmpWrite
5499//      Make/O/R/N=1 wTmpWrite
5500        String groupName = "/entry/instrument/sample_aperture_2"
5501        String varName = "distance"
5502        wTmpWrite[0] = val
5503
5504        variable err
5505        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5506        if(err)
5507                Print "HDF write err = ",err
5508        endif
5509        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5510//      err = V_KillNamedDataFolder(fname)
5511//      if(err)
5512//              Print "DataFolder kill err = ",err
5513//      endif
5514        return(err)
5515End
5516
5517
5518//      shape (data folder)
5519Function V_writeSampleAp2_height(fname,val)
5520        String fname
5521        Variable val
5522
5523//      String path = "entry:instrument:sample_aperture:distance"
5524       
5525        Make/O/D/N=1 wTmpWrite
5526//      Make/O/R/N=1 wTmpWrite
5527        String groupName = "/entry/instrument/sample_aperture_2/shape"
5528        String varName = "height"
5529        wTmpWrite[0] = val
5530
5531        variable err
5532        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5533        if(err)
5534                Print "HDF write err = ",err
5535        endif
5536        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5537//      err = V_KillNamedDataFolder(fname)
5538//      if(err)
5539//              Print "DataFolder kill err = ",err
5540//      endif
5541        return(err)
5542End
5543
5544Function V_writeSampleAp2_shape(fname,str)
5545        String fname,str
5546
5547//      String path = "entry:instrument:sample_aperture_2:shape:shape"
5548
5549        Make/O/T/N=1 tmpTW
5550        String groupName = "/entry/instrument/sample_aperture_2/shape"
5551        String varName = "shape"
5552        tmpTW[0] = str //
5553
5554        variable err
5555        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5556        if(err)
5557                Print "HDF write err = ",err
5558        endif
5559       
5560        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5561//      err = V_KillNamedDataFolder(fname)
5562//      if(err)
5563//              Print "DataFolder kill err = ",err
5564//      endif
5565               
5566        return(err)
5567End
5568
5569Function V_writeSampleAp2_size(fname,val)
5570        String fname
5571        Variable val
5572
5573//      String path = "entry:instrument:sample_aperture:distance"
5574       
5575        Make/O/D/N=1 wTmpWrite
5576//      Make/O/R/N=1 wTmpWrite
5577        String groupName = "/entry/instrument/sample_aperture_2/shape"
5578        String varName = "size"
5579        wTmpWrite[0] = val
5580
5581        variable err
5582        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5583        if(err)
5584                Print "HDF write err = ",err
5585        endif
5586        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5587//      err = V_KillNamedDataFolder(fname)
5588//      if(err)
5589//              Print "DataFolder kill err = ",err
5590//      endif
5591        return(err)
5592End
5593
5594Function V_writeSampleAp2_width(fname,val)
5595        String fname
5596        Variable val
5597
5598//      String path = "entry:instrument:sample_aperture:distance"
5599       
5600        Make/O/D/N=1 wTmpWrite
5601//      Make/O/R/N=1 wTmpWrite
5602        String groupName = "/entry/instrument/sample_aperture_2/shape"
5603        String varName = "width"
5604        wTmpWrite[0] = val
5605
5606        variable err
5607        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5608        if(err)
5609                Print "HDF write err = ",err
5610        endif
5611        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5612//      err = V_KillNamedDataFolder(fname)
5613//      if(err)
5614//              Print "DataFolder kill err = ",err
5615//      endif
5616        return(err)
5617End
5618
5619               
5620//////  sample_table (data folder)
5621// location  = "CHAMBER" or HUBER
5622Function V_writeSampleTableLocation(fname,str)
5623        String fname,str
5624
5625//      String path = "entry:instrument:sample_table:location"
5626
5627        Make/O/T/N=1 tmpTW
5628        String groupName = "/entry/instrument/sample_table"
5629        String varName = "location"
5630        tmpTW[0] = str //
5631
5632        variable err
5633        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5634        if(err)
5635                Print "HDF write err = ",err
5636        endif
5637       
5638        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5639//      err = V_KillNamedDataFolder(fname)
5640//      if(err)
5641//              Print "DataFolder kill err = ",err
5642//      endif
5643               
5644        return(err)
5645End
5646
5647// TODO - verify the meaning
5648//      offset_distance (?? for center of sample table vs. sample position)
5649Function V_writeSampleTableOffset(fname,val)
5650        String fname
5651        Variable val
5652
5653//      String path = "entry:instrument:sample_table:offset_distance"
5654       
5655        Make/O/D/N=1 wTmpWrite
5656//      Make/O/R/N=1 wTmpWrite
5657        String groupName = "/entry/instrument/sample_table"
5658        String varName = "offset_distance"
5659        wTmpWrite[0] = val
5660
5661        variable err
5662        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5663        if(err)
5664                Print "HDF write err = ",err
5665        endif
5666        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5667//      err = V_KillNamedDataFolder(fname)
5668//      if(err)
5669//              Print "DataFolder kill err = ",err
5670//      endif
5671        return(err)
5672End     
5673       
5674//  source (data folder)
5675//name "NCNR"
5676Function V_writeSourceName(fname,str)
5677        String fname,str
5678
5679//      String path = "entry:instrument:source:name"
5680
5681        Make/O/T/N=1 tmpTW
5682        String groupName = "/entry/instrument/source"
5683        String varName = "name"
5684        tmpTW[0] = str //
5685
5686        variable err
5687        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5688        if(err)
5689                Print "HDF write err = ",err
5690        endif
5691       
5692        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5693//      err = V_KillNamedDataFolder(fname)
5694//      if(err)
5695//              Print "DataFolder kill err = ",err
5696//      endif
5697               
5698        return(err)
5699End
5700
5701//      power -- nominal only, not connected to any real number
5702Function V_writeReactorPower(fname,val)
5703        String fname
5704        Variable val
5705
5706//      String path = "entry:instrument:source:power"
5707       
5708        Make/O/D/N=1 wTmpWrite
5709//      Make/O/R/N=1 wTmpWrite
5710        String groupName = "/entry/instrument/source"
5711        String varName = "power"
5712        wTmpWrite[0] = val
5713
5714        variable err
5715        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5716        if(err)
5717                Print "HDF write err = ",err
5718        endif
5719        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5720//      err = V_KillNamedDataFolder(fname)
5721//      if(err)
5722//              Print "DataFolder kill err = ",err
5723//      endif
5724        return(err)
5725End     
5726
5727//probe (wave) "neutron"
5728Function V_writeSourceProbe(fname,str)
5729        String fname,str
5730
5731//      String path = "entry:instrument:source:probe"
5732
5733        Make/O/T/N=1 tmpTW
5734        String groupName = "/entry/instrument/source"
5735        String varName = "probe"
5736        tmpTW[0] = str //
5737
5738        variable err
5739        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5740        if(err)
5741                Print "HDF write err = ",err
5742        endif
5743       
5744        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5745//      err = V_KillNamedDataFolder(fname)
5746//      if(err)
5747//              Print "DataFolder kill err = ",err
5748//      endif
5749               
5750        return(err)
5751End
5752
5753//type (wave) "Reactor Neutron Source"
5754Function V_writeSourceType(fname,str)
5755        String fname,str
5756
5757//      String path = "entry:instrument:source:type"
5758
5759        Make/O/T/N=1 tmpTW
5760        String groupName = "/entry/instrument/source"
5761        String varName = "type"
5762        tmpTW[0] = str //
5763
5764        variable err
5765        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5766        if(err)
5767                Print "HDF write err = ",err
5768        endif
5769       
5770        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5771//      err = V_KillNamedDataFolder(fname)
5772//      if(err)
5773//              Print "DataFolder kill err = ",err
5774//      endif
5775               
5776        return(err)
5777End
5778
5779       
5780///////  source_aperture (data folder)
5781
5782Function V_writeSourceAp_Description(fname,str)
5783        String fname,str
5784
5785//      String path = "entry:instrument:source_aperture:description"
5786
5787        Make/O/T/N=1 tmpTW
5788        String groupName = "/entry/instrument/source_aperture"
5789        String varName = "description"
5790        tmpTW[0] = str //
5791
5792        variable err
5793        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5794        if(err)
5795                Print "HDF write err = ",err
5796        endif
5797       
5798        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5799//      err = V_KillNamedDataFolder(fname)
5800//      if(err)
5801//              Print "DataFolder kill err = ",err
5802//      endif
5803               
5804        return(err)
5805End
5806
5807Function V_writeSourceAp_distance(fname,val)
5808        String fname
5809        Variable val
5810
5811//      String path = "entry:instrument:source_aperture:distance"
5812       
5813        Make/O/D/N=1 wTmpWrite
5814//      Make/O/R/N=1 wTmpWrite
5815        String groupName = "/entry/instrument/source_aperture"
5816        String varName = "distance"
5817        wTmpWrite[0] = val
5818
5819        variable err
5820        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5821        if(err)
5822                Print "HDF write err = ",err
5823        endif
5824        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5825//      err = V_KillNamedDataFolder(fname)
5826//      if(err)
5827//              Print "DataFolder kill err = ",err
5828//      endif
5829        return(err)
5830End
5831
5832
5833//      shape (data folder)
5834Function V_writeSourceAp_height(fname,val)
5835        String fname
5836        Variable val
5837
5838//      String path = "entry:instrument:sample_aperture:distance"
5839       
5840        Make/O/D/N=1 wTmpWrite
5841//      Make/O/R/N=1 wTmpWrite
5842        String groupName = "/entry/instrument/source_aperture/shape"
5843        String varName = "height"
5844        wTmpWrite[0] = val
5845
5846        variable err
5847        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5848        if(err)
5849                Print "HDF write err = ",err
5850        endif
5851        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5852//      err = V_KillNamedDataFolder(fname)
5853//      if(err)
5854//              Print "DataFolder kill err = ",err
5855//      endif
5856        return(err)
5857End
5858
5859Function V_writeSourceAp_shape(fname,str)
5860        String fname,str
5861
5862//      String path = "entry:instrument:source_aperture:shape:shape"
5863
5864        Make/O/T/N=1 tmpTW
5865        String groupName = "/entry/instrument/source_aperture/shape"
5866        String varName = "shape"
5867        tmpTW[0] = str //
5868
5869        variable err
5870        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5871        if(err)
5872                Print "HDF write err = ",err
5873        endif
5874       
5875        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5876//      err = V_KillNamedDataFolder(fname)
5877//      if(err)
5878//              Print "DataFolder kill err = ",err
5879//      endif
5880               
5881        return(err)
5882End
5883
5884Function V_writeSourceAp_size(fname,str)
5885        String fname,str
5886
5887//      String path = "entry:instrument:source_aperture:shape:shape"
5888
5889        Make/O/T/N=1 tmpTW
5890        String groupName = "/entry/instrument/source_aperture/shape"
5891        String varName = "size"
5892        tmpTW[0] = str //
5893
5894        variable err
5895        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5896        if(err)
5897                Print "HDF write err = ",err
5898        endif
5899       
5900        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5901//      err = V_KillNamedDataFolder(fname)
5902//      if(err)
5903//              Print "DataFolder kill err = ",err
5904//      endif
5905               
5906        return(err)
5907End
5908
5909Function V_writeSourceAp_width(fname,val)
5910        String fname
5911        Variable val
5912
5913//      String path = "entry:instrument:sample_aperture:distance"
5914       
5915        Make/O/D/N=1 wTmpWrite
5916//      Make/O/R/N=1 wTmpWrite
5917        String groupName = "/entry/instrument/source_aperture/shape"
5918        String varName = "width"
5919        wTmpWrite[0] = val
5920
5921        variable err
5922        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5923        if(err)
5924                Print "HDF write err = ",err
5925        endif
5926        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5927//      err = V_KillNamedDataFolder(fname)
5928//      if(err)
5929//              Print "DataFolder kill err = ",err
5930//      endif
5931        return(err)
5932End
5933
5934
5935//////// SAMPLE
5936//////// SAMPLE
5937//////// SAMPLE
5938
5939//Sample position in changer
5940Function V_writeSamplePosition(fname,str)
5941        String fname,str
5942
5943//      String path = "entry:sample:changer_position"   
5944
5945        Make/O/T/N=1 tmpTW
5946        String groupName = "/entry/sample"
5947        String varName = "changer_position"
5948        tmpTW[0] = str //
5949
5950        variable err
5951        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5952        if(err)
5953                Print "HDF write err = ",err
5954        endif
5955       
5956        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5957//      err = V_KillNamedDataFolder(fname)
5958//      if(err)
5959//              Print "DataFolder kill err = ",err
5960//      endif
5961               
5962        return(err)
5963End
5964
5965
5966// sample label
5967// TODO: value of num is currently not used
5968Function V_writeSampleDescription(fname,str)
5969        String fname,str
5970
5971//      String path = "entry:sample:description"
5972
5973        Make/O/T/N=1 tmpTW
5974        String groupName = "/entry/sample"
5975        String varName = "description"
5976        tmpTW[0] = str //
5977
5978        variable err
5979        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5980        if(err)
5981                Print "HDF write err = ",err
5982        endif
5983       
5984        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5985//      err = V_KillNamedDataFolder(fname)
5986//      if(err)
5987//              Print "DataFolder kill err = ",err
5988//      endif
5989               
5990        return(err)
5991End
5992
5993// fname is a local WORK folder
5994Function V_putSampleDescription(fname,str)
5995        String fname,str
5996
5997        String path = "root:Packages:NIST:VSANS:"+fname+":"
5998        path += "entry:sample:description"
5999       
6000        Wave/Z/T w = $path
6001        if(waveExists(w) == 0)
6002                return(1)
6003        else
6004        w[0] = str
6005                return(0)
6006        endif
6007
6008End
6009
6010
6011
6012// for a z-stage??
6013Function V_writeSample_elevation(fname,val)
6014        String fname
6015        Variable val
6016       
6017//      String path = "entry:sample:elevation" 
6018       
6019        Make/O/D/N=1 wTmpWrite
6020//      Make/O/R/N=1 wTmpWrite
6021        String groupName = "/entry/sample"
6022        String varName = "elevation"
6023        wTmpWrite[0] = val
6024
6025        variable err
6026        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6027        if(err)
6028                Print "HDF write err = ",err
6029        endif
6030        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6031//      err = V_KillNamedDataFolder(fname)
6032//      if(err)
6033//              Print "DataFolder kill err = ",err
6034//      endif
6035        return(err)
6036end
6037
6038//no meaning to this...
6039Function V_writeSample_equatorial_ang(fname,val)
6040        String fname
6041        Variable val
6042       
6043//      String path = "entry:sample:equatorial_angle"   
6044       
6045        Make/O/D/N=1 wTmpWrite
6046//      Make/O/R/N=1 wTmpWrite
6047        String groupName = "/entry/sample"
6048        String varName = "equatorial_angle"
6049        wTmpWrite[0] = val
6050
6051        variable err
6052        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6053        if(err)
6054                Print "HDF write err = ",err
6055        endif
6056        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6057//      err = V_KillNamedDataFolder(fname)
6058//      if(err)
6059//              Print "DataFolder kill err = ",err
6060//      endif
6061        return(err)
6062end
6063
6064
6065//
6066// TODO x- I need to make sure that this is an integer in the JSON definition
6067//              x- currently a text value in the data file - see trac ticket
6068// x- this is also a duplicated field in the reduction block (reduction/group_id is no longer used)
6069//
6070// group ID !!! very important for matching up files
6071// integer value
6072//
6073Function V_writeSample_GroupID(fname,val)
6074        String fname
6075        Variable val
6076       
6077//      String path = "entry:sample:group_id"   
6078       
6079        Make/O/I/N=1 wTmpWrite
6080//      Make/O/R/N=1 wTmpWrite
6081        String groupName = "/entry/sample"
6082        String varName = "group_id"
6083        wTmpWrite[0] = val
6084
6085        variable err
6086        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6087        if(err)
6088                Print "HDF write err = ",err
6089        endif
6090        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6091//      err = V_KillNamedDataFolder(fname)
6092//      if(err)
6093//              Print "DataFolder kill err = ",err
6094//      endif
6095        return(err)
6096end
6097
6098
6099//Sample Rotation Angle
6100Function V_writeSampleRotationAngle(fname,val)
6101        String fname
6102        Variable val
6103       
6104//      String path = "entry:sample:rotation_angle"     
6105       
6106        Make/O/D/N=1 wTmpWrite
6107//      Make/O/R/N=1 wTmpWrite
6108        String groupName = "/entry/sample"
6109        String varName = "rotation_angle"
6110        wTmpWrite[0] = val
6111
6112        variable err
6113        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6114        if(err)
6115                Print "HDF write err = ",err
6116        endif
6117        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6118//      err = V_KillNamedDataFolder(fname)
6119//      if(err)
6120//              Print "DataFolder kill err = ",err
6121//      endif
6122        return(err)
6123end
6124
6125//?? this is huber/chamber??
6126// TODO -- then where is the description of 10CB, etc...
6127Function V_writeSampleHolderDescription(fname,str)
6128        String fname,str
6129
6130//      String path = "entry:sample:sample_holder_description"
6131
6132        Make/O/T/N=1 tmpTW
6133        String groupName = "/entry/sample"
6134        String varName = "sample_holder_description"
6135        tmpTW[0] = str //
6136
6137        variable err
6138        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6139        if(err)
6140                Print "HDF write err = ",err
6141        endif
6142       
6143        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6144//      err = V_KillNamedDataFolder(fname)
6145//      if(err)
6146//              Print "DataFolder kill err = ",err
6147//      endif
6148               
6149        return(err)
6150End
6151
6152
6153
6154//Sample Temperature
6155Function V_writeSampleTemperature(fname,val)
6156        String fname
6157        Variable val
6158       
6159//      String path = "entry:sample:temperature"       
6160       
6161        Make/O/D/N=1 wTmpWrite
6162//      Make/O/R/N=1 wTmpWrite
6163        String groupName = "/entry/sample"
6164        String varName = "temperature"
6165        wTmpWrite[0] = val
6166
6167        variable err
6168        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6169        if(err)
6170                Print "HDF write err = ",err
6171        endif
6172        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6173//      err = V_KillNamedDataFolder(fname)
6174//      if(err)
6175//              Print "DataFolder kill err = ",err
6176//      endif
6177        return(err)
6178end
6179
6180
6181//Sample Temperature set point
6182Function V_writeSampleTempSetPoint(fname,val)
6183        String fname
6184        Variable val
6185       
6186//      String path = "entry:sample:temperature_setpoint"       
6187       
6188        Make/O/D/N=1 wTmpWrite
6189//      Make/O/R/N=1 wTmpWrite
6190        String groupName = "/entry/sample"
6191        String varName = "temperature_setpoint"
6192        wTmpWrite[0] = val
6193
6194        variable err
6195        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6196        if(err)
6197                Print "HDF write err = ",err
6198        endif
6199        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6200//      err = V_KillNamedDataFolder(fname)
6201//      if(err)
6202//              Print "DataFolder kill err = ",err
6203//      endif
6204        return(err)
6205end
6206
6207
6208//Sample Thickness
6209// TODO -- somehow, this is not set correctly in the acquisition, so NaN results
6210Function V_writeSampleThickness(fname,val)
6211        String fname
6212        Variable val
6213       
6214//      String path = "entry:sample:thickness" 
6215       
6216        Make/O/D/N=1 wTmpWrite
6217//      Make/O/R/N=1 wTmpWrite
6218        String groupName = "/entry/sample"
6219        String varName = "thickness"
6220        wTmpWrite[0] = val
6221
6222        variable err
6223        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6224        if(err)
6225                Print "HDF write err = ",err
6226        endif
6227        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6228//      err = V_KillNamedDataFolder(fname)
6229//      if(err)
6230//              Print "DataFolder kill err = ",err
6231//      endif
6232        return(err)
6233end
6234
6235
6236//Sample Translation
6237Function V_writeSampleTranslation(fname,val)
6238        String fname
6239        Variable val
6240       
6241//      String path = "entry:sample:translation"       
6242       
6243        Make/O/D/N=1 wTmpWrite
6244//      Make/O/R/N=1 wTmpWrite
6245        String groupName = "/entry/sample"
6246        String varName = "translation"
6247        wTmpWrite[0] = val
6248
6249        variable err
6250        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6251        if(err)
6252                Print "HDF write err = ",err
6253        endif
6254        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6255//      err = V_KillNamedDataFolder(fname)
6256//      if(err)
6257//              Print "DataFolder kill err = ",err
6258//      endif
6259        return(err)
6260end
6261
6262// sample transmission
6263Function V_writeSampleTransmission(fname,val)
6264        String fname
6265        Variable val
6266       
6267        String path = "entry:sample:transmission"       
6268       
6269        Make/O/D/N=1 wTmpWrite
6270//      Make/O/R/N=1 wTmpWrite
6271        String groupName = "/entry/sample"
6272        String varName = "transmission"
6273        wTmpWrite[0] = val
6274
6275        variable err
6276        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6277        if(err)
6278                Print "HDF write err = ",err
6279        endif
6280        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6281//      err = V_KillNamedDataFolder(fname)
6282//      if(err)
6283//              Print "DataFolder kill err = ",err
6284//      endif
6285        return(err)
6286end
6287
6288//transmission error (one sigma)
6289Function V_writeSampleTransError(fname,val)
6290        String fname
6291        Variable val
6292       
6293//      String path = "entry:sample:transmission_error"
6294       
6295        Make/O/D/N=1 wTmpWrite
6296//      Make/O/R/N=1 wTmpWrite
6297        String groupName = "/entry/sample"
6298        String varName = "transmission_error"
6299        wTmpWrite[0] = val
6300
6301        variable err
6302        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6303        if(err)
6304                Print "HDF write err = ",err
6305        endif
6306        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6307//      err = V_KillNamedDataFolder(fname)
6308//      if(err)
6309//              Print "DataFolder kill err = ",err
6310//      endif
6311        return(err)
6312end
6313
6314
6315
6316//// SAMPLE / DATA LOGS
6317// write this generic , call with the name of the environment log desired
6318//
6319//
6320// shear_field
6321// pressure
6322// magnetic_field
6323// electric_field
6324//
6325//////// (for example) electric_field (data folder)
6326
6327Function V_writeLog_attachedTo(fname,logStr,str)
6328        String fname,logStr,str
6329
6330//      String path = "entry:sample:"+logstr+":attached_to"
6331
6332        Make/O/T/N=1 tmpTW
6333        String groupName = "/entry/sample/"+logStr
6334        String varName = "attached_to"
6335        tmpTW[0] = str //
6336
6337        variable err
6338        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6339        if(err)
6340                Print "HDF write err = ",err
6341        endif
6342       
6343        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6344//      err = V_KillNamedDataFolder(fname)
6345//      if(err)
6346//              Print "DataFolder kill err = ",err
6347//      endif
6348               
6349        return(err)
6350End
6351
6352
6353Function V_writeLog_measurement(fname,logStr,str)
6354        String fname,logStr,str
6355
6356        String path = "entry:sample:"+logstr+":measurement"
6357
6358        Make/O/T/N=1 tmpTW
6359        String groupName = "/entry/sample/"+logStr
6360        String varName = "measurement"
6361        tmpTW[0] = str //
6362
6363        variable err
6364        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6365        if(err)
6366                Print "HDF write err = ",err
6367        endif
6368       
6369        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6370//      err = V_KillNamedDataFolder(fname)
6371//      if(err)
6372//              Print "DataFolder kill err = ",err
6373//      endif
6374               
6375        return(err)
6376End
6377
6378
6379Function V_writeLog_Name(fname,logStr,str)
6380        String fname,logStr,str
6381
6382//      String path = "entry:sample:"+logstr+":name"
6383
6384        Make/O/T/N=1 tmpTW
6385        String groupName = "/entry/sample/"+logStr
6386        String varName = "name"
6387        tmpTW[0] = str //
6388
6389        variable err
6390        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6391        if(err)
6392                Print "HDF write err = ",err
6393        endif
6394       
6395        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6396//      err = V_KillNamedDataFolder(fname)
6397//      if(err)
6398//              Print "DataFolder kill err = ",err
6399//      endif
6400               
6401        return(err)
6402End
6403
6404
6405//// TODO -- this may require multiple entries, for each sensor _1, _2, etc.
6406//Function V_writeLog_setPoint(fname,logStr,val)
6407//      String fname,logStr
6408//      Variable val
6409//     
6410////    String path = "entry:sample:"+logstr+":setpoint_1"
6411//     
6412//      Make/O/D/N=1 wTmpWrite
6413////    Make/O/R/N=1 wTmpWrite
6414//      String groupName = "/entry/sample/"+logStr
6415//      String varName = "setpoint_1"
6416//      wTmpWrite[0] = val
6417//
6418//      variable err
6419//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6420//      if(err)
6421//              Print "HDF write err = ",err
6422//      endif
6423//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6424////    err = V_KillNamedDataFolder(fname)
6425////    if(err)
6426////            Print "DataFolder kill err = ",err
6427////    endif
6428//      return(err)
6429//end
6430//
6431//Function V_writeLog_startTime(fname,logStr,str)
6432//      String fname,logStr,str
6433//
6434////    String path = "entry:sample:"+logstr+":start"
6435//
6436//      Make/O/T/N=1 tmpTW
6437//      String groupName = "/entry/sample/"+logStr
6438//      String varName = "start"
6439//      tmpTW[0] = str //
6440//
6441//      variable err
6442//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6443//      if(err)
6444//              Print "HDF write err = ",err
6445//      endif
6446//     
6447//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6448////    err = V_KillNamedDataFolder(fname)
6449////    if(err)
6450////            Print "DataFolder kill err = ",err
6451////    endif
6452//             
6453//      return(err)
6454//End
6455//
6456//
6457//// TODO -- this may only exist for electric and magnetic field, or be removed
6458//Function V_writeLog_nomValue(fname,logStr,val)
6459//      String fname,logStr
6460//      Variable val
6461//     
6462////    String path = "entry:sample:"+logstr+":value"
6463//     
6464//      Make/O/D/N=1 wTmpWrite
6465////    Make/O/R/N=1 wTmpWrite
6466//      String groupName = "/entry/sample/"+logStr
6467//      String varName = "value"
6468//      wTmpWrite[0] = val
6469//
6470//      variable err
6471//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6472//      if(err)
6473//              Print "HDF write err = ",err
6474//      endif
6475//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6476////    err = V_KillNamedDataFolder(fname)
6477////    if(err)
6478////            Print "DataFolder kill err = ",err
6479////    endif
6480//      return(err)
6481//end
6482
6483
6484// for temperature only, logStr must be "temperature_env"
6485Function V_writeTempLog_ControlSensor(fname,logStr,str)
6486        String fname,logStr,str
6487
6488//      String path = "entry:sample:"+logstr+":control_sensor"
6489
6490        Make/O/T/N=1 tmpTW
6491        String groupName = "/entry/sample/"+logStr
6492        String varName = "control_sensor"
6493        tmpTW[0] = str //
6494
6495        variable err
6496        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6497        if(err)
6498                Print "HDF write err = ",err
6499        endif
6500       
6501        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6502//      err = V_KillNamedDataFolder(fname)
6503//      if(err)
6504//              Print "DataFolder kill err = ",err
6505//      endif
6506               
6507        return(err)
6508End
6509
6510// for temperature only, logStr must be "temperature_env"
6511Function V_writeTempLog_MonitorSensor(fname,logStr,str)
6512        String fname,logStr,str
6513
6514//      String path = "entry:sample:"+logstr+":monitor_sensor"
6515
6516        Make/O/T/N=1 tmpTW
6517        String groupName = "/entry/sample/"+logStr
6518        String varName = "monitor_sensor"
6519        tmpTW[0] = str //
6520
6521        variable err
6522        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6523        if(err)
6524                Print "HDF write err = ",err
6525        endif
6526       
6527        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6528//      err = V_KillNamedDataFolder(fname)
6529//      if(err)
6530//              Print "DataFolder kill err = ",err
6531//      endif
6532               
6533        return(err)
6534End
6535
6536
6537
6538////////////////////
6539//
6540///////////
6541// NOTE
6542//
6543// for temperature, the "attached_to", "measurement", and "name" fields
6544// are one level down farther than before, and down deeper than for other sensors
6545//
6546//
6547// read the value of V_getTemp_MonitorSensor/ControlSensor to get the name of the sensor level .
6548//
6549
6550Function V_writeTempLog_attachedTo(fname,logStr,str)
6551        String fname,logStr,str
6552
6553//      String path = "entry:sample:temperature_env:"+logstr+":attached_to"
6554
6555        Make/O/T/N=1 tmpTW
6556        String groupName = "/entry/sample/temperature_env/"+logStr
6557        String varName = "attached_to"
6558        tmpTW[0] = str //
6559
6560        variable err
6561        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6562        if(err)
6563                Print "HDF write err = ",err
6564        endif
6565       
6566        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6567//      err = V_KillNamedDataFolder(fname)
6568//      if(err)
6569//              Print "DataFolder kill err = ",err
6570//      endif
6571               
6572        return(err)
6573End
6574
6575
6576Function V_writeTempLog_highTrip(fname,logStr,val)
6577        String fname,logStr
6578        Variable val
6579       
6580//      String path = "entry:sample:temperature_env:"+logstr+":high_trip_value"
6581       
6582        Make/O/D/N=1 wTmpWrite
6583//      Make/O/R/N=1 wTmpWrite
6584        String groupName = "/entry/sample/temperature_env/"+logStr
6585        String varName = "high_trip_value"
6586        wTmpWrite[0] = val
6587
6588        variable err
6589        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6590        if(err)
6591                Print "HDF write err = ",err
6592        endif
6593        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6594//      err = V_KillNamedDataFolder(fname)
6595//      if(err)
6596//              Print "DataFolder kill err = ",err
6597//      endif
6598        return(err)
6599end
6600
6601Function V_writeTempLog_holdTime(fname,logStr,val)
6602        String fname,logStr
6603        Variable val
6604       
6605//      String path = "entry:sample:temperature_env:"+logstr+":hold_time"
6606       
6607        Make/O/D/N=1 wTmpWrite
6608//      Make/O/R/N=1 wTmpWrite
6609        String groupName = "/entry/sample/temperature_env/"+logStr
6610        String varName = "hold_time"
6611        wTmpWrite[0] = val
6612
6613        variable err
6614        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6615        if(err)
6616                Print "HDF write err = ",err
6617        endif
6618        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6619//      err = V_KillNamedDataFolder(fname)
6620//      if(err)
6621//              Print "DataFolder kill err = ",err
6622//      endif
6623        return(err)
6624end
6625
6626Function V_writeTempLog_lowTrip(fname,logStr,val)
6627        String fname,logStr
6628        Variable val
6629       
6630//      String path = "entry:sample:temperature_env:"+logstr+":low_trip_value"
6631       
6632        Make/O/D/N=1 wTmpWrite
6633//      Make/O/R/N=1 wTmpWrite
6634        String groupName = "/entry/sample/temperature_env/"+logStr
6635        String varName = "low_trip_value"
6636        wTmpWrite[0] = val
6637
6638        variable err
6639        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6640        if(err)
6641                Print "HDF write err = ",err
6642        endif
6643        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6644//      err = V_KillNamedDataFolder(fname)
6645//      if(err)
6646//              Print "DataFolder kill err = ",err
6647//      endif
6648        return(err)
6649end
6650
6651Function V_writeTempLog_measurement(fname,logStr,str)
6652        String fname,logStr,str
6653
6654//      String path = "entry:sample:temperature_env:"+logstr+":measurement"
6655
6656        Make/O/T/N=1 tmpTW
6657        String groupName = "/entry/sample/temperature_env/"+logStr
6658        String varName = "measurement"
6659        tmpTW[0] = str //
6660
6661        variable err
6662        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6663        if(err)
6664                Print "HDF write err = ",err
6665        endif
6666       
6667        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6668//      err = V_KillNamedDataFolder(fname)
6669//      if(err)
6670//              Print "DataFolder kill err = ",err
6671//      endif
6672               
6673        return(err)
6674End
6675
6676Function V_writeTempLog_model(fname,logStr,str)
6677        String fname,logStr,str
6678
6679//      String path = "entry:sample:temperature_env:"+logstr+":model"
6680
6681        Make/O/T/N=1 tmpTW
6682        String groupName = "/entry/sample/temperature_env/"+logStr
6683        String varName = "model"
6684        tmpTW[0] = str //
6685
6686        variable err
6687        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6688        if(err)
6689                Print "HDF write err = ",err
6690        endif
6691       
6692        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6693//      err = V_KillNamedDataFolder(fname)
6694//      if(err)
6695//              Print "DataFolder kill err = ",err
6696//      endif
6697               
6698        return(err)
6699End
6700
6701Function V_writeTempLog_name(fname,logStr,str)
6702        String fname,logStr,str
6703
6704//      String path = "entry:sample:temperature_env:"+logstr+":name"
6705
6706        Make/O/T/N=1 tmpTW
6707        String groupName = "/entry/sample/temperature_env/"+logStr
6708        String varName = "name"
6709        tmpTW[0] = str //
6710
6711        variable err
6712        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6713        if(err)
6714                Print "HDF write err = ",err
6715        endif
6716       
6717        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6718//      err = V_KillNamedDataFolder(fname)
6719//      if(err)
6720//              Print "DataFolder kill err = ",err
6721//      endif
6722               
6723        return(err)
6724End
6725
6726Function V_writeTempLog_runControl(fname,logStr,val)
6727        String fname,logStr
6728        Variable val
6729       
6730//      String path = "entry:sample:temperature_env:"+logstr+":run_control"
6731       
6732        Make/O/D/N=1 wTmpWrite
6733//      Make/O/R/N=1 wTmpWrite
6734        String groupName = "/entry/sample/temperature_env/"+logStr
6735        String varName = "run_control"
6736        wTmpWrite[0] = val
6737
6738        variable err
6739        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6740        if(err)
6741                Print "HDF write err = ",err
6742        endif
6743        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6744//      err = V_KillNamedDataFolder(fname)
6745//      if(err)
6746//              Print "DataFolder kill err = ",err
6747//      endif
6748        return(err)
6749end
6750
6751Function V_writeTempLog_setPoint(fname,logStr,val)
6752        String fname,logStr
6753        Variable val
6754       
6755//      String path = "entry:sample:temperature_env:"+logstr+":setpoint"
6756       
6757        Make/O/D/N=1 wTmpWrite
6758//      Make/O/R/N=1 wTmpWrite
6759        String groupName = "/entry/sample/temperature_env/"+logStr
6760        String varName = "setpoint"
6761        wTmpWrite[0] = val
6762
6763        variable err
6764        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6765        if(err)
6766                Print "HDF write err = ",err
6767        endif
6768        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6769//      err = V_KillNamedDataFolder(fname)
6770//      if(err)
6771//              Print "DataFolder kill err = ",err
6772//      endif
6773        return(err)
6774end
6775
6776Function V_writeTempLog_shortName(fname,logStr,str)
6777        String fname,logStr,str
6778
6779//      String path = "entry:sample:temperature_env:"+logstr+":short_name"
6780
6781        Make/O/T/N=1 tmpTW
6782        String groupName = "/entry/sample/temperature_env/"+logStr
6783        String varName = "short_name"
6784        tmpTW[0] = str //
6785
6786        variable err
6787        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6788        if(err)
6789                Print "HDF write err = ",err
6790        endif
6791       
6792        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6793//      err = V_KillNamedDataFolder(fname)
6794//      if(err)
6795//              Print "DataFolder kill err = ",err
6796//      endif
6797               
6798        return(err)
6799End
6800
6801Function V_writeTempLog_timeout(fname,logStr,val)
6802        String fname,logStr
6803        Variable val
6804       
6805//      String path = "entry:sample:temperature_env:"+logstr+":timeout"
6806       
6807        Make/O/D/N=1 wTmpWrite
6808//      Make/O/R/N=1 wTmpWrite
6809        String groupName = "/entry/sample/temperature_env/"+logStr
6810        String varName = "timeout"
6811        wTmpWrite[0] = val
6812
6813        variable err
6814        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6815        if(err)
6816                Print "HDF write err = ",err
6817        endif
6818        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6819//      err = V_KillNamedDataFolder(fname)
6820//      if(err)
6821//              Print "DataFolder kill err = ",err
6822//      endif
6823        return(err)
6824end
6825
6826Function V_writeTempLog_tolerance(fname,logStr,val)
6827        String fname,logStr
6828        Variable val
6829       
6830//      String path = "entry:sample:temperature_env:"+logstr+":tolerance"
6831       
6832        Make/O/D/N=1 wTmpWrite
6833//      Make/O/R/N=1 wTmpWrite
6834        String groupName = "/entry/sample/temperature_env/"+logStr
6835        String varName = "tolerance"
6836        wTmpWrite[0] = val
6837
6838        variable err
6839        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6840        if(err)
6841                Print "HDF write err = ",err
6842        endif
6843        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6844//      err = V_KillNamedDataFolder(fname)
6845//      if(err)
6846//              Print "DataFolder kill err = ",err
6847//      endif
6848        return(err)
6849end
6850
6851Function V_writeTempLog_toleranceBand(fname,logStr,val)
6852        String fname,logStr
6853        Variable val
6854       
6855//      String path = "entry:sample:temperature_env:"+logstr+":tolerance_band_time"
6856       
6857        Make/O/D/N=1 wTmpWrite
6858//      Make/O/R/N=1 wTmpWrite
6859        String groupName = "/entry/sample/temperature_env/"+logStr
6860        String varName = "tolerance_band_time"
6861        wTmpWrite[0] = val
6862
6863        variable err
6864        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6865        if(err)
6866                Print "HDF write err = ",err
6867        endif
6868        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6869//      err = V_KillNamedDataFolder(fname)
6870//      if(err)
6871//              Print "DataFolder kill err = ",err
6872//      endif
6873        return(err)
6874end
6875
6876Function V_writeTempLog_Value(fname,logStr,val)
6877        String fname,logStr
6878        Variable val
6879       
6880//      String path = "entry:sample:temperature_env:"+logstr+":value"
6881       
6882        Make/O/D/N=1 wTmpWrite
6883//      Make/O/R/N=1 wTmpWrite
6884        String groupName = "/entry/sample/temperature_env/"+logStr
6885        String varName = "value"
6886        wTmpWrite[0] = val
6887
6888        variable err
6889        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6890        if(err)
6891                Print "HDF write err = ",err
6892        endif
6893        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6894//      err = V_KillNamedDataFolder(fname)
6895//      if(err)
6896//              Print "DataFolder kill err = ",err
6897//      endif
6898        return(err)
6899end
6900
6901
6902
6903
6904
6905//
6906// temperature_env:temp_Internal_1:value_log
6907//
6908////            value_log (data folder)
6909//
6910// TODO:
6911// -- be sure that the calling function properly calls for temperture
6912// logs which are down an extra layer:
6913//      for example, logStr = "temperature_env:temp_Internal_1"
6914//
6915// read the value of V_getTemp_MonitorSensor to get the name of the sensor the next level down.
6916//
6917//
6918/////////////////////////////////////
6919////            value_log (data folder)
6920//
6921// TODO --
6922Function V_writeLog_avgValue(fname,logStr,val)
6923        String fname,logStr
6924        Variable val
6925       
6926//      String path = "entry:sample:"+logstr+":value_log:average_value"
6927       
6928        Make/O/D/N=1 wTmpWrite
6929//      Make/O/R/N=1 wTmpWrite
6930        String groupName = "/entry/sample/"+logStr+"/value_log"
6931        String varName = "average_value"
6932        wTmpWrite[0] = val
6933
6934        variable err
6935        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6936        if(err)
6937                Print "HDF write err = ",err
6938        endif
6939        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6940//      err = V_KillNamedDataFolder(fname)
6941//      if(err)
6942//              Print "DataFolder kill err = ",err
6943//      endif
6944        return(err)
6945end
6946
6947Function V_writeLog_avgValue_err(fname,logStr,val)
6948        String fname,logStr
6949        Variable val
6950       
6951//      String path = "entry:sample:"+logstr+":value_log:average_value_error"
6952       
6953        Make/O/D/N=1 wTmpWrite
6954//      Make/O/R/N=1 wTmpWrite
6955        String groupName = "/entry/sample/"+logStr+"/value_log"
6956        String varName = "average_value_error"
6957        wTmpWrite[0] = val
6958
6959        variable err
6960        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6961        if(err)
6962                Print "HDF write err = ",err
6963        endif
6964        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6965//      err = V_KillNamedDataFolder(fname)
6966//      if(err)
6967//              Print "DataFolder kill err = ",err
6968//      endif
6969        return(err)
6970end
6971
6972Function V_writeLog_maximumValue(fname,logStr,val)
6973        String fname,logStr
6974        Variable val
6975       
6976//      String path = "entry:sample:"+logstr+":value_log:maximum_value"
6977       
6978        Make/O/D/N=1 wTmpWrite
6979//      Make/O/R/N=1 wTmpWrite
6980        String groupName = "/entry/sample/"+logStr+"/value_log"
6981        String varName = "maximum_value"
6982        wTmpWrite[0] = val
6983
6984        variable err
6985        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6986        if(err)
6987                Print "HDF write err = ",err
6988        endif
6989        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6990//      err = V_KillNamedDataFolder(fname)
6991//      if(err)
6992//              Print "DataFolder kill err = ",err
6993//      endif
6994        return(err)
6995end
6996
6997Function V_writeLog_medianValue(fname,logStr,val)
6998        String fname,logStr
6999        Variable val
7000       
7001//      String path = "entry:sample:"+logstr+":value_log:median_value"
7002       
7003        Make/O/D/N=1 wTmpWrite
7004//      Make/O/R/N=1 wTmpWrite
7005        String groupName = "/entry/sample/"+logStr+"/value_log"
7006        String varName = "median_value"
7007        wTmpWrite[0] = val
7008
7009        variable err
7010        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7011        if(err)
7012                Print "HDF write err = ",err
7013        endif
7014        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7015//      err = V_KillNamedDataFolder(fname)
7016//      if(err)
7017//              Print "DataFolder kill err = ",err
7018//      endif
7019        return(err)
7020end
7021
7022Function V_writeLog_minimumValue(fname,logStr,val)
7023        String fname,logStr
7024        Variable val
7025       
7026//      String path = "entry:sample:"+logstr+":value_log:minimum_value"
7027       
7028        Make/O/D/N=1 wTmpWrite
7029//      Make/O/R/N=1 wTmpWrite
7030        String groupName = "/entry/sample/"+logStr+"/value_log"
7031        String varName = "minimum_value"
7032        wTmpWrite[0] = val
7033
7034        variable err
7035        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7036        if(err)
7037                Print "HDF write err = ",err
7038        endif
7039        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7040//      err = V_KillNamedDataFolder(fname)
7041//      if(err)
7042//              Print "DataFolder kill err = ",err
7043//      endif
7044        return(err)
7045end
7046
7047
7048
7049// TODO -- this needs to be a WAVE reference
7050// be sure this gets written as "time", even though it is read in as "time0"
7051Function V_writeLog_timeWave(fname,logStr,inW)
7052        String fname,logStr
7053        Wave inW
7054       
7055//      String path = "entry:sample:"+logstr+":value_log:time"
7056
7057        Duplicate/O inW wTmpWrite       
7058// then use redimension as needed to cast the wave to write to the specified type
7059// see WaveType for the proper codes
7060//      Redimension/T=() wTmpWrite
7061// -- May also need to check the dimension(s) before writing (don't trust the input)
7062        String groupName = "/entry/sample/"+logStr+"/value_log"
7063        String varName = "time"
7064
7065        variable err
7066        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7067        if(err)
7068                Print "HDF write err = ",err
7069        endif
7070        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7071//      err = V_KillNamedDataFolder(fname)
7072//      if(err)
7073//              Print "DataFolder kill err = ",err
7074//      endif
7075        return(err)
7076end
7077
7078
7079// TODO -- this needs to be a WAVE reference
7080Function V_writeLog_ValueWave(fname,logStr,inW)
7081        String fname,logStr
7082        Wave inW
7083       
7084//      String path = "entry:sample:"+logstr+":value_log:value"
7085
7086        Duplicate/O inW wTmpWrite       
7087// then use redimension as needed to cast the wave to write to the specified type
7088// see WaveType for the proper codes
7089//      Redimension/T=() wTmpWrite
7090// -- May also need to check the dimension(s) before writing (don't trust the input)
7091        String groupName = "/entry/sample/"+logStr+"/value_log"
7092        String varName = "value"
7093
7094        variable err
7095        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7096        if(err)
7097                Print "HDF write err = ",err
7098        endif
7099        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7100//      err = V_KillNamedDataFolder(fname)
7101//      if(err)
7102//              Print "DataFolder kill err = ",err
7103//      endif
7104        return(err)
7105end
7106
7107
7108
7109
7110
7111
7112
7113
7114///////// REDUCTION
7115///////// REDUCTION
7116///////// REDUCTION
7117
7118
7119// TODO
7120// -- come up with a scheme to write the entire protocol to the data file?
7121// -- or a scheme to write just the missing bits?
7122
7123
7124// TODO -- needs to be a Text WAVE, and of the proper size and type!!!
7125//  -- this is a test where I write a wave to a field that does not exist...
7126Function V_writeReductionProtocolWave(fname,inTW)
7127        String fname
7128        Wave/T inTW
7129       
7130//      String path = "entry:reduction:absolute_scaling"
7131       
7132        Duplicate/O inTW wTTmpWrite     
7133// then use redimension as needed to cast the wave to write to the specified type
7134// see WaveType for the proper codes
7135//      Redimension/T=() wTmpWrite
7136// -- May also need to check the dimension(s) before writing (don't trust the input)
7137        String groupName = "/entry/reduction"   
7138        String varName = "protocol"
7139
7140        variable err
7141        err = V_WriteWaveToHDF(fname, groupName, varName, wTTmpWrite)
7142        if(err)
7143                Print "HDF write err = ",err
7144        endif
7145        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7146//      err = V_KillNamedDataFolder(fname)
7147//      if(err)
7148//              Print "DataFolder kill err = ",err
7149//      endif
7150        return(err)
7151end
7152
7153
7154// this is a NON NICE entered field
7155//
7156// this is a flag to mark the file as "flipped" so it prevents a 2nd flip
7157// if the flip has been done, the field is written with a value of 1 (= true)
7158//
7159// to "un-mark" the file and allow the flip to be re-done, write -999999
7160Function V_writeLeftRightFlipDone(fname,val)
7161        String fname
7162        Variable val
7163       
7164//      String path = "entry:reduction:left_right_flip"
7165       
7166        Make/O/D/N=1 wTmpWrite
7167//      Make/O/R/N=1 wTmpWrite
7168        String groupName = "/entry/reduction"
7169        String varName = "left_right_flip"
7170        wTmpWrite[0] = val
7171
7172        variable err
7173        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7174        if(err)
7175                Print "HDF write err = ",err
7176        endif
7177        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7178//      err = V_KillNamedDataFolder(fname)
7179//      if(err)
7180//              Print "DataFolder kill err = ",err
7181//      endif
7182        return(err)
7183end
7184
7185
7186
7187// TODO -- needs to be a WAVE, and of the proper size and type!!!
7188Function V_writeAbsolute_Scaling(fname,inW)
7189        String fname
7190        Wave inW
7191       
7192//      String path = "entry:reduction:absolute_scaling"
7193       
7194        Duplicate/O inW wTmpWrite       
7195// then use redimension as needed to cast the wave to write to the specified type
7196// see WaveType for the proper codes
7197//      Redimension/T=() wTmpWrite
7198// -- May also need to check the dimension(s) before writing (don't trust the input)
7199        String groupName = "/entry/reduction"   
7200        String varName = "absolute_scaling"
7201
7202        variable err
7203        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7204        if(err)
7205                Print "HDF write err = ",err
7206        endif
7207        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7208//      err = V_KillNamedDataFolder(fname)
7209//      if(err)
7210//              Print "DataFolder kill err = ",err
7211//      endif
7212        return(err)
7213end
7214
7215Function V_writeBackgroundFileName(fname,str)
7216        String fname,str
7217
7218//      String path = "entry:reduction:background_file_name"   
7219
7220        Make/O/T/N=1 tmpTW
7221        String groupName = "/entry/reduction"
7222        String varName = "background_file_name"
7223        tmpTW[0] = str //
7224
7225        variable err
7226        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7227        if(err)
7228                Print "HDF write err = ",err
7229        endif
7230       
7231        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7232//      err = V_KillNamedDataFolder(fname)
7233//      if(err)
7234//              Print "DataFolder kill err = ",err
7235//      endif
7236               
7237        return(err)
7238End
7239
7240
7241// TODO -- needs to be a WAVE
7242Function V_writeBoxCoordinates(fname,inW)
7243        String fname
7244        Wave inW
7245       
7246//      String path = "entry:reduction:box_coordinates"
7247               
7248        Duplicate/O inW wTmpWrite       
7249// then use redimension as needed to cast the wave to write to the specified type
7250// see WaveType for the proper codes
7251//      Redimension/T=() wTmpWrite
7252// -- May also need to check the dimension(s) before writing (don't trust the input)
7253        String groupName = "/entry/reduction"   
7254        String varName = "box_coordinates"
7255
7256        variable err
7257        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7258        if(err)
7259                Print "HDF write err = ",err
7260        endif
7261        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7262//      err = V_KillNamedDataFolder(fname)
7263//      if(err)
7264//              Print "DataFolder kill err = ",err
7265//      endif
7266        return(err)
7267end
7268
7269// THIS IS A NON-NICE ENTERED FIELD
7270// -- this is the panel string where the box coordinates refer to (for the open beam and transmission)
7271Function V_writeReduction_BoxPanel(fname,str)
7272        String fname,str
7273
7274//      String path = "entry:reduction:comments"       
7275
7276        Make/O/T/N=1 tmpTW
7277        String groupName = "/entry/reduction"
7278        String varName = "box_panel"
7279        tmpTW[0] = str //
7280
7281        variable err
7282        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7283        if(err)
7284                Print "HDF write err = ",err
7285        endif
7286       
7287        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7288//      err = V_KillNamedDataFolder(fname)
7289//      if(err)
7290//              Print "DataFolder kill err = ",err
7291//      endif
7292               
7293        return(err)
7294End
7295
7296//box counts
7297Function V_writeBoxCounts(fname,val)
7298        String fname
7299        Variable val
7300       
7301//      String path = "entry:reduction:box_count"       
7302       
7303        Make/O/D/N=1 wTmpWrite
7304//      Make/O/R/N=1 wTmpWrite
7305        String groupName = "/entry/reduction"
7306        String varName = "box_count"
7307        wTmpWrite[0] = val
7308
7309        variable err
7310        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7311        if(err)
7312                Print "HDF write err = ",err
7313        endif
7314        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7315//      err = V_KillNamedDataFolder(fname)
7316//      if(err)
7317//              Print "DataFolder kill err = ",err
7318//      endif
7319        return(err)
7320end
7321
7322//box counts error
7323Function V_writeBoxCountsError(fname,val)
7324        String fname
7325        Variable val
7326       
7327//      String path = "entry:reduction:box_count_error"
7328       
7329        Make/O/D/N=1 wTmpWrite
7330//      Make/O/R/N=1 wTmpWrite
7331        String groupName = "/entry/reduction"
7332        String varName = "box_count_error"
7333        wTmpWrite[0] = val
7334
7335        variable err
7336        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7337        if(err)
7338                Print "HDF write err = ",err
7339        endif
7340        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7341//      err = V_KillNamedDataFolder(fname)
7342//      if(err)
7343//              Print "DataFolder kill err = ",err
7344//      endif
7345        return(err)
7346end
7347
7348Function V_writeReductionComments(fname,str)
7349        String fname,str
7350
7351//      String path = "entry:reduction:comments"       
7352
7353        Make/O/T/N=1 tmpTW
7354        String groupName = "/entry/reduction"
7355        String varName = "comments"
7356        tmpTW[0] = str //
7357
7358        variable err
7359        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7360        if(err)
7361                Print "HDF write err = ",err
7362        endif
7363       
7364        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7365//      err = V_KillNamedDataFolder(fname)
7366//      if(err)
7367//              Print "DataFolder kill err = ",err
7368//      endif
7369               
7370        return(err)
7371End
7372
7373Function V_writeEmptyBeamFileName(fname,str)
7374        String fname,str
7375
7376//      String path = "entry:reduction:empty_beam_file_name"   
7377
7378        Make/O/T/N=1 tmpTW
7379        String groupName = "/entry/reduction"
7380        String varName = "empty_beam_file_name"
7381        tmpTW[0] = str //
7382
7383        variable err
7384        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7385        if(err)
7386                Print "HDF write err = ",err
7387        endif
7388       
7389        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7390//      err = V_KillNamedDataFolder(fname)
7391//      if(err)
7392//              Print "DataFolder kill err = ",err
7393//      endif
7394               
7395        return(err)
7396End
7397
7398Function V_writeEmptyFileName(fname,str)
7399        String fname,str
7400
7401//      String path = "entry:reduction:empty_beam_file_name"   
7402
7403        Make/O/T/N=1 tmpTW
7404        String groupName = "/entry/reduction"
7405        String varName = "empty_file_name"
7406        tmpTW[0] = str //
7407
7408        variable err
7409        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7410        if(err)
7411                Print "HDF write err = ",err
7412        endif
7413       
7414        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7415//      err = V_KillNamedDataFolder(fname)
7416//      if(err)
7417//              Print "DataFolder kill err = ",err
7418//      endif
7419               
7420        return(err)
7421End
7422
7423Function V_writeReduction_purpose(fname,str)
7424        String fname,str
7425
7426//      String path = "entry:reduction:file_purpose"   
7427
7428        Make/O/T/N=1 tmpTW
7429        String groupName = "/entry/reduction"
7430        String varName = "file_purpose"
7431        tmpTW[0] = str //
7432
7433        variable err
7434        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7435        if(err)
7436                Print "HDF write err = ",err
7437        endif
7438       
7439        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7440//      err = V_KillNamedDataFolder(fname)
7441//      if(err)
7442//              Print "DataFolder kill err = ",err
7443//      endif
7444               
7445        return(err)
7446End
7447
7448// DONE x- commented out, not to be used
7449//  x- is this duplicated? - yes - this is duplicated in /entry/sample
7450//  x- so I need to pick a location, or be sure to fix it in both places
7451//Function V_writeReduction_group_ID(fname,val)
7452//      String fname
7453//      Variable val
7454//     
7455////    String path = "entry:reduction:group_id"       
7456//     
7457//      Make/O/D/N=1 wTmpWrite
7458////    Make/O/R/N=1 wTmpWrite
7459//      String groupName = "/entry/reduction"
7460//      String varName = "group_id"
7461//      wTmpWrite[0] = val
7462//
7463//      variable err
7464//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7465//      if(err)
7466//              Print "HDF write err = ",err
7467//      endif
7468//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7469////    err = V_KillNamedDataFolder(fname)
7470////    if(err)
7471////            Print "DataFolder kill err = ",err
7472////    endif
7473//      return(err)
7474//end
7475
7476Function V_writeReductionIntent(fname,str)
7477        String fname,str
7478
7479//      String path = "entry:reduction:intent" 
7480
7481        Make/O/T/N=1 tmpTW
7482        String groupName = "/entry/reduction"
7483        String varName = "intent"
7484        tmpTW[0] = str //
7485
7486        variable err
7487        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7488        if(err)
7489                Print "HDF write err = ",err
7490        endif
7491       
7492        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7493//      err = V_KillNamedDataFolder(fname)
7494//      if(err)
7495//              Print "DataFolder kill err = ",err
7496//      endif
7497               
7498        return(err)
7499End
7500
7501Function V_writeMaskFileName(fname,str)
7502        String fname,str
7503
7504//      String path = "entry:reduction:empty_beam_file_name"   
7505
7506        Make/O/T/N=1 tmpTW
7507        String groupName = "/entry/reduction"
7508        String varName = "mask_file_name"
7509        tmpTW[0] = str //
7510
7511        variable err
7512        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7513        if(err)
7514                Print "HDF write err = ",err
7515        endif
7516       
7517        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7518//      err = V_KillNamedDataFolder(fname)
7519//      if(err)
7520//              Print "DataFolder kill err = ",err
7521//      endif
7522               
7523        return(err)
7524End
7525
7526
7527
7528Function V_writeLogFileName(fname,str)
7529        String fname,str
7530
7531//      String path = "entry:reduction:sans_log_file_name"     
7532
7533        Make/O/T/N=1 tmpTW
7534        String groupName = "/entry/reduction"
7535        String varName = "sans_log_file_name"
7536        tmpTW[0] = str //
7537
7538        variable err
7539        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7540        if(err)
7541                Print "HDF write err = ",err
7542        endif
7543       
7544        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7545//      err = V_KillNamedDataFolder(fname)
7546//      if(err)
7547//              Print "DataFolder kill err = ",err
7548//      endif
7549               
7550        return(err)
7551End
7552
7553
7554Function V_writeSensitivityFileName(fname,str)
7555        String fname,str
7556
7557//      String path = "entry:reduction:sensitivity_file_name"   
7558
7559        Make/O/T/N=1 tmpTW
7560        String groupName = "/entry/reduction"
7561        String varName = "sensitivity_file_name"
7562        tmpTW[0] = str //
7563
7564        variable err
7565        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7566        if(err)
7567                Print "HDF write err = ",err
7568        endif
7569       
7570        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7571//      err = V_KillNamedDataFolder(fname)
7572//      if(err)
7573//              Print "DataFolder kill err = ",err
7574//      endif
7575               
7576        return(err)
7577End
7578
7579Function V_writeTransmissionFileName(fname,str)
7580        String fname,str
7581
7582//      String path = "entry:reduction:transmission_file_name" 
7583
7584        Make/O/T/N=1 tmpTW
7585        String groupName = "/entry/reduction"
7586        String varName = "transmission_file_name"
7587        tmpTW[0] = str //
7588
7589        variable err
7590        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7591        if(err)
7592                Print "HDF write err = ",err
7593        endif
7594       
7595        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7596//      err = V_KillNamedDataFolder(fname)
7597//      if(err)
7598//              Print "DataFolder kill err = ",err
7599//      endif
7600               
7601        return(err)
7602End
7603
7604
7605//whole detector transmission
7606Function V_writeSampleTransWholeDetector(fname,val)
7607        String fname
7608        Variable val
7609       
7610//      String path = "entry:reduction:whole_trans"     
7611       
7612        Make/O/D/N=1 wTmpWrite
7613//      Make/O/R/N=1 wTmpWrite
7614        String groupName = "/entry/reduction"
7615        String varName = "whole_trans"
7616        wTmpWrite[0] = val
7617
7618        variable err
7619        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7620        if(err)
7621                Print "HDF write err = ",err
7622        endif
7623        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7624//      err = V_KillNamedDataFolder(fname)
7625//      if(err)
7626//              Print "DataFolder kill err = ",err
7627//      endif
7628        return(err)
7629end
7630
7631//whole detector transmission error
7632Function V_writeSampleTransWholeDetErr(fname,val)
7633        String fname
7634        Variable val
7635       
7636//      String path = "entry:reduction:whole_trans_error"       
7637       
7638        Make/O/D/N=1 wTmpWrite
7639//      Make/O/R/N=1 wTmpWrite
7640        String groupName = "/entry/reduction"
7641        String varName = "whole_trans_error"
7642        wTmpWrite[0] = val
7643
7644        variable err
7645        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7646        if(err)
7647                Print "HDF write err = ",err
7648        endif
7649        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7650//      err = V_KillNamedDataFolder(fname)
7651//      if(err)
7652//              Print "DataFolder kill err = ",err
7653//      endif
7654        return(err)
7655end
7656
7657                       
7658///////                 pol_sans (data folder)
7659//
7660//Function V_writePolSANS_cellName(fname,str)
7661//      String fname,str
7662//
7663////    String path = "entry:reduction:pol_sans:cell_name"     
7664//
7665//      Make/O/T/N=1 tmpTW
7666//      String groupName = "/entry/reduction/pol_sans"
7667//      String varName = "cell_name"
7668//      tmpTW[0] = str //
7669//
7670//      variable err
7671//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7672//      if(err)
7673//              Print "HDF write err = ",err
7674//      endif
7675//     
7676//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7677////    err = V_KillNamedDataFolder(fname)
7678////    if(err)
7679////            Print "DataFolder kill err = ",err
7680////    endif
7681//             
7682//      return(err)
7683//End
7684//
7685//
7686//// TODO -- needs to be a WAVE
7687//// is this a text wave?? if it's mixed names + values, then what?
7688//Function V_writePolSANS_cellParams(fname,inW)
7689//      String fname
7690//      Wave inW
7691//     
7692////    String path = "entry:reduction:pol_sans:cell_parameters"
7693//             
7694//      Duplicate/O inW wTmpWrite       
7695//// then use redimension as needed to cast the wave to write to the specified type
7696//// see WaveType for the proper codes
7697////    Redimension/T=() wTmpWrite
7698//// -- May also need to check the dimension(s) before writing (don't trust the input)
7699//      String groupName = "/entry/reduction/pol_sans" 
7700//      String varName = "cell_parameters"
7701//
7702//      variable err
7703//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7704//      if(err)
7705//              Print "HDF write err = ",err
7706//      endif
7707//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7708////    err = V_KillNamedDataFolder(fname)
7709////    if(err)
7710////            Print "DataFolder kill err = ",err
7711////    endif
7712//      return(err)
7713//end
7714//
7715//Function V_writePolSANS_PolSANSPurpose(fname,str)
7716//      String fname,str
7717//
7718////    String path = "entry:reduction:pol_sans:pol_sans_purpose"       
7719//
7720//      Make/O/T/N=1 tmpTW
7721//      String groupName = "/entry/reduction/pol_sans"
7722//      String varName = "pol_sans_purpose"
7723//      tmpTW[0] = str //
7724//
7725//      variable err
7726//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7727//      if(err)
7728//              Print "HDF write err = ",err
7729//      endif
7730//     
7731//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7732////    err = V_KillNamedDataFolder(fname)
7733////    if(err)
7734////            Print "DataFolder kill err = ",err
7735////    endif
7736//             
7737//      return(err)
7738//End
7739
7740                               
7741//////// TOP LEVEL DATA REPRESENTATION
7742//
7743// note that here the data is (supposed to be) a link, not the actual data
7744// Igor HDf implementation cannot follow links properly, as far as I know.
7745// so ignore them here, and focus on the image that may be possible to read
7746//
7747
7748//              data_B (data folder)
7749//                      data (wave) 1           //ignore this, it's a link
7750//                      variables (wave) 320
7751//                      thumbnail (data folder)
7752
7753////data (wave) "binary"
7754//// TODO -- this will need to be completely replaced with a function that can
7755//// read the binary image data. should be possible, but I don't know the details on either end...
7756//Function V_writeDataImage(fname,detStr,str)
7757//      String fname,detStr,str
7758//
7759////    String path = "entry:data_"+detStr+":thumbnail:data"   
7760//
7761//      Make/O/T/N=1 tmpTW
7762//      String groupName = "/entry/data_"+detStr+"/thumbnail"
7763//      String varName = "data"
7764//      tmpTW[0] = str //
7765//
7766//      variable err
7767//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7768//      if(err)
7769//              Print "HDF write err = ",err
7770//      endif
7771//     
7772//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7773////    err = V_KillNamedDataFolder(fname)
7774////    if(err)
7775////            Print "DataFolder kill err = ",err
7776////    endif
7777//             
7778//      return(err)
7779//End
7780//
7781//Function V_writeDataImageDescription(fname,detStr,str)
7782//      String fname,detStr,str
7783//
7784////    String path = "entry:data_"+detStr+":thumbnail:description"     
7785//
7786//      Make/O/T/N=1 tmpTW
7787//      String groupName = "/entry/data_"+detStr+"/thumbnail"
7788//      String varName = "description"
7789//      tmpTW[0] = str //
7790//
7791//      variable err
7792//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7793//      if(err)
7794//              Print "HDF write err = ",err
7795//      endif
7796//     
7797//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7798////    err = V_KillNamedDataFolder(fname)
7799////    if(err)
7800////            Print "DataFolder kill err = ",err
7801////    endif
7802//             
7803//      return(err)
7804//End
7805//                                                             
7806//Function V_writeDataImageType(fname,detStr,str)
7807//      String fname,detStr,str
7808//
7809////    String path = "entry:data_"+detStr+":thumbnail:type"   
7810//
7811//      Make/O/T/N=1 tmpTW
7812//      String groupName = "/entry/data_"+detStr+"/thumbnail"
7813//      String varName = "type"
7814//      tmpTW[0] = str //
7815//
7816//      variable err
7817//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7818//      if(err)
7819//              Print "HDF write err = ",err
7820//      endif
7821//     
7822//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7823////    err = V_KillNamedDataFolder(fname)
7824////    if(err)
7825////            Print "DataFolder kill err = ",err
7826////    endif
7827//             
7828//      return(err)
7829//End
7830//
Note: See TracBrowser for help on using the repository browser.