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

Last change on this file since 1094 was 1094, checked in by srkline, 4 years ago

corrected issues with transmission calculation where the popup menu of sample files was limited in number. this limitation has been removed.

fixed the re-calculation of transmission when the same value is to be patched to multiple sample files with the same group ID. now the transmission is calculated once, for the first file in the popup and the values are simply written to the remaining files.

when the box for the open beam is defined, the panel where it is located is written to the file in a new field under /reduction. it is later recalled in the transmission panel.

Defined a "Reference" beam center position for each carriage as the RIGHT panel center. then all other panel centers (L, T, B) can be derived from this value. if the beam center is measured on the Left panel, it is converted to "right" coordinates before reporting.

File size: 188.7 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
1166Function 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)
1189end
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// gap when panels are "touching"
4443// units are mm
4444// writes panel gap for detector panel specified
4445// does not write anything if "B" is passed (no such field for this detector)
4446//
4447Function V_writeDet_panel_gap(fname,detStr,val)
4448        String fname,detStr
4449        Variable val
4450
4451        if(cmpstr(detStr,"B") == 0)
4452                return(0)
4453        endif
4454       
4455//      String path = "entry:instrument:detector_"+detStr+":panel_gap"
4456
4457        Make/O/D/N=1 wTmpWrite
4458//      Make/O/R/N=1 wTmpWrite
4459        String groupName = "/entry/instrument/detector_"+detStr
4460        String varName = "panel_gap"
4461        wTmpWrite[0] = val
4462
4463        variable err
4464        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4465        if(err)
4466                Print "HDF write err = ",err
4467        endif
4468        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4469//      err = V_KillNamedDataFolder(fname)
4470//      if(err)
4471//              Print "DataFolder kill err = ",err
4472//      endif
4473        return(err)
4474End
4475
4476
4477
4478//// only defined for the "B" detector, and only to satisfy NXsas
4479//Function V_writeDet_polar_angle(fname,detStr,val)
4480//      String fname,detStr
4481//      Variable val
4482//
4483//      if(cmpstr(detStr,"B") == 0)
4484////            String path = "entry:instrument:detector_"+detStr+":polar_angle"
4485//     
4486//              Make/O/D/N=1 wTmpWrite
4487//      //      Make/O/R/N=1 wTmpWrite
4488//              String groupName = "/entry/instrument/detector_"+detStr
4489//              String varName = "polar_angle"
4490//              wTmpWrite[0] = val
4491//
4492//              variable err
4493//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4494//              if(err)
4495//                      Print "HDF write err = ",err
4496//              endif
4497//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4498////            err = V_KillNamedDataFolder(fname)
4499////            if(err)
4500////                    Print "DataFolder kill err = ",err
4501////            endif
4502//              return(err)
4503//      else
4504//              return(0)
4505//      endif
4506//End
4507
4508//// only defined for the "B" detector, and only to satisfy NXsas
4509//Function V_writeDet_rotational_angle(fname,detStr,val)
4510//      String fname,detStr
4511//      Variable val
4512//
4513//      if(cmpstr(detStr,"B") == 0)
4514////            String path = "entry:instrument:detector_"+detStr+":rotational_angle"
4515//     
4516//              Make/O/D/N=1 wTmpWrite
4517//      //      Make/O/R/N=1 wTmpWrite
4518//              String groupName = "/entry/instrument/detector_"+detStr
4519//              String varName = "rotational_angle"
4520//              wTmpWrite[0] = val
4521//
4522//              variable err
4523//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4524//              if(err)
4525//                      Print "HDF write err = ",err
4526//              endif
4527//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4528////            err = V_KillNamedDataFolder(fname)
4529////            if(err)
4530////                    Print "DataFolder kill err = ",err
4531////            endif
4532//              return(err)
4533//      else
4534//              return(0)
4535//      endif
4536//End
4537
4538Function V_writeDetSettings(fname,detStr,str)
4539        String fname,detStr,str
4540
4541//      String path = "entry:instrument:detector_"+detStr+":settings"
4542
4543        Make/O/T/N=1 tmpTW
4544        String groupName = "/entry/instrument/detector_"+detStr //     
4545        String varName = "settings"
4546        tmpTW[0] = str //
4547
4548        variable err
4549        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4550        if(err)
4551                Print "HDF write err = ",err
4552        endif
4553       
4554        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4555//      err = V_KillNamedDataFolder(fname)
4556//      if(err)
4557//              Print "DataFolder kill err = ",err
4558//      endif
4559               
4560        return(err)
4561End
4562
4563//// really has no meaning at all
4564//Function V_writeDet_size(fname,detStr,val)
4565//      String fname,detStr
4566//      Variable val
4567//
4568////    String path = "entry:instrument:detector_"+detStr+":size"
4569//     
4570//      Make/O/D/N=1 wTmpWrite
4571////    Make/O/R/N=1 wTmpWrite
4572//      String groupName = "/entry/instrument/detector_"+detStr
4573//      String varName = "size"
4574//      wTmpWrite[0] = val
4575//
4576//      variable err
4577//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4578//      if(err)
4579//              Print "HDF write err = ",err
4580//      endif
4581//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4582////    err = V_KillNamedDataFolder(fname)
4583////    if(err)
4584////            Print "DataFolder kill err = ",err
4585////    endif
4586//      return(err)
4587//End
4588
4589//Function V_writeDetType(fname,detStr,str)
4590//      String fname,detStr,str
4591//
4592////    String path = "entry:instrument:detector_"+detStr+":type"
4593//
4594//      Make/O/T/N=1 tmpTW
4595//      String groupName = "/entry/instrument/detector_"+detStr //     
4596//      String varName = "type"
4597//      tmpTW[0] = str //
4598//
4599//      variable err
4600//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4601//      if(err)
4602//              Print "HDF write err = ",err
4603//      endif
4604//     
4605//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4606////    err = V_KillNamedDataFolder(fname)
4607////    if(err)
4608////            Print "DataFolder kill err = ",err
4609////    endif
4610//             
4611//      return(err)
4612//End
4613
4614Function V_writeDet_x_pixel_size(fname,detStr,val)
4615        String fname,detStr
4616        Variable val
4617
4618//      String path = "entry:instrument:detector_"+detStr+":x_pixel_size"
4619       
4620        Make/O/D/N=1 wTmpWrite
4621//      Make/O/R/N=1 wTmpWrite
4622        String groupName = "/entry/instrument/detector_"+detStr
4623        String varName = "x_pixel_size"
4624        wTmpWrite[0] = val
4625
4626        variable err
4627        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4628        if(err)
4629                Print "HDF write err = ",err
4630        endif
4631        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4632//      err = V_KillNamedDataFolder(fname)
4633//      if(err)
4634//              Print "DataFolder kill err = ",err
4635//      endif
4636        return(err)
4637End
4638
4639Function V_writeDet_y_pixel_size(fname,detStr,val)
4640        String fname,detStr
4641        Variable val
4642
4643//      String path = "entry:instrument:detector_"+detStr+":y_pixel_size"
4644       
4645        Make/O/D/N=1 wTmpWrite
4646//      Make/O/R/N=1 wTmpWrite
4647        String groupName = "/entry/instrument/detector_"+detStr
4648        String varName = "y_pixel_size"
4649        wTmpWrite[0] = val
4650
4651        variable err
4652        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4653        if(err)
4654                Print "HDF write err = ",err
4655        endif
4656        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4657//      err = V_KillNamedDataFolder(fname)
4658//      if(err)
4659//              Print "DataFolder kill err = ",err
4660//      endif
4661        return(err)
4662End
4663
4664/////////                       detector_FB (data folder) + ALL other PANEL DETECTORS
4665
4666// integer value
4667Function V_writeDet_numberOfTubes(fname,detStr,val)
4668        String fname,detStr
4669        Variable val
4670
4671//      String path = "entry:instrument:detector_"+detStr+":number_of_tubes"
4672        if(cmpstr(detStr,"B") == 0)
4673                return(0)
4674        else
4675       
4676                Make/O/I/N=1 wTmpWrite
4677        //      Make/O/R/N=1 wTmpWrite
4678                String groupName = "/entry/instrument/detector_"+detStr
4679                String varName = "number_of_tubes"
4680                wTmpWrite[0] = val
4681
4682                variable err
4683                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4684                if(err)
4685                        Print "HDF write err = ",err
4686                endif
4687                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4688//              err = V_KillNamedDataFolder(fname)
4689//              if(err)
4690//                      Print "DataFolder kill err = ",err
4691//              endif
4692                return(err)
4693        endif
4694End
4695
4696// deleted from definition
4697//Function V_writeDetPanelSeparation(fname,detStr,val)
4698//      String fname,detStr
4699//      Variable val
4700//
4701////    String path = "entry:instrument:detector_"+detStr+":separation"
4702//      if(cmpstr(detStr,"B") == 0)
4703//              return(0)
4704//      else
4705//     
4706//              Make/O/D/N=1 wTmpWrite
4707//      //      Make/O/R/N=1 wTmpWrite
4708//              String groupName = "/entry/instrument/detector_"+detStr
4709//              String varName = "separation"
4710//              wTmpWrite[0] = val
4711//
4712//              variable err
4713//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4714//              if(err)
4715//                      Print "HDF write err = ",err
4716//              endif
4717//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4718////            err = V_KillNamedDataFolder(fname)
4719////            if(err)
4720////                    Print "DataFolder kill err = ",err
4721////            endif
4722//              return(err)
4723//      endif
4724//End
4725
4726// TODO -- write this function to return a WAVE with the data
4727// either as a wave reference, or as an input parameter
4728Function V_writeDetTube_spatialCalib(fname,detStr,inW)
4729        String fname,detStr
4730        Wave inW
4731
4732//      String path = "entry:instrument:detector_"+detStr+":spatial_calibration"
4733
4734        if(cmpstr(detStr,"B") == 0)
4735                return(0)
4736        else
4737                Duplicate/O inW wTmpWrite       
4738        // then use redimension as needed to cast the wave to write to the specified type
4739        // see WaveType for the proper codes
4740        //      Redimension/T=() wTmpWrite
4741        // -- May also need to check the dimension(s) before writing (don't trust the input)
4742                String groupName = "/entry/instrument/detector_"+detStr
4743                String varName = "spatial_calibration"
4744
4745                variable err
4746                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4747                if(err)
4748                        Print "HDF write err = ",err
4749                endif
4750                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4751//              err = V_KillNamedDataFolder(fname)
4752//              if(err)
4753//                      Print "DataFolder kill err = ",err
4754//              endif
4755                return(err)
4756        endif
4757End
4758
4759//// TODO -- be clear on how this is defined.
4760//Function V_writeDet_tubeIndex(fname,detStr,val)
4761//      String fname,detStr
4762//      Variable val
4763//
4764////    String path = "entry:instrument:detector_"+detStr+":tube_index"
4765//      if(cmpstr(detStr,"B") == 0)
4766//              return(0)
4767//      else
4768//     
4769//              Make/O/D/N=1 wTmpWrite
4770//      //      Make/O/R/N=1 wTmpWrite
4771//              String groupName = "/entry/instrument/detector_"+detStr
4772//              String varName = "tube_index"
4773//              wTmpWrite[0] = val
4774//
4775//              variable err
4776//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4777//              if(err)
4778//                      Print "HDF write err = ",err
4779//              endif
4780//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4781////            err = V_KillNamedDataFolder(fname)
4782////            if(err)
4783////                    Print "DataFolder kill err = ",err
4784////            endif
4785//              return(err)
4786//      endif
4787//End
4788
4789Function V_writeDet_tubeOrientation(fname,detStr,str)
4790        String fname,detStr,str
4791
4792//      String path = "entry:instrument:detector_"+detStr+":tube_orientation"
4793
4794        if(cmpstr(detStr,"B") == 0)
4795                return(0)
4796        else
4797                Make/O/T/N=1 tmpTW
4798                String groupName = "/entry/instrument/detector_"+detStr //     
4799                String varName = "tube_orientation"
4800                tmpTW[0] = str //
4801
4802                variable err
4803                err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4804                if(err)
4805                        Print "HDF write err = ",err
4806                endif
4807       
4808                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4809//              err = V_KillNamedDataFolder(fname)
4810//              if(err)
4811//                      Print "DataFolder kill err = ",err
4812//              endif
4813               
4814                return(err)
4815
4816        endif
4817End
4818
4819// TODO -- be clear on how this is defined. Units?
4820Function V_writeDet_tubeWidth(fname,detStr,val)
4821        String fname,detStr
4822        Variable val
4823
4824//      String path = "entry:instrument:detector_"+detStr+":tube_width"
4825        if(cmpstr(detStr,"B") == 0)
4826                return(0)
4827        else
4828       
4829                Make/O/D/N=1 wTmpWrite
4830        //      Make/O/R/N=1 wTmpWrite
4831                String groupName = "/entry/instrument/detector_"+detStr
4832                String varName = "tube_width"
4833                wTmpWrite[0] = val
4834
4835                variable err
4836                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4837                if(err)
4838                        Print "HDF write err = ",err
4839                endif
4840                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4841//              err = V_KillNamedDataFolder(fname)
4842//              if(err)
4843//                      Print "DataFolder kill err = ",err
4844//              endif
4845                return(err)
4846        endif
4847End
4848
4849//////////////////////
4850
4851// INSTRUMENT/LENSES    /APERTURES
4852//  lenses (data folder)
4853
4854Function V_writeLensCurvature(fname,val)
4855        String fname
4856        Variable val
4857
4858//      String path = "entry:instrument:lenses:curvature"
4859       
4860        Make/O/D/N=1 wTmpWrite
4861//      Make/O/R/N=1 wTmpWrite
4862        String groupName = "/entry/instrument/lenses"
4863        String varName = "curvature"
4864        wTmpWrite[0] = val
4865
4866        variable err
4867        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4868        if(err)
4869                Print "HDF write err = ",err
4870        endif
4871        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4872//      err = V_KillNamedDataFolder(fname)
4873//      if(err)
4874//              Print "DataFolder kill err = ",err
4875//      endif
4876        return(err)
4877End
4878
4879Function V_writeLensesFocusType(fname,str)
4880        String fname,str
4881
4882//      String path = "entry:instrument:lenses:focus_type"
4883
4884        Make/O/T/N=1 tmpTW
4885        String groupName = "/entry/instrument/lenses"
4886        String varName = "focus_type"
4887        tmpTW[0] = str //
4888
4889        variable err
4890        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4891        if(err)
4892                Print "HDF write err = ",err
4893        endif
4894       
4895        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4896//      err = V_KillNamedDataFolder(fname)
4897//      if(err)
4898//              Print "DataFolder kill err = ",err
4899//      endif
4900               
4901        return(err)
4902End
4903
4904Function V_writeLensDistance(fname,val)
4905        String fname
4906        Variable val
4907
4908//      String path = "entry:instrument:lenses:lens_distance"
4909       
4910        Make/O/D/N=1 wTmpWrite
4911//      Make/O/R/N=1 wTmpWrite
4912        String groupName = "/entry/instrument/lenses"
4913        String varName = "lens_distance"
4914        wTmpWrite[0] = val
4915
4916        variable err
4917        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4918        if(err)
4919                Print "HDF write err = ",err
4920        endif
4921        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4922//      err = V_KillNamedDataFolder(fname)
4923//      if(err)
4924//              Print "DataFolder kill err = ",err
4925//      endif
4926        return(err)
4927End
4928
4929Function V_writeLensGeometry(fname,str)
4930        String fname,str
4931
4932//      String path = "entry:instrument:lenses:lens_geometry"
4933
4934        Make/O/T/N=1 tmpTW
4935        String groupName = "/entry/instrument/lenses"
4936        String varName = "lens_geometry"
4937        tmpTW[0] = str //
4938
4939        variable err
4940        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4941        if(err)
4942                Print "HDF write err = ",err
4943        endif
4944       
4945        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4946//      err = V_KillNamedDataFolder(fname)
4947//      if(err)
4948//              Print "DataFolder kill err = ",err
4949//      endif
4950               
4951        return(err)
4952End
4953
4954Function V_writeLensMaterial(fname,str)
4955        String fname,str
4956
4957//      String path = "entry:instrument:lenses:lens_material"
4958
4959        Make/O/T/N=1 tmpTW
4960        String groupName = "/entry/instrument/lenses"
4961        String varName = "lens_material"
4962        tmpTW[0] = str //
4963
4964        variable err
4965        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4966        if(err)
4967                Print "HDF write err = ",err
4968        endif
4969       
4970        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4971//      err = V_KillNamedDataFolder(fname)
4972//      if(err)
4973//              Print "DataFolder kill err = ",err
4974//      endif
4975               
4976        return(err)
4977End
4978
4979// integer value
4980Function V_writeNumber_of_Lenses(fname,val)
4981        String fname
4982        Variable val
4983
4984//      String path = "entry:instrument:lenses:number_of_lenses"
4985       
4986        Make/O/I/N=1 wTmpWrite
4987//      Make/O/R/N=1 wTmpWrite
4988        String groupName = "/entry/instrument/lenses"
4989        String varName = "number_of_lenses"
4990        wTmpWrite[0] = val
4991
4992        variable err
4993        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4994        if(err)
4995                Print "HDF write err = ",err
4996        endif
4997        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4998//      err = V_KillNamedDataFolder(fname)
4999//      if(err)
5000//              Print "DataFolder kill err = ",err
5001//      endif
5002        return(err)
5003End
5004
5005// integer value
5006Function V_writeNumber_of_prisms(fname,val)
5007        String fname
5008        Variable val
5009
5010//      String path = "entry:instrument:lenses:number_of_prisms"
5011       
5012        Make/O/I/N=1 wTmpWrite
5013//      Make/O/R/N=1 wTmpWrite
5014        String groupName = "/entry/instrument/lenses"
5015        String varName = "number_of_prisms"
5016        wTmpWrite[0] = val
5017
5018        variable err
5019        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5020        if(err)
5021                Print "HDF write err = ",err
5022        endif
5023        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5024//      err = V_KillNamedDataFolder(fname)
5025//      if(err)
5026//              Print "DataFolder kill err = ",err
5027//      endif
5028        return(err)
5029End
5030
5031Function V_writePrism_distance(fname,val)
5032        String fname
5033        Variable val
5034
5035//      String path = "entry:instrument:lenses:prism_distance"
5036       
5037        Make/O/D/N=1 wTmpWrite
5038//      Make/O/R/N=1 wTmpWrite
5039        String groupName = "/entry/instrument/lenses"
5040        String varName = "prism_distance"
5041        wTmpWrite[0] = val
5042
5043        variable err
5044        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5045        if(err)
5046                Print "HDF write err = ",err
5047        endif
5048        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5049//      err = V_KillNamedDataFolder(fname)
5050//      if(err)
5051//              Print "DataFolder kill err = ",err
5052//      endif
5053        return(err)
5054End
5055
5056Function V_writePrismMaterial(fname,str)
5057        String fname,str
5058
5059//      String path = "entry:instrument:lenses:prism_material"
5060
5061        Make/O/T/N=1 tmpTW
5062        String groupName = "/entry/instrument/lenses"
5063        String varName = "prism_material"
5064        tmpTW[0] = str //
5065
5066        variable err
5067        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5068        if(err)
5069                Print "HDF write err = ",err
5070        endif
5071       
5072        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5073//      err = V_KillNamedDataFolder(fname)
5074//      if(err)
5075//              Print "DataFolder kill err = ",err
5076//      endif
5077               
5078        return(err)
5079End
5080
5081// status of lens/prism = lens | prism | both | out
5082Function V_writeLensPrismStatus(fname,str)
5083        String fname,str
5084
5085//      String path = "entry:instrument:lenses:status"
5086
5087        Make/O/T/N=1 tmpTW
5088        String groupName = "/entry/instrument/lenses"
5089        String varName = "status"
5090        tmpTW[0] = str //
5091
5092        variable err
5093        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5094        if(err)
5095                Print "HDF write err = ",err
5096        endif
5097       
5098        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5099//      err = V_KillNamedDataFolder(fname)
5100//      if(err)
5101//              Print "DataFolder kill err = ",err
5102//      endif
5103               
5104        return(err)
5105End
5106       
5107
5108///////  sample_aperture (1) (data folder)
5109// this is the INTERNAL sample aperture
5110Function V_writeSampleAp_Description(fname,str)
5111        String fname,str
5112
5113//      String path = "entry:instrument:sample_aperture:description"
5114
5115        Make/O/T/N=1 tmpTW
5116        String groupName = "/entry/instrument/sample_aperture"
5117        String varName = "description"
5118        tmpTW[0] = str //
5119
5120        variable err
5121        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5122        if(err)
5123                Print "HDF write err = ",err
5124        endif
5125       
5126        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5127//      err = V_KillNamedDataFolder(fname)
5128//      if(err)
5129//              Print "DataFolder kill err = ",err
5130//      endif
5131               
5132        return(err)
5133End
5134
5135Function V_writeSampleAp_distance(fname,val)
5136        String fname
5137        Variable val
5138
5139//      String path = "entry:instrument:sample_aperture:distance"
5140       
5141        Make/O/D/N=1 wTmpWrite
5142//      Make/O/R/N=1 wTmpWrite
5143        String groupName = "/entry/instrument/sample_aperture"
5144        String varName = "distance"
5145        wTmpWrite[0] = val
5146
5147        variable err
5148        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5149        if(err)
5150                Print "HDF write err = ",err
5151        endif
5152        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5153//      err = V_KillNamedDataFolder(fname)
5154//      if(err)
5155//              Print "DataFolder kill err = ",err
5156//      endif
5157        return(err)
5158End
5159
5160//      sample_apertuer/shape (data folder)
5161Function V_writeSampleAp_height(fname,val)
5162        String fname
5163        Variable val
5164
5165//      String path = "entry:instrument:sample_aperture:distance"
5166       
5167        Make/O/D/N=1 wTmpWrite
5168//      Make/O/R/N=1 wTmpWrite
5169        String groupName = "/entry/instrument/sample_aperture/shape"
5170        String varName = "height"
5171        wTmpWrite[0] = val
5172
5173        variable err
5174        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5175        if(err)
5176                Print "HDF write err = ",err
5177        endif
5178        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5179//      err = V_KillNamedDataFolder(fname)
5180//      if(err)
5181//              Print "DataFolder kill err = ",err
5182//      endif
5183        return(err)
5184End
5185
5186Function V_writeSampleAp_shape(fname,str)
5187        String fname,str
5188
5189//      String path = "entry:instrument:sample_aperture:shape:shape"
5190
5191        Make/O/T/N=1 tmpTW
5192        String groupName = "/entry/instrument/sample_aperture/shape"
5193        String varName = "shape"
5194        tmpTW[0] = str //
5195
5196        variable err
5197        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5198        if(err)
5199                Print "HDF write err = ",err
5200        endif
5201       
5202        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5203//      err = V_KillNamedDataFolder(fname)
5204//      if(err)
5205//              Print "DataFolder kill err = ",err
5206//      endif
5207               
5208        return(err)
5209End
5210
5211Function V_writeSampleAp_size(fname,str)
5212        String fname,str
5213
5214//      String path = "entry:instrument:sample_aperture:shape:shape"
5215
5216        Make/O/T/N=1 tmpTW
5217        String groupName = "/entry/instrument/sample_aperture/shape"
5218        String varName = "size"
5219        tmpTW[0] = str //
5220
5221        variable err
5222        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5223        if(err)
5224                Print "HDF write err = ",err
5225        endif
5226       
5227        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5228//      err = V_KillNamedDataFolder(fname)
5229//      if(err)
5230//              Print "DataFolder kill err = ",err
5231//      endif
5232               
5233        return(err)
5234End
5235
5236Function V_writeSampleAp_width(fname,val)
5237        String fname
5238        Variable val
5239
5240//      String path = "entry:instrument:sample_aperture:distance"
5241       
5242        Make/O/D/N=1 wTmpWrite
5243//      Make/O/R/N=1 wTmpWrite
5244        String groupName = "/entry/instrument/sample_aperture/shape"
5245        String varName = "width"
5246        wTmpWrite[0] = val
5247
5248        variable err
5249        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5250        if(err)
5251                Print "HDF write err = ",err
5252        endif
5253        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5254//      err = V_KillNamedDataFolder(fname)
5255//      if(err)
5256//              Print "DataFolder kill err = ",err
5257//      endif
5258        return(err)
5259End
5260
5261///////  sample_aperture_2 (data folder)
5262// sample aperture (2) is the external aperture, which may or may not be present
5263
5264Function V_writeSampleAp2_Description(fname,str)
5265        String fname,str
5266
5267//      String path = "entry:instrument:sample_aperture_2:description"
5268
5269        Make/O/T/N=1 tmpTW
5270        String groupName = "/entry/instrument/sample_aperture_2"
5271        String varName = "description"
5272        tmpTW[0] = str //
5273
5274        variable err
5275        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5276        if(err)
5277                Print "HDF write err = ",err
5278        endif
5279       
5280        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5281//      err = V_KillNamedDataFolder(fname)
5282//      if(err)
5283//              Print "DataFolder kill err = ",err
5284//      endif
5285               
5286        return(err)
5287End
5288
5289Function V_writeSampleAp2_distance(fname,val)
5290        String fname
5291        Variable val
5292
5293//      String path = "entry:instrument:sample_aperture_2:distance"
5294       
5295        Make/O/D/N=1 wTmpWrite
5296//      Make/O/R/N=1 wTmpWrite
5297        String groupName = "/entry/instrument/sample_aperture_2"
5298        String varName = "distance"
5299        wTmpWrite[0] = val
5300
5301        variable err
5302        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5303        if(err)
5304                Print "HDF write err = ",err
5305        endif
5306        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5307//      err = V_KillNamedDataFolder(fname)
5308//      if(err)
5309//              Print "DataFolder kill err = ",err
5310//      endif
5311        return(err)
5312End
5313
5314
5315//      shape (data folder)
5316Function V_writeSampleAp2_height(fname,val)
5317        String fname
5318        Variable val
5319
5320//      String path = "entry:instrument:sample_aperture:distance"
5321       
5322        Make/O/D/N=1 wTmpWrite
5323//      Make/O/R/N=1 wTmpWrite
5324        String groupName = "/entry/instrument/sample_aperture_2/shape"
5325        String varName = "height"
5326        wTmpWrite[0] = val
5327
5328        variable err
5329        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5330        if(err)
5331                Print "HDF write err = ",err
5332        endif
5333        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5334//      err = V_KillNamedDataFolder(fname)
5335//      if(err)
5336//              Print "DataFolder kill err = ",err
5337//      endif
5338        return(err)
5339End
5340
5341Function V_writeSampleAp2_shape(fname,str)
5342        String fname,str
5343
5344//      String path = "entry:instrument:sample_aperture_2:shape:shape"
5345
5346        Make/O/T/N=1 tmpTW
5347        String groupName = "/entry/instrument/sample_aperture_2/shape"
5348        String varName = "shape"
5349        tmpTW[0] = str //
5350
5351        variable err
5352        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5353        if(err)
5354                Print "HDF write err = ",err
5355        endif
5356       
5357        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5358//      err = V_KillNamedDataFolder(fname)
5359//      if(err)
5360//              Print "DataFolder kill err = ",err
5361//      endif
5362               
5363        return(err)
5364End
5365
5366Function V_writeSampleAp2_size(fname,val)
5367        String fname
5368        Variable val
5369
5370//      String path = "entry:instrument:sample_aperture:distance"
5371       
5372        Make/O/D/N=1 wTmpWrite
5373//      Make/O/R/N=1 wTmpWrite
5374        String groupName = "/entry/instrument/sample_aperture_2/shape"
5375        String varName = "size"
5376        wTmpWrite[0] = val
5377
5378        variable err
5379        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5380        if(err)
5381                Print "HDF write err = ",err
5382        endif
5383        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5384//      err = V_KillNamedDataFolder(fname)
5385//      if(err)
5386//              Print "DataFolder kill err = ",err
5387//      endif
5388        return(err)
5389End
5390
5391Function V_writeSampleAp2_width(fname,val)
5392        String fname
5393        Variable val
5394
5395//      String path = "entry:instrument:sample_aperture:distance"
5396       
5397        Make/O/D/N=1 wTmpWrite
5398//      Make/O/R/N=1 wTmpWrite
5399        String groupName = "/entry/instrument/sample_aperture_2/shape"
5400        String varName = "width"
5401        wTmpWrite[0] = val
5402
5403        variable err
5404        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5405        if(err)
5406                Print "HDF write err = ",err
5407        endif
5408        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5409//      err = V_KillNamedDataFolder(fname)
5410//      if(err)
5411//              Print "DataFolder kill err = ",err
5412//      endif
5413        return(err)
5414End
5415
5416               
5417//////  sample_table (data folder)
5418// location  = "CHAMBER" or HUBER
5419Function V_writeSampleTableLocation(fname,str)
5420        String fname,str
5421
5422//      String path = "entry:instrument:sample_table:location"
5423
5424        Make/O/T/N=1 tmpTW
5425        String groupName = "/entry/instrument/sample_table"
5426        String varName = "location"
5427        tmpTW[0] = str //
5428
5429        variable err
5430        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5431        if(err)
5432                Print "HDF write err = ",err
5433        endif
5434       
5435        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5436//      err = V_KillNamedDataFolder(fname)
5437//      if(err)
5438//              Print "DataFolder kill err = ",err
5439//      endif
5440               
5441        return(err)
5442End
5443
5444// TODO - verify the meaning
5445//      offset_distance (?? for center of sample table vs. sample position)
5446Function V_writeSampleTableOffset(fname,val)
5447        String fname
5448        Variable val
5449
5450//      String path = "entry:instrument:sample_table:offset_distance"
5451       
5452        Make/O/D/N=1 wTmpWrite
5453//      Make/O/R/N=1 wTmpWrite
5454        String groupName = "/entry/instrument/sample_table"
5455        String varName = "offset_distance"
5456        wTmpWrite[0] = val
5457
5458        variable err
5459        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5460        if(err)
5461                Print "HDF write err = ",err
5462        endif
5463        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5464//      err = V_KillNamedDataFolder(fname)
5465//      if(err)
5466//              Print "DataFolder kill err = ",err
5467//      endif
5468        return(err)
5469End     
5470       
5471//  source (data folder)
5472//name "NCNR"
5473Function V_writeSourceName(fname,str)
5474        String fname,str
5475
5476//      String path = "entry:instrument:source:name"
5477
5478        Make/O/T/N=1 tmpTW
5479        String groupName = "/entry/instrument/source"
5480        String varName = "name"
5481        tmpTW[0] = str //
5482
5483        variable err
5484        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5485        if(err)
5486                Print "HDF write err = ",err
5487        endif
5488       
5489        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5490//      err = V_KillNamedDataFolder(fname)
5491//      if(err)
5492//              Print "DataFolder kill err = ",err
5493//      endif
5494               
5495        return(err)
5496End
5497
5498//      power -- nominal only, not connected to any real number
5499Function V_writeReactorPower(fname,val)
5500        String fname
5501        Variable val
5502
5503//      String path = "entry:instrument:source:power"
5504       
5505        Make/O/D/N=1 wTmpWrite
5506//      Make/O/R/N=1 wTmpWrite
5507        String groupName = "/entry/instrument/source"
5508        String varName = "power"
5509        wTmpWrite[0] = val
5510
5511        variable err
5512        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5513        if(err)
5514                Print "HDF write err = ",err
5515        endif
5516        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5517//      err = V_KillNamedDataFolder(fname)
5518//      if(err)
5519//              Print "DataFolder kill err = ",err
5520//      endif
5521        return(err)
5522End     
5523
5524//probe (wave) "neutron"
5525Function V_writeSourceProbe(fname,str)
5526        String fname,str
5527
5528//      String path = "entry:instrument:source:probe"
5529
5530        Make/O/T/N=1 tmpTW
5531        String groupName = "/entry/instrument/source"
5532        String varName = "probe"
5533        tmpTW[0] = str //
5534
5535        variable err
5536        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5537        if(err)
5538                Print "HDF write err = ",err
5539        endif
5540       
5541        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5542//      err = V_KillNamedDataFolder(fname)
5543//      if(err)
5544//              Print "DataFolder kill err = ",err
5545//      endif
5546               
5547        return(err)
5548End
5549
5550//type (wave) "Reactor Neutron Source"
5551Function V_writeSourceType(fname,str)
5552        String fname,str
5553
5554//      String path = "entry:instrument:source:type"
5555
5556        Make/O/T/N=1 tmpTW
5557        String groupName = "/entry/instrument/source"
5558        String varName = "type"
5559        tmpTW[0] = str //
5560
5561        variable err
5562        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5563        if(err)
5564                Print "HDF write err = ",err
5565        endif
5566       
5567        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5568//      err = V_KillNamedDataFolder(fname)
5569//      if(err)
5570//              Print "DataFolder kill err = ",err
5571//      endif
5572               
5573        return(err)
5574End
5575
5576       
5577///////  source_aperture (data folder)
5578
5579Function V_writeSourceAp_Description(fname,str)
5580        String fname,str
5581
5582//      String path = "entry:instrument:source_aperture:description"
5583
5584        Make/O/T/N=1 tmpTW
5585        String groupName = "/entry/instrument/source_aperture"
5586        String varName = "description"
5587        tmpTW[0] = str //
5588
5589        variable err
5590        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5591        if(err)
5592                Print "HDF write err = ",err
5593        endif
5594       
5595        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5596//      err = V_KillNamedDataFolder(fname)
5597//      if(err)
5598//              Print "DataFolder kill err = ",err
5599//      endif
5600               
5601        return(err)
5602End
5603
5604Function V_writeSourceAp_distance(fname,val)
5605        String fname
5606        Variable val
5607
5608//      String path = "entry:instrument:source_aperture:distance"
5609       
5610        Make/O/D/N=1 wTmpWrite
5611//      Make/O/R/N=1 wTmpWrite
5612        String groupName = "/entry/instrument/source_aperture"
5613        String varName = "distance"
5614        wTmpWrite[0] = val
5615
5616        variable err
5617        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5618        if(err)
5619                Print "HDF write err = ",err
5620        endif
5621        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5622//      err = V_KillNamedDataFolder(fname)
5623//      if(err)
5624//              Print "DataFolder kill err = ",err
5625//      endif
5626        return(err)
5627End
5628
5629
5630//      shape (data folder)
5631Function V_writeSourceAp_height(fname,val)
5632        String fname
5633        Variable val
5634
5635//      String path = "entry:instrument:sample_aperture:distance"
5636       
5637        Make/O/D/N=1 wTmpWrite
5638//      Make/O/R/N=1 wTmpWrite
5639        String groupName = "/entry/instrument/source_aperture/shape"
5640        String varName = "height"
5641        wTmpWrite[0] = val
5642
5643        variable err
5644        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5645        if(err)
5646                Print "HDF write err = ",err
5647        endif
5648        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5649//      err = V_KillNamedDataFolder(fname)
5650//      if(err)
5651//              Print "DataFolder kill err = ",err
5652//      endif
5653        return(err)
5654End
5655
5656Function V_writeSourceAp_shape(fname,str)
5657        String fname,str
5658
5659//      String path = "entry:instrument:source_aperture:shape:shape"
5660
5661        Make/O/T/N=1 tmpTW
5662        String groupName = "/entry/instrument/source_aperture/shape"
5663        String varName = "shape"
5664        tmpTW[0] = str //
5665
5666        variable err
5667        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5668        if(err)
5669                Print "HDF write err = ",err
5670        endif
5671       
5672        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5673//      err = V_KillNamedDataFolder(fname)
5674//      if(err)
5675//              Print "DataFolder kill err = ",err
5676//      endif
5677               
5678        return(err)
5679End
5680
5681Function V_writeSourceAp_size(fname,str)
5682        String fname,str
5683
5684//      String path = "entry:instrument:source_aperture:shape:shape"
5685
5686        Make/O/T/N=1 tmpTW
5687        String groupName = "/entry/instrument/source_aperture/shape"
5688        String varName = "size"
5689        tmpTW[0] = str //
5690
5691        variable err
5692        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5693        if(err)
5694                Print "HDF write err = ",err
5695        endif
5696       
5697        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5698//      err = V_KillNamedDataFolder(fname)
5699//      if(err)
5700//              Print "DataFolder kill err = ",err
5701//      endif
5702               
5703        return(err)
5704End
5705
5706Function V_writeSourceAp_width(fname,val)
5707        String fname
5708        Variable val
5709
5710//      String path = "entry:instrument:sample_aperture:distance"
5711       
5712        Make/O/D/N=1 wTmpWrite
5713//      Make/O/R/N=1 wTmpWrite
5714        String groupName = "/entry/instrument/source_aperture/shape"
5715        String varName = "width"
5716        wTmpWrite[0] = val
5717
5718        variable err
5719        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5720        if(err)
5721                Print "HDF write err = ",err
5722        endif
5723        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5724//      err = V_KillNamedDataFolder(fname)
5725//      if(err)
5726//              Print "DataFolder kill err = ",err
5727//      endif
5728        return(err)
5729End
5730
5731
5732//////// SAMPLE
5733//////// SAMPLE
5734//////// SAMPLE
5735
5736//Sample position in changer
5737Function V_writeSamplePosition(fname,str)
5738        String fname,str
5739
5740//      String path = "entry:sample:changer_position"   
5741
5742        Make/O/T/N=1 tmpTW
5743        String groupName = "/entry/sample"
5744        String varName = "changer_position"
5745        tmpTW[0] = str //
5746
5747        variable err
5748        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5749        if(err)
5750                Print "HDF write err = ",err
5751        endif
5752       
5753        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5754//      err = V_KillNamedDataFolder(fname)
5755//      if(err)
5756//              Print "DataFolder kill err = ",err
5757//      endif
5758               
5759        return(err)
5760End
5761
5762
5763// sample label
5764// TODO: value of num is currently not used
5765Function V_writeSampleDescription(fname,str)
5766        String fname,str
5767
5768//      String path = "entry:sample:description"
5769
5770        Make/O/T/N=1 tmpTW
5771        String groupName = "/entry/sample"
5772        String varName = "description"
5773        tmpTW[0] = str //
5774
5775        variable err
5776        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5777        if(err)
5778                Print "HDF write err = ",err
5779        endif
5780       
5781        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5782//      err = V_KillNamedDataFolder(fname)
5783//      if(err)
5784//              Print "DataFolder kill err = ",err
5785//      endif
5786               
5787        return(err)
5788End
5789
5790// for a z-stage??
5791Function V_writeSample_elevation(fname,val)
5792        String fname
5793        Variable val
5794       
5795//      String path = "entry:sample:elevation" 
5796       
5797        Make/O/D/N=1 wTmpWrite
5798//      Make/O/R/N=1 wTmpWrite
5799        String groupName = "/entry/sample"
5800        String varName = "elevation"
5801        wTmpWrite[0] = val
5802
5803        variable err
5804        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5805        if(err)
5806                Print "HDF write err = ",err
5807        endif
5808        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5809//      err = V_KillNamedDataFolder(fname)
5810//      if(err)
5811//              Print "DataFolder kill err = ",err
5812//      endif
5813        return(err)
5814end
5815
5816//no meaning to this...
5817Function V_writeSample_equatorial_ang(fname,val)
5818        String fname
5819        Variable val
5820       
5821//      String path = "entry:sample:equatorial_angle"   
5822       
5823        Make/O/D/N=1 wTmpWrite
5824//      Make/O/R/N=1 wTmpWrite
5825        String groupName = "/entry/sample"
5826        String varName = "equatorial_angle"
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//
5844// TODO x- I need to make sure that this is an integer in the JSON definition
5845//              x- currently a text value in the data file - see trac ticket
5846// x- this is also a duplicated field in the reduction block (reduction/group_id is no longer used)
5847//
5848// group ID !!! very important for matching up files
5849// integer value
5850//
5851Function V_writeSample_GroupID(fname,val)
5852        String fname
5853        Variable val
5854       
5855//      String path = "entry:sample:group_id"   
5856       
5857        Make/O/I/N=1 wTmpWrite
5858//      Make/O/R/N=1 wTmpWrite
5859        String groupName = "/entry/sample"
5860        String varName = "group_id"
5861        wTmpWrite[0] = val
5862
5863        variable err
5864        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5865        if(err)
5866                Print "HDF write err = ",err
5867        endif
5868        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5869//      err = V_KillNamedDataFolder(fname)
5870//      if(err)
5871//              Print "DataFolder kill err = ",err
5872//      endif
5873        return(err)
5874end
5875
5876
5877//Sample Rotation Angle
5878Function V_writeSampleRotationAngle(fname,val)
5879        String fname
5880        Variable val
5881       
5882//      String path = "entry:sample:rotation_angle"     
5883       
5884        Make/O/D/N=1 wTmpWrite
5885//      Make/O/R/N=1 wTmpWrite
5886        String groupName = "/entry/sample"
5887        String varName = "rotation_angle"
5888        wTmpWrite[0] = val
5889
5890        variable err
5891        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5892        if(err)
5893                Print "HDF write err = ",err
5894        endif
5895        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5896//      err = V_KillNamedDataFolder(fname)
5897//      if(err)
5898//              Print "DataFolder kill err = ",err
5899//      endif
5900        return(err)
5901end
5902
5903//?? this is huber/chamber??
5904// TODO -- then where is the description of 10CB, etc...
5905Function V_writeSampleHolderDescription(fname,str)
5906        String fname,str
5907
5908//      String path = "entry:sample:sample_holder_description"
5909
5910        Make/O/T/N=1 tmpTW
5911        String groupName = "/entry/sample"
5912        String varName = "sample_holder_description"
5913        tmpTW[0] = str //
5914
5915        variable err
5916        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5917        if(err)
5918                Print "HDF write err = ",err
5919        endif
5920       
5921        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5922//      err = V_KillNamedDataFolder(fname)
5923//      if(err)
5924//              Print "DataFolder kill err = ",err
5925//      endif
5926               
5927        return(err)
5928End
5929
5930
5931
5932//Sample Temperature
5933Function V_writeSampleTemperature(fname,val)
5934        String fname
5935        Variable val
5936       
5937//      String path = "entry:sample:temperature"       
5938       
5939        Make/O/D/N=1 wTmpWrite
5940//      Make/O/R/N=1 wTmpWrite
5941        String groupName = "/entry/sample"
5942        String varName = "temperature"
5943        wTmpWrite[0] = val
5944
5945        variable err
5946        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5947        if(err)
5948                Print "HDF write err = ",err
5949        endif
5950        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5951//      err = V_KillNamedDataFolder(fname)
5952//      if(err)
5953//              Print "DataFolder kill err = ",err
5954//      endif
5955        return(err)
5956end
5957
5958
5959//Sample Temperature set point
5960Function V_writeSampleTempSetPoint(fname,val)
5961        String fname
5962        Variable val
5963       
5964//      String path = "entry:sample:temperature_setpoint"       
5965       
5966        Make/O/D/N=1 wTmpWrite
5967//      Make/O/R/N=1 wTmpWrite
5968        String groupName = "/entry/sample"
5969        String varName = "temperature_setpoint"
5970        wTmpWrite[0] = val
5971
5972        variable err
5973        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5974        if(err)
5975                Print "HDF write err = ",err
5976        endif
5977        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5978//      err = V_KillNamedDataFolder(fname)
5979//      if(err)
5980//              Print "DataFolder kill err = ",err
5981//      endif
5982        return(err)
5983end
5984
5985
5986//Sample Thickness
5987// TODO -- somehow, this is not set correctly in the acquisition, so NaN results
5988Function V_writeSampleThickness(fname,val)
5989        String fname
5990        Variable val
5991       
5992//      String path = "entry:sample:thickness" 
5993       
5994        Make/O/D/N=1 wTmpWrite
5995//      Make/O/R/N=1 wTmpWrite
5996        String groupName = "/entry/sample"
5997        String varName = "thickness"
5998        wTmpWrite[0] = val
5999
6000        variable err
6001        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6002        if(err)
6003                Print "HDF write err = ",err
6004        endif
6005        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6006//      err = V_KillNamedDataFolder(fname)
6007//      if(err)
6008//              Print "DataFolder kill err = ",err
6009//      endif
6010        return(err)
6011end
6012
6013
6014//Sample Translation
6015Function V_writeSampleTranslation(fname,val)
6016        String fname
6017        Variable val
6018       
6019//      String path = "entry:sample:translation"       
6020       
6021        Make/O/D/N=1 wTmpWrite
6022//      Make/O/R/N=1 wTmpWrite
6023        String groupName = "/entry/sample"
6024        String varName = "translation"
6025        wTmpWrite[0] = val
6026
6027        variable err
6028        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6029        if(err)
6030                Print "HDF write err = ",err
6031        endif
6032        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6033//      err = V_KillNamedDataFolder(fname)
6034//      if(err)
6035//              Print "DataFolder kill err = ",err
6036//      endif
6037        return(err)
6038end
6039
6040// sample transmission
6041Function V_writeSampleTransmission(fname,val)
6042        String fname
6043        Variable val
6044       
6045        String path = "entry:sample:transmission"       
6046       
6047        Make/O/D/N=1 wTmpWrite
6048//      Make/O/R/N=1 wTmpWrite
6049        String groupName = "/entry/sample"
6050        String varName = "transmission"
6051        wTmpWrite[0] = val
6052
6053        variable err
6054        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6055        if(err)
6056                Print "HDF write err = ",err
6057        endif
6058        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6059//      err = V_KillNamedDataFolder(fname)
6060//      if(err)
6061//              Print "DataFolder kill err = ",err
6062//      endif
6063        return(err)
6064end
6065
6066//transmission error (one sigma)
6067Function V_writeSampleTransError(fname,val)
6068        String fname
6069        Variable val
6070       
6071//      String path = "entry:sample:transmission_error"
6072       
6073        Make/O/D/N=1 wTmpWrite
6074//      Make/O/R/N=1 wTmpWrite
6075        String groupName = "/entry/sample"
6076        String varName = "transmission_error"
6077        wTmpWrite[0] = val
6078
6079        variable err
6080        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6081        if(err)
6082                Print "HDF write err = ",err
6083        endif
6084        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6085//      err = V_KillNamedDataFolder(fname)
6086//      if(err)
6087//              Print "DataFolder kill err = ",err
6088//      endif
6089        return(err)
6090end
6091
6092
6093
6094//// SAMPLE / DATA LOGS
6095// write this generic , call with the name of the environment log desired
6096//
6097//
6098// shear_field
6099// pressure
6100// magnetic_field
6101// electric_field
6102//
6103//////// (for example) electric_field (data folder)
6104
6105Function V_writeLog_attachedTo(fname,logStr,str)
6106        String fname,logStr,str
6107
6108//      String path = "entry:sample:"+logstr+":attached_to"
6109
6110        Make/O/T/N=1 tmpTW
6111        String groupName = "/entry/sample/"+logStr
6112        String varName = "attached_to"
6113        tmpTW[0] = str //
6114
6115        variable err
6116        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6117        if(err)
6118                Print "HDF write err = ",err
6119        endif
6120       
6121        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6122//      err = V_KillNamedDataFolder(fname)
6123//      if(err)
6124//              Print "DataFolder kill err = ",err
6125//      endif
6126               
6127        return(err)
6128End
6129
6130
6131Function V_writeLog_measurement(fname,logStr,str)
6132        String fname,logStr,str
6133
6134        String path = "entry:sample:"+logstr+":measurement"
6135
6136        Make/O/T/N=1 tmpTW
6137        String groupName = "/entry/sample/"+logStr
6138        String varName = "measurement"
6139        tmpTW[0] = str //
6140
6141        variable err
6142        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6143        if(err)
6144                Print "HDF write err = ",err
6145        endif
6146       
6147        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6148//      err = V_KillNamedDataFolder(fname)
6149//      if(err)
6150//              Print "DataFolder kill err = ",err
6151//      endif
6152               
6153        return(err)
6154End
6155
6156
6157Function V_writeLog_Name(fname,logStr,str)
6158        String fname,logStr,str
6159
6160//      String path = "entry:sample:"+logstr+":name"
6161
6162        Make/O/T/N=1 tmpTW
6163        String groupName = "/entry/sample/"+logStr
6164        String varName = "name"
6165        tmpTW[0] = str //
6166
6167        variable err
6168        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6169        if(err)
6170                Print "HDF write err = ",err
6171        endif
6172       
6173        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6174//      err = V_KillNamedDataFolder(fname)
6175//      if(err)
6176//              Print "DataFolder kill err = ",err
6177//      endif
6178               
6179        return(err)
6180End
6181
6182
6183//// TODO -- this may require multiple entries, for each sensor _1, _2, etc.
6184//Function V_writeLog_setPoint(fname,logStr,val)
6185//      String fname,logStr
6186//      Variable val
6187//     
6188////    String path = "entry:sample:"+logstr+":setpoint_1"
6189//     
6190//      Make/O/D/N=1 wTmpWrite
6191////    Make/O/R/N=1 wTmpWrite
6192//      String groupName = "/entry/sample/"+logStr
6193//      String varName = "setpoint_1"
6194//      wTmpWrite[0] = val
6195//
6196//      variable err
6197//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6198//      if(err)
6199//              Print "HDF write err = ",err
6200//      endif
6201//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6202////    err = V_KillNamedDataFolder(fname)
6203////    if(err)
6204////            Print "DataFolder kill err = ",err
6205////    endif
6206//      return(err)
6207//end
6208//
6209//Function V_writeLog_startTime(fname,logStr,str)
6210//      String fname,logStr,str
6211//
6212////    String path = "entry:sample:"+logstr+":start"
6213//
6214//      Make/O/T/N=1 tmpTW
6215//      String groupName = "/entry/sample/"+logStr
6216//      String varName = "start"
6217//      tmpTW[0] = str //
6218//
6219//      variable err
6220//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6221//      if(err)
6222//              Print "HDF write err = ",err
6223//      endif
6224//     
6225//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6226////    err = V_KillNamedDataFolder(fname)
6227////    if(err)
6228////            Print "DataFolder kill err = ",err
6229////    endif
6230//             
6231//      return(err)
6232//End
6233//
6234//
6235//// TODO -- this may only exist for electric and magnetic field, or be removed
6236//Function V_writeLog_nomValue(fname,logStr,val)
6237//      String fname,logStr
6238//      Variable val
6239//     
6240////    String path = "entry:sample:"+logstr+":value"
6241//     
6242//      Make/O/D/N=1 wTmpWrite
6243////    Make/O/R/N=1 wTmpWrite
6244//      String groupName = "/entry/sample/"+logStr
6245//      String varName = "value"
6246//      wTmpWrite[0] = val
6247//
6248//      variable err
6249//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6250//      if(err)
6251//              Print "HDF write err = ",err
6252//      endif
6253//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6254////    err = V_KillNamedDataFolder(fname)
6255////    if(err)
6256////            Print "DataFolder kill err = ",err
6257////    endif
6258//      return(err)
6259//end
6260
6261
6262// for temperature only, logStr must be "temperature_env"
6263Function V_writeTempLog_ControlSensor(fname,logStr,str)
6264        String fname,logStr,str
6265
6266//      String path = "entry:sample:"+logstr+":control_sensor"
6267
6268        Make/O/T/N=1 tmpTW
6269        String groupName = "/entry/sample/"+logStr
6270        String varName = "control_sensor"
6271        tmpTW[0] = str //
6272
6273        variable err
6274        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6275        if(err)
6276                Print "HDF write err = ",err
6277        endif
6278       
6279        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6280//      err = V_KillNamedDataFolder(fname)
6281//      if(err)
6282//              Print "DataFolder kill err = ",err
6283//      endif
6284               
6285        return(err)
6286End
6287
6288// for temperature only, logStr must be "temperature_env"
6289Function V_writeTempLog_MonitorSensor(fname,logStr,str)
6290        String fname,logStr,str
6291
6292//      String path = "entry:sample:"+logstr+":monitor_sensor"
6293
6294        Make/O/T/N=1 tmpTW
6295        String groupName = "/entry/sample/"+logStr
6296        String varName = "monitor_sensor"
6297        tmpTW[0] = str //
6298
6299        variable err
6300        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6301        if(err)
6302                Print "HDF write err = ",err
6303        endif
6304       
6305        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6306//      err = V_KillNamedDataFolder(fname)
6307//      if(err)
6308//              Print "DataFolder kill err = ",err
6309//      endif
6310               
6311        return(err)
6312End
6313
6314
6315
6316////////////////////
6317//
6318///////////
6319// NOTE
6320//
6321// for temperature, the "attached_to", "measurement", and "name" fields
6322// are one level down farther than before, and down deeper than for other sensors
6323//
6324//
6325// read the value of V_getTemp_MonitorSensor/ControlSensor to get the name of the sensor level .
6326//
6327
6328Function V_writeTempLog_attachedTo(fname,logStr,str)
6329        String fname,logStr,str
6330
6331//      String path = "entry:sample:temperature_env:"+logstr+":attached_to"
6332
6333        Make/O/T/N=1 tmpTW
6334        String groupName = "/entry/sample/temperature_env/"+logStr
6335        String varName = "attached_to"
6336        tmpTW[0] = str //
6337
6338        variable err
6339        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6340        if(err)
6341                Print "HDF write err = ",err
6342        endif
6343       
6344        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6345//      err = V_KillNamedDataFolder(fname)
6346//      if(err)
6347//              Print "DataFolder kill err = ",err
6348//      endif
6349               
6350        return(err)
6351End
6352
6353
6354Function V_writeTempLog_highTrip(fname,logStr,val)
6355        String fname,logStr
6356        Variable val
6357       
6358//      String path = "entry:sample:temperature_env:"+logstr+":high_trip_value"
6359       
6360        Make/O/D/N=1 wTmpWrite
6361//      Make/O/R/N=1 wTmpWrite
6362        String groupName = "/entry/sample/temperature_env/"+logStr
6363        String varName = "high_trip_value"
6364        wTmpWrite[0] = val
6365
6366        variable err
6367        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6368        if(err)
6369                Print "HDF write err = ",err
6370        endif
6371        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6372//      err = V_KillNamedDataFolder(fname)
6373//      if(err)
6374//              Print "DataFolder kill err = ",err
6375//      endif
6376        return(err)
6377end
6378
6379Function V_writeTempLog_holdTime(fname,logStr,val)
6380        String fname,logStr
6381        Variable val
6382       
6383//      String path = "entry:sample:temperature_env:"+logstr+":hold_time"
6384       
6385        Make/O/D/N=1 wTmpWrite
6386//      Make/O/R/N=1 wTmpWrite
6387        String groupName = "/entry/sample/temperature_env/"+logStr
6388        String varName = "hold_time"
6389        wTmpWrite[0] = val
6390
6391        variable err
6392        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6393        if(err)
6394                Print "HDF write err = ",err
6395        endif
6396        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6397//      err = V_KillNamedDataFolder(fname)
6398//      if(err)
6399//              Print "DataFolder kill err = ",err
6400//      endif
6401        return(err)
6402end
6403
6404Function V_writeTempLog_lowTrip(fname,logStr,val)
6405        String fname,logStr
6406        Variable val
6407       
6408//      String path = "entry:sample:temperature_env:"+logstr+":low_trip_value"
6409       
6410        Make/O/D/N=1 wTmpWrite
6411//      Make/O/R/N=1 wTmpWrite
6412        String groupName = "/entry/sample/temperature_env/"+logStr
6413        String varName = "low_trip_value"
6414        wTmpWrite[0] = val
6415
6416        variable err
6417        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6418        if(err)
6419                Print "HDF write err = ",err
6420        endif
6421        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6422//      err = V_KillNamedDataFolder(fname)
6423//      if(err)
6424//              Print "DataFolder kill err = ",err
6425//      endif
6426        return(err)
6427end
6428
6429Function V_writeTempLog_measurement(fname,logStr,str)
6430        String fname,logStr,str
6431
6432//      String path = "entry:sample:temperature_env:"+logstr+":measurement"
6433
6434        Make/O/T/N=1 tmpTW
6435        String groupName = "/entry/sample/temperature_env/"+logStr
6436        String varName = "measurement"
6437        tmpTW[0] = str //
6438
6439        variable err
6440        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6441        if(err)
6442                Print "HDF write err = ",err
6443        endif
6444       
6445        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6446//      err = V_KillNamedDataFolder(fname)
6447//      if(err)
6448//              Print "DataFolder kill err = ",err
6449//      endif
6450               
6451        return(err)
6452End
6453
6454Function V_writeTempLog_model(fname,logStr,str)
6455        String fname,logStr,str
6456
6457//      String path = "entry:sample:temperature_env:"+logstr+":model"
6458
6459        Make/O/T/N=1 tmpTW
6460        String groupName = "/entry/sample/temperature_env/"+logStr
6461        String varName = "model"
6462        tmpTW[0] = str //
6463
6464        variable err
6465        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6466        if(err)
6467                Print "HDF write err = ",err
6468        endif
6469       
6470        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6471//      err = V_KillNamedDataFolder(fname)
6472//      if(err)
6473//              Print "DataFolder kill err = ",err
6474//      endif
6475               
6476        return(err)
6477End
6478
6479Function V_writeTempLog_name(fname,logStr,str)
6480        String fname,logStr,str
6481
6482//      String path = "entry:sample:temperature_env:"+logstr+":name"
6483
6484        Make/O/T/N=1 tmpTW
6485        String groupName = "/entry/sample/temperature_env/"+logStr
6486        String varName = "name"
6487        tmpTW[0] = str //
6488
6489        variable err
6490        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6491        if(err)
6492                Print "HDF write err = ",err
6493        endif
6494       
6495        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6496//      err = V_KillNamedDataFolder(fname)
6497//      if(err)
6498//              Print "DataFolder kill err = ",err
6499//      endif
6500               
6501        return(err)
6502End
6503
6504Function V_writeTempLog_runControl(fname,logStr,val)
6505        String fname,logStr
6506        Variable val
6507       
6508//      String path = "entry:sample:temperature_env:"+logstr+":run_control"
6509       
6510        Make/O/D/N=1 wTmpWrite
6511//      Make/O/R/N=1 wTmpWrite
6512        String groupName = "/entry/sample/temperature_env/"+logStr
6513        String varName = "run_control"
6514        wTmpWrite[0] = val
6515
6516        variable err
6517        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6518        if(err)
6519                Print "HDF write err = ",err
6520        endif
6521        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6522//      err = V_KillNamedDataFolder(fname)
6523//      if(err)
6524//              Print "DataFolder kill err = ",err
6525//      endif
6526        return(err)
6527end
6528
6529Function V_writeTempLog_setPoint(fname,logStr,val)
6530        String fname,logStr
6531        Variable val
6532       
6533//      String path = "entry:sample:temperature_env:"+logstr+":setpoint"
6534       
6535        Make/O/D/N=1 wTmpWrite
6536//      Make/O/R/N=1 wTmpWrite
6537        String groupName = "/entry/sample/temperature_env/"+logStr
6538        String varName = "setpoint"
6539        wTmpWrite[0] = val
6540
6541        variable err
6542        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6543        if(err)
6544                Print "HDF write err = ",err
6545        endif
6546        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6547//      err = V_KillNamedDataFolder(fname)
6548//      if(err)
6549//              Print "DataFolder kill err = ",err
6550//      endif
6551        return(err)
6552end
6553
6554Function V_writeTempLog_shortName(fname,logStr,str)
6555        String fname,logStr,str
6556
6557//      String path = "entry:sample:temperature_env:"+logstr+":short_name"
6558
6559        Make/O/T/N=1 tmpTW
6560        String groupName = "/entry/sample/temperature_env/"+logStr
6561        String varName = "short_name"
6562        tmpTW[0] = str //
6563
6564        variable err
6565        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6566        if(err)
6567                Print "HDF write err = ",err
6568        endif
6569       
6570        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6571//      err = V_KillNamedDataFolder(fname)
6572//      if(err)
6573//              Print "DataFolder kill err = ",err
6574//      endif
6575               
6576        return(err)
6577End
6578
6579Function V_writeTempLog_timeout(fname,logStr,val)
6580        String fname,logStr
6581        Variable val
6582       
6583//      String path = "entry:sample:temperature_env:"+logstr+":timeout"
6584       
6585        Make/O/D/N=1 wTmpWrite
6586//      Make/O/R/N=1 wTmpWrite
6587        String groupName = "/entry/sample/temperature_env/"+logStr
6588        String varName = "timeout"
6589        wTmpWrite[0] = val
6590
6591        variable err
6592        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6593        if(err)
6594                Print "HDF write err = ",err
6595        endif
6596        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6597//      err = V_KillNamedDataFolder(fname)
6598//      if(err)
6599//              Print "DataFolder kill err = ",err
6600//      endif
6601        return(err)
6602end
6603
6604Function V_writeTempLog_tolerance(fname,logStr,val)
6605        String fname,logStr
6606        Variable val
6607       
6608//      String path = "entry:sample:temperature_env:"+logstr+":tolerance"
6609       
6610        Make/O/D/N=1 wTmpWrite
6611//      Make/O/R/N=1 wTmpWrite
6612        String groupName = "/entry/sample/temperature_env/"+logStr
6613        String varName = "tolerance"
6614        wTmpWrite[0] = val
6615
6616        variable err
6617        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6618        if(err)
6619                Print "HDF write err = ",err
6620        endif
6621        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6622//      err = V_KillNamedDataFolder(fname)
6623//      if(err)
6624//              Print "DataFolder kill err = ",err
6625//      endif
6626        return(err)
6627end
6628
6629Function V_writeTempLog_toleranceBand(fname,logStr,val)
6630        String fname,logStr
6631        Variable val
6632       
6633//      String path = "entry:sample:temperature_env:"+logstr+":tolerance_band_time"
6634       
6635        Make/O/D/N=1 wTmpWrite
6636//      Make/O/R/N=1 wTmpWrite
6637        String groupName = "/entry/sample/temperature_env/"+logStr
6638        String varName = "tolerance_band_time"
6639        wTmpWrite[0] = val
6640
6641        variable err
6642        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6643        if(err)
6644                Print "HDF write err = ",err
6645        endif
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        return(err)
6652end
6653
6654Function V_writeTempLog_Value(fname,logStr,val)
6655        String fname,logStr
6656        Variable val
6657       
6658//      String path = "entry:sample:temperature_env:"+logstr+":value"
6659       
6660        Make/O/D/N=1 wTmpWrite
6661//      Make/O/R/N=1 wTmpWrite
6662        String groupName = "/entry/sample/temperature_env/"+logStr
6663        String varName = "value"
6664        wTmpWrite[0] = val
6665
6666        variable err
6667        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6668        if(err)
6669                Print "HDF write err = ",err
6670        endif
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        return(err)
6677end
6678
6679
6680
6681
6682
6683//
6684// temperature_env:temp_Internal_1:value_log
6685//
6686////            value_log (data folder)
6687//
6688// TODO:
6689// -- be sure that the calling function properly calls for temperture
6690// logs which are down an extra layer:
6691//      for example, logStr = "temperature_env:temp_Internal_1"
6692//
6693// read the value of V_getTemp_MonitorSensor to get the name of the sensor the next level down.
6694//
6695//
6696/////////////////////////////////////
6697////            value_log (data folder)
6698//
6699// TODO --
6700Function V_writeLog_avgValue(fname,logStr,val)
6701        String fname,logStr
6702        Variable val
6703       
6704//      String path = "entry:sample:"+logstr+":value_log:average_value"
6705       
6706        Make/O/D/N=1 wTmpWrite
6707//      Make/O/R/N=1 wTmpWrite
6708        String groupName = "/entry/sample/"+logStr+"/value_log"
6709        String varName = "average_value"
6710        wTmpWrite[0] = val
6711
6712        variable err
6713        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6714        if(err)
6715                Print "HDF write err = ",err
6716        endif
6717        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6718//      err = V_KillNamedDataFolder(fname)
6719//      if(err)
6720//              Print "DataFolder kill err = ",err
6721//      endif
6722        return(err)
6723end
6724
6725Function V_writeLog_avgValue_err(fname,logStr,val)
6726        String fname,logStr
6727        Variable val
6728       
6729//      String path = "entry:sample:"+logstr+":value_log:average_value_error"
6730       
6731        Make/O/D/N=1 wTmpWrite
6732//      Make/O/R/N=1 wTmpWrite
6733        String groupName = "/entry/sample/"+logStr+"/value_log"
6734        String varName = "average_value_error"
6735        wTmpWrite[0] = val
6736
6737        variable err
6738        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6739        if(err)
6740                Print "HDF write err = ",err
6741        endif
6742        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6743//      err = V_KillNamedDataFolder(fname)
6744//      if(err)
6745//              Print "DataFolder kill err = ",err
6746//      endif
6747        return(err)
6748end
6749
6750Function V_writeLog_maximumValue(fname,logStr,val)
6751        String fname,logStr
6752        Variable val
6753       
6754//      String path = "entry:sample:"+logstr+":value_log:maximum_value"
6755       
6756        Make/O/D/N=1 wTmpWrite
6757//      Make/O/R/N=1 wTmpWrite
6758        String groupName = "/entry/sample/"+logStr+"/value_log"
6759        String varName = "maximum_value"
6760        wTmpWrite[0] = val
6761
6762        variable err
6763        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6764        if(err)
6765                Print "HDF write err = ",err
6766        endif
6767        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6768//      err = V_KillNamedDataFolder(fname)
6769//      if(err)
6770//              Print "DataFolder kill err = ",err
6771//      endif
6772        return(err)
6773end
6774
6775Function V_writeLog_medianValue(fname,logStr,val)
6776        String fname,logStr
6777        Variable val
6778       
6779//      String path = "entry:sample:"+logstr+":value_log:median_value"
6780       
6781        Make/O/D/N=1 wTmpWrite
6782//      Make/O/R/N=1 wTmpWrite
6783        String groupName = "/entry/sample/"+logStr+"/value_log"
6784        String varName = "median_value"
6785        wTmpWrite[0] = val
6786
6787        variable err
6788        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6789        if(err)
6790                Print "HDF write err = ",err
6791        endif
6792        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6793//      err = V_KillNamedDataFolder(fname)
6794//      if(err)
6795//              Print "DataFolder kill err = ",err
6796//      endif
6797        return(err)
6798end
6799
6800Function V_writeLog_minimumValue(fname,logStr,val)
6801        String fname,logStr
6802        Variable val
6803       
6804//      String path = "entry:sample:"+logstr+":value_log:minimum_value"
6805       
6806        Make/O/D/N=1 wTmpWrite
6807//      Make/O/R/N=1 wTmpWrite
6808        String groupName = "/entry/sample/"+logStr+"/value_log"
6809        String varName = "minimum_value"
6810        wTmpWrite[0] = val
6811
6812        variable err
6813        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6814        if(err)
6815                Print "HDF write err = ",err
6816        endif
6817        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6818//      err = V_KillNamedDataFolder(fname)
6819//      if(err)
6820//              Print "DataFolder kill err = ",err
6821//      endif
6822        return(err)
6823end
6824
6825
6826
6827// TODO -- this needs to be a WAVE reference
6828// be sure this gets written as "time", even though it is read in as "time0"
6829Function V_writeLog_timeWave(fname,logStr,inW)
6830        String fname,logStr
6831        Wave inW
6832       
6833//      String path = "entry:sample:"+logstr+":value_log:time"
6834
6835        Duplicate/O inW wTmpWrite       
6836// then use redimension as needed to cast the wave to write to the specified type
6837// see WaveType for the proper codes
6838//      Redimension/T=() wTmpWrite
6839// -- May also need to check the dimension(s) before writing (don't trust the input)
6840        String groupName = "/entry/sample/"+logStr+"/value_log"
6841        String varName = "time"
6842
6843        variable err
6844        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6845        if(err)
6846                Print "HDF write err = ",err
6847        endif
6848        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6849//      err = V_KillNamedDataFolder(fname)
6850//      if(err)
6851//              Print "DataFolder kill err = ",err
6852//      endif
6853        return(err)
6854end
6855
6856
6857// TODO -- this needs to be a WAVE reference
6858Function V_writeLog_ValueWave(fname,logStr,inW)
6859        String fname,logStr
6860        Wave inW
6861       
6862//      String path = "entry:sample:"+logstr+":value_log:value"
6863
6864        Duplicate/O inW wTmpWrite       
6865// then use redimension as needed to cast the wave to write to the specified type
6866// see WaveType for the proper codes
6867//      Redimension/T=() wTmpWrite
6868// -- May also need to check the dimension(s) before writing (don't trust the input)
6869        String groupName = "/entry/sample/"+logStr+"/value_log"
6870        String varName = "value"
6871
6872        variable err
6873        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6874        if(err)
6875                Print "HDF write err = ",err
6876        endif
6877        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6878//      err = V_KillNamedDataFolder(fname)
6879//      if(err)
6880//              Print "DataFolder kill err = ",err
6881//      endif
6882        return(err)
6883end
6884
6885
6886
6887
6888
6889
6890
6891
6892///////// REDUCTION
6893///////// REDUCTION
6894///////// REDUCTION
6895
6896
6897// TODO
6898// -- come up with a scheme to write the entire protocol to the data file?
6899// -- or a scheme to write just the missing bits?
6900
6901
6902// TODO -- needs to be a Text WAVE, and of the proper size and type!!!
6903//  -- this is a test where I write a wave to a field that does not exist...
6904Function V_writeReductionProtocolWave(fname,inTW)
6905        String fname
6906        Wave/T inTW
6907       
6908//      String path = "entry:reduction:absolute_scaling"
6909       
6910        Duplicate/O inTW wTTmpWrite     
6911// then use redimension as needed to cast the wave to write to the specified type
6912// see WaveType for the proper codes
6913//      Redimension/T=() wTmpWrite
6914// -- May also need to check the dimension(s) before writing (don't trust the input)
6915        String groupName = "/entry/reduction"   
6916        String varName = "protocol"
6917
6918        variable err
6919        err = V_WriteWaveToHDF(fname, groupName, varName, wTTmpWrite)
6920        if(err)
6921                Print "HDF write err = ",err
6922        endif
6923        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6924//      err = V_KillNamedDataFolder(fname)
6925//      if(err)
6926//              Print "DataFolder kill err = ",err
6927//      endif
6928        return(err)
6929end
6930
6931
6932// this is a NON NICE entered field
6933//
6934// this is a flag to mark the file as "flipped" so it prevents a 2nd flip
6935// if the flip has been done, the field is written with a value of 1 (= true)
6936//
6937// to "un-mark" the file and allow the flip to be re-done, write -999999
6938Function V_writeLeftRightFlipDone(fname,val)
6939        String fname
6940        Variable val
6941       
6942        String path = "entry:reduction:left_right_flip"
6943       
6944        Make/O/D/N=1 wTmpWrite
6945//      Make/O/R/N=1 wTmpWrite
6946        String groupName = "/entry/reduction"
6947        String varName = "left_right_flip"
6948        wTmpWrite[0] = val
6949
6950        variable err
6951        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6952        if(err)
6953                Print "HDF write err = ",err
6954        endif
6955        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6956//      err = V_KillNamedDataFolder(fname)
6957//      if(err)
6958//              Print "DataFolder kill err = ",err
6959//      endif
6960        return(err)
6961end
6962
6963
6964
6965// TODO -- needs to be a WAVE, and of the proper size and type!!!
6966Function V_writeAbsolute_Scaling(fname,inW)
6967        String fname
6968        Wave inW
6969       
6970//      String path = "entry:reduction:absolute_scaling"
6971       
6972        Duplicate/O inW wTmpWrite       
6973// then use redimension as needed to cast the wave to write to the specified type
6974// see WaveType for the proper codes
6975//      Redimension/T=() wTmpWrite
6976// -- May also need to check the dimension(s) before writing (don't trust the input)
6977        String groupName = "/entry/reduction"   
6978        String varName = "absolute_scaling"
6979
6980        variable err
6981        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6982        if(err)
6983                Print "HDF write err = ",err
6984        endif
6985        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6986//      err = V_KillNamedDataFolder(fname)
6987//      if(err)
6988//              Print "DataFolder kill err = ",err
6989//      endif
6990        return(err)
6991end
6992
6993Function V_writeBackgroundFileName(fname,str)
6994        String fname,str
6995
6996//      String path = "entry:reduction:background_file_name"   
6997
6998        Make/O/T/N=1 tmpTW
6999        String groupName = "/entry/reduction"
7000        String varName = "background_file_name"
7001        tmpTW[0] = str //
7002
7003        variable err
7004        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7005        if(err)
7006                Print "HDF write err = ",err
7007        endif
7008       
7009        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7010//      err = V_KillNamedDataFolder(fname)
7011//      if(err)
7012//              Print "DataFolder kill err = ",err
7013//      endif
7014               
7015        return(err)
7016End
7017
7018
7019// TODO -- needs to be a WAVE
7020Function V_writeBoxCoordinates(fname,inW)
7021        String fname
7022        Wave inW
7023       
7024//      String path = "entry:reduction:box_coordinates"
7025               
7026        Duplicate/O inW wTmpWrite       
7027// then use redimension as needed to cast the wave to write to the specified type
7028// see WaveType for the proper codes
7029//      Redimension/T=() wTmpWrite
7030// -- May also need to check the dimension(s) before writing (don't trust the input)
7031        String groupName = "/entry/reduction"   
7032        String varName = "box_coordinates"
7033
7034        variable err
7035        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7036        if(err)
7037                Print "HDF write err = ",err
7038        endif
7039        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7040//      err = V_KillNamedDataFolder(fname)
7041//      if(err)
7042//              Print "DataFolder kill err = ",err
7043//      endif
7044        return(err)
7045end
7046
7047// THIS IS A NON-NICE ENTERED FIELD
7048// -- this is the panel string where the box coordinates refer to (for the open beam and transmission)
7049Function V_writeReduction_BoxPanel(fname,str)
7050        String fname,str
7051
7052//      String path = "entry:reduction:comments"       
7053
7054        Make/O/T/N=1 tmpTW
7055        String groupName = "/entry/reduction"
7056        String varName = "box_panel"
7057        tmpTW[0] = str //
7058
7059        variable err
7060        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7061        if(err)
7062                Print "HDF write err = ",err
7063        endif
7064       
7065        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7066//      err = V_KillNamedDataFolder(fname)
7067//      if(err)
7068//              Print "DataFolder kill err = ",err
7069//      endif
7070               
7071        return(err)
7072End
7073
7074//box counts
7075Function V_writeBoxCounts(fname,val)
7076        String fname
7077        Variable val
7078       
7079//      String path = "entry:reduction:box_count"       
7080       
7081        Make/O/D/N=1 wTmpWrite
7082//      Make/O/R/N=1 wTmpWrite
7083        String groupName = "/entry/reduction"
7084        String varName = "box_count"
7085        wTmpWrite[0] = val
7086
7087        variable err
7088        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7089        if(err)
7090                Print "HDF write err = ",err
7091        endif
7092        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7093//      err = V_KillNamedDataFolder(fname)
7094//      if(err)
7095//              Print "DataFolder kill err = ",err
7096//      endif
7097        return(err)
7098end
7099
7100//box counts error
7101Function V_writeBoxCountsError(fname,val)
7102        String fname
7103        Variable val
7104       
7105//      String path = "entry:reduction:box_count_error"
7106       
7107        Make/O/D/N=1 wTmpWrite
7108//      Make/O/R/N=1 wTmpWrite
7109        String groupName = "/entry/reduction"
7110        String varName = "box_count_error"
7111        wTmpWrite[0] = val
7112
7113        variable err
7114        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7115        if(err)
7116                Print "HDF write err = ",err
7117        endif
7118        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7119//      err = V_KillNamedDataFolder(fname)
7120//      if(err)
7121//              Print "DataFolder kill err = ",err
7122//      endif
7123        return(err)
7124end
7125
7126Function V_writeReductionComments(fname,str)
7127        String fname,str
7128
7129//      String path = "entry:reduction:comments"       
7130
7131        Make/O/T/N=1 tmpTW
7132        String groupName = "/entry/reduction"
7133        String varName = "comments"
7134        tmpTW[0] = str //
7135
7136        variable err
7137        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7138        if(err)
7139                Print "HDF write err = ",err
7140        endif
7141       
7142        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7143//      err = V_KillNamedDataFolder(fname)
7144//      if(err)
7145//              Print "DataFolder kill err = ",err
7146//      endif
7147               
7148        return(err)
7149End
7150
7151Function V_writeEmptyBeamFileName(fname,str)
7152        String fname,str
7153
7154//      String path = "entry:reduction:empty_beam_file_name"   
7155
7156        Make/O/T/N=1 tmpTW
7157        String groupName = "/entry/reduction"
7158        String varName = "empty_beam_file_name"
7159        tmpTW[0] = str //
7160
7161        variable err
7162        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7163        if(err)
7164                Print "HDF write err = ",err
7165        endif
7166       
7167        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7168//      err = V_KillNamedDataFolder(fname)
7169//      if(err)
7170//              Print "DataFolder kill err = ",err
7171//      endif
7172               
7173        return(err)
7174End
7175
7176Function V_writeEmptyFileName(fname,str)
7177        String fname,str
7178
7179//      String path = "entry:reduction:empty_beam_file_name"   
7180
7181        Make/O/T/N=1 tmpTW
7182        String groupName = "/entry/reduction"
7183        String varName = "empty_file_name"
7184        tmpTW[0] = str //
7185
7186        variable err
7187        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7188        if(err)
7189                Print "HDF write err = ",err
7190        endif
7191       
7192        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7193//      err = V_KillNamedDataFolder(fname)
7194//      if(err)
7195//              Print "DataFolder kill err = ",err
7196//      endif
7197               
7198        return(err)
7199End
7200
7201Function V_writeReduction_purpose(fname,str)
7202        String fname,str
7203
7204//      String path = "entry:reduction:file_purpose"   
7205
7206        Make/O/T/N=1 tmpTW
7207        String groupName = "/entry/reduction"
7208        String varName = "file_purpose"
7209        tmpTW[0] = str //
7210
7211        variable err
7212        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7213        if(err)
7214                Print "HDF write err = ",err
7215        endif
7216       
7217        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7218//      err = V_KillNamedDataFolder(fname)
7219//      if(err)
7220//              Print "DataFolder kill err = ",err
7221//      endif
7222               
7223        return(err)
7224End
7225
7226// DONE x- commented out, not to be used
7227//  x- is this duplicated? - yes - this is duplicated in /entry/sample
7228//  x- so I need to pick a location, or be sure to fix it in both places
7229//Function V_writeReduction_group_ID(fname,val)
7230//      String fname
7231//      Variable val
7232//     
7233////    String path = "entry:reduction:group_id"       
7234//     
7235//      Make/O/D/N=1 wTmpWrite
7236////    Make/O/R/N=1 wTmpWrite
7237//      String groupName = "/entry/reduction"
7238//      String varName = "group_id"
7239//      wTmpWrite[0] = val
7240//
7241//      variable err
7242//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7243//      if(err)
7244//              Print "HDF write err = ",err
7245//      endif
7246//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7247////    err = V_KillNamedDataFolder(fname)
7248////    if(err)
7249////            Print "DataFolder kill err = ",err
7250////    endif
7251//      return(err)
7252//end
7253
7254Function V_writeReductionIntent(fname,str)
7255        String fname,str
7256
7257//      String path = "entry:reduction:intent" 
7258
7259        Make/O/T/N=1 tmpTW
7260        String groupName = "/entry/reduction"
7261        String varName = "intent"
7262        tmpTW[0] = str //
7263
7264        variable err
7265        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7266        if(err)
7267                Print "HDF write err = ",err
7268        endif
7269       
7270        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7271//      err = V_KillNamedDataFolder(fname)
7272//      if(err)
7273//              Print "DataFolder kill err = ",err
7274//      endif
7275               
7276        return(err)
7277End
7278
7279Function V_writeMaskFileName(fname,str)
7280        String fname,str
7281
7282//      String path = "entry:reduction:empty_beam_file_name"   
7283
7284        Make/O/T/N=1 tmpTW
7285        String groupName = "/entry/reduction"
7286        String varName = "mask_file_name"
7287        tmpTW[0] = str //
7288
7289        variable err
7290        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7291        if(err)
7292                Print "HDF write err = ",err
7293        endif
7294       
7295        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7296//      err = V_KillNamedDataFolder(fname)
7297//      if(err)
7298//              Print "DataFolder kill err = ",err
7299//      endif
7300               
7301        return(err)
7302End
7303
7304
7305
7306Function V_writeLogFileName(fname,str)
7307        String fname,str
7308
7309//      String path = "entry:reduction:sans_log_file_name"     
7310
7311        Make/O/T/N=1 tmpTW
7312        String groupName = "/entry/reduction"
7313        String varName = "sans_log_file_name"
7314        tmpTW[0] = str //
7315
7316        variable err
7317        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7318        if(err)
7319                Print "HDF write err = ",err
7320        endif
7321       
7322        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7323//      err = V_KillNamedDataFolder(fname)
7324//      if(err)
7325//              Print "DataFolder kill err = ",err
7326//      endif
7327               
7328        return(err)
7329End
7330
7331
7332Function V_writeSensitivityFileName(fname,str)
7333        String fname,str
7334
7335//      String path = "entry:reduction:sensitivity_file_name"   
7336
7337        Make/O/T/N=1 tmpTW
7338        String groupName = "/entry/reduction"
7339        String varName = "sensitivity_file_name"
7340        tmpTW[0] = str //
7341
7342        variable err
7343        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7344        if(err)
7345                Print "HDF write err = ",err
7346        endif
7347       
7348        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7349//      err = V_KillNamedDataFolder(fname)
7350//      if(err)
7351//              Print "DataFolder kill err = ",err
7352//      endif
7353               
7354        return(err)
7355End
7356
7357Function V_writeTransmissionFileName(fname,str)
7358        String fname,str
7359
7360//      String path = "entry:reduction:transmission_file_name" 
7361
7362        Make/O/T/N=1 tmpTW
7363        String groupName = "/entry/reduction"
7364        String varName = "transmission_file_name"
7365        tmpTW[0] = str //
7366
7367        variable err
7368        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7369        if(err)
7370                Print "HDF write err = ",err
7371        endif
7372       
7373        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7374//      err = V_KillNamedDataFolder(fname)
7375//      if(err)
7376//              Print "DataFolder kill err = ",err
7377//      endif
7378               
7379        return(err)
7380End
7381
7382
7383//whole detector transmission
7384Function V_writeSampleTransWholeDetector(fname,val)
7385        String fname
7386        Variable val
7387       
7388//      String path = "entry:reduction:whole_trans"     
7389       
7390        Make/O/D/N=1 wTmpWrite
7391//      Make/O/R/N=1 wTmpWrite
7392        String groupName = "/entry/reduction"
7393        String varName = "whole_trans"
7394        wTmpWrite[0] = val
7395
7396        variable err
7397        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7398        if(err)
7399                Print "HDF write err = ",err
7400        endif
7401        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7402//      err = V_KillNamedDataFolder(fname)
7403//      if(err)
7404//              Print "DataFolder kill err = ",err
7405//      endif
7406        return(err)
7407end
7408
7409//whole detector transmission error
7410Function V_writeSampleTransWholeDetErr(fname,val)
7411        String fname
7412        Variable val
7413       
7414//      String path = "entry:reduction:whole_trans_error"       
7415       
7416        Make/O/D/N=1 wTmpWrite
7417//      Make/O/R/N=1 wTmpWrite
7418        String groupName = "/entry/reduction"
7419        String varName = "whole_trans_error"
7420        wTmpWrite[0] = val
7421
7422        variable err
7423        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7424        if(err)
7425                Print "HDF write err = ",err
7426        endif
7427        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7428//      err = V_KillNamedDataFolder(fname)
7429//      if(err)
7430//              Print "DataFolder kill err = ",err
7431//      endif
7432        return(err)
7433end
7434
7435                       
7436///////                 pol_sans (data folder)
7437//
7438//Function V_writePolSANS_cellName(fname,str)
7439//      String fname,str
7440//
7441////    String path = "entry:reduction:pol_sans:cell_name"     
7442//
7443//      Make/O/T/N=1 tmpTW
7444//      String groupName = "/entry/reduction/pol_sans"
7445//      String varName = "cell_name"
7446//      tmpTW[0] = str //
7447//
7448//      variable err
7449//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7450//      if(err)
7451//              Print "HDF write err = ",err
7452//      endif
7453//     
7454//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7455////    err = V_KillNamedDataFolder(fname)
7456////    if(err)
7457////            Print "DataFolder kill err = ",err
7458////    endif
7459//             
7460//      return(err)
7461//End
7462//
7463//
7464//// TODO -- needs to be a WAVE
7465//// is this a text wave?? if it's mixed names + values, then what?
7466//Function V_writePolSANS_cellParams(fname,inW)
7467//      String fname
7468//      Wave inW
7469//     
7470////    String path = "entry:reduction:pol_sans:cell_parameters"
7471//             
7472//      Duplicate/O inW wTmpWrite       
7473//// then use redimension as needed to cast the wave to write to the specified type
7474//// see WaveType for the proper codes
7475////    Redimension/T=() wTmpWrite
7476//// -- May also need to check the dimension(s) before writing (don't trust the input)
7477//      String groupName = "/entry/reduction/pol_sans" 
7478//      String varName = "cell_parameters"
7479//
7480//      variable err
7481//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7482//      if(err)
7483//              Print "HDF write err = ",err
7484//      endif
7485//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7486////    err = V_KillNamedDataFolder(fname)
7487////    if(err)
7488////            Print "DataFolder kill err = ",err
7489////    endif
7490//      return(err)
7491//end
7492//
7493//Function V_writePolSANS_PolSANSPurpose(fname,str)
7494//      String fname,str
7495//
7496////    String path = "entry:reduction:pol_sans:pol_sans_purpose"       
7497//
7498//      Make/O/T/N=1 tmpTW
7499//      String groupName = "/entry/reduction/pol_sans"
7500//      String varName = "pol_sans_purpose"
7501//      tmpTW[0] = str //
7502//
7503//      variable err
7504//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7505//      if(err)
7506//              Print "HDF write err = ",err
7507//      endif
7508//     
7509//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7510////    err = V_KillNamedDataFolder(fname)
7511////    if(err)
7512////            Print "DataFolder kill err = ",err
7513////    endif
7514//             
7515//      return(err)
7516//End
7517
7518                               
7519//////// TOP LEVEL DATA REPRESENTATION
7520//
7521// note that here the data is (supposed to be) a link, not the actual data
7522// Igor HDf implementation cannot follow links properly, as far as I know.
7523// so ignore them here, and focus on the image that may be possible to read
7524//
7525
7526//              data_B (data folder)
7527//                      data (wave) 1           //ignore this, it's a link
7528//                      variables (wave) 320
7529//                      thumbnail (data folder)
7530
7531////data (wave) "binary"
7532//// TODO -- this will need to be completely replaced with a function that can
7533//// read the binary image data. should be possible, but I don't know the details on either end...
7534//Function V_writeDataImage(fname,detStr,str)
7535//      String fname,detStr,str
7536//
7537////    String path = "entry:data_"+detStr+":thumbnail:data"   
7538//
7539//      Make/O/T/N=1 tmpTW
7540//      String groupName = "/entry/data_"+detStr+"/thumbnail"
7541//      String varName = "data"
7542//      tmpTW[0] = str //
7543//
7544//      variable err
7545//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7546//      if(err)
7547//              Print "HDF write err = ",err
7548//      endif
7549//     
7550//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7551////    err = V_KillNamedDataFolder(fname)
7552////    if(err)
7553////            Print "DataFolder kill err = ",err
7554////    endif
7555//             
7556//      return(err)
7557//End
7558//
7559//Function V_writeDataImageDescription(fname,detStr,str)
7560//      String fname,detStr,str
7561//
7562////    String path = "entry:data_"+detStr+":thumbnail:description"     
7563//
7564//      Make/O/T/N=1 tmpTW
7565//      String groupName = "/entry/data_"+detStr+"/thumbnail"
7566//      String varName = "description"
7567//      tmpTW[0] = str //
7568//
7569//      variable err
7570//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7571//      if(err)
7572//              Print "HDF write err = ",err
7573//      endif
7574//     
7575//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7576////    err = V_KillNamedDataFolder(fname)
7577////    if(err)
7578////            Print "DataFolder kill err = ",err
7579////    endif
7580//             
7581//      return(err)
7582//End
7583//                                                             
7584//Function V_writeDataImageType(fname,detStr,str)
7585//      String fname,detStr,str
7586//
7587////    String path = "entry:data_"+detStr+":thumbnail:type"   
7588//
7589//      Make/O/T/N=1 tmpTW
7590//      String groupName = "/entry/data_"+detStr+"/thumbnail"
7591//      String varName = "type"
7592//      tmpTW[0] = str //
7593//
7594//      variable err
7595//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7596//      if(err)
7597//              Print "HDF write err = ",err
7598//      endif
7599//     
7600//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7601////    err = V_KillNamedDataFolder(fname)
7602////    if(err)
7603////            Print "DataFolder kill err = ",err
7604////    endif
7605//             
7606//      return(err)
7607//End
7608//
Note: See TracBrowser for help on using the repository browser.