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

Last change on this file since 1034 was 1034, checked in by srkline, 6 years ago

re-wrote raw data reader for significant speed boost (mostly by skipping the read of DAS_logs)

added centroid calculation to the Marquee

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