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

Last change on this file since 1000 was 1000, checked in by srkline, 7 years ago

read/write for lateral + vertical offset of detectors, eliminating some extra unused fields.

more additions to the mask editor to give some basic functionality (add/del tubes, save mask)

File size: 157.2 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// TODO -- 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,val)
605        String fname
606        Variable val
607       
608//      String path = "entry:control:count_end"
609       
610        Make/O/D/N=1 wTmpWrite
611//      Make/O/R/N=1 wTmpWrite
612        String groupName = "/entry/control"     
613        String varName = "count_end"
614        wTmpWrite[0] = val
615
616        variable err
617        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
618        if(err)
619                Print "HDF write err = ",err
620        endif
621        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
622//      err = V_KillNamedDataFolder(fname)
623//      if(err)
624//              Print "DataFolder kill err = ",err
625//      endif
626        return(err)
627end
628
629
630Function V_writeCount_start(fname,val)
631        String fname
632        Variable val
633       
634//      String path = "entry:control:count_start"       
635       
636        Make/O/D/N=1 wTmpWrite
637//      Make/O/R/N=1 wTmpWrite
638        String groupName = "/entry/control"     
639        String varName = "count_start"
640        wTmpWrite[0] = val
641
642        variable err
643        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
644        if(err)
645                Print "HDF write err = ",err
646        endif
647        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
648//      err = V_KillNamedDataFolder(fname)
649//      if(err)
650//              Print "DataFolder kill err = ",err
651//      endif
652        return(err)
653end
654
655
656Function V_writeCount_time(fname,val)
657        String fname
658        Variable val
659       
660//      String path = "entry:control:count_time"       
661       
662        Make/O/D/N=1 wTmpWrite
663//      Make/O/R/N=1 wTmpWrite
664        String groupName = "/entry/control"     
665        String varName = "count_time"
666        wTmpWrite[0] = val
667
668        variable err
669        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
670        if(err)
671                Print "HDF write err = ",err
672        endif
673        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
674//      err = V_KillNamedDataFolder(fname)
675//      if(err)
676//              Print "DataFolder kill err = ",err
677//      endif
678        return(err)
679end
680
681
682Function V_writeCount_time_preset(fname,val)
683        String fname
684        Variable val
685       
686//      String path = "entry:control:count_time_preset"
687       
688        Make/O/D/N=1 wTmpWrite
689//      Make/O/R/N=1 wTmpWrite
690        String groupName = "/entry/control"     
691        String varName = "count_time_preset"
692        wTmpWrite[0] = val
693
694        variable err
695        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
696        if(err)
697                Print "HDF write err = ",err
698        endif
699        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
700//      err = V_KillNamedDataFolder(fname)
701//      if(err)
702//              Print "DataFolder kill err = ",err
703//      endif
704        return(err)
705end
706
707
708Function V_writeDetector_counts(fname,val)
709        String fname
710        Variable val
711       
712//      String path = "entry:control:detector_counts"
713       
714        Make/O/D/N=1 wTmpWrite
715//      Make/O/R/N=1 wTmpWrite
716        String groupName = "/entry/control"     
717        String varName = "detector_counts"
718        wTmpWrite[0] = val
719
720        variable err
721        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
722        if(err)
723                Print "HDF write err = ",err
724        endif
725        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
726//      err = V_KillNamedDataFolder(fname)
727//      if(err)
728//              Print "DataFolder kill err = ",err
729//      endif
730        return(err)
731end
732
733
734Function V_writeDetector_preset(fname,val)
735        String fname
736        Variable val
737       
738//      String path = "entry:control:detector_preset"   
739       
740        Make/O/D/N=1 wTmpWrite
741//      Make/O/R/N=1 wTmpWrite
742        String groupName = "/entry/control"     
743        String varName = "detector_preset"
744        wTmpWrite[0] = val
745
746        variable err
747        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
748        if(err)
749                Print "HDF write err = ",err
750        endif
751        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
752//      err = V_KillNamedDataFolder(fname)
753//      if(err)
754//              Print "DataFolder kill err = ",err
755//      endif
756        return(err)
757end
758
759// integer value
760Function V_writeIntegral(fname,val)
761        String fname
762        Variable val
763       
764//      String path = "entry:control:integral"
765       
766        Make/O/I/N=1 wTmpWrite
767//      Make/O/R/N=1 wTmpWrite
768        String groupName = "/entry/control"     
769        String varName = "integral"
770        wTmpWrite[0] = val
771
772        variable err
773        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
774        if(err)
775                Print "HDF write err = ",err
776        endif
777        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
778//      err = V_KillNamedDataFolder(fname)
779//      if(err)
780//              Print "DataFolder kill err = ",err
781//      endif
782        return(err)
783end
784
785// control mode for data acquisition, "timer"
786Function V_writeControlMode(fname,str)
787        String fname,str
788       
789//      String path = "entry:control:mode"     
790
791        Make/O/T/N=1 tmpTW
792        String groupName = "/entry/control"     //     
793        String varName = "mode"
794        tmpTW[0] = str //
795
796        variable err
797        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
798        if(err)
799                Print "HDF write err = ",err
800        endif
801       
802        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
803//      err = V_KillNamedDataFolder(fname)
804//      if(err)
805//              Print "DataFolder kill err = ",err
806//      endif
807               
808        return(err)
809End
810
811//monitor count
812// integer value
813Function V_writeMonitorCount(fname,val)
814        String fname
815        Variable val
816       
817//      String path = "entry:control:monitor_counts"   
818       
819        Make/O/I/N=1 wTmpWrite
820//      Make/O/R/N=1 wTmpWrite
821        String groupName = "/entry/control"     
822        String varName = "monitor_counts"
823        wTmpWrite[0] = val
824
825        variable err
826        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
827        if(err)
828                Print "HDF write err = ",err
829        endif
830        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
831//      err = V_KillNamedDataFolder(fname)
832//      if(err)
833//              Print "DataFolder kill err = ",err
834//      endif
835        return(err)
836end
837
838//integer value
839Function V_writeMonitor_preset(fname,val)
840        String fname
841        Variable val
842       
843//      String path = "entry:control:monitor_preset"
844       
845        Make/O/I/N=1 wTmpWrite
846//      Make/O/R/N=1 wTmpWrite
847        String groupName = "/entry/control"     
848        String varName = "monitor_preset"
849        wTmpWrite[0] = val
850
851        variable err
852        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
853        if(err)
854                Print "HDF write err = ",err
855        endif
856        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
857//      err = V_KillNamedDataFolder(fname)
858//      if(err)
859//              Print "DataFolder kill err = ",err
860//      endif
861        return(err)
862end
863
864Function V_writePreset(fname,str)
865        String fname,str
866       
867//      String path = "entry:control:preset"
868               
869        Make/O/T/N=1 tmpTW
870        String groupName = "/entry/control"     
871        String varName = "preset"
872        tmpTW[0] = str //
873
874        variable err
875        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
876        if(err)
877                Print "HDF write err = ",err
878        endif
879        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
880//      err = V_KillNamedDataFolder(fname)
881//      if(err)
882//              Print "DataFolder kill err = ",err
883//      endif
884        return(err)
885end
886
887
888
889
890
891//////// INSTRUMENT
892//////// INSTRUMENT
893//////// INSTRUMENT
894
895Function V_writeLocalContact(fname,str)
896        String fname,str
897
898//      String path = "entry:instrument:local_contact"
899
900        Make/O/T/N=1 tmpTW
901        String groupName = "/entry/instrument"  //     
902        String varName = "local_contact"
903        tmpTW[0] = str //
904
905        variable err
906        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
907        if(err)
908                Print "HDF write err = ",err
909        endif
910       
911        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
912//      err = V_KillNamedDataFolder(fname)
913//      if(err)
914//              Print "DataFolder kill err = ",err
915//      endif
916               
917        return(err)
918End
919
920Function V_writeInstrumentName(fname,str)
921        String fname,str
922
923//      String path = "entry:instrument:name"
924
925        Make/O/T/N=1 tmpTW
926        String groupName = "/entry/instrument"  //     
927        String varName = "name"
928        tmpTW[0] = str //
929
930        variable err
931        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
932        if(err)
933                Print "HDF write err = ",err
934        endif
935       
936        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
937//      err = V_KillNamedDataFolder(fname)
938//      if(err)
939//              Print "DataFolder kill err = ",err
940//      endif
941               
942        return(err)
943End
944
945Function V_writeInstrumentType(fname,str)
946        String fname,str
947
948//      String path = "entry:instrument:type"
949
950        Make/O/T/N=1 tmpTW
951        String groupName = "/entry/instrument"  //     
952        String varName = "type"
953        tmpTW[0] = str //
954
955        variable err
956        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
957        if(err)
958                Print "HDF write err = ",err
959        endif
960       
961        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
962//      err = V_KillNamedDataFolder(fname)
963//      if(err)
964//              Print "DataFolder kill err = ",err
965//      endif
966               
967        return(err)
968End
969
970////// INSTRUMENT/ATTENUATOR
971// TODO - verify the format of how these are written out to the file
972//
973//Function V_writeAtten_number(fname,val)
974//      String fname
975//      Variable val
976//     
977////    String path = "entry:instrument:attenuator:atten_number"       
978//     
979//      Make/O/D/N=1 wTmpWrite
980////    Make/O/R/N=1 wTmpWrite
981//      String groupName = "/entry/instrument/attenuator"       
982//      String varName = "atten_number"
983//      wTmpWrite[0] = val
984//
985//      variable err
986//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
987//      if(err)
988//              Print "HDF write err = ",err
989//      endif
990//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
991////    err = V_KillNamedDataFolder(fname)
992////    if(err)
993////            Print "DataFolder kill err = ",err
994////    endif
995//      return(err)
996//end
997
998
999// transmission value for the attenuator in the beam
1000// use this, but if something wrong, the tables are present
1001Function V_writeAttenuator_transmission(fname,val)
1002        String fname
1003        Variable val
1004       
1005//      String path = "entry:instrument:attenuator:attenuator_transmission"     
1006       
1007        Make/O/D/N=1 wTmpWrite
1008//      Make/O/R/N=1 wTmpWrite
1009        String groupName = "/entry/instrument/attenuator"       
1010        String varName = "attenuator_transmission"
1011        wTmpWrite[0] = val
1012
1013        variable err
1014        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1015        if(err)
1016                Print "HDF write err = ",err
1017        endif
1018        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1019//      err = V_KillNamedDataFolder(fname)
1020//      if(err)
1021//              Print "DataFolder kill err = ",err
1022//      endif
1023        return(err)
1024end
1025
1026// transmission value (error) for the attenuator in the beam
1027// use this, but if something wrong, the tables are present
1028Function V_writeAttenuator_trans_err(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 = "attenuator_transmission_error"
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// desired thickness of attenuation
1054Function V_writeAttenuator_desiredThick(fname,val)
1055        String fname
1056        Variable val
1057       
1058//      String path = "entry:instrument:attenuator:attenuator_transmission_error"       
1059       
1060        Make/O/D/N=1 wTmpWrite
1061//      Make/O/R/N=1 wTmpWrite
1062        String groupName = "/entry/instrument/attenuator"       
1063        String varName = "desired_thickness"
1064        wTmpWrite[0] = val
1065
1066        variable err
1067        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1068        if(err)
1069                Print "HDF write err = ",err
1070        endif
1071        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1072//      err = V_KillNamedDataFolder(fname)
1073//      if(err)
1074//              Print "DataFolder kill err = ",err
1075//      endif
1076        return(err)
1077end
1078
1079
1080// distance from the attenuator to the sample (units??)
1081Function V_writeAttenDistance(fname,val)
1082        String fname
1083        Variable val
1084       
1085//      String path = "entry:instrument:attenuator:distance"   
1086       
1087        Make/O/D/N=1 wTmpWrite
1088//      Make/O/R/N=1 wTmpWrite
1089        String groupName = "/entry/instrument/attenuator"       
1090        String varName = "distance"
1091        wTmpWrite[0] = val
1092
1093        variable err
1094        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1095        if(err)
1096                Print "HDF write err = ",err
1097        endif
1098        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1099//      err = V_KillNamedDataFolder(fname)
1100//      if(err)
1101//              Print "DataFolder kill err = ",err
1102//      endif
1103        return(err)
1104end
1105
1106// table of the attenuation factor error
1107Function V_writeAttenIndex_table_err(fname,inW)
1108        String fname
1109        Wave inW
1110       
1111//      String path = "entry:instrument:attenuator:index_table"
1112       
1113        Duplicate/O inW wTmpWrite       
1114// then use redimension as needed to cast the wave to write to the specified type
1115// see WaveType for the proper codes
1116//      Redimension/T=() wTmpWrite
1117// -- May also need to check the dimension(s) before writing (don't trust the input)
1118        String groupName = "/entry/instrument/attenuator"       
1119        String varName = "index_error_table"
1120
1121        variable err
1122        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1123        if(err)
1124                Print "HDF write err = ",err
1125        endif
1126        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1127//      err = V_KillNamedDataFolder(fname)
1128//      if(err)
1129//              Print "DataFolder kill err = ",err
1130//      endif
1131        return(err)
1132end
1133
1134// table of the attenuation factor
1135Function V_writeAttenIndex_table(fname,inW)
1136        String fname
1137        Wave inW
1138       
1139//      String path = "entry:instrument:attenuator:index_table"
1140       
1141        Duplicate/O inW wTmpWrite       
1142// then use redimension as needed to cast the wave to write to the specified type
1143// see WaveType for the proper codes
1144//      Redimension/T=() wTmpWrite
1145// -- May also need to check the dimension(s) before writing (don't trust the input)
1146        String groupName = "/entry/instrument/attenuator"       
1147        String varName = "index_table"
1148
1149        variable err
1150        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1151        if(err)
1152                Print "HDF write err = ",err
1153        endif
1154        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1155//      err = V_KillNamedDataFolder(fname)
1156//      if(err)
1157//              Print "DataFolder kill err = ",err
1158//      endif
1159        return(err)
1160end
1161
1162
1163//// status "in or out"
1164//Function V_writeAttenStatus(fname,str)
1165//      String fname,str
1166//
1167////    String path = "entry:instrument:attenuator:status"
1168//
1169//      Make/O/T/N=1 tmpTW
1170//      String groupName = "/entry/instrument/attenuator"       //     
1171//      String varName = "status"
1172//      tmpTW[0] = str //
1173//
1174//      variable err
1175//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1176//      if(err)
1177//              Print "HDF write err = ",err
1178//      endif
1179//     
1180//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1181////    err = V_KillNamedDataFolder(fname)
1182////    if(err)
1183////            Print "DataFolder kill err = ",err
1184////    endif
1185//             
1186//      return(err)
1187//End
1188
1189// number of attenuators actually dropped in
1190// an integer value
1191Function V_writeAtten_num_dropped(fname,val)
1192        String fname
1193        Variable val
1194       
1195//      String path = "entry:instrument:attenuator:thickness"   
1196       
1197        Make/O/I/N=1 wTmpWrite
1198//      Make/O/R/N=1 wTmpWrite
1199        String groupName = "/entry/instrument/attenuator"       
1200        String varName = "num_atten_dropped"
1201        wTmpWrite[0] = val
1202
1203        variable err
1204        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1205        if(err)
1206                Print "HDF write err = ",err
1207        endif
1208        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1209//      err = V_KillNamedDataFolder(fname)
1210//      if(err)
1211//              Print "DataFolder kill err = ",err
1212//      endif
1213        return(err)
1214end
1215
1216// thickness of the attenuator (PMMA) - units??
1217Function V_writeAttenThickness(fname,val)
1218        String fname
1219        Variable val
1220       
1221//      String path = "entry:instrument:attenuator:thickness"   
1222       
1223        Make/O/D/N=1 wTmpWrite
1224//      Make/O/R/N=1 wTmpWrite
1225        String groupName = "/entry/instrument/attenuator"       
1226        String varName = "thickness"
1227        wTmpWrite[0] = val
1228
1229        variable err
1230        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1231        if(err)
1232                Print "HDF write err = ",err
1233        endif
1234        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1235//      err = V_KillNamedDataFolder(fname)
1236//      if(err)
1237//              Print "DataFolder kill err = ",err
1238//      endif
1239        return(err)
1240end
1241
1242
1243// type of material for the atteunator
1244Function V_writeAttenType(fname,str)
1245        String fname,str
1246
1247//      String path = "entry:instrument:attenuator:type"
1248
1249        Make/O/T/N=1 tmpTW
1250        String groupName = "/entry/instrument/attenuator"       //     
1251        String varName = "type"
1252        tmpTW[0] = str //
1253
1254        variable err
1255        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1256        if(err)
1257                Print "HDF write err = ",err
1258        endif
1259       
1260        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1261//      err = V_KillNamedDataFolder(fname)
1262//      if(err)
1263//              Print "DataFolder kill err = ",err
1264//      endif
1265               
1266        return(err)
1267End
1268
1269
1270////// INSTRUMENT/BEAM
1271// instrument/beam/chopper (data folder)
1272Function V_writeChopperAngular_opening(fname,val)
1273        String fname
1274        Variable val
1275       
1276//      String path = "entry:instrument:beam:chopper:angular_opening"
1277       
1278        Make/O/D/N=1 wTmpWrite
1279//      Make/O/R/N=1 wTmpWrite
1280        String groupName = "/entry/instrument/beam/chopper"     
1281        String varName = "angular_opening"
1282        wTmpWrite[0] = val
1283
1284        variable err
1285        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1286        if(err)
1287                Print "HDF write err = ",err
1288        endif
1289        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1290//      err = V_KillNamedDataFolder(fname)
1291//      if(err)
1292//              Print "DataFolder kill err = ",err
1293//      endif
1294        return(err)
1295end
1296
1297Function V_writeChopDistance_from_sample(fname,val)
1298        String fname
1299        Variable val
1300       
1301//      String path = "entry:instrument:beam:chopper:distance_from_sample"
1302       
1303        Make/O/D/N=1 wTmpWrite
1304//      Make/O/R/N=1 wTmpWrite
1305        String groupName = "/entry/instrument/beam/chopper"     
1306        String varName = "distance_from_sample"
1307        wTmpWrite[0] = val
1308
1309        variable err
1310        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1311        if(err)
1312                Print "HDF write err = ",err
1313        endif
1314        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1315//      err = V_KillNamedDataFolder(fname)
1316//      if(err)
1317//              Print "DataFolder kill err = ",err
1318//      endif
1319        return(err)
1320end
1321
1322Function V_writeChopDistance_from_source(fname,val)
1323        String fname
1324        Variable val
1325       
1326//      String path = "entry:instrument:beam:chopper:distance_from_source"     
1327       
1328        Make/O/D/N=1 wTmpWrite
1329//      Make/O/R/N=1 wTmpWrite
1330        String groupName = "/entry/instrument/beam/chopper"     
1331        String varName = "distance_from_source"
1332        wTmpWrite[0] = val
1333
1334        variable err
1335        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1336        if(err)
1337                Print "HDF write err = ",err
1338        endif
1339        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1340//      err = V_KillNamedDataFolder(fname)
1341//      if(err)
1342//              Print "DataFolder kill err = ",err
1343//      endif
1344        return(err)
1345end
1346
1347Function V_writeChopperDuty_cycle(fname,val)
1348        String fname
1349        Variable val
1350       
1351//      String path = "entry:instrument:beam:chopper:duty_cycle"       
1352       
1353        Make/O/D/N=1 wTmpWrite
1354//      Make/O/R/N=1 wTmpWrite
1355        String groupName = "/entry/instrument/beam/chopper"     
1356        String varName = "duty_cycle"
1357        wTmpWrite[0] = val
1358
1359        variable err
1360        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1361        if(err)
1362                Print "HDF write err = ",err
1363        endif
1364        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1365//      err = V_KillNamedDataFolder(fname)
1366//      if(err)
1367//              Print "DataFolder kill err = ",err
1368//      endif
1369        return(err)
1370end
1371
1372Function V_writeChopperRotation_speed(fname,val)
1373        String fname
1374        Variable val
1375       
1376//      String path = "entry:instrument:beam:chopper:rotation_speed"   
1377       
1378        Make/O/D/N=1 wTmpWrite
1379//      Make/O/R/N=1 wTmpWrite
1380        String groupName = "/entry/instrument/beam/chopper"     
1381        String varName = "rotation_speed"
1382        wTmpWrite[0] = val
1383
1384        variable err
1385        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1386        if(err)
1387                Print "HDF write err = ",err
1388        endif
1389        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1390//      err = V_KillNamedDataFolder(fname)
1391//      if(err)
1392//              Print "DataFolder kill err = ",err
1393//      endif
1394        return(err)
1395end
1396
1397// integer value
1398Function V_writeChopperSlits(fname,val)
1399        String fname
1400        Variable val
1401       
1402//      String path = "entry:instrument:beam:chopper:slits"     
1403       
1404        Make/O/I/N=1 wTmpWrite
1405//      Make/O/R/N=1 wTmpWrite
1406        String groupName = "/entry/instrument/beam/chopper"     
1407        String varName = "slits"
1408        wTmpWrite[0] = val
1409
1410        variable err
1411        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1412        if(err)
1413                Print "HDF write err = ",err
1414        endif
1415        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1416//      err = V_KillNamedDataFolder(fname)
1417//      if(err)
1418//              Print "DataFolder kill err = ",err
1419//      endif
1420        return(err)
1421end
1422
1423Function V_writeChopperstatus(fname,str)
1424        String fname,str
1425
1426//      String path = "entry:instrument:beam:chopper:status"
1427
1428        Make/O/T/N=1 tmpTW
1429        String groupName = "/entry/instrument/beam/chopper"     //     
1430        String varName = "status"
1431        tmpTW[0] = str //
1432
1433        variable err
1434        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1435        if(err)
1436                Print "HDF write err = ",err
1437        endif
1438       
1439        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1440//      err = V_KillNamedDataFolder(fname)
1441//      if(err)
1442//              Print "DataFolder kill err = ",err
1443//      endif
1444               
1445        return(err)
1446End
1447
1448Function V_writeChoppertype(fname,str)
1449        String fname,str
1450
1451//      String path = "entry:instrument:beam:chopper:type"
1452
1453        Make/O/T/N=1 tmpTW
1454        String groupName = "/entry/instrument/beam/chopper"     //     
1455        String varName = "type"
1456        tmpTW[0] = str //
1457
1458        variable err
1459        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1460        if(err)
1461                Print "HDF write err = ",err
1462        endif
1463       
1464        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1465//      err = V_KillNamedDataFolder(fname)
1466//      if(err)
1467//              Print "DataFolder kill err = ",err
1468//      endif
1469               
1470        return(err)
1471End
1472
1473
1474// instrument/beam/flipper (data folder)
1475Function V_writeFlipperDriving_current(fname,val)
1476        String fname
1477        Variable val
1478       
1479//      String path = "entry:instrument:beam:flipper:driving_current"   
1480       
1481        Make/O/D/N=1 wTmpWrite
1482//      Make/O/R/N=1 wTmpWrite
1483        String groupName = "/entry/instrument/beam/flipper"     
1484        String varName = "driving_current"
1485        wTmpWrite[0] = val
1486
1487        variable err
1488        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1489        if(err)
1490                Print "HDF write err = ",err
1491        endif
1492        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1493//      err = V_KillNamedDataFolder(fname)
1494//      if(err)
1495//              Print "DataFolder kill err = ",err
1496//      endif
1497        return(err)
1498end
1499
1500Function V_writeFlipperFrequency(fname,val)
1501        String fname
1502        Variable val
1503       
1504//      String path = "entry:instrument:beam:flipper:frequency"
1505       
1506        Make/O/D/N=1 wTmpWrite
1507//      Make/O/R/N=1 wTmpWrite
1508        String groupName = "/entry/instrument/beam/flipper"     
1509        String varName = "frequency"
1510        wTmpWrite[0] = val
1511
1512        variable err
1513        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1514        if(err)
1515                Print "HDF write err = ",err
1516        endif
1517        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1518//      err = V_KillNamedDataFolder(fname)
1519//      if(err)
1520//              Print "DataFolder kill err = ",err
1521//      endif
1522        return(err)
1523end
1524
1525Function V_writeFlipperstatus(fname,str)
1526        String fname,str
1527
1528//      String path = "entry:instrument:beam:flipper:status"
1529
1530        Make/O/T/N=1 tmpTW
1531        String groupName = "/entry/instrument/beam/flipper"     //     
1532        String varName = "status"
1533        tmpTW[0] = str //
1534
1535        variable err
1536        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1537        if(err)
1538                Print "HDF write err = ",err
1539        endif
1540       
1541        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1542//      err = V_KillNamedDataFolder(fname)
1543//      if(err)
1544//              Print "DataFolder kill err = ",err
1545//      endif
1546               
1547        return(err)
1548End
1549
1550Function V_writeFlipperTransmitted_power(fname,val)
1551        String fname
1552        Variable val
1553       
1554//      String path = "entry:instrument:beam:flipper:transmitted_power"
1555
1556        Make/O/D/N=1 wTmpWrite
1557//      Make/O/R/N=1 wTmpWrite
1558        String groupName = "/entry/instrument/beam/flipper"     
1559        String varName = "transmitted_power"
1560        wTmpWrite[0] = val
1561
1562        variable err
1563        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1564        if(err)
1565                Print "HDF write err = ",err
1566        endif
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        return(err)
1573end
1574
1575Function V_writeFlipperWaveform(fname,str)
1576        String fname,str
1577
1578//      String path = "entry:instrument:beam:flipper:waveform"
1579
1580        Make/O/T/N=1 tmpTW
1581        String groupName = "/entry/instrument/beam/flipper"     //     
1582        String varName = "waveform"
1583        tmpTW[0] = str //
1584
1585        variable err
1586        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1587        if(err)
1588                Print "HDF write err = ",err
1589        endif
1590       
1591        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1592//      err = V_KillNamedDataFolder(fname)
1593//      if(err)
1594//              Print "DataFolder kill err = ",err
1595//      endif
1596               
1597        return(err)
1598End
1599
1600// instrument/beam/monochromator (data folder)
1601Function V_writeMonochromatorType(fname,str)
1602        String fname,str
1603
1604//      String path = "entry:instrument:beam:monochromator:type"
1605
1606        Make/O/T/N=1 tmpTW
1607        String groupName = "/entry/instrument/beam/monochromator"       //     
1608        String varName = "type"
1609        tmpTW[0] = str //
1610
1611        variable err
1612        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1613        if(err)
1614                Print "HDF write err = ",err
1615        endif
1616       
1617        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1618//      err = V_KillNamedDataFolder(fname)
1619//      if(err)
1620//              Print "DataFolder kill err = ",err
1621//      endif
1622               
1623        return(err)
1624End
1625
1626Function V_writeWavelength(fname,val)
1627        String fname
1628        Variable val
1629       
1630//      String path = "entry:instrument:beam:monochromator:wavelength" 
1631       
1632        Make/O/D/N=1 wTmpWrite
1633//      Make/O/R/N=1 wTmpWrite
1634        String groupName = "/entry/instrument/beam/monochromator"       
1635        String varName = "wavelength"
1636        wTmpWrite[0] = val
1637
1638        variable err
1639        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1640        if(err)
1641                Print "HDF write err = ",err
1642        endif
1643        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1644//      err = V_KillNamedDataFolder(fname)
1645//      if(err)
1646//              Print "DataFolder kill err = ",err
1647//      endif
1648        return(err)
1649end
1650
1651Function V_writeWavelength_spread(fname,val)
1652        String fname
1653        Variable val
1654       
1655//      String path = "entry:instrument:beam:monochromator:wavelength_spread"   
1656       
1657        Make/O/D/N=1 wTmpWrite
1658//      Make/O/R/N=1 wTmpWrite
1659        String groupName = "/entry/instrument/beam/monochromator"       
1660        String varName = "wavelength_spread"
1661        wTmpWrite[0] = val
1662
1663        variable err
1664        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1665        if(err)
1666                Print "HDF write err = ",err
1667        endif
1668        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1669//      err = V_KillNamedDataFolder(fname)
1670//      if(err)
1671//              Print "DataFolder kill err = ",err
1672//      endif
1673        return(err)
1674end
1675
1676
1677
1678
1679
1680
1681// instrument/beam/monochromator/crystal (data folder)
1682Function V_writeCrystalEnergy(fname,val)
1683        String fname
1684        Variable val
1685       
1686//      String path = "entry:instrument:beam:monochromator:crystal:energy"     
1687       
1688        Make/O/D/N=1 wTmpWrite
1689//      Make/O/R/N=1 wTmpWrite
1690        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1691        String varName = "energy"
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_writeCrystalHoriz_apert(fname,val)
1708        String fname
1709        Variable val
1710       
1711//      String path = "entry:instrument:beam:monochromator:crystal:horizontal_aperture"
1712       
1713        Make/O/D/N=1 wTmpWrite
1714//      Make/O/R/N=1 wTmpWrite
1715        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1716        String varName = "horizontal_aperture"
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
1732Function V_writeCrystalHoriz_curvature(fname,val)
1733        String fname
1734        Variable val
1735       
1736//      String path = "entry:instrument:beam:monochromator:crystal:horizontal_curvature"       
1737       
1738        Make/O/D/N=1 wTmpWrite
1739//      Make/O/R/N=1 wTmpWrite
1740        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1741        String varName = "horizontal_curvature"
1742        wTmpWrite[0] = val
1743
1744        variable err
1745        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1746        if(err)
1747                Print "HDF write err = ",err
1748        endif
1749        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1750//      err = V_KillNamedDataFolder(fname)
1751//      if(err)
1752//              Print "DataFolder kill err = ",err
1753//      endif
1754        return(err)
1755end
1756
1757Function V_writeCrystalLattice_parameter(fname,val)
1758        String fname
1759        Variable val
1760       
1761//      String path = "entry:instrument:beam:monochromator:crystal:lattice_parameter"   
1762       
1763        Make/O/D/N=1 wTmpWrite
1764//      Make/O/R/N=1 wTmpWrite
1765        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1766        String varName = "lattice_parameter"
1767        wTmpWrite[0] = val
1768
1769        variable err
1770        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1771        if(err)
1772                Print "HDF write err = ",err
1773        endif
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        return(err)
1780end
1781
1782Function V_writeCrystalDistance(fname,val)
1783        String fname
1784        Variable val
1785       
1786//      String path = "entry:instrument:beam:monochromator:crystal:distance"   
1787       
1788        Make/O/D/N=1 wTmpWrite
1789//      Make/O/R/N=1 wTmpWrite
1790        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1791        String varName = "distance"
1792        wTmpWrite[0] = val
1793
1794        variable err
1795        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1796        if(err)
1797                Print "HDF write err = ",err
1798        endif
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        return(err)
1805end
1806
1807Function V_writeCrystalReflection(fname,val)
1808        String fname
1809        Variable val
1810       
1811//      String path = "entry:instrument:beam:monochromator:crystal:reflection" 
1812       
1813        Make/O/D/N=1 wTmpWrite
1814//      Make/O/R/N=1 wTmpWrite
1815        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1816        String varName = "reflection"
1817        wTmpWrite[0] = val
1818
1819        variable err
1820        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1821        if(err)
1822                Print "HDF write err = ",err
1823        endif
1824        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1825//      err = V_KillNamedDataFolder(fname)
1826//      if(err)
1827//              Print "DataFolder kill err = ",err
1828//      endif
1829        return(err)
1830end
1831
1832Function V_writeCrystalRotation(fname,val)
1833        String fname
1834        Variable val
1835       
1836//      String path = "entry:instrument:beam:monochromator:crystal:rotation"   
1837       
1838        Make/O/D/N=1 wTmpWrite
1839//      Make/O/R/N=1 wTmpWrite
1840        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1841        String varName = "rotation"
1842        wTmpWrite[0] = val
1843
1844        variable err
1845        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1846        if(err)
1847                Print "HDF write err = ",err
1848        endif
1849        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1850//      err = V_KillNamedDataFolder(fname)
1851//      if(err)
1852//              Print "DataFolder kill err = ",err
1853//      endif
1854        return(err)
1855end
1856
1857Function V_writeCrystalStatus(fname,str)
1858        String fname,str
1859
1860//      String path = "entry:instrument:beam:monochromator:crystal:status"
1861
1862        Make/O/T/N=1 tmpTW
1863        String groupName = "/entry/instrument/beam/monochromator/crystal"       //     
1864        String varName = "status"
1865        tmpTW[0] = str //
1866
1867        variable err
1868        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1869        if(err)
1870                Print "HDF write err = ",err
1871        endif
1872       
1873        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1874//      err = V_KillNamedDataFolder(fname)
1875//      if(err)
1876//              Print "DataFolder kill err = ",err
1877//      endif
1878               
1879        return(err)
1880End
1881
1882Function V_writeCrystalVertical_aperture(fname,val)
1883        String fname
1884        Variable val
1885       
1886//      String path = "entry:instrument:beam:monochromator:crystal:vertical_aperture"   
1887       
1888        Make/O/D/N=1 wTmpWrite
1889//      Make/O/R/N=1 wTmpWrite
1890        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1891        String varName = "vertical_aperture"
1892        wTmpWrite[0] = val
1893
1894        variable err
1895        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1896        if(err)
1897                Print "HDF write err = ",err
1898        endif
1899        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1900//      err = V_KillNamedDataFolder(fname)
1901//      if(err)
1902//              Print "DataFolder kill err = ",err
1903//      endif
1904        return(err)
1905end
1906
1907Function V_writeCrystalVertical_curv(fname,val)
1908        String fname
1909        Variable val
1910       
1911//      String path = "entry:instrument:beam:monochromator:crystal:vertical_curvature" 
1912       
1913        Make/O/D/N=1 wTmpWrite
1914//      Make/O/R/N=1 wTmpWrite
1915        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1916        String varName = "vertical_curvature"
1917        wTmpWrite[0] = val
1918
1919        variable err
1920        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1921        if(err)
1922                Print "HDF write err = ",err
1923        endif
1924        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1925//      err = V_KillNamedDataFolder(fname)
1926//      if(err)
1927//              Print "DataFolder kill err = ",err
1928//      endif
1929        return(err)
1930end
1931
1932Function V_writeCrystalWavelength(fname,val)
1933        String fname
1934        Variable val
1935       
1936//      String path = "entry:instrument:beam:monochromator:crystal:wavelength" 
1937       
1938        Make/O/D/N=1 wTmpWrite
1939//      Make/O/R/N=1 wTmpWrite
1940        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1941        String varName = "wavelength"
1942        wTmpWrite[0] = val
1943
1944        variable err
1945        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1946        if(err)
1947                Print "HDF write err = ",err
1948        endif
1949        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1950//      err = V_KillNamedDataFolder(fname)
1951//      if(err)
1952//              Print "DataFolder kill err = ",err
1953//      endif
1954        return(err)
1955end
1956
1957Function V_writeCrystalWavelength_spread(fname,val)
1958        String fname
1959        Variable val
1960       
1961//      String path = "entry:instrument:beam:monochromator:crystal:wavelength_spread"   
1962       
1963        Make/O/D/N=1 wTmpWrite
1964//      Make/O/R/N=1 wTmpWrite
1965        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1966        String varName = "wavelength_spread"
1967        wTmpWrite[0] = val
1968
1969        variable err
1970        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1971        if(err)
1972                Print "HDF write err = ",err
1973        endif
1974        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1975//      err = V_KillNamedDataFolder(fname)
1976//      if(err)
1977//              Print "DataFolder kill err = ",err
1978//      endif
1979        return(err)
1980end
1981
1982Function V_writeCrystalWavevector(fname,val)
1983        String fname
1984        Variable val
1985       
1986//      String path = "entry:instrument:beam:monochromator:crystal:wavevector" 
1987       
1988        Make/O/D/N=1 wTmpWrite
1989//      Make/O/R/N=1 wTmpWrite
1990        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1991        String varName = "wavevector"
1992        wTmpWrite[0] = val
1993
1994        variable err
1995        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1996        if(err)
1997                Print "HDF write err = ",err
1998        endif
1999        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2000//      err = V_KillNamedDataFolder(fname)
2001//      if(err)
2002//              Print "DataFolder kill err = ",err
2003//      endif
2004        return(err)
2005end
2006
2007// instrument/beam/monochromator/velocity_selector (data folder)
2008Function V_writeVSDistance(fname,val)
2009        String fname
2010        Variable val
2011       
2012//      String path = "entry:instrument:beam:monochromator:velocity_selector:distance" 
2013       
2014        Make/O/D/N=1 wTmpWrite
2015//      Make/O/R/N=1 wTmpWrite
2016        String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     
2017        String varName = "distance"
2018        wTmpWrite[0] = val
2019
2020        variable err
2021        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2022        if(err)
2023                Print "HDF write err = ",err
2024        endif
2025        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2026//      err = V_KillNamedDataFolder(fname)
2027//      if(err)
2028//              Print "DataFolder kill err = ",err
2029//      endif
2030        return(err)
2031end
2032
2033Function V_writeVSRotation_speed(fname,val)
2034        String fname
2035        Variable val
2036       
2037//      String path = "entry:instrument:beam:monochromator:velocity_selector:rotation_speed"   
2038       
2039        Make/O/D/N=1 wTmpWrite
2040//      Make/O/R/N=1 wTmpWrite
2041        String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     
2042        String varName = "rotation_speed"
2043        wTmpWrite[0] = val
2044
2045        variable err
2046        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2047        if(err)
2048                Print "HDF write err = ",err
2049        endif
2050        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2051//      err = V_KillNamedDataFolder(fname)
2052//      if(err)
2053//              Print "DataFolder kill err = ",err
2054//      endif
2055        return(err)
2056end
2057
2058Function V_writeVelSelStatus(fname,str)
2059        String fname,str
2060
2061//      String path = "entry:instrument:beam:monochromator:velocity_selector:status"
2062
2063        Make/O/T/N=1 tmpTW
2064        String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     //     
2065        String varName = "status"
2066        tmpTW[0] = str //
2067
2068        variable err
2069        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2070        if(err)
2071                Print "HDF write err = ",err
2072        endif
2073       
2074        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2075//      err = V_KillNamedDataFolder(fname)
2076//      if(err)
2077//              Print "DataFolder kill err = ",err
2078//      endif
2079               
2080        return(err)
2081End
2082
2083Function V_writeVSTable_parameters(fname,inW)
2084        String fname
2085        Wave inW
2086       
2087//      String path = "entry:instrument:beam:monochromator:velocity_selector:table"     
2088
2089        Duplicate/O inW wTmpWrite       
2090// then use redimension as needed to cast the wave to write to the specified type
2091// see WaveType for the proper codes
2092//      Redimension/T=() wTmpWrite
2093// -- May also need to check the dimension(s) before writing (don't trust the input)
2094        String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     
2095        String varName = "table_parameters"
2096
2097        variable err
2098        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2099        if(err)
2100                Print "HDF write err = ",err
2101        endif
2102        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2103//      err = V_KillNamedDataFolder(fname)
2104//      if(err)
2105//              Print "DataFolder kill err = ",err
2106//      endif
2107        return(err)
2108end
2109
2110//// DONE - this does not exist for VSANS - per JGB 4/2016
2111//Function V_writeVS_tilt(fname,val)
2112//      String fname
2113//      Variable val
2114//     
2115////    String path = "entry:instrument:beam:monochromator:velocity_selector:vs_tilt"   
2116//     
2117//      Make/O/D/N=1 wTmpWrite
2118////    Make/O/R/N=1 wTmpWrite
2119//      String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     
2120//      String varName = "vs_tilt"
2121//      wTmpWrite[0] = val
2122//
2123//      variable err
2124//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2125//      if(err)
2126//              Print "HDF write err = ",err
2127//      endif
2128//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2129////    err = V_KillNamedDataFolder(fname)
2130////    if(err)
2131////            Print "DataFolder kill err = ",err
2132////    endif
2133//      return(err)
2134//end
2135
2136Function V_writeVSWavelength(fname,val)
2137        String fname
2138        Variable val
2139       
2140//      String path = "entry:instrument:beam:monochromator:velocity_selector:wavelength"       
2141       
2142        Make/O/D/N=1 wTmpWrite
2143//      Make/O/R/N=1 wTmpWrite
2144        String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     
2145        String varName = "wavelength"
2146        wTmpWrite[0] = val
2147
2148        variable err
2149        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2150        if(err)
2151                Print "HDF write err = ",err
2152        endif
2153        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2154//      err = V_KillNamedDataFolder(fname)
2155//      if(err)
2156//              Print "DataFolder kill err = ",err
2157//      endif
2158        return(err)
2159end
2160
2161Function V_writeVSWavelength_spread(fname,val)
2162        String fname
2163        Variable val
2164       
2165//      String path = "entry:instrument:beam:monochromator:velocity_selector:wavelength_spread"
2166       
2167        Make/O/D/N=1 wTmpWrite
2168//      Make/O/R/N=1 wTmpWrite
2169        String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     
2170        String varName = "wavelength_spread"
2171        wTmpWrite[0] = val
2172
2173        variable err
2174        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2175        if(err)
2176                Print "HDF write err = ",err
2177        endif
2178        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2179//      err = V_KillNamedDataFolder(fname)
2180//      if(err)
2181//              Print "DataFolder kill err = ",err
2182//      endif
2183        return(err)
2184end
2185
2186// instrument/beam/monochromator/white_beam (data folder)
2187Function V_writeWhiteBeamStatus(fname,str)
2188        String fname,str
2189
2190//      String path = "entry:instrument:beam:monochromator:white_beam:status"
2191
2192        Make/O/T/N=1 tmpTW
2193        String groupName = "/entry/instrument/beam/monochromator/white_beam"    //     
2194        String varName = "status"
2195        tmpTW[0] = str //
2196
2197        variable err
2198        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2199        if(err)
2200                Print "HDF write err = ",err
2201        endif
2202       
2203        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2204//      err = V_KillNamedDataFolder(fname)
2205//      if(err)
2206//              Print "DataFolder kill err = ",err
2207//      endif
2208               
2209        return(err)
2210End
2211
2212Function V_writeWhiteBeamWavelength(fname,val)
2213        String fname
2214        Variable val
2215       
2216//      String path = "entry:instrument:beam:monochromator:white_beam:wavelength"       
2217       
2218        Make/O/D/N=1 wTmpWrite
2219//      Make/O/R/N=1 wTmpWrite
2220        String groupName = "/entry/instrument/beam/monochromator/white_beam"   
2221        String varName = "wavelength"
2222        wTmpWrite[0] = val
2223
2224        variable err
2225        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2226        if(err)
2227                Print "HDF write err = ",err
2228        endif
2229        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2230//      err = V_KillNamedDataFolder(fname)
2231//      if(err)
2232//              Print "DataFolder kill err = ",err
2233//      endif
2234        return(err)
2235end
2236
2237Function V_writeWhiteBeamWavel_spread(fname,val)
2238        String fname
2239        Variable val
2240       
2241//      String path = "entry:instrument:beam:monochromator:white_beam:wavelength_spread"       
2242       
2243        Make/O/D/N=1 wTmpWrite
2244//      Make/O/R/N=1 wTmpWrite
2245        String groupName = "/entry/instrument/beam/monochromator/white_beam"   
2246        String varName = "wavelength_spread"
2247        wTmpWrite[0] = val
2248
2249        variable err
2250        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2251        if(err)
2252                Print "HDF write err = ",err
2253        endif
2254        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2255//      err = V_KillNamedDataFolder(fname)
2256//      if(err)
2257//              Print "DataFolder kill err = ",err
2258//      endif
2259        return(err)
2260end
2261
2262// instrument/beam/polarizer (data folder)
2263Function V_writePolarizerComposition(fname,str)
2264        String fname,str
2265
2266//      String path = "entry:instrument:beam:polarizer:composition"
2267
2268        Make/O/T/N=1 tmpTW
2269        String groupName = "/entry/instrument/beam/polarizer"   //     
2270        String varName = "composition"
2271        tmpTW[0] = str //
2272
2273        variable err
2274        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2275        if(err)
2276                Print "HDF write err = ",err
2277        endif
2278       
2279        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2280//      err = V_KillNamedDataFolder(fname)
2281//      if(err)
2282//              Print "DataFolder kill err = ",err
2283//      endif
2284               
2285        return(err)
2286End
2287
2288Function V_writePolarizerEfficiency(fname,val)
2289        String fname
2290        Variable val
2291       
2292//      String path = "entry:instrument:beam:polarizer:efficiency"     
2293       
2294        Make/O/D/N=1 wTmpWrite
2295//      Make/O/R/N=1 wTmpWrite
2296        String groupName = "/entry/instrument/beam/polarizer"   
2297        String varName = "efficiency"
2298        wTmpWrite[0] = val
2299
2300        variable err
2301        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2302        if(err)
2303                Print "HDF write err = ",err
2304        endif
2305        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2306//      err = V_KillNamedDataFolder(fname)
2307//      if(err)
2308//              Print "DataFolder kill err = ",err
2309//      endif
2310        return(err)
2311end
2312
2313Function V_writePolarizerStatus(fname,str)
2314        String fname,str
2315
2316//      String path = "entry:instrument:beam:polarizer:status"
2317
2318        Make/O/T/N=1 tmpTW
2319        String groupName = "/entry/instrument/beam/polarizer"   //     
2320        String varName = "status"
2321        tmpTW[0] = str //
2322
2323        variable err
2324        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2325        if(err)
2326                Print "HDF write err = ",err
2327        endif
2328       
2329        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2330//      err = V_KillNamedDataFolder(fname)
2331//      if(err)
2332//              Print "DataFolder kill err = ",err
2333//      endif
2334               
2335        return(err)
2336End
2337
2338Function V_writePolarizerType(fname,str)
2339        String fname,str
2340
2341//      String path = "entry:instrument:beam:polarizer:type"
2342
2343        Make/O/T/N=1 tmpTW
2344        String groupName = "/entry/instrument/beam/polarizer"   //     
2345        String varName = "type"
2346        tmpTW[0] = str //
2347
2348        variable err
2349        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2350        if(err)
2351                Print "HDF write err = ",err
2352        endif
2353       
2354        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2355//      err = V_KillNamedDataFolder(fname)
2356//      if(err)
2357//              Print "DataFolder kill err = ",err
2358//      endif
2359               
2360        return(err)
2361End
2362
2363// instrument/beam/polarizer_analyzer (data folder)
2364// integer value
2365Function V_writePolAnaCell_index(fname,val)
2366        String fname
2367        Variable val
2368
2369//      String path = "entry:instrument:beam:polarizer_analyzer:cell_index"
2370       
2371        Make/O/I/N=1 wTmpWrite
2372//      Make/O/R/N=1 wTmpWrite
2373        String groupName = "/entry/instrument/beam/polarizer_analyzer" 
2374        String varName = "cell_index"
2375        wTmpWrite[0] = val
2376
2377        variable err
2378        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2379        if(err)
2380                Print "HDF write err = ",err
2381        endif
2382        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2383//      err = V_KillNamedDataFolder(fname)
2384//      if(err)
2385//              Print "DataFolder kill err = ",err
2386//      endif
2387        return(err)
2388End
2389
2390Function V_writePolAnaCell_name(fname,str)
2391        String fname,str
2392
2393//      String path = "entry:instrument:beam:polarizer_analyzer:cell_name"
2394
2395        Make/O/T/N=1 tmpTW
2396        String groupName = "/entry/instrument/beam/polarizer_analyzer"  //     
2397        String varName = "cell_name"
2398        tmpTW[0] = str //
2399
2400        variable err
2401        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2402        if(err)
2403                Print "HDF write err = ",err
2404        endif
2405       
2406        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2407//      err = V_KillNamedDataFolder(fname)
2408//      if(err)
2409//              Print "DataFolder kill err = ",err
2410//      endif
2411               
2412        return(err)
2413End
2414
2415Function V_writePolAnaCell_parameters(fname,inW)
2416        String fname
2417        Wave inW
2418
2419//      String path = "entry:instrument:beam:polarizer_analyzer:cell_parameters"
2420
2421        Duplicate/O inW wTmpWrite       
2422// then use redimension as needed to cast the wave to write to the specified type
2423// see WaveType for the proper codes
2424//      Redimension/T=() wTmpWrite
2425// -- May also need to check the dimension(s) before writing (don't trust the input)
2426        String groupName = "/entry/instrument//beam/polarizer_analyzer"
2427        String varName = "cell_parameters"
2428
2429        variable err
2430        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2431        if(err)
2432                Print "HDF write err = ",err
2433        endif
2434        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2435//      err = V_KillNamedDataFolder(fname)
2436//      if(err)
2437//              Print "DataFolder kill err = ",err
2438//      endif
2439        return(err)
2440End
2441
2442Function V_writePolAnaGuideFieldCur_1(fname,val)
2443        String fname
2444        Variable val
2445
2446//      String path = "entry:instrument:beam:polarizer_analyzer:guide_field_current_1"
2447       
2448        Make/O/D/N=1 wTmpWrite
2449//      Make/O/R/N=1 wTmpWrite
2450        String groupName = "/entry/instrument/beam/polarizer_analyzer" 
2451        String varName = "guide_field_current_1"
2452        wTmpWrite[0] = val
2453
2454        variable err
2455        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2456        if(err)
2457                Print "HDF write err = ",err
2458        endif
2459        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2460//      err = V_KillNamedDataFolder(fname)
2461//      if(err)
2462//              Print "DataFolder kill err = ",err
2463//      endif
2464        return(err)
2465End
2466
2467Function V_writePolAnaGuideFieldCur_2(fname,val)
2468        String fname
2469        Variable val
2470
2471//      String path = "entry:instrument:beam:polarizer_analyzer:guide_field_current_2"
2472       
2473        Make/O/D/N=1 wTmpWrite
2474//      Make/O/R/N=1 wTmpWrite
2475        String groupName = "/entry/instrument/beam/polarizer_analyzer" 
2476        String varName = "guide_field_current_2"
2477        wTmpWrite[0] = val
2478
2479        variable err
2480        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2481        if(err)
2482                Print "HDF write err = ",err
2483        endif
2484        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2485//      err = V_KillNamedDataFolder(fname)
2486//      if(err)
2487//              Print "DataFolder kill err = ",err
2488//      endif
2489        return(err)
2490End
2491
2492Function V_writePolAnaSolenoid_current(fname,val)
2493        String fname
2494        Variable val
2495
2496//      String path = "entry:instrument:beam:polarizer_analyzer:solenoid_current"
2497       
2498        Make/O/D/N=1 wTmpWrite
2499//      Make/O/R/N=1 wTmpWrite
2500        String groupName = "/entry/instrument/beam/polarizer_analyzer" 
2501        String varName = "solenoid_current"
2502        wTmpWrite[0] = val
2503
2504        variable err
2505        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2506        if(err)
2507                Print "HDF write err = ",err
2508        endif
2509        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2510//      err = V_KillNamedDataFolder(fname)
2511//      if(err)
2512//              Print "DataFolder kill err = ",err
2513//      endif
2514        return(err)
2515End
2516
2517Function V_writePolAnaStatus(fname,str)
2518        String fname,str
2519
2520//      String path = "entry:instrument:beam:polarizer_analyzer:status"
2521
2522        Make/O/T/N=1 tmpTW
2523        String groupName = "/entry/instrument/beam/polarizer_analyzer"  //     
2524        String varName = "status"
2525        tmpTW[0] = str //
2526
2527        variable err
2528        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2529        if(err)
2530                Print "HDF write err = ",err
2531        endif
2532       
2533        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2534//      err = V_KillNamedDataFolder(fname)
2535//      if(err)
2536//              Print "DataFolder kill err = ",err
2537//      endif
2538               
2539        return(err)
2540End
2541
2542
2543
2544
2545                                       
2546/////// INSTRUMENT/BEAM MONITORS
2547
2548//beam_monitor_low (data folder)
2549// integer value
2550Function V_writeBeamMonLowData(fname,val)
2551        String fname
2552        Variable val
2553
2554//      String path = "entry:instrument:beam_monitor_low:data"
2555       
2556        Make/O/I/N=1 wTmpWrite
2557//      Make/O/R/N=1 wTmpWrite
2558        String groupName = "/entry/instrument/beam_monitor_low"
2559        String varName = "data"
2560        wTmpWrite[0] = val
2561
2562        variable err
2563        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2564        if(err)
2565                Print "HDF write err = ",err
2566        endif
2567        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2568//      err = V_KillNamedDataFolder(fname)
2569//      if(err)
2570//              Print "DataFolder kill err = ",err
2571//      endif
2572        return(err)
2573End
2574
2575Function V_writeBeamMonLowEfficiency(fname,val)
2576        String fname
2577        Variable val
2578
2579//      String path = "entry:instrument:beam_monitor_low:efficiency"
2580       
2581        Make/O/D/N=1 wTmpWrite
2582//      Make/O/R/N=1 wTmpWrite
2583        String groupName = "/entry/instrument/beam_monitor_low"
2584        String varName = "efficiency"
2585        wTmpWrite[0] = val
2586
2587        variable err
2588        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2589        if(err)
2590                Print "HDF write err = ",err
2591        endif
2592        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2593//      err = V_KillNamedDataFolder(fname)
2594//      if(err)
2595//              Print "DataFolder kill err = ",err
2596//      endif
2597        return(err)
2598End
2599
2600Function V_writeBeamMonLowDistance(fname,val)
2601        String fname
2602        Variable val
2603
2604//      String path = "entry:instrument:beam_monitor_low:distance"
2605       
2606        Make/O/D/N=1 wTmpWrite
2607//      Make/O/R/N=1 wTmpWrite
2608        String groupName = "/entry/instrument/beam_monitor_low"
2609        String varName = "distance"
2610        wTmpWrite[0] = val
2611
2612        variable err
2613        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2614        if(err)
2615                Print "HDF write err = ",err
2616        endif
2617        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2618//      err = V_KillNamedDataFolder(fname)
2619//      if(err)
2620//              Print "DataFolder kill err = ",err
2621//      endif
2622        return(err)
2623End
2624
2625Function V_writeBeamMonLowSaved_count(fname,val)
2626        String fname
2627        Variable val
2628
2629//      String path = "entry:instrument:beam_monitor_low:saved_count"
2630       
2631        Make/O/D/N=1 wTmpWrite
2632//      Make/O/R/N=1 wTmpWrite
2633        String groupName = "/entry/instrument/beam_monitor_low"
2634        String varName = "saved_count"
2635        wTmpWrite[0] = val
2636
2637        variable err
2638        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2639        if(err)
2640                Print "HDF write err = ",err
2641        endif
2642        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2643//      err = V_KillNamedDataFolder(fname)
2644//      if(err)
2645//              Print "DataFolder kill err = ",err
2646//      endif
2647        return(err)
2648End
2649
2650Function V_writeBeamMonLowType(fname,str)
2651        String fname,str
2652
2653//      String path = "entry:instrument:beam_monitor_low:type"
2654
2655        Make/O/T/N=1 tmpTW
2656        String groupName = "/entry/instrument/beam_monitor_low" //     
2657        String varName = "type"
2658        tmpTW[0] = str //
2659
2660        variable err
2661        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2662        if(err)
2663                Print "HDF write err = ",err
2664        endif
2665       
2666        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2667//      err = V_KillNamedDataFolder(fname)
2668//      if(err)
2669//              Print "DataFolder kill err = ",err
2670//      endif
2671               
2672        return(err)
2673End
2674
2675//beam_monitor_norm (data folder)
2676// integer value
2677Function V_writeBeamMonNormData(fname,val)
2678        String fname
2679        Variable val
2680
2681//      String path = "entry:instrument:beam_monitor_norm:data"
2682       
2683        Make/O/I/N=1 wTmpWrite
2684//      Make/O/R/N=1 wTmpWrite
2685        String groupName = "/entry/instrument/beam_monitor_norm"       
2686        String varName = "data"
2687        wTmpWrite[0] = val
2688
2689        variable err
2690        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2691        if(err)
2692                Print "HDF write err = ",err
2693        endif
2694        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2695//      err = V_KillNamedDataFolder(fname)
2696//      if(err)
2697//              Print "DataFolder kill err = ",err
2698//      endif
2699        return(err)
2700End
2701
2702Function V_writeBeamMonNormEfficiency(fname,val)
2703        String fname
2704        Variable val
2705
2706//      String path = "entry:instrument:beam_monitor_norm:efficiency"
2707       
2708        Make/O/D/N=1 wTmpWrite
2709//      Make/O/R/N=1 wTmpWrite
2710        String groupName = "/entry/instrument/beam_monitor_norm"       
2711        String varName = "efficiency"
2712        wTmpWrite[0] = val
2713
2714        variable err
2715        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2716        if(err)
2717                Print "HDF write err = ",err
2718        endif
2719        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2720//      err = V_KillNamedDataFolder(fname)
2721//      if(err)
2722//              Print "DataFolder kill err = ",err
2723//      endif
2724        return(err)
2725End
2726
2727Function V_writeBeamMonNormDistance(fname,val)
2728        String fname
2729        Variable val
2730
2731//      String path = "entry:instrument:beam_monitor_norm:distance"
2732       
2733        Make/O/D/N=1 wTmpWrite
2734//      Make/O/R/N=1 wTmpWrite
2735        String groupName = "/entry/instrument/beam_monitor_norm"       
2736        String varName = "distance"
2737        wTmpWrite[0] = val
2738
2739        variable err
2740        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2741        if(err)
2742                Print "HDF write err = ",err
2743        endif
2744        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2745//      err = V_KillNamedDataFolder(fname)
2746//      if(err)
2747//              Print "DataFolder kill err = ",err
2748//      endif
2749        return(err)
2750End
2751
2752Function V_writeBeamMonNormSaved_count(fname,val)
2753        String fname
2754        Variable val
2755
2756//      String path = "entry:instrument:beam_monitor_norm:saved_count"
2757       
2758        Make/O/D/N=1 wTmpWrite
2759//      Make/O/R/N=1 wTmpWrite
2760        String groupName = "/entry/instrument/beam_monitor_norm"       
2761        String varName = "saved_count"
2762        wTmpWrite[0] = val
2763
2764        variable err
2765        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2766        if(err)
2767                Print "HDF write err = ",err
2768        endif
2769        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2770//      err = V_KillNamedDataFolder(fname)
2771//      if(err)
2772//              Print "DataFolder kill err = ",err
2773//      endif
2774        return(err)
2775End
2776
2777Function V_writeBeamMonNormType(fname,str)
2778        String fname,str
2779
2780//      String path = "entry:instrument:beam_monitor_norm:type"
2781
2782        Make/O/T/N=1 tmpTW
2783        String groupName = "/entry/instrument/beam_monitor_norm"        //     
2784        String varName = "type"
2785        tmpTW[0] = str //
2786
2787        variable err
2788        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2789        if(err)
2790                Print "HDF write err = ",err
2791        endif
2792       
2793        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2794//      err = V_KillNamedDataFolder(fname)
2795//      if(err)
2796//              Print "DataFolder kill err = ",err
2797//      endif
2798               
2799        return(err)
2800End
2801
2802
2803//beam_stop C2 (data folder)
2804Function V_writeBeamStopC2Description(fname,str)
2805        String fname,str
2806
2807//      String path = "entry:instrument:beam_stop:description"
2808
2809        Make/O/T/N=1 tmpTW
2810        String groupName = "/entry/instrument/beam_stop_C2"     //     
2811        String varName = "description"
2812        tmpTW[0] = str //
2813
2814        variable err
2815        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2816        if(err)
2817                Print "HDF write err = ",err
2818        endif
2819       
2820        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2821//      err = V_KillNamedDataFolder(fname)
2822//      if(err)
2823//              Print "DataFolder kill err = ",err
2824//      endif
2825               
2826        return(err)
2827End
2828
2829Function V_writeBeamStopC2Dist_to_det(fname,val)
2830        String fname
2831        Variable val
2832
2833//      String path = "entry:instrument:beam_stop:distance_to_detector"
2834       
2835        Make/O/D/N=1 wTmpWrite
2836//      Make/O/R/N=1 wTmpWrite
2837        String groupName = "/entry/instrument/beam_stop_C2"     
2838        String varName = "distance_to_detector"
2839        wTmpWrite[0] = val
2840
2841        variable err
2842        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2843        if(err)
2844                Print "HDF write err = ",err
2845        endif
2846        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2847//      err = V_KillNamedDataFolder(fname)
2848//      if(err)
2849//              Print "DataFolder kill err = ",err
2850//      endif
2851        return(err)
2852End
2853
2854// is this the index of which size beam stop is in position?
2855// integer value
2856Function V_writeBeamStopC2num_stop(fname,val)
2857        String fname
2858        Variable val
2859
2860//      String path = "entry:instrument:beam_stop:distance_to_detector"
2861       
2862        Make/O/I/N=1 wTmpWrite
2863//      Make/O/R/N=1 wTmpWrite
2864        String groupName = "/entry/instrument/beam_stop_C2"     
2865        String varName = "num_beamstops"
2866        wTmpWrite[0] = val
2867
2868        variable err
2869        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2870        if(err)
2871                Print "HDF write err = ",err
2872        endif
2873        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2874//      err = V_KillNamedDataFolder(fname)
2875//      if(err)
2876//              Print "DataFolder kill err = ",err
2877//      endif
2878        return(err)
2879End
2880
2881Function V_writeBeamStopC2_x_pos(fname,val)
2882        String fname
2883        Variable val
2884
2885//      String path = "entry:instrument:beam_stop:x0"
2886       
2887        Make/O/D/N=1 wTmpWrite
2888//      Make/O/R/N=1 wTmpWrite
2889        String groupName = "/entry/instrument/beam_stop_C2"     
2890        String varName = "x_pos"
2891        wTmpWrite[0] = val
2892
2893        variable err
2894        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2895        if(err)
2896                Print "HDF write err = ",err
2897        endif
2898        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2899//      err = V_KillNamedDataFolder(fname)
2900//      if(err)
2901//              Print "DataFolder kill err = ",err
2902//      endif
2903        return(err)
2904End
2905
2906Function V_writeBeamStopC2_y_pos(fname,val)
2907        String fname
2908        Variable val
2909
2910//      String path = "entry:instrument:beam_stop:y0"
2911       
2912        Make/O/D/N=1 wTmpWrite
2913//      Make/O/R/N=1 wTmpWrite
2914        String groupName = "/entry/instrument/beam_stop_C2"     
2915        String varName = "y_pos"
2916        wTmpWrite[0] = val
2917
2918        variable err
2919        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2920        if(err)
2921                Print "HDF write err = ",err
2922        endif
2923        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2924//      err = V_KillNamedDataFolder(fname)
2925//      if(err)
2926//              Print "DataFolder kill err = ",err
2927//      endif
2928        return(err)
2929End
2930
2931
2932// beam stop C2 (shape)
2933Function V_writeBeamStopC2_height(fname,val)
2934        String fname
2935        Variable val
2936
2937//      String path = "entry:instrument:beam_stop:y0"
2938       
2939        Make/O/D/N=1 wTmpWrite
2940//      Make/O/R/N=1 wTmpWrite
2941        String groupName = "/entry/instrument/beam_stop_C2/shape"       
2942        String varName = "height"
2943        wTmpWrite[0] = val
2944
2945        variable err
2946        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2947        if(err)
2948                Print "HDF write err = ",err
2949        endif
2950        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2951//      err = V_KillNamedDataFolder(fname)
2952//      if(err)
2953//              Print "DataFolder kill err = ",err
2954//      endif
2955        return(err)
2956End
2957
2958Function V_writeBeamStopC2_shape(fname,str)
2959        String fname,str
2960
2961//      String path = "entry:instrument:beam_stop:description"
2962
2963        Make/O/T/N=1 tmpTW
2964        String groupName = "/entry/instrument/beam_stop_C2/shape"       //     
2965        String varName = "shape"
2966        tmpTW[0] = str //
2967
2968        variable err
2969        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2970        if(err)
2971                Print "HDF write err = ",err
2972        endif
2973       
2974        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2975//      err = V_KillNamedDataFolder(fname)
2976//      if(err)
2977//              Print "DataFolder kill err = ",err
2978//      endif
2979               
2980        return(err)
2981End
2982
2983// this is diameter if shape=CIRCLE
2984Function V_writeBeamStopC2_size(fname,val)
2985        String fname
2986        Variable val
2987
2988//      String path = "entry:instrument:beam_stop:y0"
2989       
2990        Make/O/D/N=1 wTmpWrite
2991//      Make/O/R/N=1 wTmpWrite
2992        String groupName = "/entry/instrument/beam_stop_C2/shape"       
2993        String varName = "size"
2994        wTmpWrite[0] = val
2995
2996        variable err
2997        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2998        if(err)
2999                Print "HDF write err = ",err
3000        endif
3001        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3002//      err = V_KillNamedDataFolder(fname)
3003//      if(err)
3004//              Print "DataFolder kill err = ",err
3005//      endif
3006        return(err)
3007End
3008
3009Function V_writeBeamStopC2_width(fname,val)
3010        String fname
3011        Variable val
3012
3013//      String path = "entry:instrument:beam_stop:y0"
3014       
3015        Make/O/D/N=1 wTmpWrite
3016//      Make/O/R/N=1 wTmpWrite
3017        String groupName = "/entry/instrument/beam_stop_C2/shape"       
3018        String varName = "width"
3019        wTmpWrite[0] = val
3020
3021        variable err
3022        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3023        if(err)
3024                Print "HDF write err = ",err
3025        endif
3026        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3027//      err = V_KillNamedDataFolder(fname)
3028//      if(err)
3029//              Print "DataFolder kill err = ",err
3030//      endif
3031        return(err)
3032End
3033
3034// beam stop C3 (data folder)
3035Function V_writeBeamStopC3Description(fname,str)
3036        String fname,str
3037
3038//      String path = "entry:instrument:beam_stop:description"
3039
3040        Make/O/T/N=1 tmpTW
3041        String groupName = "/entry/instrument/beam_stop_C3"     //     
3042        String varName = "description"
3043        tmpTW[0] = str //
3044
3045        variable err
3046        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3047        if(err)
3048                Print "HDF write err = ",err
3049        endif
3050       
3051        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3052//      err = V_KillNamedDataFolder(fname)
3053//      if(err)
3054//              Print "DataFolder kill err = ",err
3055//      endif
3056               
3057        return(err)
3058End
3059
3060Function V_writeBeamStopC3Dist_to_det(fname,val)
3061        String fname
3062        Variable val
3063
3064//      String path = "entry:instrument:beam_stop:distance_to_detector"
3065       
3066        Make/O/D/N=1 wTmpWrite
3067//      Make/O/R/N=1 wTmpWrite
3068        String groupName = "/entry/instrument/beam_stop_C3"     
3069        String varName = "distance_to_detector"
3070        wTmpWrite[0] = val
3071
3072        variable err
3073        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3074        if(err)
3075                Print "HDF write err = ",err
3076        endif
3077        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3078//      err = V_KillNamedDataFolder(fname)
3079//      if(err)
3080//              Print "DataFolder kill err = ",err
3081//      endif
3082        return(err)
3083End
3084
3085// integer value
3086Function V_writeBeamStopC3num_stop(fname,val)
3087        String fname
3088        Variable val
3089
3090//      String path = "entry:instrument:beam_stop:distance_to_detector"
3091       
3092        Make/O/I/N=1 wTmpWrite
3093//      Make/O/R/N=1 wTmpWrite
3094        String groupName = "/entry/instrument/beam_stop_C3"     
3095        String varName = "num_beamstops"
3096        wTmpWrite[0] = val
3097
3098        variable err
3099        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3100        if(err)
3101                Print "HDF write err = ",err
3102        endif
3103        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3104//      err = V_KillNamedDataFolder(fname)
3105//      if(err)
3106//              Print "DataFolder kill err = ",err
3107//      endif
3108        return(err)
3109End
3110
3111Function V_writeBeamStopC3_x_pos(fname,val)
3112        String fname
3113        Variable val
3114
3115//      String path = "entry:instrument:beam_stop:x0"
3116       
3117        Make/O/D/N=1 wTmpWrite
3118//      Make/O/R/N=1 wTmpWrite
3119        String groupName = "/entry/instrument/beam_stop_C3"     
3120        String varName = "x_pos"
3121        wTmpWrite[0] = val
3122
3123        variable err
3124        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3125        if(err)
3126                Print "HDF write err = ",err
3127        endif
3128        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3129//      err = V_KillNamedDataFolder(fname)
3130//      if(err)
3131//              Print "DataFolder kill err = ",err
3132//      endif
3133        return(err)
3134End
3135
3136Function V_writeBeamStopC3_y_pos(fname,val)
3137        String fname
3138        Variable val
3139
3140//      String path = "entry:instrument:beam_stop:y0"
3141       
3142        Make/O/D/N=1 wTmpWrite
3143//      Make/O/R/N=1 wTmpWrite
3144        String groupName = "/entry/instrument/beam_stop_C3"     
3145        String varName = "y_pos"
3146        wTmpWrite[0] = val
3147
3148        variable err
3149        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3150        if(err)
3151                Print "HDF write err = ",err
3152        endif
3153        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3154//      err = V_KillNamedDataFolder(fname)
3155//      if(err)
3156//              Print "DataFolder kill err = ",err
3157//      endif
3158        return(err)
3159End
3160
3161
3162// beam stop C3 (shape)
3163Function V_writeBeamStopC3_height(fname,val)
3164        String fname
3165        Variable val
3166
3167//      String path = "entry:instrument:beam_stop:y0"
3168       
3169        Make/O/D/N=1 wTmpWrite
3170//      Make/O/R/N=1 wTmpWrite
3171        String groupName = "/entry/instrument/beam_stop_C3/shape"       
3172        String varName = "height"
3173        wTmpWrite[0] = val
3174
3175        variable err
3176        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3177        if(err)
3178                Print "HDF write err = ",err
3179        endif
3180        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3181//      err = V_KillNamedDataFolder(fname)
3182//      if(err)
3183//              Print "DataFolder kill err = ",err
3184//      endif
3185        return(err)
3186End
3187
3188Function V_writeBeamStopC3_shape(fname,str)
3189        String fname,str
3190
3191//      String path = "entry:instrument:beam_stop:description"
3192
3193        Make/O/T/N=1 tmpTW
3194        String groupName = "/entry/instrument/beam_stop_C3/shape"       //     
3195        String varName = "shape"
3196        tmpTW[0] = str //
3197
3198        variable err
3199        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3200        if(err)
3201                Print "HDF write err = ",err
3202        endif
3203       
3204        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3205//      err = V_KillNamedDataFolder(fname)
3206//      if(err)
3207//              Print "DataFolder kill err = ",err
3208//      endif
3209               
3210        return(err)
3211End
3212
3213// this is diameter if shape=CIRCLE
3214Function V_writeBeamStopC3_size(fname,val)
3215        String fname
3216        Variable val
3217
3218//      String path = "entry:instrument:beam_stop:y0"
3219       
3220        Make/O/D/N=1 wTmpWrite
3221//      Make/O/R/N=1 wTmpWrite
3222        String groupName = "/entry/instrument/beam_stop_C3/shape"       
3223        String varName = "size"
3224        wTmpWrite[0] = val
3225
3226        variable err
3227        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3228        if(err)
3229                Print "HDF write err = ",err
3230        endif
3231        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3232//      err = V_KillNamedDataFolder(fname)
3233//      if(err)
3234//              Print "DataFolder kill err = ",err
3235//      endif
3236        return(err)
3237End
3238
3239Function V_writeBeamStopC3_width(fname,val)
3240        String fname
3241        Variable val
3242
3243//      String path = "entry:instrument:beam_stop:y0"
3244       
3245        Make/O/D/N=1 wTmpWrite
3246//      Make/O/R/N=1 wTmpWrite
3247        String groupName = "/entry/instrument/beam_stop_C3/shape"       
3248        String varName = "width"
3249        wTmpWrite[0] = val
3250
3251        variable err
3252        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3253        if(err)
3254                Print "HDF write err = ",err
3255        endif
3256        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3257//      err = V_KillNamedDataFolder(fname)
3258//      if(err)
3259//              Print "DataFolder kill err = ",err
3260//      endif
3261        return(err)
3262End
3263
3264
3265
3266//// INSTRUMENT/COLLIMATOR
3267//collimator (data folder) -- this is a TEXT field
3268Function V_writeNumberOfGuides(fname,str)
3269        String fname,str
3270
3271//      String path = "entry:instrument:collimator:number_guides"
3272
3273        Make/O/T/N=1 tmpTW
3274        String groupName = "/entry/instrument/collimator"       
3275        String varName = "number_guides"
3276        tmpTW[0] = str //
3277
3278        variable err
3279        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3280        if(err)
3281                Print "HDF write err = ",err
3282        endif
3283       
3284        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3285//      err = V_KillNamedDataFolder(fname)
3286//      if(err)
3287//              Print "DataFolder kill err = ",err
3288//      endif
3289               
3290        return(err)
3291End
3292
3293
3294//                              geometry (data folder)
3295//                                      shape (data folder)
3296Function V_writeGuideShape(fname,str)
3297        String fname,str
3298
3299//      String path = "entry:instrument:collimator:geometry:shape:shape"
3300
3301        Make/O/T/N=1 tmpTW
3302        String groupName = "/entry/instrument/collimator/geometry/shape"        //     
3303        String varName = "shape"
3304        tmpTW[0] = str //
3305
3306        variable err
3307        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3308        if(err)
3309                Print "HDF write err = ",err
3310        endif
3311       
3312        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3313//      err = V_KillNamedDataFolder(fname)
3314//      if(err)
3315//              Print "DataFolder kill err = ",err
3316//      endif
3317               
3318        return(err)
3319End
3320
3321// TODO -- this may need to be a wave to properly describe the dimensions
3322Function V_writeGuideSize(fname,val)
3323        String fname
3324        Variable val
3325
3326//      String path = "entry:instrument:collimator:geometry:shape:size"
3327       
3328        Make/O/D/N=1 wTmpWrite
3329//      Make/O/R/N=1 wTmpWrite
3330        String groupName = "/entry/instrument/collimator/geometry/shape"       
3331        String varName = "size"
3332        wTmpWrite[0] = val
3333
3334        variable err
3335        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3336        if(err)
3337                Print "HDF write err = ",err
3338        endif
3339        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3340//      err = V_KillNamedDataFolder(fname)
3341//      if(err)
3342//              Print "DataFolder kill err = ",err
3343//      endif
3344        return(err)
3345End
3346
3347//                      converging_pinholes (data folder)
3348Function V_writeConvPinholeStatus(fname,str)
3349        String fname,str
3350
3351//      String path = "entry:instrument:converging_pinholes:status"
3352
3353        Make/O/T/N=1 tmpTW
3354        String groupName = "/entry/instrument/converging_pinholes"      //     
3355        String varName = "status"
3356        tmpTW[0] = str //
3357
3358        variable err
3359        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3360        if(err)
3361                Print "HDF write err = ",err
3362        endif
3363       
3364        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3365//      err = V_KillNamedDataFolder(fname)
3366//      if(err)
3367//              Print "DataFolder kill err = ",err
3368//      endif
3369               
3370        return(err)
3371End
3372
3373//                      converging_slits (not used)
3374
3375
3376
3377
3378
3379
3380////// INSTRUMENT/DETECTORS
3381//                      detector_B (data folder)
3382//
3383// only defined for the "B" detector, and may not be necessary?
3384// TODO -- write to return an ARRAY
3385Function V_writeDet_cal_x(fname,detStr,inW)
3386        String fname,detStr
3387        Wave inW
3388
3389        if(cmpstr(detStr,"B") == 0)
3390//              String path = "entry:instrument:detector_"+detStr+":CALX"
3391               
3392                Duplicate/O inW wTmpWrite       
3393        // then use redimension as needed to cast the wave to write to the specified type
3394        // see WaveType for the proper codes
3395        //      Redimension/T=() wTmpWrite
3396        // -- May also need to check the dimension(s) before writing (don't trust the input)
3397                String groupName = "/entry/instrument/detector_"+detStr
3398                String varName = "cal_x"
3399
3400                variable err
3401                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3402                if(err)
3403                        Print "HDF write err = ",err
3404                endif
3405                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3406//              err = V_KillNamedDataFolder(fname)
3407//              if(err)
3408//                      Print "DataFolder kill err = ",err
3409//              endif
3410                return(err)
3411        else
3412                return(0)
3413        endif
3414End
3415
3416// only defined for the "B" detector, and may not be necessary?
3417// TODO -- write to return an ARRAY
3418Function V_writeDet_cal_y(fname,detStr,inW)
3419        String fname,detStr
3420        Wave inW
3421
3422        if(cmpstr(detStr,"B") == 0)
3423//              String path = "entry:instrument:detector_"+detStr+":CALY"
3424
3425                Duplicate/O inW wTmpWrite       
3426        // then use redimension as needed to cast the wave to write to the specified type
3427        // see WaveType for the proper codes
3428        //      Redimension/T=() wTmpWrite
3429        // -- May also need to check the dimension(s) before writing (don't trust the input)
3430                String groupName = "/entry/instrument/detector_"+detStr
3431                String varName = "cal_y"
3432
3433                variable err
3434                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3435                if(err)
3436                        Print "HDF write err = ",err
3437                endif
3438                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3439//              err = V_KillNamedDataFolder(fname)
3440//              if(err)
3441//                      Print "DataFolder kill err = ",err
3442//              endif
3443                return(err)
3444        else
3445                return(0)
3446        endif
3447End
3448
3449// TODO -- write and X and Y version of this. Pixels are not square
3450// so the FHWM will be different in each direction. May need to return
3451// "dummy" value for "B" detector if pixels there are square
3452Function V_writeDet_pixel_fwhm_x(fname,detStr,val)
3453        String fname,detStr
3454        Variable val
3455
3456//      String path = "entry:instrument:detector_"+detStr+":pixel_fwhm_x"
3457       
3458        Make/O/D/N=1 wTmpWrite
3459//      Make/O/R/N=1 wTmpWrite
3460        String groupName = "/entry/instrument/detector_"+detStr
3461        String varName = "pixel_fwhm_x"
3462        wTmpWrite[0] = val
3463
3464        variable err
3465        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3466        if(err)
3467                Print "HDF write err = ",err
3468        endif
3469        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3470//      err = V_KillNamedDataFolder(fname)
3471//      if(err)
3472//              Print "DataFolder kill err = ",err
3473//      endif
3474        return(err)
3475End
3476
3477
3478// TODO -- write and X and Y version of this. Pixels are not square
3479// so the FHWM will be different in each direction. May need to return
3480// "dummy" value for "B" detector if pixels there are square
3481Function V_writeDet_pixel_fwhm_y(fname,detStr,val)
3482        String fname,detStr
3483        Variable val
3484
3485//      String path = "entry:instrument:detector_"+detStr+":pixel_fwhm_y"
3486       
3487        Make/O/D/N=1 wTmpWrite
3488//      Make/O/R/N=1 wTmpWrite
3489        String groupName = "/entry/instrument/detector_"+detStr
3490        String varName = "pixel_fwhm_y"
3491        wTmpWrite[0] = val
3492
3493        variable err
3494        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3495        if(err)
3496                Print "HDF write err = ",err
3497        endif
3498        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3499//      err = V_KillNamedDataFolder(fname)
3500//      if(err)
3501//              Print "DataFolder kill err = ",err
3502//      endif
3503        return(err)
3504End
3505
3506// integer value
3507Function V_writeDet_pixel_num_x(fname,detStr,val)
3508        String fname,detStr
3509        Variable val
3510
3511//      String path = "entry:instrument:detector_"+detStr+":pixel_nnum_x"
3512       
3513        Make/O/I/N=1 wTmpWrite
3514//      Make/O/R/N=1 wTmpWrite
3515        String groupName = "/entry/instrument/detector_"+detStr
3516        String varName = "pixel_num_x"
3517        wTmpWrite[0] = val
3518
3519        variable err
3520        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3521        if(err)
3522                Print "HDF write err = ",err
3523        endif
3524        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3525//      err = V_KillNamedDataFolder(fname)
3526//      if(err)
3527//              Print "DataFolder kill err = ",err
3528//      endif
3529        return(err)
3530End
3531
3532// integer value
3533Function V_writeDet_pixel_num_y(fname,detStr,val)
3534        String fname,detStr
3535        Variable val
3536
3537//      String path = "entry:instrument:detector_"+detStr+":pixel_num_y"
3538       
3539        Make/O/I/N=1 wTmpWrite
3540//      Make/O/R/N=1 wTmpWrite
3541        String groupName = "/entry/instrument/detector_"+detStr
3542        String varName = "pixel_num_y"
3543        wTmpWrite[0] = val
3544
3545        variable err
3546        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3547        if(err)
3548                Print "HDF write err = ",err
3549        endif
3550        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3551//      err = V_KillNamedDataFolder(fname)
3552//      if(err)
3553//              Print "DataFolder kill err = ",err
3554//      endif
3555        return(err)
3556End
3557
3558//// only defined for the "B" detector, and only to satisfy NXsas
3559//Function V_writeDet_azimuthalAngle(fname,detStr,val)
3560//      String fname,detStr
3561//      Variable val
3562//
3563//      if(cmpstr(detStr,"B") == 0)
3564////            String path = "entry:instrument:detector_"+detStr+":azimuthal_angle"
3565//     
3566//              Make/O/D/N=1 wTmpWrite
3567//      //      Make/O/R/N=1 wTmpWrite
3568//              String groupName = "/entry/instrument/detector_"+detStr
3569//              String varName = "azimuthal_angle"
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)
3583//      else
3584//              return(0)
3585//      endif
3586//End
3587
3588Function V_writeDet_beam_center_x(fname,detStr,val)
3589        String fname,detStr
3590        Variable val
3591
3592//      String path = "entry:instrument:detector_"+detStr+":beam_center_x"
3593       
3594        Make/O/D/N=1 wTmpWrite
3595//      Make/O/R/N=1 wTmpWrite
3596        String groupName = "/entry/instrument/detector_"+detStr
3597        String varName = "beam_center_x"
3598        wTmpWrite[0] = val
3599
3600        variable err
3601        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3602        if(err)
3603                Print "HDF write err = ",err
3604        endif
3605        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3606//      err = V_KillNamedDataFolder(fname)
3607//      if(err)
3608//              Print "DataFolder kill err = ",err
3609//      endif
3610        return(err)
3611End
3612
3613// fname is a local WORK folder
3614Function V_putDet_beam_center_x(fname,detStr,val)
3615        String fname,detStr
3616        Variable val
3617
3618//root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:beam_center_x
3619        String path = "root:Packages:NIST:VSANS:"+fname+":"
3620        path += "entry:instrument:detector_"+detStr+":beam_center_x"
3621       
3622        Wave/Z w = $path
3623        if(waveExists(w) == 0)
3624                return(1)
3625        else
3626        w[0] = val
3627                return(0)
3628        endif
3629
3630End
3631
3632Function V_writeDet_beam_center_y(fname,detStr,val)
3633        String fname,detStr
3634        Variable val
3635
3636//      String path = "entry:instrument:detector_"+detStr+":beam_center_y"
3637       
3638        Make/O/D/N=1 wTmpWrite
3639//      Make/O/R/N=1 wTmpWrite
3640        String groupName = "/entry/instrument/detector_"+detStr
3641        String varName = "beam_center_y"
3642        wTmpWrite[0] = val
3643
3644        variable err
3645        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3646        if(err)
3647                Print "HDF write err = ",err
3648        endif
3649        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3650//      err = V_KillNamedDataFolder(fname)
3651//      if(err)
3652//              Print "DataFolder kill err = ",err
3653//      endif
3654        return(err)
3655End
3656
3657
3658// fname is a local WORK folder
3659Function V_putDet_beam_center_y(fname,detStr,val)
3660        String fname,detStr
3661        Variable val
3662
3663//root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:beam_center_y
3664        String path = "root:Packages:NIST:VSANS:"+fname+":"
3665        path += "entry:instrument:detector_"+detStr+":beam_center_y"
3666       
3667        Wave/Z w = $path
3668        if(waveExists(w) == 0)
3669                return(1)
3670        else
3671        w[0] = val
3672                return(0)
3673        endif
3674
3675End
3676
3677
3678// TODO -- write this function to return a WAVE with the data
3679// either as a wave reference, or as an input parameter
3680Function V_writeDetectorData(fname,detStr,inW)
3681        String fname,detStr
3682        Wave inW
3683
3684//      String path = "entry:instrument:detector_"+detStr+":data"
3685       
3686        Duplicate/O inW wTmpWrite       
3687// then use redimension as needed to cast the wave to write to the specified type
3688// see WaveType for the proper codes
3689//      Redimension/T=() wTmpWrite
3690// -- May also need to check the dimension(s) before writing (don't trust the input)
3691        String groupName = "/entry/instrument/detector_"+detStr
3692        String varName = "data"
3693
3694        variable err
3695        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3696        if(err)
3697                Print "HDF write err = ",err
3698        endif
3699        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3700//      err = V_KillNamedDataFolder(fname)
3701//      if(err)
3702//              Print "DataFolder kill err = ",err
3703//      endif
3704        return(err)
3705End
3706
3707
3708
3709/////////////////////////
3710
3711
3712// TODO -- write this function to return a WAVE with the data
3713// either as a wave reference, or as an input parameter
3714// ALSO -- the "B" deadtime will be a single value (probably)
3715//  but the tube banks will be 1D arrays of values, one per tube
3716Function V_writeDetector_deadtime(fname,detStr,inW)
3717        String fname,detStr
3718        Wave inW
3719
3720//      String path = "entry:instrument:detector_"+detStr+":dead_time"
3721        if(cmpstr(detStr,"B") == 0)
3722                DoAlert 0,"Bad call to V_writeDetector_deadtime"
3723                return(0)
3724        else
3725
3726                Duplicate/O inW wTmpWrite       
3727        // then use redimension as needed to cast the wave to write to the specified type
3728        // see WaveType for the proper codes
3729        //      Redimension/T=() wTmpWrite
3730        // -- May also need to check the dimension(s) before writing (don't trust the input)
3731                String groupName = "/entry/instrument/detector_"+detStr
3732                String varName = "dead_time"
3733       
3734                variable err
3735                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3736                if(err)
3737                        Print "HDF write err = ",err
3738                endif
3739                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3740        //      err = V_KillNamedDataFolder(fname)
3741        //      if(err)
3742        //              Print "DataFolder kill err = ",err
3743        //      endif
3744                return(err)
3745        endif
3746End
3747
3748// dead time, a single value, only for detB
3749Function V_writeDetector_deadtime_B(fname,detStr,val)
3750        String fname,detStr
3751        variable val
3752
3753//      String path = "entry:instrument:detector_"+detStr+":dead_time"
3754        if(cmpstr(detStr,"B") == 0)
3755       
3756                Make/O/D/N=1 wTmpWrite
3757        //      Make/O/R/N=1 wTmpWrite
3758                String groupName = "/entry/instrument/detector_"+detStr
3759                String varName = "dead_time"
3760                wTmpWrite[0] = val
3761       
3762                variable err
3763                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3764                if(err)
3765                        Print "HDF write err = ",err
3766                endif
3767                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3768        //      err = V_KillNamedDataFolder(fname)
3769        //      if(err)
3770        //              Print "DataFolder kill err = ",err
3771        //      endif
3772       
3773                return(err)     
3774        else
3775                DoAlert 0,"Bad call to V_writeDetector_deadtime_B"
3776                return(0)
3777        endif
3778End
3779
3780Function V_writeDetDescription(fname,detStr,str)
3781        String fname,detStr,str
3782
3783//      String path = "entry:instrument:detector_"+detStr+":description"
3784
3785        Make/O/T/N=1 tmpTW
3786        String groupName = "/entry/instrument/detector_"+detStr //     
3787        String varName = "description"
3788        tmpTW[0] = str //
3789
3790        variable err
3791        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3792        if(err)
3793                Print "HDF write err = ",err
3794        endif
3795       
3796        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3797//      err = V_KillNamedDataFolder(fname)
3798//      if(err)
3799//              Print "DataFolder kill err = ",err
3800//      endif
3801               
3802        return(err)
3803End
3804
3805Function V_writeDet_distance(fname,detStr,val)
3806        String fname,detStr
3807        variable val
3808
3809//      String path = "entry:instrument:detector_"+detStr+":distance"
3810       
3811        Make/O/D/N=1 wTmpWrite
3812//      Make/O/R/N=1 wTmpWrite
3813        String groupName = "/entry/instrument/detector_"+detStr
3814        String varName = "distance"
3815        wTmpWrite[0] = val
3816
3817        variable err
3818        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3819        if(err)
3820                Print "HDF write err = ",err
3821        endif
3822        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3823//      err = V_KillNamedDataFolder(fname)
3824//      if(err)
3825//              Print "DataFolder kill err = ",err
3826//      endif
3827        return(err)
3828End
3829
3830//// only defined for the "B" detector, and only to satisfy NXsas
3831//Function V_writeDet_equatorial_angle(fname,detStr,val)
3832//      String fname,detStr
3833//      variable val
3834//
3835//      if(cmpstr(detStr,"B") == 0)
3836////            String path = "entry:instrument:detector_"+detStr+":equatorial_angle"
3837//     
3838//              Make/O/D/N=1 wTmpWrite
3839//      //      Make/O/R/N=1 wTmpWrite
3840//              String groupName = "/entry/instrument/detector_"+detStr
3841//              String varName = "equatorial_angle"
3842//              wTmpWrite[0] = val
3843//
3844//              variable err
3845//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3846//              if(err)
3847//                      Print "HDF write err = ",err
3848//              endif
3849//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3850////            err = V_KillNamedDataFolder(fname)
3851////            if(err)
3852////                    Print "DataFolder kill err = ",err
3853////            endif
3854//              return(err)
3855//      else
3856//              return(0)
3857//      endif
3858//End
3859
3860Function V_writeDetEventFileName(fname,detStr,str)
3861        String fname,detStr,str
3862
3863//      String path = "entry:instrument:detector_"+detStr+":event_file_name"
3864
3865        Make/O/T/N=1 tmpTW
3866        String groupName = "/entry/instrument/detector_"+detStr //     
3867        String varName = "event_file_name"
3868        tmpTW[0] = str //
3869
3870        variable err
3871        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3872        if(err)
3873                Print "HDF write err = ",err
3874        endif
3875       
3876        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3877//      err = V_KillNamedDataFolder(fname)
3878//      if(err)
3879//              Print "DataFolder kill err = ",err
3880//      endif
3881               
3882        return(err)
3883End
3884
3885Function V_writeDet_IntegratedCount(fname,detStr,val)
3886        String fname,detStr
3887        Variable val
3888
3889//      String path = "entry:instrument:detector_"+detStr+":integrated_count"
3890       
3891        Make/O/D/N=1 wTmpWrite
3892//      Make/O/R/N=1 wTmpWrite
3893        String groupName = "/entry/instrument/detector_"+detStr
3894        String varName = "integrated_count"
3895        wTmpWrite[0] = val
3896
3897        variable err
3898        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3899        if(err)
3900                Print "HDF write err = ",err
3901        endif
3902        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3903//      err = V_KillNamedDataFolder(fname)
3904//      if(err)
3905//              Print "DataFolder kill err = ",err
3906//      endif
3907        return(err)
3908End
3909
3910// this is only written for B and L/R detectors
3911Function V_writeDet_LateralOffset(fname,detStr,val)
3912        String fname,detStr
3913        Variable val
3914
3915//      String path = "entry:instrument:detector_"+detStr+":lateral_offset"
3916
3917        if(cmpstr(detStr,"FT") == 0 || cmpstr(detStr,"FB") == 0)
3918                return(0)
3919        endif
3920        if(cmpstr(detStr,"MT") == 0 || cmpstr(detStr,"MB") == 0)
3921                return(0)
3922        endif   
3923               
3924        Make/O/D/N=1 wTmpWrite
3925//      Make/O/R/N=1 wTmpWrite
3926        String groupName = "/entry/instrument/detector_"+detStr
3927        String varName = "lateral_offset"
3928        wTmpWrite[0] = val
3929
3930        variable err
3931        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3932        if(err)
3933                Print "HDF write err = ",err
3934        endif
3935        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3936//      err = V_KillNamedDataFolder(fname)
3937//      if(err)
3938//              Print "DataFolder kill err = ",err
3939//      endif
3940        return(err)
3941End
3942
3943
3944// this is only written for T/B detectors
3945Function V_writeDet_VerticalOffset(fname,detStr,val)
3946        String fname,detStr
3947        Variable val
3948
3949//      String path = "entry:instrument:detector_"+detStr+":vertical_offset"
3950
3951        if(cmpstr(detStr,"B") == 0)
3952                return(0)
3953        endif
3954        if(cmpstr(detStr,"FR") == 0 || cmpstr(detStr,"FL") == 0)
3955                return(0)
3956        endif
3957        if(cmpstr(detStr,"MR") == 0 || cmpstr(detStr,"ML") == 0)
3958                return(0)
3959        endif   
3960               
3961        Make/O/D/N=1 wTmpWrite
3962//      Make/O/R/N=1 wTmpWrite
3963        String groupName = "/entry/instrument/detector_"+detStr
3964        String varName = "vertical_offset"
3965        wTmpWrite[0] = val
3966
3967        variable err
3968        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3969        if(err)
3970                Print "HDF write err = ",err
3971        endif
3972        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3973//      err = V_KillNamedDataFolder(fname)
3974//      if(err)
3975//              Print "DataFolder kill err = ",err
3976//      endif
3977        return(err)
3978End
3979
3980
3981// TODO - be sure that this is defined correctly
3982// -- it needs to exist in the data file, and only for TB detector panels
3983Function V_writeDet_TBSetback(fname,detStr,val)
3984        String fname,detStr
3985        Variable val
3986
3987//      String path = "entry:instrument:detector_"+detStr+":setback"
3988       
3989        if(cmpstr(detStr,"B") == 0)
3990                return(0)
3991        endif
3992        if(cmpstr(detStr,"FR") == 0 || cmpstr(detStr,"FL") == 0)
3993                return(0)
3994        endif
3995        if(cmpstr(detStr,"MR") == 0 || cmpstr(detStr,"ML") == 0)
3996                return(0)
3997        endif   
3998       
3999        Make/O/D/N=1 wTmpWrite
4000//      Make/O/R/N=1 wTmpWrite
4001        String groupName = "/entry/instrument/detector_"+detStr
4002        String varName = "setback"
4003        wTmpWrite[0] = val
4004
4005        variable err
4006        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4007        if(err)
4008                Print "HDF write err = ",err
4009        endif
4010        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4011//      err = V_KillNamedDataFolder(fname)
4012//      if(err)
4013//              Print "DataFolder kill err = ",err
4014//      endif
4015        return(err)
4016End
4017
4018
4019
4020//// only defined for the "B" detector, and only to satisfy NXsas
4021//Function V_writeDet_polar_angle(fname,detStr,val)
4022//      String fname,detStr
4023//      Variable val
4024//
4025//      if(cmpstr(detStr,"B") == 0)
4026////            String path = "entry:instrument:detector_"+detStr+":polar_angle"
4027//     
4028//              Make/O/D/N=1 wTmpWrite
4029//      //      Make/O/R/N=1 wTmpWrite
4030//              String groupName = "/entry/instrument/detector_"+detStr
4031//              String varName = "polar_angle"
4032//              wTmpWrite[0] = val
4033//
4034//              variable err
4035//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4036//              if(err)
4037//                      Print "HDF write err = ",err
4038//              endif
4039//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4040////            err = V_KillNamedDataFolder(fname)
4041////            if(err)
4042////                    Print "DataFolder kill err = ",err
4043////            endif
4044//              return(err)
4045//      else
4046//              return(0)
4047//      endif
4048//End
4049
4050//// only defined for the "B" detector, and only to satisfy NXsas
4051//Function V_writeDet_rotational_angle(fname,detStr,val)
4052//      String fname,detStr
4053//      Variable val
4054//
4055//      if(cmpstr(detStr,"B") == 0)
4056////            String path = "entry:instrument:detector_"+detStr+":rotational_angle"
4057//     
4058//              Make/O/D/N=1 wTmpWrite
4059//      //      Make/O/R/N=1 wTmpWrite
4060//              String groupName = "/entry/instrument/detector_"+detStr
4061//              String varName = "rotational_angle"
4062//              wTmpWrite[0] = val
4063//
4064//              variable err
4065//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4066//              if(err)
4067//                      Print "HDF write err = ",err
4068//              endif
4069//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4070////            err = V_KillNamedDataFolder(fname)
4071////            if(err)
4072////                    Print "DataFolder kill err = ",err
4073////            endif
4074//              return(err)
4075//      else
4076//              return(0)
4077//      endif
4078//End
4079
4080Function V_writeDetSettings(fname,detStr,str)
4081        String fname,detStr,str
4082
4083//      String path = "entry:instrument:detector_"+detStr+":settings"
4084
4085        Make/O/T/N=1 tmpTW
4086        String groupName = "/entry/instrument/detector_"+detStr //     
4087        String varName = "settings"
4088        tmpTW[0] = str //
4089
4090        variable err
4091        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4092        if(err)
4093                Print "HDF write err = ",err
4094        endif
4095       
4096        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4097//      err = V_KillNamedDataFolder(fname)
4098//      if(err)
4099//              Print "DataFolder kill err = ",err
4100//      endif
4101               
4102        return(err)
4103End
4104
4105//// really has no meaning at all
4106//Function V_writeDet_size(fname,detStr,val)
4107//      String fname,detStr
4108//      Variable val
4109//
4110////    String path = "entry:instrument:detector_"+detStr+":size"
4111//     
4112//      Make/O/D/N=1 wTmpWrite
4113////    Make/O/R/N=1 wTmpWrite
4114//      String groupName = "/entry/instrument/detector_"+detStr
4115//      String varName = "size"
4116//      wTmpWrite[0] = val
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)
4129//End
4130
4131//Function V_writeDetType(fname,detStr,str)
4132//      String fname,detStr,str
4133//
4134////    String path = "entry:instrument:detector_"+detStr+":type"
4135//
4136//      Make/O/T/N=1 tmpTW
4137//      String groupName = "/entry/instrument/detector_"+detStr //     
4138//      String varName = "type"
4139//      tmpTW[0] = str //
4140//
4141//      variable err
4142//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4143//      if(err)
4144//              Print "HDF write err = ",err
4145//      endif
4146//     
4147//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4148////    err = V_KillNamedDataFolder(fname)
4149////    if(err)
4150////            Print "DataFolder kill err = ",err
4151////    endif
4152//             
4153//      return(err)
4154//End
4155
4156Function V_writeDet_x_pixel_size(fname,detStr,val)
4157        String fname,detStr
4158        Variable val
4159
4160//      String path = "entry:instrument:detector_"+detStr+":x_pixel_size"
4161       
4162        Make/O/D/N=1 wTmpWrite
4163//      Make/O/R/N=1 wTmpWrite
4164        String groupName = "/entry/instrument/detector_"+detStr
4165        String varName = "x_pixel_size"
4166        wTmpWrite[0] = val
4167
4168        variable err
4169        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4170        if(err)
4171                Print "HDF write err = ",err
4172        endif
4173        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4174//      err = V_KillNamedDataFolder(fname)
4175//      if(err)
4176//              Print "DataFolder kill err = ",err
4177//      endif
4178        return(err)
4179End
4180
4181Function V_writeDet_y_pixel_size(fname,detStr,val)
4182        String fname,detStr
4183        Variable val
4184
4185//      String path = "entry:instrument:detector_"+detStr+":y_pixel_size"
4186       
4187        Make/O/D/N=1 wTmpWrite
4188//      Make/O/R/N=1 wTmpWrite
4189        String groupName = "/entry/instrument/detector_"+detStr
4190        String varName = "y_pixel_size"
4191        wTmpWrite[0] = val
4192
4193        variable err
4194        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4195        if(err)
4196                Print "HDF write err = ",err
4197        endif
4198        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4199//      err = V_KillNamedDataFolder(fname)
4200//      if(err)
4201//              Print "DataFolder kill err = ",err
4202//      endif
4203        return(err)
4204End
4205
4206/////////                       detector_FB (data folder) + ALL other PANEL DETECTORS
4207
4208// integer value
4209Function V_writeDet_numberOfTubes(fname,detStr,val)
4210        String fname,detStr
4211        Variable val
4212
4213//      String path = "entry:instrument:detector_"+detStr+":number_of_tubes"
4214        if(cmpstr(detStr,"B") == 0)
4215                return(0)
4216        else
4217       
4218                Make/O/I/N=1 wTmpWrite
4219        //      Make/O/R/N=1 wTmpWrite
4220                String groupName = "/entry/instrument/detector_"+detStr
4221                String varName = "number_of_tubes"
4222                wTmpWrite[0] = val
4223
4224                variable err
4225                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4226                if(err)
4227                        Print "HDF write err = ",err
4228                endif
4229                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4230//              err = V_KillNamedDataFolder(fname)
4231//              if(err)
4232//                      Print "DataFolder kill err = ",err
4233//              endif
4234                return(err)
4235        endif
4236End
4237
4238// deleted from definition
4239//Function V_writeDetPanelSeparation(fname,detStr,val)
4240//      String fname,detStr
4241//      Variable val
4242//
4243////    String path = "entry:instrument:detector_"+detStr+":separation"
4244//      if(cmpstr(detStr,"B") == 0)
4245//              return(0)
4246//      else
4247//     
4248//              Make/O/D/N=1 wTmpWrite
4249//      //      Make/O/R/N=1 wTmpWrite
4250//              String groupName = "/entry/instrument/detector_"+detStr
4251//              String varName = "separation"
4252//              wTmpWrite[0] = val
4253//
4254//              variable err
4255//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4256//              if(err)
4257//                      Print "HDF write err = ",err
4258//              endif
4259//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4260////            err = V_KillNamedDataFolder(fname)
4261////            if(err)
4262////                    Print "DataFolder kill err = ",err
4263////            endif
4264//              return(err)
4265//      endif
4266//End
4267
4268// TODO -- write this function to return a WAVE with the data
4269// either as a wave reference, or as an input parameter
4270Function V_writeDetTube_spatialCalib(fname,detStr,inW)
4271        String fname,detStr
4272        Wave inW
4273
4274//      String path = "entry:instrument:detector_"+detStr+":spatial_calibration"
4275
4276        if(cmpstr(detStr,"B") == 0)
4277                return(0)
4278        else
4279                Duplicate/O inW wTmpWrite       
4280        // then use redimension as needed to cast the wave to write to the specified type
4281        // see WaveType for the proper codes
4282        //      Redimension/T=() wTmpWrite
4283        // -- May also need to check the dimension(s) before writing (don't trust the input)
4284                String groupName = "/entry/instrument/detector_"+detStr
4285                String varName = "spatial_calibration"
4286
4287                variable err
4288                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4289                if(err)
4290                        Print "HDF write err = ",err
4291                endif
4292                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4293//              err = V_KillNamedDataFolder(fname)
4294//              if(err)
4295//                      Print "DataFolder kill err = ",err
4296//              endif
4297                return(err)
4298        endif
4299End
4300
4301//// TODO -- be clear on how this is defined.
4302//Function V_writeDet_tubeIndex(fname,detStr,val)
4303//      String fname,detStr
4304//      Variable val
4305//
4306////    String path = "entry:instrument:detector_"+detStr+":tube_index"
4307//      if(cmpstr(detStr,"B") == 0)
4308//              return(0)
4309//      else
4310//     
4311//              Make/O/D/N=1 wTmpWrite
4312//      //      Make/O/R/N=1 wTmpWrite
4313//              String groupName = "/entry/instrument/detector_"+detStr
4314//              String varName = "tube_index"
4315//              wTmpWrite[0] = val
4316//
4317//              variable err
4318//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4319//              if(err)
4320//                      Print "HDF write err = ",err
4321//              endif
4322//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4323////            err = V_KillNamedDataFolder(fname)
4324////            if(err)
4325////                    Print "DataFolder kill err = ",err
4326////            endif
4327//              return(err)
4328//      endif
4329//End
4330
4331Function V_writeDet_tubeOrientation(fname,detStr,str)
4332        String fname,detStr,str
4333
4334//      String path = "entry:instrument:detector_"+detStr+":tube_orientation"
4335
4336        if(cmpstr(detStr,"B") == 0)
4337                return(0)
4338        else
4339                Make/O/T/N=1 tmpTW
4340                String groupName = "/entry/instrument/detector_"+detStr //     
4341                String varName = "tube_orientation"
4342                tmpTW[0] = str //
4343
4344                variable err
4345                err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4346                if(err)
4347                        Print "HDF write err = ",err
4348                endif
4349       
4350                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4351//              err = V_KillNamedDataFolder(fname)
4352//              if(err)
4353//                      Print "DataFolder kill err = ",err
4354//              endif
4355               
4356                return(err)
4357
4358        endif
4359End
4360
4361// TODO -- be clear on how this is defined. Units?
4362Function V_writeDet_tubeWidth(fname,detStr,val)
4363        String fname,detStr
4364        Variable val
4365
4366//      String path = "entry:instrument:detector_"+detStr+":tube_width"
4367        if(cmpstr(detStr,"B") == 0)
4368                return(0)
4369        else
4370       
4371                Make/O/D/N=1 wTmpWrite
4372        //      Make/O/R/N=1 wTmpWrite
4373                String groupName = "/entry/instrument/detector_"+detStr
4374                String varName = "tube_width"
4375                wTmpWrite[0] = val
4376
4377                variable err
4378                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4379                if(err)
4380                        Print "HDF write err = ",err
4381                endif
4382                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4383//              err = V_KillNamedDataFolder(fname)
4384//              if(err)
4385//                      Print "DataFolder kill err = ",err
4386//              endif
4387                return(err)
4388        endif
4389End
4390
4391//////////////////////
4392
4393// INSTRUMENT/LENSES    /APERTURES
4394//  lenses (data folder)
4395
4396Function V_writeLensCurvature(fname,val)
4397        String fname
4398        Variable val
4399
4400//      String path = "entry:instrument:lenses:curvature"
4401       
4402        Make/O/D/N=1 wTmpWrite
4403//      Make/O/R/N=1 wTmpWrite
4404        String groupName = "/entry/instrument/lenses"
4405        String varName = "curvature"
4406        wTmpWrite[0] = val
4407
4408        variable err
4409        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4410        if(err)
4411                Print "HDF write err = ",err
4412        endif
4413        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4414//      err = V_KillNamedDataFolder(fname)
4415//      if(err)
4416//              Print "DataFolder kill err = ",err
4417//      endif
4418        return(err)
4419End
4420
4421Function V_writeLensesFocusType(fname,str)
4422        String fname,str
4423
4424//      String path = "entry:instrument:lenses:focus_type"
4425
4426        Make/O/T/N=1 tmpTW
4427        String groupName = "/entry/instrument/lenses"
4428        String varName = "focus_type"
4429        tmpTW[0] = str //
4430
4431        variable err
4432        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4433        if(err)
4434                Print "HDF write err = ",err
4435        endif
4436       
4437        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4438//      err = V_KillNamedDataFolder(fname)
4439//      if(err)
4440//              Print "DataFolder kill err = ",err
4441//      endif
4442               
4443        return(err)
4444End
4445
4446Function V_writeLensDistance(fname,val)
4447        String fname
4448        Variable val
4449
4450//      String path = "entry:instrument:lenses:lens_distance"
4451       
4452        Make/O/D/N=1 wTmpWrite
4453//      Make/O/R/N=1 wTmpWrite
4454        String groupName = "/entry/instrument/lenses"
4455        String varName = "lens_distance"
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)
4469End
4470
4471Function V_writeLensGeometry(fname,str)
4472        String fname,str
4473
4474//      String path = "entry:instrument:lenses:lens_geometry"
4475
4476        Make/O/T/N=1 tmpTW
4477        String groupName = "/entry/instrument/lenses"
4478        String varName = "lens_geometry"
4479        tmpTW[0] = str //
4480
4481        variable err
4482        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4483        if(err)
4484                Print "HDF write err = ",err
4485        endif
4486       
4487        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4488//      err = V_KillNamedDataFolder(fname)
4489//      if(err)
4490//              Print "DataFolder kill err = ",err
4491//      endif
4492               
4493        return(err)
4494End
4495
4496Function V_writeLensMaterial(fname,str)
4497        String fname,str
4498
4499//      String path = "entry:instrument:lenses:lens_material"
4500
4501        Make/O/T/N=1 tmpTW
4502        String groupName = "/entry/instrument/lenses"
4503        String varName = "lens_material"
4504        tmpTW[0] = str //
4505
4506        variable err
4507        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4508        if(err)
4509                Print "HDF write err = ",err
4510        endif
4511       
4512        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4513//      err = V_KillNamedDataFolder(fname)
4514//      if(err)
4515//              Print "DataFolder kill err = ",err
4516//      endif
4517               
4518        return(err)
4519End
4520
4521// integer value
4522Function V_writeNumber_of_Lenses(fname,val)
4523        String fname
4524        Variable val
4525
4526//      String path = "entry:instrument:lenses:number_of_lenses"
4527       
4528        Make/O/I/N=1 wTmpWrite
4529//      Make/O/R/N=1 wTmpWrite
4530        String groupName = "/entry/instrument/lenses"
4531        String varName = "number_of_lenses"
4532        wTmpWrite[0] = val
4533
4534        variable err
4535        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4536        if(err)
4537                Print "HDF write err = ",err
4538        endif
4539        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4540//      err = V_KillNamedDataFolder(fname)
4541//      if(err)
4542//              Print "DataFolder kill err = ",err
4543//      endif
4544        return(err)
4545End
4546
4547// integer value
4548Function V_writeNumber_of_prisms(fname,val)
4549        String fname
4550        Variable val
4551
4552//      String path = "entry:instrument:lenses:number_of_prisms"
4553       
4554        Make/O/I/N=1 wTmpWrite
4555//      Make/O/R/N=1 wTmpWrite
4556        String groupName = "/entry/instrument/lenses"
4557        String varName = "number_of_prisms"
4558        wTmpWrite[0] = val
4559
4560        variable err
4561        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4562        if(err)
4563                Print "HDF write err = ",err
4564        endif
4565        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4566//      err = V_KillNamedDataFolder(fname)
4567//      if(err)
4568//              Print "DataFolder kill err = ",err
4569//      endif
4570        return(err)
4571End
4572
4573Function V_writePrism_distance(fname,val)
4574        String fname
4575        Variable val
4576
4577//      String path = "entry:instrument:lenses:prism_distance"
4578       
4579        Make/O/D/N=1 wTmpWrite
4580//      Make/O/R/N=1 wTmpWrite
4581        String groupName = "/entry/instrument/lenses"
4582        String varName = "prism_distance"
4583        wTmpWrite[0] = val
4584
4585        variable err
4586        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4587        if(err)
4588                Print "HDF write err = ",err
4589        endif
4590        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4591//      err = V_KillNamedDataFolder(fname)
4592//      if(err)
4593//              Print "DataFolder kill err = ",err
4594//      endif
4595        return(err)
4596End
4597
4598Function V_writePrismMaterial(fname,str)
4599        String fname,str
4600
4601//      String path = "entry:instrument:lenses:prism_material"
4602
4603        Make/O/T/N=1 tmpTW
4604        String groupName = "/entry/instrument/lenses"
4605        String varName = "prism_material"
4606        tmpTW[0] = str //
4607
4608        variable err
4609        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4610        if(err)
4611                Print "HDF write err = ",err
4612        endif
4613       
4614        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4615//      err = V_KillNamedDataFolder(fname)
4616//      if(err)
4617//              Print "DataFolder kill err = ",err
4618//      endif
4619               
4620        return(err)
4621End
4622
4623// status of lens/prism = lens | prism | both | out
4624Function V_writeLensPrismStatus(fname,str)
4625        String fname,str
4626
4627//      String path = "entry:instrument:lenses:status"
4628
4629        Make/O/T/N=1 tmpTW
4630        String groupName = "/entry/instrument/lenses"
4631        String varName = "status"
4632        tmpTW[0] = str //
4633
4634        variable err
4635        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4636        if(err)
4637                Print "HDF write err = ",err
4638        endif
4639       
4640        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4641//      err = V_KillNamedDataFolder(fname)
4642//      if(err)
4643//              Print "DataFolder kill err = ",err
4644//      endif
4645               
4646        return(err)
4647End
4648       
4649
4650///////  sample_aperture (data folder)
4651
4652Function V_writeSampleAp_Description(fname,str)
4653        String fname,str
4654
4655//      String path = "entry:instrument:sample_aperture:description"
4656
4657        Make/O/T/N=1 tmpTW
4658        String groupName = "/entry/instrument/sample_aperture"
4659        String varName = "description"
4660        tmpTW[0] = str //
4661
4662        variable err
4663        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4664        if(err)
4665                Print "HDF write err = ",err
4666        endif
4667       
4668        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4669//      err = V_KillNamedDataFolder(fname)
4670//      if(err)
4671//              Print "DataFolder kill err = ",err
4672//      endif
4673               
4674        return(err)
4675End
4676
4677Function V_writeSampleAp_distance(fname,val)
4678        String fname
4679        Variable val
4680
4681//      String path = "entry:instrument:sample_aperture:distance"
4682       
4683        Make/O/D/N=1 wTmpWrite
4684//      Make/O/R/N=1 wTmpWrite
4685        String groupName = "/entry/instrument/sample_aperture"
4686        String varName = "distance"
4687        wTmpWrite[0] = val
4688
4689        variable err
4690        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4691        if(err)
4692                Print "HDF write err = ",err
4693        endif
4694        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4695//      err = V_KillNamedDataFolder(fname)
4696//      if(err)
4697//              Print "DataFolder kill err = ",err
4698//      endif
4699        return(err)
4700End
4701
4702//      shape (data folder)
4703
4704Function V_writeSampleAp_shape(fname,str)
4705        String fname,str
4706
4707//      String path = "entry:instrument:sample_aperture:shape:shape"
4708
4709        Make/O/T/N=1 tmpTW
4710        String groupName = "/entry/instrument/sample_aperture/shape"
4711        String varName = "shape"
4712        tmpTW[0] = str //
4713
4714        variable err
4715        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4716        if(err)
4717                Print "HDF write err = ",err
4718        endif
4719       
4720        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4721//      err = V_KillNamedDataFolder(fname)
4722//      if(err)
4723//              Print "DataFolder kill err = ",err
4724//      endif
4725               
4726        return(err)
4727End
4728
4729Function V_writeSampleAp_height(fname,val)
4730        String fname
4731        Variable val
4732
4733//      String path = "entry:instrument:sample_aperture:distance"
4734       
4735        Make/O/D/N=1 wTmpWrite
4736//      Make/O/R/N=1 wTmpWrite
4737        String groupName = "/entry/instrument/sample_aperture/shape"
4738        String varName = "height"
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)
4752End
4753
4754Function V_writeSampleAp_size(fname,str)
4755        String fname,str
4756
4757//      String path = "entry:instrument:sample_aperture:shape:shape"
4758
4759        Make/O/T/N=1 tmpTW
4760        String groupName = "/entry/instrument/sample_aperture/shape"
4761        String varName = "size"
4762        tmpTW[0] = str //
4763
4764        variable err
4765        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4766        if(err)
4767                Print "HDF write err = ",err
4768        endif
4769       
4770        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4771//      err = V_KillNamedDataFolder(fname)
4772//      if(err)
4773//              Print "DataFolder kill err = ",err
4774//      endif
4775               
4776        return(err)
4777End
4778
4779Function V_writeSampleAp_width(fname,val)
4780        String fname
4781        Variable val
4782
4783//      String path = "entry:instrument:sample_aperture:distance"
4784       
4785        Make/O/D/N=1 wTmpWrite
4786//      Make/O/R/N=1 wTmpWrite
4787        String groupName = "/entry/instrument/sample_aperture/shape"
4788        String varName = "width"
4789        wTmpWrite[0] = val
4790
4791        variable err
4792        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4793        if(err)
4794                Print "HDF write err = ",err
4795        endif
4796        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4797//      err = V_KillNamedDataFolder(fname)
4798//      if(err)
4799//              Print "DataFolder kill err = ",err
4800//      endif
4801        return(err)
4802End
4803
4804///////  sample_aperture_2 (data folder)
4805
4806Function V_writeSampleAp2_Description(fname,str)
4807        String fname,str
4808
4809//      String path = "entry:instrument:sample_aperture_2:description"
4810
4811        Make/O/T/N=1 tmpTW
4812        String groupName = "/entry/instrument/sample_aperture_2"
4813        String varName = "description"
4814        tmpTW[0] = str //
4815
4816        variable err
4817        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4818        if(err)
4819                Print "HDF write err = ",err
4820        endif
4821       
4822        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4823//      err = V_KillNamedDataFolder(fname)
4824//      if(err)
4825//              Print "DataFolder kill err = ",err
4826//      endif
4827               
4828        return(err)
4829End
4830
4831Function V_writeSampleAp2_distance(fname,val)
4832        String fname
4833        Variable val
4834
4835//      String path = "entry:instrument:sample_aperture_2:distance"
4836       
4837        Make/O/D/N=1 wTmpWrite
4838//      Make/O/R/N=1 wTmpWrite
4839        String groupName = "/entry/instrument/sample_aperture_2"
4840        String varName = "distance"
4841        wTmpWrite[0] = val
4842
4843        variable err
4844        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4845        if(err)
4846                Print "HDF write err = ",err
4847        endif
4848        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4849//      err = V_KillNamedDataFolder(fname)
4850//      if(err)
4851//              Print "DataFolder kill err = ",err
4852//      endif
4853        return(err)
4854End
4855
4856
4857//      shape (data folder)
4858
4859Function V_writeSampleAp2_shape(fname,str)
4860        String fname,str
4861
4862//      String path = "entry:instrument:sample_aperture_2:shape:shape"
4863
4864        Make/O/T/N=1 tmpTW
4865        String groupName = "/entry/instrument/sample_aperture_2/shape"
4866        String varName = "shape"
4867        tmpTW[0] = str //
4868
4869        variable err
4870        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4871        if(err)
4872                Print "HDF write err = ",err
4873        endif
4874       
4875        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4876//      err = V_KillNamedDataFolder(fname)
4877//      if(err)
4878//              Print "DataFolder kill err = ",err
4879//      endif
4880               
4881        return(err)
4882End
4883
4884Function V_writeSampleAp2_height(fname,val)
4885        String fname
4886        Variable val
4887
4888//      String path = "entry:instrument:sample_aperture:distance"
4889       
4890        Make/O/D/N=1 wTmpWrite
4891//      Make/O/R/N=1 wTmpWrite
4892        String groupName = "/entry/instrument/sample_aperture_2/shape"
4893        String varName = "height"
4894        wTmpWrite[0] = val
4895
4896        variable err
4897        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4898        if(err)
4899                Print "HDF write err = ",err
4900        endif
4901        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4902//      err = V_KillNamedDataFolder(fname)
4903//      if(err)
4904//              Print "DataFolder kill err = ",err
4905//      endif
4906        return(err)
4907End
4908
4909Function V_writeSampleAp2_size(fname,val)
4910        String fname
4911        Variable val
4912
4913//      String path = "entry:instrument:sample_aperture:distance"
4914       
4915        Make/O/D/N=1 wTmpWrite
4916//      Make/O/R/N=1 wTmpWrite
4917        String groupName = "/entry/instrument/sample_aperture_2/shape"
4918        String varName = "size"
4919        wTmpWrite[0] = val
4920
4921        variable err
4922        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4923        if(err)
4924                Print "HDF write err = ",err
4925        endif
4926        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4927//      err = V_KillNamedDataFolder(fname)
4928//      if(err)
4929//              Print "DataFolder kill err = ",err
4930//      endif
4931        return(err)
4932End
4933
4934Function V_writeSampleAp2_width(fname,val)
4935        String fname
4936        Variable val
4937
4938//      String path = "entry:instrument:sample_aperture:distance"
4939       
4940        Make/O/D/N=1 wTmpWrite
4941//      Make/O/R/N=1 wTmpWrite
4942        String groupName = "/entry/instrument/sample_aperture_2/shape"
4943        String varName = "width"
4944        wTmpWrite[0] = val
4945
4946        variable err
4947        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4948        if(err)
4949                Print "HDF write err = ",err
4950        endif
4951        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4952//      err = V_KillNamedDataFolder(fname)
4953//      if(err)
4954//              Print "DataFolder kill err = ",err
4955//      endif
4956        return(err)
4957End
4958
4959               
4960//////  sample_table (data folder)
4961// location  = "CHAMBER" or HUBER
4962Function V_writeSampleTableLocation(fname,str)
4963        String fname,str
4964
4965//      String path = "entry:instrument:sample_table:location"
4966
4967        Make/O/T/N=1 tmpTW
4968        String groupName = "/entry/instrument/sample_table"
4969        String varName = "location"
4970        tmpTW[0] = str //
4971
4972        variable err
4973        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4974        if(err)
4975                Print "HDF write err = ",err
4976        endif
4977       
4978        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4979//      err = V_KillNamedDataFolder(fname)
4980//      if(err)
4981//              Print "DataFolder kill err = ",err
4982//      endif
4983               
4984        return(err)
4985End
4986
4987// TODO - verify the meaning
4988//      offset_distance (?? for center of sample table vs. sample position)
4989Function V_writeSampleTableOffset(fname,val)
4990        String fname
4991        Variable val
4992
4993//      String path = "entry:instrument:sample_table:offset_distance"
4994       
4995        Make/O/D/N=1 wTmpWrite
4996//      Make/O/R/N=1 wTmpWrite
4997        String groupName = "/entry/instrument/sample_table"
4998        String varName = "offset_distance"
4999        wTmpWrite[0] = val
5000
5001        variable err
5002        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5003        if(err)
5004                Print "HDF write err = ",err
5005        endif
5006        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5007//      err = V_KillNamedDataFolder(fname)
5008//      if(err)
5009//              Print "DataFolder kill err = ",err
5010//      endif
5011        return(err)
5012End     
5013       
5014//  source (data folder)
5015//name "NCNR"
5016Function V_writeSourceName(fname,str)
5017        String fname,str
5018
5019//      String path = "entry:instrument:source:name"
5020
5021        Make/O/T/N=1 tmpTW
5022        String groupName = "/entry/instrument/source"
5023        String varName = "name"
5024        tmpTW[0] = str //
5025
5026        variable err
5027        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5028        if(err)
5029                Print "HDF write err = ",err
5030        endif
5031       
5032        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5033//      err = V_KillNamedDataFolder(fname)
5034//      if(err)
5035//              Print "DataFolder kill err = ",err
5036//      endif
5037               
5038        return(err)
5039End
5040
5041//      power -- nominal only, not connected to any real number
5042Function V_writeReactorPower(fname,val)
5043        String fname
5044        Variable val
5045
5046//      String path = "entry:instrument:source:power"
5047       
5048        Make/O/D/N=1 wTmpWrite
5049//      Make/O/R/N=1 wTmpWrite
5050        String groupName = "/entry/instrument/source"
5051        String varName = "power"
5052        wTmpWrite[0] = val
5053
5054        variable err
5055        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5056        if(err)
5057                Print "HDF write err = ",err
5058        endif
5059        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5060//      err = V_KillNamedDataFolder(fname)
5061//      if(err)
5062//              Print "DataFolder kill err = ",err
5063//      endif
5064        return(err)
5065End     
5066
5067//probe (wave) "neutron"
5068Function V_writeSourceProbe(fname,str)
5069        String fname,str
5070
5071//      String path = "entry:instrument:source:probe"
5072
5073        Make/O/T/N=1 tmpTW
5074        String groupName = "/entry/instrument/source"
5075        String varName = "probe"
5076        tmpTW[0] = str //
5077
5078        variable err
5079        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5080        if(err)
5081                Print "HDF write err = ",err
5082        endif
5083       
5084        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5085//      err = V_KillNamedDataFolder(fname)
5086//      if(err)
5087//              Print "DataFolder kill err = ",err
5088//      endif
5089               
5090        return(err)
5091End
5092
5093//type (wave) "Reactor Neutron Source"
5094Function V_writeSourceType(fname,str)
5095        String fname,str
5096
5097//      String path = "entry:instrument:source:type"
5098
5099        Make/O/T/N=1 tmpTW
5100        String groupName = "/entry/instrument/source"
5101        String varName = "type"
5102        tmpTW[0] = str //
5103
5104        variable err
5105        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5106        if(err)
5107                Print "HDF write err = ",err
5108        endif
5109       
5110        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5111//      err = V_KillNamedDataFolder(fname)
5112//      if(err)
5113//              Print "DataFolder kill err = ",err
5114//      endif
5115               
5116        return(err)
5117End
5118
5119       
5120///////  source_aperture (data folder)
5121
5122Function V_writeSourceAp_Description(fname,str)
5123        String fname,str
5124
5125//      String path = "entry:instrument:source_aperture:description"
5126
5127        Make/O/T/N=1 tmpTW
5128        String groupName = "/entry/instrument/source_aperture"
5129        String varName = "description"
5130        tmpTW[0] = str //
5131
5132        variable err
5133        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5134        if(err)
5135                Print "HDF write err = ",err
5136        endif
5137       
5138        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5139//      err = V_KillNamedDataFolder(fname)
5140//      if(err)
5141//              Print "DataFolder kill err = ",err
5142//      endif
5143               
5144        return(err)
5145End
5146
5147Function V_writeSourceAp_distance(fname,val)
5148        String fname
5149        Variable val
5150
5151//      String path = "entry:instrument:source_aperture:distance"
5152       
5153        Make/O/D/N=1 wTmpWrite
5154//      Make/O/R/N=1 wTmpWrite
5155        String groupName = "/entry/instrument/source_aperture"
5156        String varName = "distance"
5157        wTmpWrite[0] = val
5158
5159        variable err
5160        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5161        if(err)
5162                Print "HDF write err = ",err
5163        endif
5164        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5165//      err = V_KillNamedDataFolder(fname)
5166//      if(err)
5167//              Print "DataFolder kill err = ",err
5168//      endif
5169        return(err)
5170End
5171//      shape (data folder)
5172
5173Function V_writeSourceAp_shape(fname,str)
5174        String fname,str
5175
5176//      String path = "entry:instrument:source_aperture:shape:shape"
5177
5178        Make/O/T/N=1 tmpTW
5179        String groupName = "/entry/instrument/source_aperture/shape"
5180        String varName = "shape"
5181        tmpTW[0] = str //
5182
5183        variable err
5184        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5185        if(err)
5186                Print "HDF write err = ",err
5187        endif
5188       
5189        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5190//      err = V_KillNamedDataFolder(fname)
5191//      if(err)
5192//              Print "DataFolder kill err = ",err
5193//      endif
5194               
5195        return(err)
5196End
5197
5198Function V_writeSourceAp_size(fname,str)
5199        String fname,str
5200
5201//      String path = "entry:instrument:source_aperture:shape:shape"
5202
5203        Make/O/T/N=1 tmpTW
5204        String groupName = "/entry/instrument/source_aperture/shape"
5205        String varName = "size"
5206        tmpTW[0] = str //
5207
5208        variable err
5209        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5210        if(err)
5211                Print "HDF write err = ",err
5212        endif
5213       
5214        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5215//      err = V_KillNamedDataFolder(fname)
5216//      if(err)
5217//              Print "DataFolder kill err = ",err
5218//      endif
5219               
5220        return(err)
5221End
5222
5223Function V_writeSourceAp_height(fname,val)
5224        String fname
5225        Variable val
5226
5227//      String path = "entry:instrument:sample_aperture:distance"
5228       
5229        Make/O/D/N=1 wTmpWrite
5230//      Make/O/R/N=1 wTmpWrite
5231        String groupName = "/entry/instrument/source_aperture/shape"
5232        String varName = "height"
5233        wTmpWrite[0] = val
5234
5235        variable err
5236        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5237        if(err)
5238                Print "HDF write err = ",err
5239        endif
5240        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5241//      err = V_KillNamedDataFolder(fname)
5242//      if(err)
5243//              Print "DataFolder kill err = ",err
5244//      endif
5245        return(err)
5246End
5247
5248Function V_writeSourceAp_width(fname,val)
5249        String fname
5250        Variable val
5251
5252//      String path = "entry:instrument:sample_aperture:distance"
5253       
5254        Make/O/D/N=1 wTmpWrite
5255//      Make/O/R/N=1 wTmpWrite
5256        String groupName = "/entry/instrument/source_aperture/shape"
5257        String varName = "width"
5258        wTmpWrite[0] = val
5259
5260        variable err
5261        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5262        if(err)
5263                Print "HDF write err = ",err
5264        endif
5265        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5266//      err = V_KillNamedDataFolder(fname)
5267//      if(err)
5268//              Print "DataFolder kill err = ",err
5269//      endif
5270        return(err)
5271End
5272
5273
5274//////// SAMPLE
5275//////// SAMPLE
5276//////// SAMPLE
5277
5278//Sample position in changer
5279Function V_writeSamplePosition(fname,str)
5280        String fname,str
5281
5282//      String path = "entry:sample:changer_position"   
5283
5284        Make/O/T/N=1 tmpTW
5285        String groupName = "/entry/sample"
5286        String varName = "changer_position"
5287        tmpTW[0] = str //
5288
5289        variable err
5290        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5291        if(err)
5292                Print "HDF write err = ",err
5293        endif
5294       
5295        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5296//      err = V_KillNamedDataFolder(fname)
5297//      if(err)
5298//              Print "DataFolder kill err = ",err
5299//      endif
5300               
5301        return(err)
5302End
5303
5304
5305// sample label
5306// TODO: value of num is currently not used
5307Function V_writeSampleDescription(fname,str)
5308        String fname,str
5309
5310//      String path = "entry:sample:description"
5311
5312        Make/O/T/N=1 tmpTW
5313        String groupName = "/entry/sample"
5314        String varName = "description"
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
5332// for a z-stage??
5333Function V_writeSample_elevation(fname,val)
5334        String fname
5335        Variable val
5336       
5337//      String path = "entry:sample:elevation" 
5338       
5339        Make/O/D/N=1 wTmpWrite
5340//      Make/O/R/N=1 wTmpWrite
5341        String groupName = "/entry/sample"
5342        String varName = "elevation"
5343        wTmpWrite[0] = val
5344
5345        variable err
5346        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5347        if(err)
5348                Print "HDF write err = ",err
5349        endif
5350        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5351//      err = V_KillNamedDataFolder(fname)
5352//      if(err)
5353//              Print "DataFolder kill err = ",err
5354//      endif
5355        return(err)
5356end
5357
5358//no meaning to this...
5359Function V_writeSample_equatorial_ang(fname,val)
5360        String fname
5361        Variable val
5362       
5363//      String path = "entry:sample:equatorial_angle"   
5364       
5365        Make/O/D/N=1 wTmpWrite
5366//      Make/O/R/N=1 wTmpWrite
5367        String groupName = "/entry/sample"
5368        String varName = "equatorial_angle"
5369        wTmpWrite[0] = val
5370
5371        variable err
5372        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5373        if(err)
5374                Print "HDF write err = ",err
5375        endif
5376        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5377//      err = V_KillNamedDataFolder(fname)
5378//      if(err)
5379//              Print "DataFolder kill err = ",err
5380//      endif
5381        return(err)
5382end
5383
5384// TODO -- do  I need to make sure that this is an integer?
5385// group ID !!! very important for matching up files
5386// integer value
5387Function V_writeSample_GroupID(fname,val)
5388        String fname
5389        Variable val
5390       
5391//      String path = "entry:sample:group_id"   
5392       
5393        Make/O/I/N=1 wTmpWrite
5394//      Make/O/R/N=1 wTmpWrite
5395        String groupName = "/entry/sample"
5396        String varName = "group_id"
5397        wTmpWrite[0] = val
5398
5399        variable err
5400        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5401        if(err)
5402                Print "HDF write err = ",err
5403        endif
5404        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5405//      err = V_KillNamedDataFolder(fname)
5406//      if(err)
5407//              Print "DataFolder kill err = ",err
5408//      endif
5409        return(err)
5410end
5411
5412
5413//Sample Rotation Angle
5414Function V_writeSampleRotationAngle(fname,val)
5415        String fname
5416        Variable val
5417       
5418//      String path = "entry:sample:rotation_angle"     
5419       
5420        Make/O/D/N=1 wTmpWrite
5421//      Make/O/R/N=1 wTmpWrite
5422        String groupName = "/entry/sample"
5423        String varName = "rotation_angle"
5424        wTmpWrite[0] = val
5425
5426        variable err
5427        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5428        if(err)
5429                Print "HDF write err = ",err
5430        endif
5431        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5432//      err = V_KillNamedDataFolder(fname)
5433//      if(err)
5434//              Print "DataFolder kill err = ",err
5435//      endif
5436        return(err)
5437end
5438
5439//?? this is huber/chamber??
5440// TODO -- then where is the description of 10CB, etc...
5441Function V_writeSampleHolderDescription(fname,str)
5442        String fname,str
5443
5444//      String path = "entry:sample:sample_holder_description"
5445
5446        Make/O/T/N=1 tmpTW
5447        String groupName = "/entry/sample"
5448        String varName = "sample_holder_description"
5449        tmpTW[0] = str //
5450
5451        variable err
5452        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5453        if(err)
5454                Print "HDF write err = ",err
5455        endif
5456       
5457        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5458//      err = V_KillNamedDataFolder(fname)
5459//      if(err)
5460//              Print "DataFolder kill err = ",err
5461//      endif
5462               
5463        return(err)
5464End
5465
5466//Sample Thickness
5467// TODO -- somehow, this is not set correctly in the acquisition, so NaN results
5468Function V_writeSampleThickness(fname,val)
5469        String fname
5470        Variable val
5471       
5472//      String path = "entry:sample:thickness" 
5473       
5474        Make/O/D/N=1 wTmpWrite
5475//      Make/O/R/N=1 wTmpWrite
5476        String groupName = "/entry/sample"
5477        String varName = "thickness"
5478        wTmpWrite[0] = val
5479
5480        variable err
5481        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5482        if(err)
5483                Print "HDF write err = ",err
5484        endif
5485        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5486//      err = V_KillNamedDataFolder(fname)
5487//      if(err)
5488//              Print "DataFolder kill err = ",err
5489//      endif
5490        return(err)
5491end
5492
5493//Sample Translation
5494Function V_writeSampleTranslation(fname,val)
5495        String fname
5496        Variable val
5497       
5498//      String path = "entry:sample:translation"       
5499       
5500        Make/O/D/N=1 wTmpWrite
5501//      Make/O/R/N=1 wTmpWrite
5502        String groupName = "/entry/sample"
5503        String varName = "translation"
5504        wTmpWrite[0] = val
5505
5506        variable err
5507        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5508        if(err)
5509                Print "HDF write err = ",err
5510        endif
5511        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5512//      err = V_KillNamedDataFolder(fname)
5513//      if(err)
5514//              Print "DataFolder kill err = ",err
5515//      endif
5516        return(err)
5517end
5518
5519// sample transmission
5520Function V_writeSampleTransmission(fname,val)
5521        String fname
5522        Variable val
5523       
5524        String path = "entry:sample:transmission"       
5525//      String path = "QKK0037737:data:Transmission"   
5526       
5527        Make/O/D/N=1 wTmpWrite
5528//      Make/O/R/N=1 wTmpWrite
5529        String groupName = "/entry/sample"
5530        String varName = "transmission"
5531        wTmpWrite[0] = val
5532
5533        variable err
5534        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5535        if(err)
5536                Print "HDF write err = ",err
5537        endif
5538        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5539//      err = V_KillNamedDataFolder(fname)
5540//      if(err)
5541//              Print "DataFolder kill err = ",err
5542//      endif
5543        return(err)
5544end
5545
5546//transmission error (one sigma)
5547Function V_writeSampleTransError(fname,val)
5548        String fname
5549        Variable val
5550       
5551//      String path = "entry:sample:transmission_error"
5552       
5553        Make/O/D/N=1 wTmpWrite
5554//      Make/O/R/N=1 wTmpWrite
5555        String groupName = "/entry/sample"
5556        String varName = "transmission_error"
5557        wTmpWrite[0] = val
5558
5559        variable err
5560        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5561        if(err)
5562                Print "HDF write err = ",err
5563        endif
5564        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5565//      err = V_KillNamedDataFolder(fname)
5566//      if(err)
5567//              Print "DataFolder kill err = ",err
5568//      endif
5569        return(err)
5570end
5571
5572
5573
5574//// SAMPLE / DATA LOGS
5575// write this generic , call with the name of the environment log desired
5576//
5577// temperature_1
5578// temperature_2
5579// shear_field
5580// pressure
5581// magnetic_field
5582// electric_field
5583//
5584//////// (for example) electric_field (data folder)
5585
5586Function V_writeLog_attachedTo(fname,logStr,str)
5587        String fname,logStr,str
5588
5589//      String path = "entry:sample:"+logstr+":attached_to"
5590
5591        Make/O/T/N=1 tmpTW
5592        String groupName = "/entry/sample/"+logStr
5593        String varName = "attached_to"
5594        tmpTW[0] = str //
5595
5596        variable err
5597        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5598        if(err)
5599                Print "HDF write err = ",err
5600        endif
5601       
5602        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5603//      err = V_KillNamedDataFolder(fname)
5604//      if(err)
5605//              Print "DataFolder kill err = ",err
5606//      endif
5607               
5608        return(err)
5609End
5610
5611
5612Function V_writeLog_measurement(fname,logStr,str)
5613        String fname,logStr,str
5614
5615        String path = "entry:sample:"+logstr+":measurement"
5616
5617        Make/O/T/N=1 tmpTW
5618        String groupName = "/entry/sample/"+logStr
5619        String varName = "measurement"
5620        tmpTW[0] = str //
5621
5622        variable err
5623        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5624        if(err)
5625                Print "HDF write err = ",err
5626        endif
5627       
5628        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5629//      err = V_KillNamedDataFolder(fname)
5630//      if(err)
5631//              Print "DataFolder kill err = ",err
5632//      endif
5633               
5634        return(err)
5635End
5636
5637
5638Function V_writeLog_Name(fname,logStr,str)
5639        String fname,logStr,str
5640
5641//      String path = "entry:sample:"+logstr+":name"
5642
5643        Make/O/T/N=1 tmpTW
5644        String groupName = "/entry/sample/"+logStr
5645        String varName = "name"
5646        tmpTW[0] = str //
5647
5648        variable err
5649        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5650        if(err)
5651                Print "HDF write err = ",err
5652        endif
5653       
5654        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5655//      err = V_KillNamedDataFolder(fname)
5656//      if(err)
5657//              Print "DataFolder kill err = ",err
5658//      endif
5659               
5660        return(err)
5661End
5662
5663
5664// TODO --
5665Function V_writeLog_nomValue(fname,logStr,val)
5666        String fname,logStr
5667        Variable val
5668       
5669//      String path = "entry:sample:"+logstr+":value"
5670       
5671        Make/O/D/N=1 wTmpWrite
5672//      Make/O/R/N=1 wTmpWrite
5673        String groupName = "/entry/sample/"+logStr
5674        String varName = "value"
5675        wTmpWrite[0] = val
5676
5677        variable err
5678        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5679        if(err)
5680                Print "HDF write err = ",err
5681        endif
5682        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5683//      err = V_KillNamedDataFolder(fname)
5684//      if(err)
5685//              Print "DataFolder kill err = ",err
5686//      endif
5687        return(err)
5688end
5689
5690////            value_log (data folder)
5691Function V_writeLog_startTime(fname,logStr,str)
5692        String fname,logStr,str
5693
5694//      String path = "entry:sample:"+logstr+":value_log:start"
5695
5696        Make/O/T/N=1 tmpTW
5697        String groupName = "/entry/sample/"+logStr+"/value_log"
5698        String varName = "start"
5699        tmpTW[0] = str //
5700
5701        variable err
5702        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5703        if(err)
5704                Print "HDF write err = ",err
5705        endif
5706       
5707        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5708//      err = V_KillNamedDataFolder(fname)
5709//      if(err)
5710//              Print "DataFolder kill err = ",err
5711//      endif
5712               
5713        return(err)
5714End
5715
5716// TODO --
5717Function V_writeLog_avgValue(fname,logStr,val)
5718        String fname,logStr
5719        Variable val
5720       
5721//      String path = "entry:sample:"+logstr+":value_log:average_value"
5722       
5723        Make/O/D/N=1 wTmpWrite
5724//      Make/O/R/N=1 wTmpWrite
5725        String groupName = "/entry/sample/"+logStr+"/value_log"
5726        String varName = "average_value"
5727        wTmpWrite[0] = val
5728
5729        variable err
5730        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5731        if(err)
5732                Print "HDF write err = ",err
5733        endif
5734        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5735//      err = V_KillNamedDataFolder(fname)
5736//      if(err)
5737//              Print "DataFolder kill err = ",err
5738//      endif
5739        return(err)
5740end
5741
5742// TODO -- this needs to be a WAVE reference
5743Function V_writeLog_time(fname,logStr,inW)
5744        String fname,logStr
5745        Wave inW
5746       
5747//      String path = "entry:sample:"+logstr+":value_log:time"
5748
5749        Duplicate/O inW wTmpWrite       
5750// then use redimension as needed to cast the wave to write to the specified type
5751// see WaveType for the proper codes
5752//      Redimension/T=() wTmpWrite
5753// -- May also need to check the dimension(s) before writing (don't trust the input)
5754        String groupName = "/entry/sample/"+logStr+"/value_log"
5755        String varName = "time"
5756
5757        variable err
5758        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5759        if(err)
5760                Print "HDF write err = ",err
5761        endif
5762        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5763//      err = V_KillNamedDataFolder(fname)
5764//      if(err)
5765//              Print "DataFolder kill err = ",err
5766//      endif
5767        return(err)
5768end
5769
5770
5771// TODO -- this needs to be a WAVE reference
5772Function V_writeLog_Value(fname,logStr,inW)
5773        String fname,logStr
5774        Wave inW
5775       
5776//      String path = "entry:sample:"+logstr+":value_log:value"
5777
5778        Duplicate/O inW wTmpWrite       
5779// then use redimension as needed to cast the wave to write to the specified type
5780// see WaveType for the proper codes
5781//      Redimension/T=() wTmpWrite
5782// -- May also need to check the dimension(s) before writing (don't trust the input)
5783        String groupName = "/entry/sample/"+logStr+"/value_log"
5784        String varName = "value"
5785
5786        variable err
5787        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5788        if(err)
5789                Print "HDF write err = ",err
5790        endif
5791        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5792//      err = V_KillNamedDataFolder(fname)
5793//      if(err)
5794//              Print "DataFolder kill err = ",err
5795//      endif
5796        return(err)
5797end
5798
5799
5800
5801///////// REDUCTION
5802///////// REDUCTION
5803///////// REDUCTION
5804
5805
5806// TODO -- needs to be a WAVE, and of the proper size and type!!!
5807Function V_writeAbsolute_Scaling(fname,inW)
5808        String fname
5809        Wave inW
5810       
5811//      String path = "entry:reduction:absolute_scaling"
5812       
5813        Duplicate/O inW wTmpWrite       
5814// then use redimension as needed to cast the wave to write to the specified type
5815// see WaveType for the proper codes
5816//      Redimension/T=() wTmpWrite
5817// -- May also need to check the dimension(s) before writing (don't trust the input)
5818        String groupName = "/entry/reduction"   
5819        String varName = "absolute_scaling"
5820
5821        variable err
5822        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5823        if(err)
5824                Print "HDF write err = ",err
5825        endif
5826        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5827//      err = V_KillNamedDataFolder(fname)
5828//      if(err)
5829//              Print "DataFolder kill err = ",err
5830//      endif
5831        return(err)
5832end
5833
5834// TODO -- needs to be a WAVE
5835Function V_writeBoxCoordinates(fname,inW)
5836        String fname
5837        Wave inW
5838       
5839//      String path = "entry:reduction:box_coordinates"
5840               
5841        Duplicate/O inW wTmpWrite       
5842// then use redimension as needed to cast the wave to write to the specified type
5843// see WaveType for the proper codes
5844//      Redimension/T=() wTmpWrite
5845// -- May also need to check the dimension(s) before writing (don't trust the input)
5846        String groupName = "/entry/reduction"   
5847        String varName = "box_coordinates"
5848
5849        variable err
5850        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5851        if(err)
5852                Print "HDF write err = ",err
5853        endif
5854        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5855//      err = V_KillNamedDataFolder(fname)
5856//      if(err)
5857//              Print "DataFolder kill err = ",err
5858//      endif
5859        return(err)
5860end
5861
5862//box counts
5863Function V_writeBoxCounts(fname,val)
5864        String fname
5865        Variable val
5866       
5867//      String path = "entry:reduction:box_count"       
5868       
5869        Make/O/D/N=1 wTmpWrite
5870//      Make/O/R/N=1 wTmpWrite
5871        String groupName = "/entry/reduction"
5872        String varName = "box_count"
5873        wTmpWrite[0] = val
5874
5875        variable err
5876        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5877        if(err)
5878                Print "HDF write err = ",err
5879        endif
5880        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5881//      err = V_KillNamedDataFolder(fname)
5882//      if(err)
5883//              Print "DataFolder kill err = ",err
5884//      endif
5885        return(err)
5886end
5887
5888//box counts error
5889Function V_writeBoxCountsError(fname,val)
5890        String fname
5891        Variable val
5892       
5893//      String path = "entry:reduction:box_count_error"
5894       
5895        Make/O/D/N=1 wTmpWrite
5896//      Make/O/R/N=1 wTmpWrite
5897        String groupName = "/entry/reduction"
5898        String varName = "box_count_error"
5899        wTmpWrite[0] = val
5900
5901        variable err
5902        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5903        if(err)
5904                Print "HDF write err = ",err
5905        endif
5906        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5907//      err = V_KillNamedDataFolder(fname)
5908//      if(err)
5909//              Print "DataFolder kill err = ",err
5910//      endif
5911        return(err)
5912end
5913
5914Function V_writeReductionComments(fname,str)
5915        String fname,str
5916
5917//      String path = "entry:reduction:comments"       
5918
5919        Make/O/T/N=1 tmpTW
5920        String groupName = "/entry/reduction"
5921        String varName = "comments"
5922        tmpTW[0] = str //
5923
5924        variable err
5925        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5926        if(err)
5927                Print "HDF write err = ",err
5928        endif
5929       
5930        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5931//      err = V_KillNamedDataFolder(fname)
5932//      if(err)
5933//              Print "DataFolder kill err = ",err
5934//      endif
5935               
5936        return(err)
5937End
5938
5939
5940Function V_writeReductionIntent(fname,str)
5941        String fname,str
5942
5943//      String path = "entry:reduction:intent" 
5944
5945        Make/O/T/N=1 tmpTW
5946        String groupName = "/entry/reduction"
5947        String varName = "intent"
5948        tmpTW[0] = str //
5949
5950        variable err
5951        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5952        if(err)
5953                Print "HDF write err = ",err
5954        endif
5955       
5956        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5957//      err = V_KillNamedDataFolder(fname)
5958//      if(err)
5959//              Print "DataFolder kill err = ",err
5960//      endif
5961               
5962        return(err)
5963End
5964
5965
5966Function V_writeLogFileName(fname,str)
5967        String fname,str
5968
5969//      String path = "entry:reduction:sans_log_file_name"     
5970
5971        Make/O/T/N=1 tmpTW
5972        String groupName = "/entry/reduction"
5973        String varName = "sans_log_file_name"
5974        tmpTW[0] = str //
5975
5976        variable err
5977        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5978        if(err)
5979                Print "HDF write err = ",err
5980        endif
5981       
5982        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5983//      err = V_KillNamedDataFolder(fname)
5984//      if(err)
5985//              Print "DataFolder kill err = ",err
5986//      endif
5987               
5988        return(err)
5989End
5990
5991
5992Function V_writeSensitivityFileName(fname,str)
5993        String fname,str
5994
5995//      String path = "entry:reduction:sensitivity_file_name"   
5996
5997        Make/O/T/N=1 tmpTW
5998        String groupName = "/entry/reduction"
5999        String varName = "sensitivity_file_name"
6000        tmpTW[0] = str //
6001
6002        variable err
6003        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6004        if(err)
6005                Print "HDF write err = ",err
6006        endif
6007       
6008        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6009//      err = V_KillNamedDataFolder(fname)
6010//      if(err)
6011//              Print "DataFolder kill err = ",err
6012//      endif
6013               
6014        return(err)
6015End
6016
6017Function V_writeTransmissionFileName(fname,str)
6018        String fname,str
6019
6020//      String path = "entry:reduction:transmission_file_name" 
6021
6022        Make/O/T/N=1 tmpTW
6023        String groupName = "/entry/reduction"
6024        String varName = "transmission_file_name"
6025        tmpTW[0] = str //
6026
6027        variable err
6028        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6029        if(err)
6030                Print "HDF write err = ",err
6031        endif
6032       
6033        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6034//      err = V_KillNamedDataFolder(fname)
6035//      if(err)
6036//              Print "DataFolder kill err = ",err
6037//      endif
6038               
6039        return(err)
6040End
6041
6042Function V_writeEmptyBeamFileName(fname,str)
6043        String fname,str
6044
6045//      String path = "entry:reduction:empty_beam_file_name"   
6046
6047        Make/O/T/N=1 tmpTW
6048        String groupName = "/entry/reduction"
6049        String varName = "empty_beam_file_name"
6050        tmpTW[0] = str //
6051
6052        variable err
6053        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6054        if(err)
6055                Print "HDF write err = ",err
6056        endif
6057       
6058        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6059//      err = V_KillNamedDataFolder(fname)
6060//      if(err)
6061//              Print "DataFolder kill err = ",err
6062//      endif
6063               
6064        return(err)
6065End
6066
6067Function V_writeEmptyFileName(fname,str)
6068        String fname,str
6069
6070//      String path = "entry:reduction:empty_beam_file_name"   
6071
6072        Make/O/T/N=1 tmpTW
6073        String groupName = "/entry/reduction"
6074        String varName = "empty_file_name"
6075        tmpTW[0] = str //
6076
6077        variable err
6078        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6079        if(err)
6080                Print "HDF write err = ",err
6081        endif
6082       
6083        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6084//      err = V_KillNamedDataFolder(fname)
6085//      if(err)
6086//              Print "DataFolder kill err = ",err
6087//      endif
6088               
6089        return(err)
6090End
6091
6092Function V_writeMaskFileName(fname,str)
6093        String fname,str
6094
6095//      String path = "entry:reduction:empty_beam_file_name"   
6096
6097        Make/O/T/N=1 tmpTW
6098        String groupName = "/entry/reduction"
6099        String varName = "mask_file_name"
6100        tmpTW[0] = str //
6101
6102        variable err
6103        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6104        if(err)
6105                Print "HDF write err = ",err
6106        endif
6107       
6108        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6109//      err = V_KillNamedDataFolder(fname)
6110//      if(err)
6111//              Print "DataFolder kill err = ",err
6112//      endif
6113               
6114        return(err)
6115End
6116
6117Function V_writeBackgroundFileName(fname,str)
6118        String fname,str
6119
6120//      String path = "entry:reduction:empty_beam_file_name"   
6121
6122        Make/O/T/N=1 tmpTW
6123        String groupName = "/entry/reduction"
6124        String varName = "background_file_name"
6125        tmpTW[0] = str //
6126
6127        variable err
6128        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6129        if(err)
6130                Print "HDF write err = ",err
6131        endif
6132       
6133        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6134//      err = V_KillNamedDataFolder(fname)
6135//      if(err)
6136//              Print "DataFolder kill err = ",err
6137//      endif
6138               
6139        return(err)
6140End
6141
6142//whole detector transmission
6143Function V_writeSampleTransWholeDetector(fname,val)
6144        String fname
6145        Variable val
6146       
6147//      String path = "entry:reduction:whole_trans"     
6148       
6149        Make/O/D/N=1 wTmpWrite
6150//      Make/O/R/N=1 wTmpWrite
6151        String groupName = "/entry/reduction"
6152        String varName = "whole_trans"
6153        wTmpWrite[0] = val
6154
6155        variable err
6156        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6157        if(err)
6158                Print "HDF write err = ",err
6159        endif
6160        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6161//      err = V_KillNamedDataFolder(fname)
6162//      if(err)
6163//              Print "DataFolder kill err = ",err
6164//      endif
6165        return(err)
6166end
6167
6168//whole detector transmission error
6169Function V_writeSampleTransWholeDetErr(fname,val)
6170        String fname
6171        Variable val
6172       
6173//      String path = "entry:reduction:whole_trans_error"       
6174       
6175        Make/O/D/N=1 wTmpWrite
6176//      Make/O/R/N=1 wTmpWrite
6177        String groupName = "/entry/reduction"
6178        String varName = "whole_trans_error"
6179        wTmpWrite[0] = val
6180
6181        variable err
6182        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6183        if(err)
6184                Print "HDF write err = ",err
6185        endif
6186        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6187//      err = V_KillNamedDataFolder(fname)
6188//      if(err)
6189//              Print "DataFolder kill err = ",err
6190//      endif
6191        return(err)
6192end
6193
6194                       
6195/////                   pol_sans (data folder)
6196
6197Function V_writePolSANS_cellName(fname,str)
6198        String fname,str
6199
6200//      String path = "entry:reduction:pol_sans:cell_name"     
6201
6202        Make/O/T/N=1 tmpTW
6203        String groupName = "/entry/reduction/pol_sans"
6204        String varName = "cell_name"
6205        tmpTW[0] = str //
6206
6207        variable err
6208        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6209        if(err)
6210                Print "HDF write err = ",err
6211        endif
6212       
6213        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6214//      err = V_KillNamedDataFolder(fname)
6215//      if(err)
6216//              Print "DataFolder kill err = ",err
6217//      endif
6218               
6219        return(err)
6220End
6221
6222
6223// TODO -- needs to be a WAVE
6224// is this a text wave?? if it's mixed names + values, then what?
6225Function V_writePolSANS_cellParams(fname,inW)
6226        String fname
6227        Wave inW
6228       
6229//      String path = "entry:reduction:pol_sans:cell_parameters"
6230               
6231        Duplicate/O inW wTmpWrite       
6232// then use redimension as needed to cast the wave to write to the specified type
6233// see WaveType for the proper codes
6234//      Redimension/T=() wTmpWrite
6235// -- May also need to check the dimension(s) before writing (don't trust the input)
6236        String groupName = "/entry/reduction/pol_sans" 
6237        String varName = "cell_parameters"
6238
6239        variable err
6240        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6241        if(err)
6242                Print "HDF write err = ",err
6243        endif
6244        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6245//      err = V_KillNamedDataFolder(fname)
6246//      if(err)
6247//              Print "DataFolder kill err = ",err
6248//      endif
6249        return(err)
6250end
6251
6252Function V_writePolSANS_PolSANSPurpose(fname,str)
6253        String fname,str
6254
6255//      String path = "entry:reduction:pol_sans:pol_sans_purpose"       
6256
6257        Make/O/T/N=1 tmpTW
6258        String groupName = "/entry/reduction/pol_sans"
6259        String varName = "pol_sans_purpose"
6260        tmpTW[0] = str //
6261
6262        variable err
6263        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6264        if(err)
6265                Print "HDF write err = ",err
6266        endif
6267       
6268        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6269//      err = V_KillNamedDataFolder(fname)
6270//      if(err)
6271//              Print "DataFolder kill err = ",err
6272//      endif
6273               
6274        return(err)
6275End
6276
6277                               
6278//////// TOP LEVEL DATA REPRESENTATION
6279//
6280// note that here the data is (supposed to be) a link, not the actual data
6281// Igor HDf implementation cannot follow links properly, as far as I know.
6282// so ignore them here, and focus on the image that may be possible to read
6283//
6284
6285//              data_B (data folder)
6286//                      data (wave) 1           //ignore this, it's a link
6287//                      variables (wave) 320
6288//                      thumbnail (data folder)
6289
6290////data (wave) "binary"
6291//// TODO -- this will need to be completely replaced with a function that can
6292//// read the binary image data. should be possible, but I don't know the details on either end...
6293//Function V_writeDataImage(fname,detStr,str)
6294//      String fname,detStr,str
6295//
6296////    String path = "entry:data_"+detStr+":thumbnail:data"   
6297//
6298//      Make/O/T/N=1 tmpTW
6299//      String groupName = "/entry/data_"+detStr+"/thumbnail"
6300//      String varName = "data"
6301//      tmpTW[0] = str //
6302//
6303//      variable err
6304//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6305//      if(err)
6306//              Print "HDF write err = ",err
6307//      endif
6308//     
6309//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6310////    err = V_KillNamedDataFolder(fname)
6311////    if(err)
6312////            Print "DataFolder kill err = ",err
6313////    endif
6314//             
6315//      return(err)
6316//End
6317//
6318//Function V_writeDataImageDescription(fname,detStr,str)
6319//      String fname,detStr,str
6320//
6321////    String path = "entry:data_"+detStr+":thumbnail:description"     
6322//
6323//      Make/O/T/N=1 tmpTW
6324//      String groupName = "/entry/data_"+detStr+"/thumbnail"
6325//      String varName = "description"
6326//      tmpTW[0] = str //
6327//
6328//      variable err
6329//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6330//      if(err)
6331//              Print "HDF write err = ",err
6332//      endif
6333//     
6334//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6335////    err = V_KillNamedDataFolder(fname)
6336////    if(err)
6337////            Print "DataFolder kill err = ",err
6338////    endif
6339//             
6340//      return(err)
6341//End
6342//                                                             
6343//Function V_writeDataImageType(fname,detStr,str)
6344//      String fname,detStr,str
6345//
6346////    String path = "entry:data_"+detStr+":thumbnail:type"   
6347//
6348//      Make/O/T/N=1 tmpTW
6349//      String groupName = "/entry/data_"+detStr+"/thumbnail"
6350//      String varName = "type"
6351//      tmpTW[0] = str //
6352//
6353//      variable err
6354//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6355//      if(err)
6356//              Print "HDF write err = ",err
6357//      endif
6358//     
6359//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6360////    err = V_KillNamedDataFolder(fname)
6361////    if(err)
6362////            Print "DataFolder kill err = ",err
6363////    endif
6364//             
6365//      return(err)
6366//End
6367//
Note: See TracBrowser for help on using the repository browser.