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

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

bug fixes for:

RealTime? updating at VSANS
Mask loading at SANS

added highResGain field for VSANS R/W

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