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

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

more changes to VCALC functionality and bug fixes for VCALC

File size: 193.1 KB
Line 
1#pragma rtGlobals=3             // Use modern global access method and strict wave access.
2
3
4// Start to build up and test the r/w accessors for VSANS
5// (SANS has a template, VSANS does not, so just start from scratch here, since the
6// file structure will be different)
7//
8//
9
10//////////// WRITE FUNCTIONS ////////////////////
11//
12// Each of the individual write functions have both the "write" and "kill" function
13// calls explicitly in each named function to allow flexibility during real implementation.
14// The calls could be streamlined, but writing this way allows for individualized kill/nokill, depending
15// on the details of what is actually being written out, and the possibility of changing the
16// particular "Write" routine, if specific changes need to be made to match the data type (int, fp, etc).
17// Currently, I don't know all of the data types, or what is important in the HDF structure.
18// NOV 2015
19//
20
21
22//////////////////////////////////////////////
23//////////////////////////////////
24// for TESTING of the get functions - to quickly access and see if there are errors
25//
26// -- not sure how to test the string functions -- can't seem to get a FUNCREF to a string function
27// to work -- maybe it's not alllowed?
28//
29// -- also, now I have get_functions that take a detStr input with the detector information, so that the
30//    functions didn't need to be repeated
31//
32//      -- Not sure how to test the "write" functions. writing the wrong data type to the wrong data field will be a disaster
33//    Writing odd, dummy values will also be a mess - no way to know if I'm doing anything correctly
34//
35Function proto_V_write_FP(str)
36        String str
37        return(0)
38end
39Function proto_V_write_FP2(str,str2)
40        String str,str2
41        return(0)
42end
43//Function proto_V_write_STR(str)
44//      String str
45//      return("")
46//end
47
48Function Test_V_write_FP(str,fname)
49        String str,fname
50       
51        Variable ii,num
52        String list,item
53       
54       
55        list=FunctionList(str,";","NPARAMS:1,VALTYPE:1") //,VALTYPE:1 gives real return values, not strings
56//      Print list
57        num = ItemsInlist(list)
58       
59       
60        for(ii=0;ii<num;ii+=1)
61                item = StringFromList(ii, list , ";")
62                FUNCREF proto_V_write_FP f = $item
63                Print item ," = ", f(fname)
64        endfor
65       
66        return(0)
67end
68
69Function Test_V_write_FP2(str,fname,detStr)
70        String str,fname,detStr
71       
72        Variable ii,num
73        String list,item
74       
75       
76        list=FunctionList(str,";","NPARAMS:2,VALTYPE:1") //,VALTYPE:1 gives real return values, not strings
77//      Print list
78        num = ItemsInlist(list)
79       
80       
81        for(ii=0;ii<num;ii+=1)
82                item = StringFromList(ii, list , ";")
83                FUNCREF proto_V_write_FP2 f = $item
84                Print item ," = ", f(fname,detStr)
85        endfor
86       
87        return(0)
88end
89
90Function Test_V_write_STR(str,fname)
91        String str,fname
92       
93        Variable ii,num
94        String list,item,strToEx
95       
96       
97        list=FunctionList(str,";","NPARAMS:1,VALTYPE:4")
98//      Print list
99        num = ItemsInlist(list)
100       
101       
102        for(ii=0;ii<num;ii+=1)
103                item = StringFromList(ii, list , ";")
104        //      FUNCREF proto_V_write_STR f = $item
105                printf "%s = ",item
106                sprintf strToEx,"Print %s(\"%s\")",item,fname
107                Execute strToEx
108//              print strToEx
109//              Print item ," = ", f(fname)
110        endfor
111       
112        return(0)
113end
114
115Function Test_V_write_STR2(str,fname,detStr)
116        String str,fname,detStr
117       
118        Variable ii,num
119        String list,item,strToEx
120       
121       
122        list=FunctionList(str,";","NPARAMS:2,VALTYPE:4")
123//      Print list
124        num = ItemsInlist(list)
125       
126       
127        for(ii=0;ii<num;ii+=1)
128                item = StringFromList(ii, list , ";")
129        //      FUNCREF proto_V_write_STR f = $item
130                printf "%s = ",item
131                sprintf strToEx,"Print %s(\"%s\",\"%s\")",item,fname,detStr
132                Execute strToEx
133//              print strToEx
134//              Print item ," = ", f(fname)
135        endfor
136       
137        return(0)
138end
139///////////////////////////////////////
140
141
142//////////////////////////////////////////////
143
144
145///////////////////////
146//
147// *These are the specific bits of information to retrieve (or write) to the data file
148// *These functions use the path to the file as input, and each has the specific
149//   path to the variable srting, or wave hard-coded into the access function
150// *They call the generic worker functions to get the values, either from the local copy if present,
151//   or the full file is loaded.
152//
153// *Since the path is the important bit, these are written as get/write pairs to make it easier to
154//   keep up with any changes in path
155//
156//
157// TODO -- verify the paths, and add more as needed
158// TODO -- for all of the String functions -- "num" does nothing right now -
159//         -- if it ever does, or needs to, a lot of locations will need to be corrected
160//
161
162
163//////// TOP LEVEL
164//////// TOP LEVEL
165//////// TOP LEVEL
166
167//// nexus version used for definitions
168//Function V_writeNeXus_version(fname,str)
169//      String fname,str
170//     
171////    String path = "entry:NeXus_version"     
172//     
173//      Make/O/T/N=1 tmpTW
174//      String groupName = "/entry"     //     
175//      String varName = "NeXus_version"
176//      tmpTW[0] = str //
177//
178//      variable err
179//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
180//      if(err)
181//              Print "HDF write err = ",err
182//      endif
183//     
184//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
185////    err = V_KillNamedDataFolder(fname)
186////    if(err)
187////            Print "DataFolder kill err = ",err
188////    endif
189//             
190//      return(err)
191//End
192
193// TODO -- not mine, added somewhere by Nexus writer?
194// data collection time (! this is the true counting time??)
195Function V_writeCollectionTime(fname,val)
196        String fname
197        Variable val
198       
199//      String path = "entry:collection_time"   
200       
201        Make/O/D/N=1 wTmpWrite
202//      Make/O/R/N=1 wTmpWrite
203        String groupName = "/entry"     
204        String varName = "collection_time"
205        wTmpWrite[0] = val
206
207        variable err
208        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
209        if(err)
210                Print "HDF write err = ",err
211        endif
212        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
213//      err = V_KillNamedDataFolder(fname)
214//      if(err)
215//              Print "DataFolder kill err = ",err
216//      endif
217        return(err)
218End
219
220// 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
4169// fname is a local WORK folder
4170Function V_putDet_beam_center_x_pix(fname,detStr,val)
4171        String fname,detStr
4172        Variable val
4173
4174//root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:beam_center_x_pix
4175        String path = "root:Packages:NIST:VSANS:"+fname+":"
4176        path += "entry:instrument:detector_"+detStr+":beam_center_x_pix"
4177       
4178        Wave/Z w = $path
4179        if(waveExists(w) == 0)
4180                return(1)
4181        else
4182        w[0] = val
4183                return(0)
4184        endif
4185
4186End
4187
4188Function V_writeDet_beam_center_y(fname,detStr,val)
4189        String fname,detStr
4190        Variable val
4191
4192//      String path = "entry:instrument:detector_"+detStr+":beam_center_y"
4193       
4194        Make/O/D/N=1 wTmpWrite
4195//      Make/O/R/N=1 wTmpWrite
4196        String groupName = "/entry/instrument/detector_"+detStr
4197        String varName = "beam_center_y"
4198        wTmpWrite[0] = val
4199
4200        variable err
4201        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4202        if(err)
4203                Print "HDF write err = ",err
4204        endif
4205        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4206//      err = V_KillNamedDataFolder(fname)
4207//      if(err)
4208//              Print "DataFolder kill err = ",err
4209//      endif
4210        return(err)
4211End
4212
4213
4214// fname is a local WORK folder
4215Function V_putDet_beam_center_y(fname,detStr,val)
4216        String fname,detStr
4217        Variable val
4218
4219//root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:beam_center_y
4220        String path = "root:Packages:NIST:VSANS:"+fname+":"
4221        path += "entry:instrument:detector_"+detStr+":beam_center_y"
4222       
4223        Wave/Z w = $path
4224        if(waveExists(w) == 0)
4225                return(1)
4226        else
4227        w[0] = val
4228                return(0)
4229        endif
4230
4231End
4232
4233// fname is a local WORK folder
4234Function V_putDet_beam_center_y_pix(fname,detStr,val)
4235        String fname,detStr
4236        Variable val
4237
4238//root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:beam_center_y_pix
4239        String path = "root:Packages:NIST:VSANS:"+fname+":"
4240        path += "entry:instrument:detector_"+detStr+":beam_center_y_pix"
4241       
4242        Wave/Z w = $path
4243        if(waveExists(w) == 0)
4244                return(1)
4245        else
4246        w[0] = val
4247                return(0)
4248        endif
4249
4250End
4251
4252// TODO -- write this function to return a WAVE with the data
4253// either as a wave reference, or as an input parameter
4254Function V_writeDetectorData(fname,detStr,inW)
4255        String fname,detStr
4256        Wave inW
4257
4258//      String path = "entry:instrument:detector_"+detStr+":data"
4259       
4260        Duplicate/O inW wTmpWrite       
4261// then use redimension as needed to cast the wave to write to the specified type
4262// see WaveType for the proper codes
4263//      Redimension/T=() wTmpWrite
4264// -- May also need to check the dimension(s) before writing (don't trust the input)
4265        String groupName = "/entry/instrument/detector_"+detStr
4266        String varName = "data"
4267
4268        variable err
4269        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4270        if(err)
4271                Print "HDF write err = ",err
4272        endif
4273        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4274//      err = V_KillNamedDataFolder(fname)
4275//      if(err)
4276//              Print "DataFolder kill err = ",err
4277//      endif
4278        return(err)
4279End
4280
4281
4282
4283/////////////////////////
4284
4285
4286// TODO -- write this function to return a WAVE with the data
4287// either as a wave reference, or as an input parameter
4288// ALSO -- the "B" deadtime will be a single value (probably)
4289//  but the tube banks will be 1D arrays of values, one per tube
4290Function V_writeDetector_deadtime(fname,detStr,inW)
4291        String fname,detStr
4292        Wave inW
4293
4294//      String path = "entry:instrument:detector_"+detStr+":dead_time"
4295        if(cmpstr(detStr,"B") == 0)
4296                DoAlert 0,"Bad call to V_writeDetector_deadtime"
4297                return(0)
4298        else
4299
4300                Duplicate/O inW wTmpWrite       
4301        // then use redimension as needed to cast the wave to write to the specified type
4302        // see WaveType for the proper codes
4303        //      Redimension/T=() wTmpWrite
4304        // -- May also need to check the dimension(s) before writing (don't trust the input)
4305                String groupName = "/entry/instrument/detector_"+detStr
4306                String varName = "dead_time"
4307       
4308                variable err
4309                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4310                if(err)
4311                        Print "HDF write err = ",err
4312                endif
4313                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4314        //      err = V_KillNamedDataFolder(fname)
4315        //      if(err)
4316        //              Print "DataFolder kill err = ",err
4317        //      endif
4318                return(err)
4319        endif
4320End
4321
4322// dead time, a single value, only for detB
4323Function V_writeDetector_deadtime_B(fname,detStr,val)
4324        String fname,detStr
4325        variable val
4326
4327//      String path = "entry:instrument:detector_"+detStr+":dead_time"
4328        if(cmpstr(detStr,"B") == 0)
4329       
4330                Make/O/D/N=1 wTmpWrite
4331        //      Make/O/R/N=1 wTmpWrite
4332                String groupName = "/entry/instrument/detector_"+detStr
4333                String varName = "dead_time"
4334                wTmpWrite[0] = val
4335       
4336                variable err
4337                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4338                if(err)
4339                        Print "HDF write err = ",err
4340                endif
4341                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4342        //      err = V_KillNamedDataFolder(fname)
4343        //      if(err)
4344        //              Print "DataFolder kill err = ",err
4345        //      endif
4346       
4347                return(err)     
4348        else
4349                DoAlert 0,"Bad call to V_writeDetector_deadtime_B"
4350                return(0)
4351        endif
4352End
4353
4354// high res detector gain, a single value, only for detB
4355Function V_writeDetector_highResGain(fname,detStr,val)
4356        String fname,detStr
4357        variable val
4358
4359//      String path = "entry:instrument:detector_"+detStr+":highResGain"
4360        if(cmpstr(detStr,"B") == 0)
4361       
4362                Make/O/D/N=1 wTmpWrite
4363        //      Make/O/R/N=1 wTmpWrite
4364                String groupName = "/entry/instrument/detector_"+detStr
4365                String varName = "highResGain"
4366                wTmpWrite[0] = val
4367       
4368                variable err
4369                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4370                if(err)
4371                        Print "HDF write err = ",err
4372                endif
4373                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4374        //      err = V_KillNamedDataFolder(fname)
4375        //      if(err)
4376        //              Print "DataFolder kill err = ",err
4377        //      endif
4378       
4379                return(err)     
4380        else
4381                DoAlert 0,"Bad call to V_writeDetector_highResGain"
4382                return(0)
4383        endif
4384End
4385
4386
4387Function V_writeDetDescription(fname,detStr,str)
4388        String fname,detStr,str
4389
4390//      String path = "entry:instrument:detector_"+detStr+":description"
4391
4392        Make/O/T/N=1 tmpTW
4393        String groupName = "/entry/instrument/detector_"+detStr //     
4394        String varName = "description"
4395        tmpTW[0] = str //
4396
4397        variable err
4398        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4399        if(err)
4400                Print "HDF write err = ",err
4401        endif
4402       
4403        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4404//      err = V_KillNamedDataFolder(fname)
4405//      if(err)
4406//              Print "DataFolder kill err = ",err
4407//      endif
4408               
4409        return(err)
4410End
4411
4412Function V_writeDet_distance(fname,detStr,val)
4413        String fname,detStr
4414        variable val
4415
4416//      String path = "entry:instrument:detector_"+detStr+":distance"
4417       
4418        Make/O/D/N=1 wTmpWrite
4419//      Make/O/R/N=1 wTmpWrite
4420        String groupName = "/entry/instrument/detector_"+detStr
4421        String varName = "distance"
4422        wTmpWrite[0] = val
4423
4424        variable err
4425        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4426        if(err)
4427                Print "HDF write err = ",err
4428        endif
4429        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4430//      err = V_KillNamedDataFolder(fname)
4431//      if(err)
4432//              Print "DataFolder kill err = ",err
4433//      endif
4434        return(err)
4435End
4436
4437//// only defined for the "B" detector, and only to satisfy NXsas
4438//Function V_writeDet_equatorial_angle(fname,detStr,val)
4439//      String fname,detStr
4440//      variable val
4441//
4442//      if(cmpstr(detStr,"B") == 0)
4443////            String path = "entry:instrument:detector_"+detStr+":equatorial_angle"
4444//     
4445//              Make/O/D/N=1 wTmpWrite
4446//      //      Make/O/R/N=1 wTmpWrite
4447//              String groupName = "/entry/instrument/detector_"+detStr
4448//              String varName = "equatorial_angle"
4449//              wTmpWrite[0] = val
4450//
4451//              variable err
4452//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4453//              if(err)
4454//                      Print "HDF write err = ",err
4455//              endif
4456//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4457////            err = V_KillNamedDataFolder(fname)
4458////            if(err)
4459////                    Print "DataFolder kill err = ",err
4460////            endif
4461//              return(err)
4462//      else
4463//              return(0)
4464//      endif
4465//End
4466
4467Function V_writeDetEventFileName(fname,detStr,str)
4468        String fname,detStr,str
4469
4470//      String path = "entry:instrument:detector_"+detStr+":event_file_name"
4471
4472        Make/O/T/N=1 tmpTW
4473        String groupName = "/entry/instrument/detector_"+detStr //     
4474        String varName = "event_file_name"
4475        tmpTW[0] = str //
4476
4477        variable err
4478        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4479        if(err)
4480                Print "HDF write err = ",err
4481        endif
4482       
4483        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4484//      err = V_KillNamedDataFolder(fname)
4485//      if(err)
4486//              Print "DataFolder kill err = ",err
4487//      endif
4488               
4489        return(err)
4490End
4491
4492Function V_writeDet_IntegratedCount(fname,detStr,val)
4493        String fname,detStr
4494        Variable val
4495
4496//      String path = "entry:instrument:detector_"+detStr+":integrated_count"
4497       
4498        Make/O/D/N=1 wTmpWrite
4499//      Make/O/R/N=1 wTmpWrite
4500        String groupName = "/entry/instrument/detector_"+detStr
4501        String varName = "integrated_count"
4502        wTmpWrite[0] = val
4503
4504        variable err
4505        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4506        if(err)
4507                Print "HDF write err = ",err
4508        endif
4509        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4510//      err = V_KillNamedDataFolder(fname)
4511//      if(err)
4512//              Print "DataFolder kill err = ",err
4513//      endif
4514        return(err)
4515End
4516
4517// fname is a local WORK folder
4518Function V_putDet_IntegratedCount(fname,detStr,val)
4519        String fname,detStr
4520        Variable val
4521
4522//root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:beam_center_x
4523        String path = "root:Packages:NIST:VSANS:"+fname+":"
4524        path += "entry:instrument:detector_"+detStr+":integrated_count"
4525       
4526        Wave/Z w = $path
4527        if(waveExists(w) == 0)
4528                return(1)
4529        else
4530        w[0] = val
4531                return(0)
4532        endif
4533
4534End
4535
4536// this is only written for B and L/R detectors
4537Function V_writeDet_LateralOffset(fname,detStr,val)
4538        String fname,detStr
4539        Variable val
4540
4541//      String path = "entry:instrument:detector_"+detStr+":lateral_offset"
4542
4543        if(cmpstr(detStr,"FT") == 0 || cmpstr(detStr,"FB") == 0)
4544                return(0)
4545        endif
4546        if(cmpstr(detStr,"MT") == 0 || cmpstr(detStr,"MB") == 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 = "lateral_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// this is only written for T/B detectors
4571Function V_writeDet_VerticalOffset(fname,detStr,val)
4572        String fname,detStr
4573        Variable val
4574
4575//      String path = "entry:instrument:detector_"+detStr+":vertical_offset"
4576
4577        if(cmpstr(detStr,"B") == 0)
4578                return(0)
4579        endif
4580        if(cmpstr(detStr,"FR") == 0 || cmpstr(detStr,"FL") == 0)
4581                return(0)
4582        endif
4583        if(cmpstr(detStr,"MR") == 0 || cmpstr(detStr,"ML") == 0)
4584                return(0)
4585        endif   
4586               
4587        Make/O/D/N=1 wTmpWrite
4588//      Make/O/R/N=1 wTmpWrite
4589        String groupName = "/entry/instrument/detector_"+detStr
4590        String varName = "vertical_offset"
4591        wTmpWrite[0] = val
4592
4593        variable err
4594        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4595        if(err)
4596                Print "HDF write err = ",err
4597        endif
4598        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4599//      err = V_KillNamedDataFolder(fname)
4600//      if(err)
4601//              Print "DataFolder kill err = ",err
4602//      endif
4603        return(err)
4604End
4605
4606
4607// TODO - be sure that this is defined correctly
4608// -- it needs to exist in the data file, and only for TB detector panels
4609Function V_writeDet_TBSetback(fname,detStr,val)
4610        String fname,detStr
4611        Variable val
4612
4613//      String path = "entry:instrument:detector_"+detStr+":setback"
4614       
4615        if(cmpstr(detStr,"B") == 0)
4616                return(0)
4617        endif
4618        if(cmpstr(detStr,"FR") == 0 || cmpstr(detStr,"FL") == 0)
4619                return(0)
4620        endif
4621        if(cmpstr(detStr,"MR") == 0 || cmpstr(detStr,"ML") == 0)
4622                return(0)
4623        endif   
4624       
4625        Make/O/D/N=1 wTmpWrite
4626//      Make/O/R/N=1 wTmpWrite
4627        String groupName = "/entry/instrument/detector_"+detStr
4628        String varName = "setback"
4629        wTmpWrite[0] = val
4630
4631        variable err
4632        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4633        if(err)
4634                Print "HDF write err = ",err
4635        endif
4636        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4637//      err = V_KillNamedDataFolder(fname)
4638//      if(err)
4639//              Print "DataFolder kill err = ",err
4640//      endif
4641        return(err)
4642End
4643
4644// gap when panels are "touching"
4645// units are mm
4646// writes panel gap for detector panel specified
4647// does not write anything if "B" is passed (no such field for this detector)
4648//
4649Function V_writeDet_panel_gap(fname,detStr,val)
4650        String fname,detStr
4651        Variable val
4652
4653        if(cmpstr(detStr,"B") == 0)
4654                return(0)
4655        endif
4656       
4657//      String path = "entry:instrument:detector_"+detStr+":panel_gap"
4658
4659        Make/O/D/N=1 wTmpWrite
4660//      Make/O/R/N=1 wTmpWrite
4661        String groupName = "/entry/instrument/detector_"+detStr
4662        String varName = "panel_gap"
4663        wTmpWrite[0] = val
4664
4665        variable err
4666        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4667        if(err)
4668                Print "HDF write err = ",err
4669        endif
4670        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4671//      err = V_KillNamedDataFolder(fname)
4672//      if(err)
4673//              Print "DataFolder kill err = ",err
4674//      endif
4675        return(err)
4676End
4677
4678
4679
4680//// only defined for the "B" detector, and only to satisfy NXsas
4681//Function V_writeDet_polar_angle(fname,detStr,val)
4682//      String fname,detStr
4683//      Variable val
4684//
4685//      if(cmpstr(detStr,"B") == 0)
4686////            String path = "entry:instrument:detector_"+detStr+":polar_angle"
4687//     
4688//              Make/O/D/N=1 wTmpWrite
4689//      //      Make/O/R/N=1 wTmpWrite
4690//              String groupName = "/entry/instrument/detector_"+detStr
4691//              String varName = "polar_angle"
4692//              wTmpWrite[0] = val
4693//
4694//              variable err
4695//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4696//              if(err)
4697//                      Print "HDF write err = ",err
4698//              endif
4699//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4700////            err = V_KillNamedDataFolder(fname)
4701////            if(err)
4702////                    Print "DataFolder kill err = ",err
4703////            endif
4704//              return(err)
4705//      else
4706//              return(0)
4707//      endif
4708//End
4709
4710//// only defined for the "B" detector, and only to satisfy NXsas
4711//Function V_writeDet_rotational_angle(fname,detStr,val)
4712//      String fname,detStr
4713//      Variable val
4714//
4715//      if(cmpstr(detStr,"B") == 0)
4716////            String path = "entry:instrument:detector_"+detStr+":rotational_angle"
4717//     
4718//              Make/O/D/N=1 wTmpWrite
4719//      //      Make/O/R/N=1 wTmpWrite
4720//              String groupName = "/entry/instrument/detector_"+detStr
4721//              String varName = "rotational_angle"
4722//              wTmpWrite[0] = val
4723//
4724//              variable err
4725//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4726//              if(err)
4727//                      Print "HDF write err = ",err
4728//              endif
4729//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4730////            err = V_KillNamedDataFolder(fname)
4731////            if(err)
4732////                    Print "DataFolder kill err = ",err
4733////            endif
4734//              return(err)
4735//      else
4736//              return(0)
4737//      endif
4738//End
4739
4740Function V_writeDetSettings(fname,detStr,str)
4741        String fname,detStr,str
4742
4743//      String path = "entry:instrument:detector_"+detStr+":settings"
4744
4745        Make/O/T/N=1 tmpTW
4746        String groupName = "/entry/instrument/detector_"+detStr //     
4747        String varName = "settings"
4748        tmpTW[0] = str //
4749
4750        variable err
4751        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4752        if(err)
4753                Print "HDF write err = ",err
4754        endif
4755       
4756        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4757//      err = V_KillNamedDataFolder(fname)
4758//      if(err)
4759//              Print "DataFolder kill err = ",err
4760//      endif
4761               
4762        return(err)
4763End
4764
4765//// really has no meaning at all
4766//Function V_writeDet_size(fname,detStr,val)
4767//      String fname,detStr
4768//      Variable val
4769//
4770////    String path = "entry:instrument:detector_"+detStr+":size"
4771//     
4772//      Make/O/D/N=1 wTmpWrite
4773////    Make/O/R/N=1 wTmpWrite
4774//      String groupName = "/entry/instrument/detector_"+detStr
4775//      String varName = "size"
4776//      wTmpWrite[0] = val
4777//
4778//      variable err
4779//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4780//      if(err)
4781//              Print "HDF write err = ",err
4782//      endif
4783//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4784////    err = V_KillNamedDataFolder(fname)
4785////    if(err)
4786////            Print "DataFolder kill err = ",err
4787////    endif
4788//      return(err)
4789//End
4790
4791//Function V_writeDetType(fname,detStr,str)
4792//      String fname,detStr,str
4793//
4794////    String path = "entry:instrument:detector_"+detStr+":type"
4795//
4796//      Make/O/T/N=1 tmpTW
4797//      String groupName = "/entry/instrument/detector_"+detStr //     
4798//      String varName = "type"
4799//      tmpTW[0] = str //
4800//
4801//      variable err
4802//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4803//      if(err)
4804//              Print "HDF write err = ",err
4805//      endif
4806//     
4807//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4808////    err = V_KillNamedDataFolder(fname)
4809////    if(err)
4810////            Print "DataFolder kill err = ",err
4811////    endif
4812//             
4813//      return(err)
4814//End
4815
4816Function V_writeDet_x_pixel_size(fname,detStr,val)
4817        String fname,detStr
4818        Variable val
4819
4820//      String path = "entry:instrument:detector_"+detStr+":x_pixel_size"
4821       
4822        Make/O/D/N=1 wTmpWrite
4823//      Make/O/R/N=1 wTmpWrite
4824        String groupName = "/entry/instrument/detector_"+detStr
4825        String varName = "x_pixel_size"
4826        wTmpWrite[0] = val
4827
4828        variable err
4829        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4830        if(err)
4831                Print "HDF write err = ",err
4832        endif
4833        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4834//      err = V_KillNamedDataFolder(fname)
4835//      if(err)
4836//              Print "DataFolder kill err = ",err
4837//      endif
4838        return(err)
4839End
4840
4841Function V_writeDet_y_pixel_size(fname,detStr,val)
4842        String fname,detStr
4843        Variable val
4844
4845//      String path = "entry:instrument:detector_"+detStr+":y_pixel_size"
4846       
4847        Make/O/D/N=1 wTmpWrite
4848//      Make/O/R/N=1 wTmpWrite
4849        String groupName = "/entry/instrument/detector_"+detStr
4850        String varName = "y_pixel_size"
4851        wTmpWrite[0] = val
4852
4853        variable err
4854        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4855        if(err)
4856                Print "HDF write err = ",err
4857        endif
4858        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4859//      err = V_KillNamedDataFolder(fname)
4860//      if(err)
4861//              Print "DataFolder kill err = ",err
4862//      endif
4863        return(err)
4864End
4865
4866/////////                       detector_FB (data folder) + ALL other PANEL DETECTORS
4867
4868// integer value
4869Function V_writeDet_numberOfTubes(fname,detStr,val)
4870        String fname,detStr
4871        Variable val
4872
4873//      String path = "entry:instrument:detector_"+detStr+":number_of_tubes"
4874        if(cmpstr(detStr,"B") == 0)
4875                return(0)
4876        else
4877       
4878                Make/O/I/N=1 wTmpWrite
4879        //      Make/O/R/N=1 wTmpWrite
4880                String groupName = "/entry/instrument/detector_"+detStr
4881                String varName = "number_of_tubes"
4882                wTmpWrite[0] = val
4883
4884                variable err
4885                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4886                if(err)
4887                        Print "HDF write err = ",err
4888                endif
4889                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4890//              err = V_KillNamedDataFolder(fname)
4891//              if(err)
4892//                      Print "DataFolder kill err = ",err
4893//              endif
4894                return(err)
4895        endif
4896End
4897
4898// deleted from definition
4899//Function V_writeDetPanelSeparation(fname,detStr,val)
4900//      String fname,detStr
4901//      Variable val
4902//
4903////    String path = "entry:instrument:detector_"+detStr+":separation"
4904//      if(cmpstr(detStr,"B") == 0)
4905//              return(0)
4906//      else
4907//     
4908//              Make/O/D/N=1 wTmpWrite
4909//      //      Make/O/R/N=1 wTmpWrite
4910//              String groupName = "/entry/instrument/detector_"+detStr
4911//              String varName = "separation"
4912//              wTmpWrite[0] = val
4913//
4914//              variable err
4915//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4916//              if(err)
4917//                      Print "HDF write err = ",err
4918//              endif
4919//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4920////            err = V_KillNamedDataFolder(fname)
4921////            if(err)
4922////                    Print "DataFolder kill err = ",err
4923////            endif
4924//              return(err)
4925//      endif
4926//End
4927
4928// TODO -- write this function to return a WAVE with the data
4929// either as a wave reference, or as an input parameter
4930Function V_writeDetTube_spatialCalib(fname,detStr,inW)
4931        String fname,detStr
4932        Wave inW
4933
4934//      String path = "entry:instrument:detector_"+detStr+":spatial_calibration"
4935
4936        if(cmpstr(detStr,"B") == 0)
4937                return(0)
4938        else
4939                Duplicate/O inW wTmpWrite       
4940        // then use redimension as needed to cast the wave to write to the specified type
4941        // see WaveType for the proper codes
4942        //      Redimension/T=() wTmpWrite
4943        // -- May also need to check the dimension(s) before writing (don't trust the input)
4944                String groupName = "/entry/instrument/detector_"+detStr
4945                String varName = "spatial_calibration"
4946
4947                variable err
4948                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4949                if(err)
4950                        Print "HDF write err = ",err
4951                endif
4952                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4953//              err = V_KillNamedDataFolder(fname)
4954//              if(err)
4955//                      Print "DataFolder kill err = ",err
4956//              endif
4957                return(err)
4958        endif
4959End
4960
4961//// TODO -- be clear on how this is defined.
4962//Function V_writeDet_tubeIndex(fname,detStr,val)
4963//      String fname,detStr
4964//      Variable val
4965//
4966////    String path = "entry:instrument:detector_"+detStr+":tube_index"
4967//      if(cmpstr(detStr,"B") == 0)
4968//              return(0)
4969//      else
4970//     
4971//              Make/O/D/N=1 wTmpWrite
4972//      //      Make/O/R/N=1 wTmpWrite
4973//              String groupName = "/entry/instrument/detector_"+detStr
4974//              String varName = "tube_index"
4975//              wTmpWrite[0] = val
4976//
4977//              variable err
4978//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4979//              if(err)
4980//                      Print "HDF write err = ",err
4981//              endif
4982//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4983////            err = V_KillNamedDataFolder(fname)
4984////            if(err)
4985////                    Print "DataFolder kill err = ",err
4986////            endif
4987//              return(err)
4988//      endif
4989//End
4990
4991Function V_writeDet_tubeOrientation(fname,detStr,str)
4992        String fname,detStr,str
4993
4994//      String path = "entry:instrument:detector_"+detStr+":tube_orientation"
4995
4996        if(cmpstr(detStr,"B") == 0)
4997                return(0)
4998        else
4999                Make/O/T/N=1 tmpTW
5000                String groupName = "/entry/instrument/detector_"+detStr //     
5001                String varName = "tube_orientation"
5002                tmpTW[0] = str //
5003
5004                variable err
5005                err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5006                if(err)
5007                        Print "HDF write err = ",err
5008                endif
5009       
5010                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5011//              err = V_KillNamedDataFolder(fname)
5012//              if(err)
5013//                      Print "DataFolder kill err = ",err
5014//              endif
5015               
5016                return(err)
5017
5018        endif
5019End
5020
5021// TODO -- be clear on how this is defined. Units?
5022Function V_writeDet_tubeWidth(fname,detStr,val)
5023        String fname,detStr
5024        Variable val
5025
5026//      String path = "entry:instrument:detector_"+detStr+":tube_width"
5027        if(cmpstr(detStr,"B") == 0)
5028                return(0)
5029        else
5030       
5031                Make/O/D/N=1 wTmpWrite
5032        //      Make/O/R/N=1 wTmpWrite
5033                String groupName = "/entry/instrument/detector_"+detStr
5034                String varName = "tube_width"
5035                wTmpWrite[0] = val
5036
5037                variable err
5038                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5039                if(err)
5040                        Print "HDF write err = ",err
5041                endif
5042                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5043//              err = V_KillNamedDataFolder(fname)
5044//              if(err)
5045//                      Print "DataFolder kill err = ",err
5046//              endif
5047                return(err)
5048        endif
5049End
5050
5051//////////////////////
5052
5053// INSTRUMENT/LENSES    /APERTURES
5054//  lenses (data folder)
5055
5056Function V_writeLensCurvature(fname,val)
5057        String fname
5058        Variable val
5059
5060//      String path = "entry:instrument:lenses:curvature"
5061       
5062        Make/O/D/N=1 wTmpWrite
5063//      Make/O/R/N=1 wTmpWrite
5064        String groupName = "/entry/instrument/lenses"
5065        String varName = "curvature"
5066        wTmpWrite[0] = val
5067
5068        variable err
5069        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5070        if(err)
5071                Print "HDF write err = ",err
5072        endif
5073        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5074//      err = V_KillNamedDataFolder(fname)
5075//      if(err)
5076//              Print "DataFolder kill err = ",err
5077//      endif
5078        return(err)
5079End
5080
5081Function V_writeLensesFocusType(fname,str)
5082        String fname,str
5083
5084//      String path = "entry:instrument:lenses:focus_type"
5085
5086        Make/O/T/N=1 tmpTW
5087        String groupName = "/entry/instrument/lenses"
5088        String varName = "focus_type"
5089        tmpTW[0] = str //
5090
5091        variable err
5092        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5093        if(err)
5094                Print "HDF write err = ",err
5095        endif
5096       
5097        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5098//      err = V_KillNamedDataFolder(fname)
5099//      if(err)
5100//              Print "DataFolder kill err = ",err
5101//      endif
5102               
5103        return(err)
5104End
5105
5106Function V_writeLensDistance(fname,val)
5107        String fname
5108        Variable val
5109
5110//      String path = "entry:instrument:lenses:lens_distance"
5111       
5112        Make/O/D/N=1 wTmpWrite
5113//      Make/O/R/N=1 wTmpWrite
5114        String groupName = "/entry/instrument/lenses"
5115        String varName = "lens_distance"
5116        wTmpWrite[0] = val
5117
5118        variable err
5119        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5120        if(err)
5121                Print "HDF write err = ",err
5122        endif
5123        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5124//      err = V_KillNamedDataFolder(fname)
5125//      if(err)
5126//              Print "DataFolder kill err = ",err
5127//      endif
5128        return(err)
5129End
5130
5131Function V_writeLensGeometry(fname,str)
5132        String fname,str
5133
5134//      String path = "entry:instrument:lenses:lens_geometry"
5135
5136        Make/O/T/N=1 tmpTW
5137        String groupName = "/entry/instrument/lenses"
5138        String varName = "lens_geometry"
5139        tmpTW[0] = str //
5140
5141        variable err
5142        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5143        if(err)
5144                Print "HDF write err = ",err
5145        endif
5146       
5147        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5148//      err = V_KillNamedDataFolder(fname)
5149//      if(err)
5150//              Print "DataFolder kill err = ",err
5151//      endif
5152               
5153        return(err)
5154End
5155
5156Function V_writeLensMaterial(fname,str)
5157        String fname,str
5158
5159//      String path = "entry:instrument:lenses:lens_material"
5160
5161        Make/O/T/N=1 tmpTW
5162        String groupName = "/entry/instrument/lenses"
5163        String varName = "lens_material"
5164        tmpTW[0] = str //
5165
5166        variable err
5167        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5168        if(err)
5169                Print "HDF write err = ",err
5170        endif
5171       
5172        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5173//      err = V_KillNamedDataFolder(fname)
5174//      if(err)
5175//              Print "DataFolder kill err = ",err
5176//      endif
5177               
5178        return(err)
5179End
5180
5181// integer value
5182Function V_writeNumber_of_Lenses(fname,val)
5183        String fname
5184        Variable val
5185
5186//      String path = "entry:instrument:lenses:number_of_lenses"
5187       
5188        Make/O/I/N=1 wTmpWrite
5189//      Make/O/R/N=1 wTmpWrite
5190        String groupName = "/entry/instrument/lenses"
5191        String varName = "number_of_lenses"
5192        wTmpWrite[0] = val
5193
5194        variable err
5195        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5196        if(err)
5197                Print "HDF write err = ",err
5198        endif
5199        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5200//      err = V_KillNamedDataFolder(fname)
5201//      if(err)
5202//              Print "DataFolder kill err = ",err
5203//      endif
5204        return(err)
5205End
5206
5207// integer value
5208Function V_writeNumber_of_prisms(fname,val)
5209        String fname
5210        Variable val
5211
5212//      String path = "entry:instrument:lenses:number_of_prisms"
5213       
5214        Make/O/I/N=1 wTmpWrite
5215//      Make/O/R/N=1 wTmpWrite
5216        String groupName = "/entry/instrument/lenses"
5217        String varName = "number_of_prisms"
5218        wTmpWrite[0] = val
5219
5220        variable err
5221        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5222        if(err)
5223                Print "HDF write err = ",err
5224        endif
5225        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5226//      err = V_KillNamedDataFolder(fname)
5227//      if(err)
5228//              Print "DataFolder kill err = ",err
5229//      endif
5230        return(err)
5231End
5232
5233Function V_writePrism_distance(fname,val)
5234        String fname
5235        Variable val
5236
5237//      String path = "entry:instrument:lenses:prism_distance"
5238       
5239        Make/O/D/N=1 wTmpWrite
5240//      Make/O/R/N=1 wTmpWrite
5241        String groupName = "/entry/instrument/lenses"
5242        String varName = "prism_distance"
5243        wTmpWrite[0] = val
5244
5245        variable err
5246        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5247        if(err)
5248                Print "HDF write err = ",err
5249        endif
5250        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5251//      err = V_KillNamedDataFolder(fname)
5252//      if(err)
5253//              Print "DataFolder kill err = ",err
5254//      endif
5255        return(err)
5256End
5257
5258Function V_writePrismMaterial(fname,str)
5259        String fname,str
5260
5261//      String path = "entry:instrument:lenses:prism_material"
5262
5263        Make/O/T/N=1 tmpTW
5264        String groupName = "/entry/instrument/lenses"
5265        String varName = "prism_material"
5266        tmpTW[0] = str //
5267
5268        variable err
5269        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5270        if(err)
5271                Print "HDF write err = ",err
5272        endif
5273       
5274        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5275//      err = V_KillNamedDataFolder(fname)
5276//      if(err)
5277//              Print "DataFolder kill err = ",err
5278//      endif
5279               
5280        return(err)
5281End
5282
5283// status of lens/prism = lens | prism | both | out
5284Function V_writeLensPrismStatus(fname,str)
5285        String fname,str
5286
5287//      String path = "entry:instrument:lenses:status"
5288
5289        Make/O/T/N=1 tmpTW
5290        String groupName = "/entry/instrument/lenses"
5291        String varName = "status"
5292        tmpTW[0] = str //
5293
5294        variable err
5295        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5296        if(err)
5297                Print "HDF write err = ",err
5298        endif
5299       
5300        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5301//      err = V_KillNamedDataFolder(fname)
5302//      if(err)
5303//              Print "DataFolder kill err = ",err
5304//      endif
5305               
5306        return(err)
5307End
5308       
5309
5310///////  sample_aperture (1) (data folder)
5311// this is the INTERNAL sample aperture
5312Function V_writeSampleAp_Description(fname,str)
5313        String fname,str
5314
5315//      String path = "entry:instrument:sample_aperture:description"
5316
5317        Make/O/T/N=1 tmpTW
5318        String groupName = "/entry/instrument/sample_aperture"
5319        String varName = "description"
5320        tmpTW[0] = str //
5321
5322        variable err
5323        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5324        if(err)
5325                Print "HDF write err = ",err
5326        endif
5327       
5328        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5329//      err = V_KillNamedDataFolder(fname)
5330//      if(err)
5331//              Print "DataFolder kill err = ",err
5332//      endif
5333               
5334        return(err)
5335End
5336
5337Function V_writeSampleAp_distance(fname,val)
5338        String fname
5339        Variable val
5340
5341//      String path = "entry:instrument:sample_aperture:distance"
5342       
5343        Make/O/D/N=1 wTmpWrite
5344//      Make/O/R/N=1 wTmpWrite
5345        String groupName = "/entry/instrument/sample_aperture"
5346        String varName = "distance"
5347        wTmpWrite[0] = val
5348
5349        variable err
5350        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5351        if(err)
5352                Print "HDF write err = ",err
5353        endif
5354        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5355//      err = V_KillNamedDataFolder(fname)
5356//      if(err)
5357//              Print "DataFolder kill err = ",err
5358//      endif
5359        return(err)
5360End
5361
5362//      sample_apertuer/shape (data folder)
5363Function V_writeSampleAp_height(fname,val)
5364        String fname
5365        Variable val
5366
5367//      String path = "entry:instrument:sample_aperture:distance"
5368       
5369        Make/O/D/N=1 wTmpWrite
5370//      Make/O/R/N=1 wTmpWrite
5371        String groupName = "/entry/instrument/sample_aperture/shape"
5372        String varName = "height"
5373        wTmpWrite[0] = val
5374
5375        variable err
5376        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5377        if(err)
5378                Print "HDF write err = ",err
5379        endif
5380        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5381//      err = V_KillNamedDataFolder(fname)
5382//      if(err)
5383//              Print "DataFolder kill err = ",err
5384//      endif
5385        return(err)
5386End
5387
5388Function V_writeSampleAp_shape(fname,str)
5389        String fname,str
5390
5391//      String path = "entry:instrument:sample_aperture:shape:shape"
5392
5393        Make/O/T/N=1 tmpTW
5394        String groupName = "/entry/instrument/sample_aperture/shape"
5395        String varName = "shape"
5396        tmpTW[0] = str //
5397
5398        variable err
5399        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5400        if(err)
5401                Print "HDF write err = ",err
5402        endif
5403       
5404        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5405//      err = V_KillNamedDataFolder(fname)
5406//      if(err)
5407//              Print "DataFolder kill err = ",err
5408//      endif
5409               
5410        return(err)
5411End
5412
5413Function V_writeSampleAp_size(fname,str)
5414        String fname,str
5415
5416//      String path = "entry:instrument:sample_aperture:shape:shape"
5417
5418        Make/O/T/N=1 tmpTW
5419        String groupName = "/entry/instrument/sample_aperture/shape"
5420        String varName = "size"
5421        tmpTW[0] = str //
5422
5423        variable err
5424        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5425        if(err)
5426                Print "HDF write err = ",err
5427        endif
5428       
5429        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5430//      err = V_KillNamedDataFolder(fname)
5431//      if(err)
5432//              Print "DataFolder kill err = ",err
5433//      endif
5434               
5435        return(err)
5436End
5437
5438Function V_writeSampleAp_width(fname,val)
5439        String fname
5440        Variable val
5441
5442//      String path = "entry:instrument:sample_aperture:distance"
5443       
5444        Make/O/D/N=1 wTmpWrite
5445//      Make/O/R/N=1 wTmpWrite
5446        String groupName = "/entry/instrument/sample_aperture/shape"
5447        String varName = "width"
5448        wTmpWrite[0] = val
5449
5450        variable err
5451        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5452        if(err)
5453                Print "HDF write err = ",err
5454        endif
5455        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5456//      err = V_KillNamedDataFolder(fname)
5457//      if(err)
5458//              Print "DataFolder kill err = ",err
5459//      endif
5460        return(err)
5461End
5462
5463///////  sample_aperture_2 (data folder)
5464// sample aperture (2) is the external aperture, which may or may not be present
5465
5466Function V_writeSampleAp2_Description(fname,str)
5467        String fname,str
5468
5469//      String path = "entry:instrument:sample_aperture_2:description"
5470
5471        Make/O/T/N=1 tmpTW
5472        String groupName = "/entry/instrument/sample_aperture_2"
5473        String varName = "description"
5474        tmpTW[0] = str //
5475
5476        variable err
5477        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5478        if(err)
5479                Print "HDF write err = ",err
5480        endif
5481       
5482        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5483//      err = V_KillNamedDataFolder(fname)
5484//      if(err)
5485//              Print "DataFolder kill err = ",err
5486//      endif
5487               
5488        return(err)
5489End
5490
5491Function V_writeSampleAp2_distance(fname,val)
5492        String fname
5493        Variable val
5494
5495//      String path = "entry:instrument:sample_aperture_2:distance"
5496       
5497        Make/O/D/N=1 wTmpWrite
5498//      Make/O/R/N=1 wTmpWrite
5499        String groupName = "/entry/instrument/sample_aperture_2"
5500        String varName = "distance"
5501        wTmpWrite[0] = val
5502
5503        variable err
5504        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5505        if(err)
5506                Print "HDF write err = ",err
5507        endif
5508        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5509//      err = V_KillNamedDataFolder(fname)
5510//      if(err)
5511//              Print "DataFolder kill err = ",err
5512//      endif
5513        return(err)
5514End
5515
5516
5517//      shape (data folder)
5518Function V_writeSampleAp2_height(fname,val)
5519        String fname
5520        Variable val
5521
5522//      String path = "entry:instrument:sample_aperture:distance"
5523       
5524        Make/O/D/N=1 wTmpWrite
5525//      Make/O/R/N=1 wTmpWrite
5526        String groupName = "/entry/instrument/sample_aperture_2/shape"
5527        String varName = "height"
5528        wTmpWrite[0] = val
5529
5530        variable err
5531        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5532        if(err)
5533                Print "HDF write err = ",err
5534        endif
5535        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5536//      err = V_KillNamedDataFolder(fname)
5537//      if(err)
5538//              Print "DataFolder kill err = ",err
5539//      endif
5540        return(err)
5541End
5542
5543Function V_writeSampleAp2_shape(fname,str)
5544        String fname,str
5545
5546//      String path = "entry:instrument:sample_aperture_2:shape:shape"
5547
5548        Make/O/T/N=1 tmpTW
5549        String groupName = "/entry/instrument/sample_aperture_2/shape"
5550        String varName = "shape"
5551        tmpTW[0] = str //
5552
5553        variable err
5554        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5555        if(err)
5556                Print "HDF write err = ",err
5557        endif
5558       
5559        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5560//      err = V_KillNamedDataFolder(fname)
5561//      if(err)
5562//              Print "DataFolder kill err = ",err
5563//      endif
5564               
5565        return(err)
5566End
5567
5568Function V_writeSampleAp2_size(fname,val)
5569        String fname
5570        Variable val
5571
5572//      String path = "entry:instrument:sample_aperture:distance"
5573       
5574        Make/O/D/N=1 wTmpWrite
5575//      Make/O/R/N=1 wTmpWrite
5576        String groupName = "/entry/instrument/sample_aperture_2/shape"
5577        String varName = "size"
5578        wTmpWrite[0] = val
5579
5580        variable err
5581        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5582        if(err)
5583                Print "HDF write err = ",err
5584        endif
5585        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5586//      err = V_KillNamedDataFolder(fname)
5587//      if(err)
5588//              Print "DataFolder kill err = ",err
5589//      endif
5590        return(err)
5591End
5592
5593Function V_writeSampleAp2_width(fname,val)
5594        String fname
5595        Variable val
5596
5597//      String path = "entry:instrument:sample_aperture:distance"
5598       
5599        Make/O/D/N=1 wTmpWrite
5600//      Make/O/R/N=1 wTmpWrite
5601        String groupName = "/entry/instrument/sample_aperture_2/shape"
5602        String varName = "width"
5603        wTmpWrite[0] = val
5604
5605        variable err
5606        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5607        if(err)
5608                Print "HDF write err = ",err
5609        endif
5610        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5611//      err = V_KillNamedDataFolder(fname)
5612//      if(err)
5613//              Print "DataFolder kill err = ",err
5614//      endif
5615        return(err)
5616End
5617
5618               
5619//////  sample_table (data folder)
5620// location  = "CHAMBER" or HUBER
5621Function V_writeSampleTableLocation(fname,str)
5622        String fname,str
5623
5624//      String path = "entry:instrument:sample_table:location"
5625
5626        Make/O/T/N=1 tmpTW
5627        String groupName = "/entry/instrument/sample_table"
5628        String varName = "location"
5629        tmpTW[0] = str //
5630
5631        variable err
5632        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5633        if(err)
5634                Print "HDF write err = ",err
5635        endif
5636       
5637        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5638//      err = V_KillNamedDataFolder(fname)
5639//      if(err)
5640//              Print "DataFolder kill err = ",err
5641//      endif
5642               
5643        return(err)
5644End
5645
5646// TODO - verify the meaning
5647//      offset_distance (?? for center of sample table vs. sample position)
5648Function V_writeSampleTableOffset(fname,val)
5649        String fname
5650        Variable val
5651
5652//      String path = "entry:instrument:sample_table:offset_distance"
5653       
5654        Make/O/D/N=1 wTmpWrite
5655//      Make/O/R/N=1 wTmpWrite
5656        String groupName = "/entry/instrument/sample_table"
5657        String varName = "offset_distance"
5658        wTmpWrite[0] = val
5659
5660        variable err
5661        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5662        if(err)
5663                Print "HDF write err = ",err
5664        endif
5665        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5666//      err = V_KillNamedDataFolder(fname)
5667//      if(err)
5668//              Print "DataFolder kill err = ",err
5669//      endif
5670        return(err)
5671End     
5672       
5673//  source (data folder)
5674//name "NCNR"
5675Function V_writeSourceName(fname,str)
5676        String fname,str
5677
5678//      String path = "entry:instrument:source:name"
5679
5680        Make/O/T/N=1 tmpTW
5681        String groupName = "/entry/instrument/source"
5682        String varName = "name"
5683        tmpTW[0] = str //
5684
5685        variable err
5686        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5687        if(err)
5688                Print "HDF write err = ",err
5689        endif
5690       
5691        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5692//      err = V_KillNamedDataFolder(fname)
5693//      if(err)
5694//              Print "DataFolder kill err = ",err
5695//      endif
5696               
5697        return(err)
5698End
5699
5700//      power -- nominal only, not connected to any real number
5701Function V_writeReactorPower(fname,val)
5702        String fname
5703        Variable val
5704
5705//      String path = "entry:instrument:source:power"
5706       
5707        Make/O/D/N=1 wTmpWrite
5708//      Make/O/R/N=1 wTmpWrite
5709        String groupName = "/entry/instrument/source"
5710        String varName = "power"
5711        wTmpWrite[0] = val
5712
5713        variable err
5714        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5715        if(err)
5716                Print "HDF write err = ",err
5717        endif
5718        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5719//      err = V_KillNamedDataFolder(fname)
5720//      if(err)
5721//              Print "DataFolder kill err = ",err
5722//      endif
5723        return(err)
5724End     
5725
5726//probe (wave) "neutron"
5727Function V_writeSourceProbe(fname,str)
5728        String fname,str
5729
5730//      String path = "entry:instrument:source:probe"
5731
5732        Make/O/T/N=1 tmpTW
5733        String groupName = "/entry/instrument/source"
5734        String varName = "probe"
5735        tmpTW[0] = str //
5736
5737        variable err
5738        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5739        if(err)
5740                Print "HDF write err = ",err
5741        endif
5742       
5743        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5744//      err = V_KillNamedDataFolder(fname)
5745//      if(err)
5746//              Print "DataFolder kill err = ",err
5747//      endif
5748               
5749        return(err)
5750End
5751
5752//type (wave) "Reactor Neutron Source"
5753Function V_writeSourceType(fname,str)
5754        String fname,str
5755
5756//      String path = "entry:instrument:source:type"
5757
5758        Make/O/T/N=1 tmpTW
5759        String groupName = "/entry/instrument/source"
5760        String varName = "type"
5761        tmpTW[0] = str //
5762
5763        variable err
5764        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5765        if(err)
5766                Print "HDF write err = ",err
5767        endif
5768       
5769        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5770//      err = V_KillNamedDataFolder(fname)
5771//      if(err)
5772//              Print "DataFolder kill err = ",err
5773//      endif
5774               
5775        return(err)
5776End
5777
5778       
5779///////  source_aperture (data folder)
5780
5781Function V_writeSourceAp_Description(fname,str)
5782        String fname,str
5783
5784//      String path = "entry:instrument:source_aperture:description"
5785
5786        Make/O/T/N=1 tmpTW
5787        String groupName = "/entry/instrument/source_aperture"
5788        String varName = "description"
5789        tmpTW[0] = str //
5790
5791        variable err
5792        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5793        if(err)
5794                Print "HDF write err = ",err
5795        endif
5796       
5797        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5798//      err = V_KillNamedDataFolder(fname)
5799//      if(err)
5800//              Print "DataFolder kill err = ",err
5801//      endif
5802               
5803        return(err)
5804End
5805
5806Function V_writeSourceAp_distance(fname,val)
5807        String fname
5808        Variable val
5809
5810//      String path = "entry:instrument:source_aperture:distance"
5811       
5812        Make/O/D/N=1 wTmpWrite
5813//      Make/O/R/N=1 wTmpWrite
5814        String groupName = "/entry/instrument/source_aperture"
5815        String varName = "distance"
5816        wTmpWrite[0] = val
5817
5818        variable err
5819        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5820        if(err)
5821                Print "HDF write err = ",err
5822        endif
5823        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5824//      err = V_KillNamedDataFolder(fname)
5825//      if(err)
5826//              Print "DataFolder kill err = ",err
5827//      endif
5828        return(err)
5829End
5830
5831
5832//      shape (data folder)
5833Function V_writeSourceAp_height(fname,val)
5834        String fname
5835        Variable val
5836
5837//      String path = "entry:instrument:sample_aperture:distance"
5838       
5839        Make/O/D/N=1 wTmpWrite
5840//      Make/O/R/N=1 wTmpWrite
5841        String groupName = "/entry/instrument/source_aperture/shape"
5842        String varName = "height"
5843        wTmpWrite[0] = val
5844
5845        variable err
5846        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5847        if(err)
5848                Print "HDF write err = ",err
5849        endif
5850        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5851//      err = V_KillNamedDataFolder(fname)
5852//      if(err)
5853//              Print "DataFolder kill err = ",err
5854//      endif
5855        return(err)
5856End
5857
5858Function V_writeSourceAp_shape(fname,str)
5859        String fname,str
5860
5861//      String path = "entry:instrument:source_aperture:shape:shape"
5862
5863        Make/O/T/N=1 tmpTW
5864        String groupName = "/entry/instrument/source_aperture/shape"
5865        String varName = "shape"
5866        tmpTW[0] = str //
5867
5868        variable err
5869        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5870        if(err)
5871                Print "HDF write err = ",err
5872        endif
5873       
5874        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5875//      err = V_KillNamedDataFolder(fname)
5876//      if(err)
5877//              Print "DataFolder kill err = ",err
5878//      endif
5879               
5880        return(err)
5881End
5882
5883Function V_writeSourceAp_size(fname,str)
5884        String fname,str
5885
5886//      String path = "entry:instrument:source_aperture:shape:shape"
5887
5888        Make/O/T/N=1 tmpTW
5889        String groupName = "/entry/instrument/source_aperture/shape"
5890        String varName = "size"
5891        tmpTW[0] = str //
5892
5893        variable err
5894        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5895        if(err)
5896                Print "HDF write err = ",err
5897        endif
5898       
5899        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5900//      err = V_KillNamedDataFolder(fname)
5901//      if(err)
5902//              Print "DataFolder kill err = ",err
5903//      endif
5904               
5905        return(err)
5906End
5907
5908Function V_writeSourceAp_width(fname,val)
5909        String fname
5910        Variable val
5911
5912//      String path = "entry:instrument:sample_aperture:distance"
5913       
5914        Make/O/D/N=1 wTmpWrite
5915//      Make/O/R/N=1 wTmpWrite
5916        String groupName = "/entry/instrument/source_aperture/shape"
5917        String varName = "width"
5918        wTmpWrite[0] = val
5919
5920        variable err
5921        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5922        if(err)
5923                Print "HDF write err = ",err
5924        endif
5925        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5926//      err = V_KillNamedDataFolder(fname)
5927//      if(err)
5928//              Print "DataFolder kill err = ",err
5929//      endif
5930        return(err)
5931End
5932
5933
5934//////// SAMPLE
5935//////// SAMPLE
5936//////// SAMPLE
5937
5938//Sample position in changer
5939Function V_writeSamplePosition(fname,str)
5940        String fname,str
5941
5942//      String path = "entry:sample:changer_position"   
5943
5944        Make/O/T/N=1 tmpTW
5945        String groupName = "/entry/sample"
5946        String varName = "changer_position"
5947        tmpTW[0] = str //
5948
5949        variable err
5950        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5951        if(err)
5952                Print "HDF write err = ",err
5953        endif
5954       
5955        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5956//      err = V_KillNamedDataFolder(fname)
5957//      if(err)
5958//              Print "DataFolder kill err = ",err
5959//      endif
5960               
5961        return(err)
5962End
5963
5964
5965// sample label
5966// TODO: value of num is currently not used
5967Function V_writeSampleDescription(fname,str)
5968        String fname,str
5969
5970//      String path = "entry:sample:description"
5971
5972        Make/O/T/N=1 tmpTW
5973        String groupName = "/entry/sample"
5974        String varName = "description"
5975        tmpTW[0] = str //
5976
5977        variable err
5978        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5979        if(err)
5980                Print "HDF write err = ",err
5981        endif
5982       
5983        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5984//      err = V_KillNamedDataFolder(fname)
5985//      if(err)
5986//              Print "DataFolder kill err = ",err
5987//      endif
5988               
5989        return(err)
5990End
5991
5992// fname is a local WORK folder
5993Function V_putSampleDescription(fname,str)
5994        String fname,str
5995
5996        String path = "root:Packages:NIST:VSANS:"+fname+":"
5997        path += "entry:sample:description"
5998       
5999        Wave/Z/T w = $path
6000        if(waveExists(w) == 0)
6001                return(1)
6002        else
6003        w[0] = str
6004                return(0)
6005        endif
6006
6007End
6008
6009
6010
6011// for a z-stage??
6012Function V_writeSample_elevation(fname,val)
6013        String fname
6014        Variable val
6015       
6016//      String path = "entry:sample:elevation" 
6017       
6018        Make/O/D/N=1 wTmpWrite
6019//      Make/O/R/N=1 wTmpWrite
6020        String groupName = "/entry/sample"
6021        String varName = "elevation"
6022        wTmpWrite[0] = val
6023
6024        variable err
6025        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6026        if(err)
6027                Print "HDF write err = ",err
6028        endif
6029        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6030//      err = V_KillNamedDataFolder(fname)
6031//      if(err)
6032//              Print "DataFolder kill err = ",err
6033//      endif
6034        return(err)
6035end
6036
6037//no meaning to this...
6038Function V_writeSample_equatorial_ang(fname,val)
6039        String fname
6040        Variable val
6041       
6042//      String path = "entry:sample:equatorial_angle"   
6043       
6044        Make/O/D/N=1 wTmpWrite
6045//      Make/O/R/N=1 wTmpWrite
6046        String groupName = "/entry/sample"
6047        String varName = "equatorial_angle"
6048        wTmpWrite[0] = val
6049
6050        variable err
6051        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6052        if(err)
6053                Print "HDF write err = ",err
6054        endif
6055        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6056//      err = V_KillNamedDataFolder(fname)
6057//      if(err)
6058//              Print "DataFolder kill err = ",err
6059//      endif
6060        return(err)
6061end
6062
6063
6064//
6065// TODO x- I need to make sure that this is an integer in the JSON definition
6066//              x- currently a text value in the data file - see trac ticket
6067// x- this is also a duplicated field in the reduction block (reduction/group_id is no longer used)
6068//
6069// group ID !!! very important for matching up files
6070// integer value
6071//
6072Function V_writeSample_GroupID(fname,val)
6073        String fname
6074        Variable val
6075       
6076//      String path = "entry:sample:group_id"   
6077       
6078        Make/O/I/N=1 wTmpWrite
6079//      Make/O/R/N=1 wTmpWrite
6080        String groupName = "/entry/sample"
6081        String varName = "group_id"
6082        wTmpWrite[0] = val
6083
6084        variable err
6085        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6086        if(err)
6087                Print "HDF write err = ",err
6088        endif
6089        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6090//      err = V_KillNamedDataFolder(fname)
6091//      if(err)
6092//              Print "DataFolder kill err = ",err
6093//      endif
6094        return(err)
6095end
6096
6097
6098//Sample Rotation Angle
6099Function V_writeSampleRotationAngle(fname,val)
6100        String fname
6101        Variable val
6102       
6103//      String path = "entry:sample:rotation_angle"     
6104       
6105        Make/O/D/N=1 wTmpWrite
6106//      Make/O/R/N=1 wTmpWrite
6107        String groupName = "/entry/sample"
6108        String varName = "rotation_angle"
6109        wTmpWrite[0] = val
6110
6111        variable err
6112        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6113        if(err)
6114                Print "HDF write err = ",err
6115        endif
6116        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6117//      err = V_KillNamedDataFolder(fname)
6118//      if(err)
6119//              Print "DataFolder kill err = ",err
6120//      endif
6121        return(err)
6122end
6123
6124//?? this is huber/chamber??
6125// TODO -- then where is the description of 10CB, etc...
6126Function V_writeSampleHolderDescription(fname,str)
6127        String fname,str
6128
6129//      String path = "entry:sample:sample_holder_description"
6130
6131        Make/O/T/N=1 tmpTW
6132        String groupName = "/entry/sample"
6133        String varName = "sample_holder_description"
6134        tmpTW[0] = str //
6135
6136        variable err
6137        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6138        if(err)
6139                Print "HDF write err = ",err
6140        endif
6141       
6142        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6143//      err = V_KillNamedDataFolder(fname)
6144//      if(err)
6145//              Print "DataFolder kill err = ",err
6146//      endif
6147               
6148        return(err)
6149End
6150
6151
6152
6153//Sample Temperature
6154Function V_writeSampleTemperature(fname,val)
6155        String fname
6156        Variable val
6157       
6158//      String path = "entry:sample:temperature"       
6159       
6160        Make/O/D/N=1 wTmpWrite
6161//      Make/O/R/N=1 wTmpWrite
6162        String groupName = "/entry/sample"
6163        String varName = "temperature"
6164        wTmpWrite[0] = val
6165
6166        variable err
6167        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6168        if(err)
6169                Print "HDF write err = ",err
6170        endif
6171        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6172//      err = V_KillNamedDataFolder(fname)
6173//      if(err)
6174//              Print "DataFolder kill err = ",err
6175//      endif
6176        return(err)
6177end
6178
6179
6180//Sample Temperature set point
6181Function V_writeSampleTempSetPoint(fname,val)
6182        String fname
6183        Variable val
6184       
6185//      String path = "entry:sample:temperature_setpoint"       
6186       
6187        Make/O/D/N=1 wTmpWrite
6188//      Make/O/R/N=1 wTmpWrite
6189        String groupName = "/entry/sample"
6190        String varName = "temperature_setpoint"
6191        wTmpWrite[0] = val
6192
6193        variable err
6194        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6195        if(err)
6196                Print "HDF write err = ",err
6197        endif
6198        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6199//      err = V_KillNamedDataFolder(fname)
6200//      if(err)
6201//              Print "DataFolder kill err = ",err
6202//      endif
6203        return(err)
6204end
6205
6206
6207//Sample Thickness
6208// TODO -- somehow, this is not set correctly in the acquisition, so NaN results
6209Function V_writeSampleThickness(fname,val)
6210        String fname
6211        Variable val
6212       
6213//      String path = "entry:sample:thickness" 
6214       
6215        Make/O/D/N=1 wTmpWrite
6216//      Make/O/R/N=1 wTmpWrite
6217        String groupName = "/entry/sample"
6218        String varName = "thickness"
6219        wTmpWrite[0] = val
6220
6221        variable err
6222        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6223        if(err)
6224                Print "HDF write err = ",err
6225        endif
6226        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6227//      err = V_KillNamedDataFolder(fname)
6228//      if(err)
6229//              Print "DataFolder kill err = ",err
6230//      endif
6231        return(err)
6232end
6233
6234
6235//Sample Translation
6236Function V_writeSampleTranslation(fname,val)
6237        String fname
6238        Variable val
6239       
6240//      String path = "entry:sample:translation"       
6241       
6242        Make/O/D/N=1 wTmpWrite
6243//      Make/O/R/N=1 wTmpWrite
6244        String groupName = "/entry/sample"
6245        String varName = "translation"
6246        wTmpWrite[0] = val
6247
6248        variable err
6249        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6250        if(err)
6251                Print "HDF write err = ",err
6252        endif
6253        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6254//      err = V_KillNamedDataFolder(fname)
6255//      if(err)
6256//              Print "DataFolder kill err = ",err
6257//      endif
6258        return(err)
6259end
6260
6261// sample transmission
6262Function V_writeSampleTransmission(fname,val)
6263        String fname
6264        Variable val
6265       
6266        String path = "entry:sample:transmission"       
6267       
6268        Make/O/D/N=1 wTmpWrite
6269//      Make/O/R/N=1 wTmpWrite
6270        String groupName = "/entry/sample"
6271        String varName = "transmission"
6272        wTmpWrite[0] = val
6273
6274        variable err
6275        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6276        if(err)
6277                Print "HDF write err = ",err
6278        endif
6279        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6280//      err = V_KillNamedDataFolder(fname)
6281//      if(err)
6282//              Print "DataFolder kill err = ",err
6283//      endif
6284        return(err)
6285end
6286
6287//transmission error (one sigma)
6288Function V_writeSampleTransError(fname,val)
6289        String fname
6290        Variable val
6291       
6292//      String path = "entry:sample:transmission_error"
6293       
6294        Make/O/D/N=1 wTmpWrite
6295//      Make/O/R/N=1 wTmpWrite
6296        String groupName = "/entry/sample"
6297        String varName = "transmission_error"
6298        wTmpWrite[0] = val
6299
6300        variable err
6301        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6302        if(err)
6303                Print "HDF write err = ",err
6304        endif
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        return(err)
6311end
6312
6313
6314
6315//// SAMPLE / DATA LOGS
6316// write this generic , call with the name of the environment log desired
6317//
6318//
6319// shear_field
6320// pressure
6321// magnetic_field
6322// electric_field
6323//
6324//////// (for example) electric_field (data folder)
6325
6326Function V_writeLog_attachedTo(fname,logStr,str)
6327        String fname,logStr,str
6328
6329//      String path = "entry:sample:"+logstr+":attached_to"
6330
6331        Make/O/T/N=1 tmpTW
6332        String groupName = "/entry/sample/"+logStr
6333        String varName = "attached_to"
6334        tmpTW[0] = str //
6335
6336        variable err
6337        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6338        if(err)
6339                Print "HDF write err = ",err
6340        endif
6341       
6342        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6343//      err = V_KillNamedDataFolder(fname)
6344//      if(err)
6345//              Print "DataFolder kill err = ",err
6346//      endif
6347               
6348        return(err)
6349End
6350
6351
6352Function V_writeLog_measurement(fname,logStr,str)
6353        String fname,logStr,str
6354
6355        String path = "entry:sample:"+logstr+":measurement"
6356
6357        Make/O/T/N=1 tmpTW
6358        String groupName = "/entry/sample/"+logStr
6359        String varName = "measurement"
6360        tmpTW[0] = str //
6361
6362        variable err
6363        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6364        if(err)
6365                Print "HDF write err = ",err
6366        endif
6367       
6368        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6369//      err = V_KillNamedDataFolder(fname)
6370//      if(err)
6371//              Print "DataFolder kill err = ",err
6372//      endif
6373               
6374        return(err)
6375End
6376
6377
6378Function V_writeLog_Name(fname,logStr,str)
6379        String fname,logStr,str
6380
6381//      String path = "entry:sample:"+logstr+":name"
6382
6383        Make/O/T/N=1 tmpTW
6384        String groupName = "/entry/sample/"+logStr
6385        String varName = "name"
6386        tmpTW[0] = str //
6387
6388        variable err
6389        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6390        if(err)
6391                Print "HDF write err = ",err
6392        endif
6393       
6394        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6395//      err = V_KillNamedDataFolder(fname)
6396//      if(err)
6397//              Print "DataFolder kill err = ",err
6398//      endif
6399               
6400        return(err)
6401End
6402
6403
6404//// TODO -- this may require multiple entries, for each sensor _1, _2, etc.
6405//Function V_writeLog_setPoint(fname,logStr,val)
6406//      String fname,logStr
6407//      Variable val
6408//     
6409////    String path = "entry:sample:"+logstr+":setpoint_1"
6410//     
6411//      Make/O/D/N=1 wTmpWrite
6412////    Make/O/R/N=1 wTmpWrite
6413//      String groupName = "/entry/sample/"+logStr
6414//      String varName = "setpoint_1"
6415//      wTmpWrite[0] = val
6416//
6417//      variable err
6418//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6419//      if(err)
6420//              Print "HDF write err = ",err
6421//      endif
6422//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6423////    err = V_KillNamedDataFolder(fname)
6424////    if(err)
6425////            Print "DataFolder kill err = ",err
6426////    endif
6427//      return(err)
6428//end
6429//
6430//Function V_writeLog_startTime(fname,logStr,str)
6431//      String fname,logStr,str
6432//
6433////    String path = "entry:sample:"+logstr+":start"
6434//
6435//      Make/O/T/N=1 tmpTW
6436//      String groupName = "/entry/sample/"+logStr
6437//      String varName = "start"
6438//      tmpTW[0] = str //
6439//
6440//      variable err
6441//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6442//      if(err)
6443//              Print "HDF write err = ",err
6444//      endif
6445//     
6446//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6447////    err = V_KillNamedDataFolder(fname)
6448////    if(err)
6449////            Print "DataFolder kill err = ",err
6450////    endif
6451//             
6452//      return(err)
6453//End
6454//
6455//
6456//// TODO -- this may only exist for electric and magnetic field, or be removed
6457//Function V_writeLog_nomValue(fname,logStr,val)
6458//      String fname,logStr
6459//      Variable val
6460//     
6461////    String path = "entry:sample:"+logstr+":value"
6462//     
6463//      Make/O/D/N=1 wTmpWrite
6464////    Make/O/R/N=1 wTmpWrite
6465//      String groupName = "/entry/sample/"+logStr
6466//      String varName = "value"
6467//      wTmpWrite[0] = val
6468//
6469//      variable err
6470//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6471//      if(err)
6472//              Print "HDF write err = ",err
6473//      endif
6474//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6475////    err = V_KillNamedDataFolder(fname)
6476////    if(err)
6477////            Print "DataFolder kill err = ",err
6478////    endif
6479//      return(err)
6480//end
6481
6482
6483// for temperature only, logStr must be "temperature_env"
6484Function V_writeTempLog_ControlSensor(fname,logStr,str)
6485        String fname,logStr,str
6486
6487//      String path = "entry:sample:"+logstr+":control_sensor"
6488
6489        Make/O/T/N=1 tmpTW
6490        String groupName = "/entry/sample/"+logStr
6491        String varName = "control_sensor"
6492        tmpTW[0] = str //
6493
6494        variable err
6495        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6496        if(err)
6497                Print "HDF write err = ",err
6498        endif
6499       
6500        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6501//      err = V_KillNamedDataFolder(fname)
6502//      if(err)
6503//              Print "DataFolder kill err = ",err
6504//      endif
6505               
6506        return(err)
6507End
6508
6509// for temperature only, logStr must be "temperature_env"
6510Function V_writeTempLog_MonitorSensor(fname,logStr,str)
6511        String fname,logStr,str
6512
6513//      String path = "entry:sample:"+logstr+":monitor_sensor"
6514
6515        Make/O/T/N=1 tmpTW
6516        String groupName = "/entry/sample/"+logStr
6517        String varName = "monitor_sensor"
6518        tmpTW[0] = str //
6519
6520        variable err
6521        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6522        if(err)
6523                Print "HDF write err = ",err
6524        endif
6525       
6526        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6527//      err = V_KillNamedDataFolder(fname)
6528//      if(err)
6529//              Print "DataFolder kill err = ",err
6530//      endif
6531               
6532        return(err)
6533End
6534
6535
6536
6537////////////////////
6538//
6539///////////
6540// NOTE
6541//
6542// for temperature, the "attached_to", "measurement", and "name" fields
6543// are one level down farther than before, and down deeper than for other sensors
6544//
6545//
6546// read the value of V_getTemp_MonitorSensor/ControlSensor to get the name of the sensor level .
6547//
6548
6549Function V_writeTempLog_attachedTo(fname,logStr,str)
6550        String fname,logStr,str
6551
6552//      String path = "entry:sample:temperature_env:"+logstr+":attached_to"
6553
6554        Make/O/T/N=1 tmpTW
6555        String groupName = "/entry/sample/temperature_env/"+logStr
6556        String varName = "attached_to"
6557        tmpTW[0] = str //
6558
6559        variable err
6560        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6561        if(err)
6562                Print "HDF write err = ",err
6563        endif
6564       
6565        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6566//      err = V_KillNamedDataFolder(fname)
6567//      if(err)
6568//              Print "DataFolder kill err = ",err
6569//      endif
6570               
6571        return(err)
6572End
6573
6574
6575Function V_writeTempLog_highTrip(fname,logStr,val)
6576        String fname,logStr
6577        Variable val
6578       
6579//      String path = "entry:sample:temperature_env:"+logstr+":high_trip_value"
6580       
6581        Make/O/D/N=1 wTmpWrite
6582//      Make/O/R/N=1 wTmpWrite
6583        String groupName = "/entry/sample/temperature_env/"+logStr
6584        String varName = "high_trip_value"
6585        wTmpWrite[0] = val
6586
6587        variable err
6588        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6589        if(err)
6590                Print "HDF write err = ",err
6591        endif
6592        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6593//      err = V_KillNamedDataFolder(fname)
6594//      if(err)
6595//              Print "DataFolder kill err = ",err
6596//      endif
6597        return(err)
6598end
6599
6600Function V_writeTempLog_holdTime(fname,logStr,val)
6601        String fname,logStr
6602        Variable val
6603       
6604//      String path = "entry:sample:temperature_env:"+logstr+":hold_time"
6605       
6606        Make/O/D/N=1 wTmpWrite
6607//      Make/O/R/N=1 wTmpWrite
6608        String groupName = "/entry/sample/temperature_env/"+logStr
6609        String varName = "hold_time"
6610        wTmpWrite[0] = val
6611
6612        variable err
6613        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6614        if(err)
6615                Print "HDF write err = ",err
6616        endif
6617        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6618//      err = V_KillNamedDataFolder(fname)
6619//      if(err)
6620//              Print "DataFolder kill err = ",err
6621//      endif
6622        return(err)
6623end
6624
6625Function V_writeTempLog_lowTrip(fname,logStr,val)
6626        String fname,logStr
6627        Variable val
6628       
6629//      String path = "entry:sample:temperature_env:"+logstr+":low_trip_value"
6630       
6631        Make/O/D/N=1 wTmpWrite
6632//      Make/O/R/N=1 wTmpWrite
6633        String groupName = "/entry/sample/temperature_env/"+logStr
6634        String varName = "low_trip_value"
6635        wTmpWrite[0] = val
6636
6637        variable err
6638        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6639        if(err)
6640                Print "HDF write err = ",err
6641        endif
6642        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6643//      err = V_KillNamedDataFolder(fname)
6644//      if(err)
6645//              Print "DataFolder kill err = ",err
6646//      endif
6647        return(err)
6648end
6649
6650Function V_writeTempLog_measurement(fname,logStr,str)
6651        String fname,logStr,str
6652
6653//      String path = "entry:sample:temperature_env:"+logstr+":measurement"
6654
6655        Make/O/T/N=1 tmpTW
6656        String groupName = "/entry/sample/temperature_env/"+logStr
6657        String varName = "measurement"
6658        tmpTW[0] = str //
6659
6660        variable err
6661        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6662        if(err)
6663                Print "HDF write err = ",err
6664        endif
6665       
6666        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6667//      err = V_KillNamedDataFolder(fname)
6668//      if(err)
6669//              Print "DataFolder kill err = ",err
6670//      endif
6671               
6672        return(err)
6673End
6674
6675Function V_writeTempLog_model(fname,logStr,str)
6676        String fname,logStr,str
6677
6678//      String path = "entry:sample:temperature_env:"+logstr+":model"
6679
6680        Make/O/T/N=1 tmpTW
6681        String groupName = "/entry/sample/temperature_env/"+logStr
6682        String varName = "model"
6683        tmpTW[0] = str //
6684
6685        variable err
6686        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6687        if(err)
6688                Print "HDF write err = ",err
6689        endif
6690       
6691        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6692//      err = V_KillNamedDataFolder(fname)
6693//      if(err)
6694//              Print "DataFolder kill err = ",err
6695//      endif
6696               
6697        return(err)
6698End
6699
6700Function V_writeTempLog_name(fname,logStr,str)
6701        String fname,logStr,str
6702
6703//      String path = "entry:sample:temperature_env:"+logstr+":name"
6704
6705        Make/O/T/N=1 tmpTW
6706        String groupName = "/entry/sample/temperature_env/"+logStr
6707        String varName = "name"
6708        tmpTW[0] = str //
6709
6710        variable err
6711        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6712        if(err)
6713                Print "HDF write err = ",err
6714        endif
6715       
6716        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6717//      err = V_KillNamedDataFolder(fname)
6718//      if(err)
6719//              Print "DataFolder kill err = ",err
6720//      endif
6721               
6722        return(err)
6723End
6724
6725Function V_writeTempLog_runControl(fname,logStr,val)
6726        String fname,logStr
6727        Variable val
6728       
6729//      String path = "entry:sample:temperature_env:"+logstr+":run_control"
6730       
6731        Make/O/D/N=1 wTmpWrite
6732//      Make/O/R/N=1 wTmpWrite
6733        String groupName = "/entry/sample/temperature_env/"+logStr
6734        String varName = "run_control"
6735        wTmpWrite[0] = val
6736
6737        variable err
6738        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6739        if(err)
6740                Print "HDF write err = ",err
6741        endif
6742        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6743//      err = V_KillNamedDataFolder(fname)
6744//      if(err)
6745//              Print "DataFolder kill err = ",err
6746//      endif
6747        return(err)
6748end
6749
6750Function V_writeTempLog_setPoint(fname,logStr,val)
6751        String fname,logStr
6752        Variable val
6753       
6754//      String path = "entry:sample:temperature_env:"+logstr+":setpoint"
6755       
6756        Make/O/D/N=1 wTmpWrite
6757//      Make/O/R/N=1 wTmpWrite
6758        String groupName = "/entry/sample/temperature_env/"+logStr
6759        String varName = "setpoint"
6760        wTmpWrite[0] = val
6761
6762        variable err
6763        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6764        if(err)
6765                Print "HDF write err = ",err
6766        endif
6767        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6768//      err = V_KillNamedDataFolder(fname)
6769//      if(err)
6770//              Print "DataFolder kill err = ",err
6771//      endif
6772        return(err)
6773end
6774
6775Function V_writeTempLog_shortName(fname,logStr,str)
6776        String fname,logStr,str
6777
6778//      String path = "entry:sample:temperature_env:"+logstr+":short_name"
6779
6780        Make/O/T/N=1 tmpTW
6781        String groupName = "/entry/sample/temperature_env/"+logStr
6782        String varName = "short_name"
6783        tmpTW[0] = str //
6784
6785        variable err
6786        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6787        if(err)
6788                Print "HDF write err = ",err
6789        endif
6790       
6791        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6792//      err = V_KillNamedDataFolder(fname)
6793//      if(err)
6794//              Print "DataFolder kill err = ",err
6795//      endif
6796               
6797        return(err)
6798End
6799
6800Function V_writeTempLog_timeout(fname,logStr,val)
6801        String fname,logStr
6802        Variable val
6803       
6804//      String path = "entry:sample:temperature_env:"+logstr+":timeout"
6805       
6806        Make/O/D/N=1 wTmpWrite
6807//      Make/O/R/N=1 wTmpWrite
6808        String groupName = "/entry/sample/temperature_env/"+logStr
6809        String varName = "timeout"
6810        wTmpWrite[0] = val
6811
6812        variable err
6813        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6814        if(err)
6815                Print "HDF write err = ",err
6816        endif
6817        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6818//      err = V_KillNamedDataFolder(fname)
6819//      if(err)
6820//              Print "DataFolder kill err = ",err
6821//      endif
6822        return(err)
6823end
6824
6825Function V_writeTempLog_tolerance(fname,logStr,val)
6826        String fname,logStr
6827        Variable val
6828       
6829//      String path = "entry:sample:temperature_env:"+logstr+":tolerance"
6830       
6831        Make/O/D/N=1 wTmpWrite
6832//      Make/O/R/N=1 wTmpWrite
6833        String groupName = "/entry/sample/temperature_env/"+logStr
6834        String varName = "tolerance"
6835        wTmpWrite[0] = val
6836
6837        variable err
6838        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6839        if(err)
6840                Print "HDF write err = ",err
6841        endif
6842        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6843//      err = V_KillNamedDataFolder(fname)
6844//      if(err)
6845//              Print "DataFolder kill err = ",err
6846//      endif
6847        return(err)
6848end
6849
6850Function V_writeTempLog_toleranceBand(fname,logStr,val)
6851        String fname,logStr
6852        Variable val
6853       
6854//      String path = "entry:sample:temperature_env:"+logstr+":tolerance_band_time"
6855       
6856        Make/O/D/N=1 wTmpWrite
6857//      Make/O/R/N=1 wTmpWrite
6858        String groupName = "/entry/sample/temperature_env/"+logStr
6859        String varName = "tolerance_band_time"
6860        wTmpWrite[0] = val
6861
6862        variable err
6863        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6864        if(err)
6865                Print "HDF write err = ",err
6866        endif
6867        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6868//      err = V_KillNamedDataFolder(fname)
6869//      if(err)
6870//              Print "DataFolder kill err = ",err
6871//      endif
6872        return(err)
6873end
6874
6875Function V_writeTempLog_Value(fname,logStr,val)
6876        String fname,logStr
6877        Variable val
6878       
6879//      String path = "entry:sample:temperature_env:"+logstr+":value"
6880       
6881        Make/O/D/N=1 wTmpWrite
6882//      Make/O/R/N=1 wTmpWrite
6883        String groupName = "/entry/sample/temperature_env/"+logStr
6884        String varName = "value"
6885        wTmpWrite[0] = val
6886
6887        variable err
6888        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6889        if(err)
6890                Print "HDF write err = ",err
6891        endif
6892        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6893//      err = V_KillNamedDataFolder(fname)
6894//      if(err)
6895//              Print "DataFolder kill err = ",err
6896//      endif
6897        return(err)
6898end
6899
6900
6901
6902
6903
6904//
6905// temperature_env:temp_Internal_1:value_log
6906//
6907////            value_log (data folder)
6908//
6909// TODO:
6910// -- be sure that the calling function properly calls for temperture
6911// logs which are down an extra layer:
6912//      for example, logStr = "temperature_env:temp_Internal_1"
6913//
6914// read the value of V_getTemp_MonitorSensor to get the name of the sensor the next level down.
6915//
6916//
6917/////////////////////////////////////
6918////            value_log (data folder)
6919//
6920// TODO --
6921Function V_writeLog_avgValue(fname,logStr,val)
6922        String fname,logStr
6923        Variable val
6924       
6925//      String path = "entry:sample:"+logstr+":value_log:average_value"
6926       
6927        Make/O/D/N=1 wTmpWrite
6928//      Make/O/R/N=1 wTmpWrite
6929        String groupName = "/entry/sample/"+logStr+"/value_log"
6930        String varName = "average_value"
6931        wTmpWrite[0] = val
6932
6933        variable err
6934        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6935        if(err)
6936                Print "HDF write err = ",err
6937        endif
6938        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6939//      err = V_KillNamedDataFolder(fname)
6940//      if(err)
6941//              Print "DataFolder kill err = ",err
6942//      endif
6943        return(err)
6944end
6945
6946Function V_writeLog_avgValue_err(fname,logStr,val)
6947        String fname,logStr
6948        Variable val
6949       
6950//      String path = "entry:sample:"+logstr+":value_log:average_value_error"
6951       
6952        Make/O/D/N=1 wTmpWrite
6953//      Make/O/R/N=1 wTmpWrite
6954        String groupName = "/entry/sample/"+logStr+"/value_log"
6955        String varName = "average_value_error"
6956        wTmpWrite[0] = val
6957
6958        variable err
6959        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6960        if(err)
6961                Print "HDF write err = ",err
6962        endif
6963        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6964//      err = V_KillNamedDataFolder(fname)
6965//      if(err)
6966//              Print "DataFolder kill err = ",err
6967//      endif
6968        return(err)
6969end
6970
6971Function V_writeLog_maximumValue(fname,logStr,val)
6972        String fname,logStr
6973        Variable val
6974       
6975//      String path = "entry:sample:"+logstr+":value_log:maximum_value"
6976       
6977        Make/O/D/N=1 wTmpWrite
6978//      Make/O/R/N=1 wTmpWrite
6979        String groupName = "/entry/sample/"+logStr+"/value_log"
6980        String varName = "maximum_value"
6981        wTmpWrite[0] = val
6982
6983        variable err
6984        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6985        if(err)
6986                Print "HDF write err = ",err
6987        endif
6988        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6989//      err = V_KillNamedDataFolder(fname)
6990//      if(err)
6991//              Print "DataFolder kill err = ",err
6992//      endif
6993        return(err)
6994end
6995
6996Function V_writeLog_medianValue(fname,logStr,val)
6997        String fname,logStr
6998        Variable val
6999       
7000//      String path = "entry:sample:"+logstr+":value_log:median_value"
7001       
7002        Make/O/D/N=1 wTmpWrite
7003//      Make/O/R/N=1 wTmpWrite
7004        String groupName = "/entry/sample/"+logStr+"/value_log"
7005        String varName = "median_value"
7006        wTmpWrite[0] = val
7007
7008        variable err
7009        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7010        if(err)
7011                Print "HDF write err = ",err
7012        endif
7013        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7014//      err = V_KillNamedDataFolder(fname)
7015//      if(err)
7016//              Print "DataFolder kill err = ",err
7017//      endif
7018        return(err)
7019end
7020
7021Function V_writeLog_minimumValue(fname,logStr,val)
7022        String fname,logStr
7023        Variable val
7024       
7025//      String path = "entry:sample:"+logstr+":value_log:minimum_value"
7026       
7027        Make/O/D/N=1 wTmpWrite
7028//      Make/O/R/N=1 wTmpWrite
7029        String groupName = "/entry/sample/"+logStr+"/value_log"
7030        String varName = "minimum_value"
7031        wTmpWrite[0] = val
7032
7033        variable err
7034        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7035        if(err)
7036                Print "HDF write err = ",err
7037        endif
7038        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7039//      err = V_KillNamedDataFolder(fname)
7040//      if(err)
7041//              Print "DataFolder kill err = ",err
7042//      endif
7043        return(err)
7044end
7045
7046
7047
7048// TODO -- this needs to be a WAVE reference
7049// be sure this gets written as "time", even though it is read in as "time0"
7050Function V_writeLog_timeWave(fname,logStr,inW)
7051        String fname,logStr
7052        Wave inW
7053       
7054//      String path = "entry:sample:"+logstr+":value_log:time"
7055
7056        Duplicate/O inW wTmpWrite       
7057// then use redimension as needed to cast the wave to write to the specified type
7058// see WaveType for the proper codes
7059//      Redimension/T=() wTmpWrite
7060// -- May also need to check the dimension(s) before writing (don't trust the input)
7061        String groupName = "/entry/sample/"+logStr+"/value_log"
7062        String varName = "time"
7063
7064        variable err
7065        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7066        if(err)
7067                Print "HDF write err = ",err
7068        endif
7069        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7070//      err = V_KillNamedDataFolder(fname)
7071//      if(err)
7072//              Print "DataFolder kill err = ",err
7073//      endif
7074        return(err)
7075end
7076
7077
7078// TODO -- this needs to be a WAVE reference
7079Function V_writeLog_ValueWave(fname,logStr,inW)
7080        String fname,logStr
7081        Wave inW
7082       
7083//      String path = "entry:sample:"+logstr+":value_log:value"
7084
7085        Duplicate/O inW wTmpWrite       
7086// then use redimension as needed to cast the wave to write to the specified type
7087// see WaveType for the proper codes
7088//      Redimension/T=() wTmpWrite
7089// -- May also need to check the dimension(s) before writing (don't trust the input)
7090        String groupName = "/entry/sample/"+logStr+"/value_log"
7091        String varName = "value"
7092
7093        variable err
7094        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7095        if(err)
7096                Print "HDF write err = ",err
7097        endif
7098        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7099//      err = V_KillNamedDataFolder(fname)
7100//      if(err)
7101//              Print "DataFolder kill err = ",err
7102//      endif
7103        return(err)
7104end
7105
7106
7107
7108
7109
7110
7111
7112
7113///////// REDUCTION
7114///////// REDUCTION
7115///////// REDUCTION
7116
7117
7118// TODO
7119// -- come up with a scheme to write the entire protocol to the data file?
7120// -- or a scheme to write just the missing bits?
7121
7122
7123// TODO -- needs to be a Text WAVE, and of the proper size and type!!!
7124//  -- this is a test where I write a wave to a field that does not exist...
7125Function V_writeReductionProtocolWave(fname,inTW)
7126        String fname
7127        Wave/T inTW
7128       
7129//      String path = "entry:reduction:absolute_scaling"
7130       
7131        Duplicate/O inTW wTTmpWrite     
7132// then use redimension as needed to cast the wave to write to the specified type
7133// see WaveType for the proper codes
7134//      Redimension/T=() wTmpWrite
7135// -- May also need to check the dimension(s) before writing (don't trust the input)
7136        String groupName = "/entry/reduction"   
7137        String varName = "protocol"
7138
7139        variable err
7140        err = V_WriteWaveToHDF(fname, groupName, varName, wTTmpWrite)
7141        if(err)
7142                Print "HDF write err = ",err
7143        endif
7144        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7145//      err = V_KillNamedDataFolder(fname)
7146//      if(err)
7147//              Print "DataFolder kill err = ",err
7148//      endif
7149        return(err)
7150end
7151
7152
7153// this is a NON NICE entered field
7154//
7155// this is a flag to mark the file as "flipped" so it prevents a 2nd flip
7156// if the flip has been done, the field is written with a value of 1 (= true)
7157//
7158// to "un-mark" the file and allow the flip to be re-done, write -999999
7159Function V_writeLeftRightFlipDone(fname,val)
7160        String fname
7161        Variable val
7162       
7163//      String path = "entry:reduction:left_right_flip"
7164       
7165        Make/O/D/N=1 wTmpWrite
7166//      Make/O/R/N=1 wTmpWrite
7167        String groupName = "/entry/reduction"
7168        String varName = "left_right_flip"
7169        wTmpWrite[0] = val
7170
7171        variable err
7172        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7173        if(err)
7174                Print "HDF write err = ",err
7175        endif
7176        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7177//      err = V_KillNamedDataFolder(fname)
7178//      if(err)
7179//              Print "DataFolder kill err = ",err
7180//      endif
7181        return(err)
7182end
7183
7184
7185
7186// TODO -- needs to be a WAVE, and of the proper size and type!!!
7187Function V_writeAbsolute_Scaling(fname,inW)
7188        String fname
7189        Wave inW
7190       
7191//      String path = "entry:reduction:absolute_scaling"
7192       
7193        Duplicate/O inW wTmpWrite       
7194// then use redimension as needed to cast the wave to write to the specified type
7195// see WaveType for the proper codes
7196//      Redimension/T=() wTmpWrite
7197// -- May also need to check the dimension(s) before writing (don't trust the input)
7198        String groupName = "/entry/reduction"   
7199        String varName = "absolute_scaling"
7200
7201        variable err
7202        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7203        if(err)
7204                Print "HDF write err = ",err
7205        endif
7206        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7207//      err = V_KillNamedDataFolder(fname)
7208//      if(err)
7209//              Print "DataFolder kill err = ",err
7210//      endif
7211        return(err)
7212end
7213
7214Function V_writeBackgroundFileName(fname,str)
7215        String fname,str
7216
7217//      String path = "entry:reduction:background_file_name"   
7218
7219        Make/O/T/N=1 tmpTW
7220        String groupName = "/entry/reduction"
7221        String varName = "background_file_name"
7222        tmpTW[0] = str //
7223
7224        variable err
7225        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7226        if(err)
7227                Print "HDF write err = ",err
7228        endif
7229       
7230        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7231//      err = V_KillNamedDataFolder(fname)
7232//      if(err)
7233//              Print "DataFolder kill err = ",err
7234//      endif
7235               
7236        return(err)
7237End
7238
7239
7240// TODO -- needs to be a WAVE
7241Function V_writeBoxCoordinates(fname,inW)
7242        String fname
7243        Wave inW
7244       
7245//      String path = "entry:reduction:box_coordinates"
7246               
7247        Duplicate/O inW wTmpWrite       
7248// then use redimension as needed to cast the wave to write to the specified type
7249// see WaveType for the proper codes
7250//      Redimension/T=() wTmpWrite
7251// -- May also need to check the dimension(s) before writing (don't trust the input)
7252        String groupName = "/entry/reduction"   
7253        String varName = "box_coordinates"
7254
7255        variable err
7256        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7257        if(err)
7258                Print "HDF write err = ",err
7259        endif
7260        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7261//      err = V_KillNamedDataFolder(fname)
7262//      if(err)
7263//              Print "DataFolder kill err = ",err
7264//      endif
7265        return(err)
7266end
7267
7268// THIS IS A NON-NICE ENTERED FIELD
7269// -- this is the panel string where the box coordinates refer to (for the open beam and transmission)
7270Function V_writeReduction_BoxPanel(fname,str)
7271        String fname,str
7272
7273//      String path = "entry:reduction:comments"       
7274
7275        Make/O/T/N=1 tmpTW
7276        String groupName = "/entry/reduction"
7277        String varName = "box_panel"
7278        tmpTW[0] = str //
7279
7280        variable err
7281        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7282        if(err)
7283                Print "HDF write err = ",err
7284        endif
7285       
7286        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7287//      err = V_KillNamedDataFolder(fname)
7288//      if(err)
7289//              Print "DataFolder kill err = ",err
7290//      endif
7291               
7292        return(err)
7293End
7294
7295//box counts
7296Function V_writeBoxCounts(fname,val)
7297        String fname
7298        Variable val
7299       
7300//      String path = "entry:reduction:box_count"       
7301       
7302        Make/O/D/N=1 wTmpWrite
7303//      Make/O/R/N=1 wTmpWrite
7304        String groupName = "/entry/reduction"
7305        String varName = "box_count"
7306        wTmpWrite[0] = val
7307
7308        variable err
7309        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7310        if(err)
7311                Print "HDF write err = ",err
7312        endif
7313        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7314//      err = V_KillNamedDataFolder(fname)
7315//      if(err)
7316//              Print "DataFolder kill err = ",err
7317//      endif
7318        return(err)
7319end
7320
7321//box counts error
7322Function V_writeBoxCountsError(fname,val)
7323        String fname
7324        Variable val
7325       
7326//      String path = "entry:reduction:box_count_error"
7327       
7328        Make/O/D/N=1 wTmpWrite
7329//      Make/O/R/N=1 wTmpWrite
7330        String groupName = "/entry/reduction"
7331        String varName = "box_count_error"
7332        wTmpWrite[0] = val
7333
7334        variable err
7335        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7336        if(err)
7337                Print "HDF write err = ",err
7338        endif
7339        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7340//      err = V_KillNamedDataFolder(fname)
7341//      if(err)
7342//              Print "DataFolder kill err = ",err
7343//      endif
7344        return(err)
7345end
7346
7347Function V_writeReductionComments(fname,str)
7348        String fname,str
7349
7350//      String path = "entry:reduction:comments"       
7351
7352        Make/O/T/N=1 tmpTW
7353        String groupName = "/entry/reduction"
7354        String varName = "comments"
7355        tmpTW[0] = str //
7356
7357        variable err
7358        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7359        if(err)
7360                Print "HDF write err = ",err
7361        endif
7362       
7363        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7364//      err = V_KillNamedDataFolder(fname)
7365//      if(err)
7366//              Print "DataFolder kill err = ",err
7367//      endif
7368               
7369        return(err)
7370End
7371
7372Function V_writeEmptyBeamFileName(fname,str)
7373        String fname,str
7374
7375//      String path = "entry:reduction:empty_beam_file_name"   
7376
7377        Make/O/T/N=1 tmpTW
7378        String groupName = "/entry/reduction"
7379        String varName = "empty_beam_file_name"
7380        tmpTW[0] = str //
7381
7382        variable err
7383        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7384        if(err)
7385                Print "HDF write err = ",err
7386        endif
7387       
7388        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7389//      err = V_KillNamedDataFolder(fname)
7390//      if(err)
7391//              Print "DataFolder kill err = ",err
7392//      endif
7393               
7394        return(err)
7395End
7396
7397Function V_writeEmptyFileName(fname,str)
7398        String fname,str
7399
7400//      String path = "entry:reduction:empty_beam_file_name"   
7401
7402        Make/O/T/N=1 tmpTW
7403        String groupName = "/entry/reduction"
7404        String varName = "empty_file_name"
7405        tmpTW[0] = str //
7406
7407        variable err
7408        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7409        if(err)
7410                Print "HDF write err = ",err
7411        endif
7412       
7413        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7414//      err = V_KillNamedDataFolder(fname)
7415//      if(err)
7416//              Print "DataFolder kill err = ",err
7417//      endif
7418               
7419        return(err)
7420End
7421
7422Function V_writeReduction_purpose(fname,str)
7423        String fname,str
7424
7425//      String path = "entry:reduction:file_purpose"   
7426
7427        Make/O/T/N=1 tmpTW
7428        String groupName = "/entry/reduction"
7429        String varName = "file_purpose"
7430        tmpTW[0] = str //
7431
7432        variable err
7433        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7434        if(err)
7435                Print "HDF write err = ",err
7436        endif
7437       
7438        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7439//      err = V_KillNamedDataFolder(fname)
7440//      if(err)
7441//              Print "DataFolder kill err = ",err
7442//      endif
7443               
7444        return(err)
7445End
7446
7447// DONE x- commented out, not to be used
7448//  x- is this duplicated? - yes - this is duplicated in /entry/sample
7449//  x- so I need to pick a location, or be sure to fix it in both places
7450//Function V_writeReduction_group_ID(fname,val)
7451//      String fname
7452//      Variable val
7453//     
7454////    String path = "entry:reduction:group_id"       
7455//     
7456//      Make/O/D/N=1 wTmpWrite
7457////    Make/O/R/N=1 wTmpWrite
7458//      String groupName = "/entry/reduction"
7459//      String varName = "group_id"
7460//      wTmpWrite[0] = val
7461//
7462//      variable err
7463//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7464//      if(err)
7465//              Print "HDF write err = ",err
7466//      endif
7467//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7468////    err = V_KillNamedDataFolder(fname)
7469////    if(err)
7470////            Print "DataFolder kill err = ",err
7471////    endif
7472//      return(err)
7473//end
7474
7475Function V_writeReductionIntent(fname,str)
7476        String fname,str
7477
7478//      String path = "entry:reduction:intent" 
7479
7480        Make/O/T/N=1 tmpTW
7481        String groupName = "/entry/reduction"
7482        String varName = "intent"
7483        tmpTW[0] = str //
7484
7485        variable err
7486        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7487        if(err)
7488                Print "HDF write err = ",err
7489        endif
7490       
7491        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7492//      err = V_KillNamedDataFolder(fname)
7493//      if(err)
7494//              Print "DataFolder kill err = ",err
7495//      endif
7496               
7497        return(err)
7498End
7499
7500Function V_writeMaskFileName(fname,str)
7501        String fname,str
7502
7503//      String path = "entry:reduction:empty_beam_file_name"   
7504
7505        Make/O/T/N=1 tmpTW
7506        String groupName = "/entry/reduction"
7507        String varName = "mask_file_name"
7508        tmpTW[0] = str //
7509
7510        variable err
7511        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7512        if(err)
7513                Print "HDF write err = ",err
7514        endif
7515       
7516        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7517//      err = V_KillNamedDataFolder(fname)
7518//      if(err)
7519//              Print "DataFolder kill err = ",err
7520//      endif
7521               
7522        return(err)
7523End
7524
7525
7526
7527Function V_writeLogFileName(fname,str)
7528        String fname,str
7529
7530//      String path = "entry:reduction:sans_log_file_name"     
7531
7532        Make/O/T/N=1 tmpTW
7533        String groupName = "/entry/reduction"
7534        String varName = "sans_log_file_name"
7535        tmpTW[0] = str //
7536
7537        variable err
7538        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7539        if(err)
7540                Print "HDF write err = ",err
7541        endif
7542       
7543        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7544//      err = V_KillNamedDataFolder(fname)
7545//      if(err)
7546//              Print "DataFolder kill err = ",err
7547//      endif
7548               
7549        return(err)
7550End
7551
7552
7553Function V_writeSensitivityFileName(fname,str)
7554        String fname,str
7555
7556//      String path = "entry:reduction:sensitivity_file_name"   
7557
7558        Make/O/T/N=1 tmpTW
7559        String groupName = "/entry/reduction"
7560        String varName = "sensitivity_file_name"
7561        tmpTW[0] = str //
7562
7563        variable err
7564        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7565        if(err)
7566                Print "HDF write err = ",err
7567        endif
7568       
7569        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7570//      err = V_KillNamedDataFolder(fname)
7571//      if(err)
7572//              Print "DataFolder kill err = ",err
7573//      endif
7574               
7575        return(err)
7576End
7577
7578Function V_writeTransmissionFileName(fname,str)
7579        String fname,str
7580
7581//      String path = "entry:reduction:transmission_file_name" 
7582
7583        Make/O/T/N=1 tmpTW
7584        String groupName = "/entry/reduction"
7585        String varName = "transmission_file_name"
7586        tmpTW[0] = str //
7587
7588        variable err
7589        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7590        if(err)
7591                Print "HDF write err = ",err
7592        endif
7593       
7594        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7595//      err = V_KillNamedDataFolder(fname)
7596//      if(err)
7597//              Print "DataFolder kill err = ",err
7598//      endif
7599               
7600        return(err)
7601End
7602
7603
7604//whole detector transmission
7605Function V_writeSampleTransWholeDetector(fname,val)
7606        String fname
7607        Variable val
7608       
7609//      String path = "entry:reduction:whole_trans"     
7610       
7611        Make/O/D/N=1 wTmpWrite
7612//      Make/O/R/N=1 wTmpWrite
7613        String groupName = "/entry/reduction"
7614        String varName = "whole_trans"
7615        wTmpWrite[0] = val
7616
7617        variable err
7618        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7619        if(err)
7620                Print "HDF write err = ",err
7621        endif
7622        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7623//      err = V_KillNamedDataFolder(fname)
7624//      if(err)
7625//              Print "DataFolder kill err = ",err
7626//      endif
7627        return(err)
7628end
7629
7630//whole detector transmission error
7631Function V_writeSampleTransWholeDetErr(fname,val)
7632        String fname
7633        Variable val
7634       
7635//      String path = "entry:reduction:whole_trans_error"       
7636       
7637        Make/O/D/N=1 wTmpWrite
7638//      Make/O/R/N=1 wTmpWrite
7639        String groupName = "/entry/reduction"
7640        String varName = "whole_trans_error"
7641        wTmpWrite[0] = val
7642
7643        variable err
7644        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7645        if(err)
7646                Print "HDF write err = ",err
7647        endif
7648        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7649//      err = V_KillNamedDataFolder(fname)
7650//      if(err)
7651//              Print "DataFolder kill err = ",err
7652//      endif
7653        return(err)
7654end
7655
7656                       
7657///////                 pol_sans (data folder)
7658//
7659//Function V_writePolSANS_cellName(fname,str)
7660//      String fname,str
7661//
7662////    String path = "entry:reduction:pol_sans:cell_name"     
7663//
7664//      Make/O/T/N=1 tmpTW
7665//      String groupName = "/entry/reduction/pol_sans"
7666//      String varName = "cell_name"
7667//      tmpTW[0] = str //
7668//
7669//      variable err
7670//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7671//      if(err)
7672//              Print "HDF write err = ",err
7673//      endif
7674//     
7675//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7676////    err = V_KillNamedDataFolder(fname)
7677////    if(err)
7678////            Print "DataFolder kill err = ",err
7679////    endif
7680//             
7681//      return(err)
7682//End
7683//
7684//
7685//// TODO -- needs to be a WAVE
7686//// is this a text wave?? if it's mixed names + values, then what?
7687//Function V_writePolSANS_cellParams(fname,inW)
7688//      String fname
7689//      Wave inW
7690//     
7691////    String path = "entry:reduction:pol_sans:cell_parameters"
7692//             
7693//      Duplicate/O inW wTmpWrite       
7694//// then use redimension as needed to cast the wave to write to the specified type
7695//// see WaveType for the proper codes
7696////    Redimension/T=() wTmpWrite
7697//// -- May also need to check the dimension(s) before writing (don't trust the input)
7698//      String groupName = "/entry/reduction/pol_sans" 
7699//      String varName = "cell_parameters"
7700//
7701//      variable err
7702//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
7703//      if(err)
7704//              Print "HDF write err = ",err
7705//      endif
7706//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7707////    err = V_KillNamedDataFolder(fname)
7708////    if(err)
7709////            Print "DataFolder kill err = ",err
7710////    endif
7711//      return(err)
7712//end
7713//
7714//Function V_writePolSANS_PolSANSPurpose(fname,str)
7715//      String fname,str
7716//
7717////    String path = "entry:reduction:pol_sans:pol_sans_purpose"       
7718//
7719//      Make/O/T/N=1 tmpTW
7720//      String groupName = "/entry/reduction/pol_sans"
7721//      String varName = "pol_sans_purpose"
7722//      tmpTW[0] = str //
7723//
7724//      variable err
7725//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7726//      if(err)
7727//              Print "HDF write err = ",err
7728//      endif
7729//     
7730//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7731////    err = V_KillNamedDataFolder(fname)
7732////    if(err)
7733////            Print "DataFolder kill err = ",err
7734////    endif
7735//             
7736//      return(err)
7737//End
7738
7739                               
7740//////// TOP LEVEL DATA REPRESENTATION
7741//
7742// note that here the data is (supposed to be) a link, not the actual data
7743// Igor HDf implementation cannot follow links properly, as far as I know.
7744// so ignore them here, and focus on the image that may be possible to read
7745//
7746
7747//              data_B (data folder)
7748//                      data (wave) 1           //ignore this, it's a link
7749//                      variables (wave) 320
7750//                      thumbnail (data folder)
7751
7752////data (wave) "binary"
7753//// TODO -- this will need to be completely replaced with a function that can
7754//// read the binary image data. should be possible, but I don't know the details on either end...
7755//Function V_writeDataImage(fname,detStr,str)
7756//      String fname,detStr,str
7757//
7758////    String path = "entry:data_"+detStr+":thumbnail:data"   
7759//
7760//      Make/O/T/N=1 tmpTW
7761//      String groupName = "/entry/data_"+detStr+"/thumbnail"
7762//      String varName = "data"
7763//      tmpTW[0] = str //
7764//
7765//      variable err
7766//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7767//      if(err)
7768//              Print "HDF write err = ",err
7769//      endif
7770//     
7771//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7772////    err = V_KillNamedDataFolder(fname)
7773////    if(err)
7774////            Print "DataFolder kill err = ",err
7775////    endif
7776//             
7777//      return(err)
7778//End
7779//
7780//Function V_writeDataImageDescription(fname,detStr,str)
7781//      String fname,detStr,str
7782//
7783////    String path = "entry:data_"+detStr+":thumbnail:description"     
7784//
7785//      Make/O/T/N=1 tmpTW
7786//      String groupName = "/entry/data_"+detStr+"/thumbnail"
7787//      String varName = "description"
7788//      tmpTW[0] = str //
7789//
7790//      variable err
7791//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7792//      if(err)
7793//              Print "HDF write err = ",err
7794//      endif
7795//     
7796//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7797////    err = V_KillNamedDataFolder(fname)
7798////    if(err)
7799////            Print "DataFolder kill err = ",err
7800////    endif
7801//             
7802//      return(err)
7803//End
7804//                                                             
7805//Function V_writeDataImageType(fname,detStr,str)
7806//      String fname,detStr,str
7807//
7808////    String path = "entry:data_"+detStr+":thumbnail:type"   
7809//
7810//      Make/O/T/N=1 tmpTW
7811//      String groupName = "/entry/data_"+detStr+"/thumbnail"
7812//      String varName = "type"
7813//      tmpTW[0] = str //
7814//
7815//      variable err
7816//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
7817//      if(err)
7818//              Print "HDF write err = ",err
7819//      endif
7820//     
7821//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
7822////    err = V_KillNamedDataFolder(fname)
7823////    if(err)
7824////            Print "DataFolder kill err = ",err
7825////    endif
7826//             
7827//      return(err)
7828//End
7829//
Note: See TracBrowser for help on using the repository browser.