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

Last change on this file since 1063 was 1063, checked in by srkline, 5 years ago

proper handling of setback, intent, and purpose. New value of setback is included, and proper definition of how purpose and intent are defined within NICE and the GUI are partly completed now. Searches still need to be updated.

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