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

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

removed the doubled "entry" field from the VSANS file load.

appears now to work fine with R/W routines and with VCALC.

File size: 155.8 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// TODO -- this may not exist for VSANS
2111Function 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)
2134end
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
3910Function V_writeDet_LateralOffset(fname,detStr,val)
3911        String fname,detStr
3912        Variable val
3913
3914//      String path = "entry:instrument:detector_"+detStr+":lateral_offset"
3915       
3916        Make/O/D/N=1 wTmpWrite
3917//      Make/O/R/N=1 wTmpWrite
3918        String groupName = "/entry/instrument/detector_"+detStr
3919        String varName = "lateral_offset"
3920        wTmpWrite[0] = val
3921
3922        variable err
3923        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3924        if(err)
3925                Print "HDF write err = ",err
3926        endif
3927        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3928//      err = V_KillNamedDataFolder(fname)
3929//      if(err)
3930//              Print "DataFolder kill err = ",err
3931//      endif
3932        return(err)
3933End
3934
3935//Function V_writeDet_VerticalOffset(fname,detStr,val)
3936//      String fname,detStr
3937//      Variable val
3938//
3939////    String path = "entry:instrument:detector_"+detStr+":vertical_offset"
3940//     
3941//      Make/O/D/N=1 wTmpWrite
3942////    Make/O/R/N=1 wTmpWrite
3943//      String groupName = "/entry/instrument/detector_"+detStr
3944//      String varName = "vertical_offset"
3945//      wTmpWrite[0] = val
3946//
3947//      variable err
3948//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3949//      if(err)
3950//              Print "HDF write err = ",err
3951//      endif
3952//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3953////    err = V_KillNamedDataFolder(fname)
3954////    if(err)
3955////            Print "DataFolder kill err = ",err
3956////    endif
3957//      return(err)
3958//End
3959
3960//// only defined for the "B" detector, and only to satisfy NXsas
3961//Function V_writeDet_polar_angle(fname,detStr,val)
3962//      String fname,detStr
3963//      Variable val
3964//
3965//      if(cmpstr(detStr,"B") == 0)
3966////            String path = "entry:instrument:detector_"+detStr+":polar_angle"
3967//     
3968//              Make/O/D/N=1 wTmpWrite
3969//      //      Make/O/R/N=1 wTmpWrite
3970//              String groupName = "/entry/instrument/detector_"+detStr
3971//              String varName = "polar_angle"
3972//              wTmpWrite[0] = val
3973//
3974//              variable err
3975//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3976//              if(err)
3977//                      Print "HDF write err = ",err
3978//              endif
3979//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3980////            err = V_KillNamedDataFolder(fname)
3981////            if(err)
3982////                    Print "DataFolder kill err = ",err
3983////            endif
3984//              return(err)
3985//      else
3986//              return(0)
3987//      endif
3988//End
3989
3990//// only defined for the "B" detector, and only to satisfy NXsas
3991//Function V_writeDet_rotational_angle(fname,detStr,val)
3992//      String fname,detStr
3993//      Variable val
3994//
3995//      if(cmpstr(detStr,"B") == 0)
3996////            String path = "entry:instrument:detector_"+detStr+":rotational_angle"
3997//     
3998//              Make/O/D/N=1 wTmpWrite
3999//      //      Make/O/R/N=1 wTmpWrite
4000//              String groupName = "/entry/instrument/detector_"+detStr
4001//              String varName = "rotational_angle"
4002//              wTmpWrite[0] = val
4003//
4004//              variable err
4005//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4006//              if(err)
4007//                      Print "HDF write err = ",err
4008//              endif
4009//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4010////            err = V_KillNamedDataFolder(fname)
4011////            if(err)
4012////                    Print "DataFolder kill err = ",err
4013////            endif
4014//              return(err)
4015//      else
4016//              return(0)
4017//      endif
4018//End
4019
4020Function V_writeDetSettings(fname,detStr,str)
4021        String fname,detStr,str
4022
4023//      String path = "entry:instrument:detector_"+detStr+":settings"
4024
4025        Make/O/T/N=1 tmpTW
4026        String groupName = "/entry/instrument/detector_"+detStr //     
4027        String varName = "settings"
4028        tmpTW[0] = str //
4029
4030        variable err
4031        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4032        if(err)
4033                Print "HDF write err = ",err
4034        endif
4035       
4036        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4037//      err = V_KillNamedDataFolder(fname)
4038//      if(err)
4039//              Print "DataFolder kill err = ",err
4040//      endif
4041               
4042        return(err)
4043End
4044
4045//// really has no meaning at all
4046//Function V_writeDet_size(fname,detStr,val)
4047//      String fname,detStr
4048//      Variable val
4049//
4050////    String path = "entry:instrument:detector_"+detStr+":size"
4051//     
4052//      Make/O/D/N=1 wTmpWrite
4053////    Make/O/R/N=1 wTmpWrite
4054//      String groupName = "/entry/instrument/detector_"+detStr
4055//      String varName = "size"
4056//      wTmpWrite[0] = val
4057//
4058//      variable err
4059//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4060//      if(err)
4061//              Print "HDF write err = ",err
4062//      endif
4063//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4064////    err = V_KillNamedDataFolder(fname)
4065////    if(err)
4066////            Print "DataFolder kill err = ",err
4067////    endif
4068//      return(err)
4069//End
4070
4071Function V_writeDetType(fname,detStr,str)
4072        String fname,detStr,str
4073
4074//      String path = "entry:instrument:detector_"+detStr+":type"
4075
4076        Make/O/T/N=1 tmpTW
4077        String groupName = "/entry/instrument/detector_"+detStr //     
4078        String varName = "type"
4079        tmpTW[0] = str //
4080
4081        variable err
4082        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4083        if(err)
4084                Print "HDF write err = ",err
4085        endif
4086       
4087        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4088//      err = V_KillNamedDataFolder(fname)
4089//      if(err)
4090//              Print "DataFolder kill err = ",err
4091//      endif
4092               
4093        return(err)
4094End
4095
4096Function V_writeDet_x_pixel_size(fname,detStr,val)
4097        String fname,detStr
4098        Variable val
4099
4100//      String path = "entry:instrument:detector_"+detStr+":x_pixel_size"
4101       
4102        Make/O/D/N=1 wTmpWrite
4103//      Make/O/R/N=1 wTmpWrite
4104        String groupName = "/entry/instrument/detector_"+detStr
4105        String varName = "x_pixel_size"
4106        wTmpWrite[0] = val
4107
4108        variable err
4109        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4110        if(err)
4111                Print "HDF write err = ",err
4112        endif
4113        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4114//      err = V_KillNamedDataFolder(fname)
4115//      if(err)
4116//              Print "DataFolder kill err = ",err
4117//      endif
4118        return(err)
4119End
4120
4121Function V_writeDet_y_pixel_size(fname,detStr,val)
4122        String fname,detStr
4123        Variable val
4124
4125//      String path = "entry:instrument:detector_"+detStr+":y_pixel_size"
4126       
4127        Make/O/D/N=1 wTmpWrite
4128//      Make/O/R/N=1 wTmpWrite
4129        String groupName = "/entry/instrument/detector_"+detStr
4130        String varName = "y_pixel_size"
4131        wTmpWrite[0] = val
4132
4133        variable err
4134        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4135        if(err)
4136                Print "HDF write err = ",err
4137        endif
4138        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4139//      err = V_KillNamedDataFolder(fname)
4140//      if(err)
4141//              Print "DataFolder kill err = ",err
4142//      endif
4143        return(err)
4144End
4145
4146/////////                       detector_FB (data folder) + ALL other PANEL DETECTORS
4147
4148// integer value
4149Function V_writeDet_numberOfTubes(fname,detStr,val)
4150        String fname,detStr
4151        Variable val
4152
4153//      String path = "entry:instrument:detector_"+detStr+":number_of_tubes"
4154        if(cmpstr(detStr,"B") == 0)
4155                return(0)
4156        else
4157       
4158                Make/O/I/N=1 wTmpWrite
4159        //      Make/O/R/N=1 wTmpWrite
4160                String groupName = "/entry/instrument/detector_"+detStr
4161                String varName = "number_of_tubes"
4162                wTmpWrite[0] = val
4163
4164                variable err
4165                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4166                if(err)
4167                        Print "HDF write err = ",err
4168                endif
4169                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4170//              err = V_KillNamedDataFolder(fname)
4171//              if(err)
4172//                      Print "DataFolder kill err = ",err
4173//              endif
4174                return(err)
4175        endif
4176End
4177
4178// TODO -- be clear on how this is defined. Separation as defined from what point? Units?
4179Function V_writeDetPanelSeparation(fname,detStr,val)
4180        String fname,detStr
4181        Variable val
4182
4183//      String path = "entry:instrument:detector_"+detStr+":separation"
4184        if(cmpstr(detStr,"B") == 0)
4185                return(0)
4186        else
4187       
4188                Make/O/D/N=1 wTmpWrite
4189        //      Make/O/R/N=1 wTmpWrite
4190                String groupName = "/entry/instrument/detector_"+detStr
4191                String varName = "separation"
4192                wTmpWrite[0] = val
4193
4194                variable err
4195                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4196                if(err)
4197                        Print "HDF write err = ",err
4198                endif
4199                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4200//              err = V_KillNamedDataFolder(fname)
4201//              if(err)
4202//                      Print "DataFolder kill err = ",err
4203//              endif
4204                return(err)
4205        endif
4206End
4207
4208// TODO -- write this function to return a WAVE with the data
4209// either as a wave reference, or as an input parameter
4210Function V_writeDetTube_spatialCalib(fname,detStr,inW)
4211        String fname,detStr
4212        Wave inW
4213
4214//      String path = "entry:instrument:detector_"+detStr+":spatial_calibration"
4215
4216        if(cmpstr(detStr,"B") == 0)
4217                return(0)
4218        else
4219                Duplicate/O inW wTmpWrite       
4220        // then use redimension as needed to cast the wave to write to the specified type
4221        // see WaveType for the proper codes
4222        //      Redimension/T=() wTmpWrite
4223        // -- May also need to check the dimension(s) before writing (don't trust the input)
4224                String groupName = "/entry/instrument/detector_"+detStr
4225                String varName = "spatial_calibration"
4226
4227                variable err
4228                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4229                if(err)
4230                        Print "HDF write err = ",err
4231                endif
4232                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4233//              err = V_KillNamedDataFolder(fname)
4234//              if(err)
4235//                      Print "DataFolder kill err = ",err
4236//              endif
4237                return(err)
4238        endif
4239End
4240
4241//// TODO -- be clear on how this is defined.
4242//Function V_writeDet_tubeIndex(fname,detStr,val)
4243//      String fname,detStr
4244//      Variable val
4245//
4246////    String path = "entry:instrument:detector_"+detStr+":tube_index"
4247//      if(cmpstr(detStr,"B") == 0)
4248//              return(0)
4249//      else
4250//     
4251//              Make/O/D/N=1 wTmpWrite
4252//      //      Make/O/R/N=1 wTmpWrite
4253//              String groupName = "/entry/instrument/detector_"+detStr
4254//              String varName = "tube_index"
4255//              wTmpWrite[0] = val
4256//
4257//              variable err
4258//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4259//              if(err)
4260//                      Print "HDF write err = ",err
4261//              endif
4262//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4263////            err = V_KillNamedDataFolder(fname)
4264////            if(err)
4265////                    Print "DataFolder kill err = ",err
4266////            endif
4267//              return(err)
4268//      endif
4269//End
4270
4271Function V_writeDet_tubeOrientation(fname,detStr,str)
4272        String fname,detStr,str
4273
4274//      String path = "entry:instrument:detector_"+detStr+":tube_orientation"
4275
4276        if(cmpstr(detStr,"B") == 0)
4277                return(0)
4278        else
4279                Make/O/T/N=1 tmpTW
4280                String groupName = "/entry/instrument/detector_"+detStr //     
4281                String varName = "tube_orientation"
4282                tmpTW[0] = str //
4283
4284                variable err
4285                err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4286                if(err)
4287                        Print "HDF write err = ",err
4288                endif
4289       
4290                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4291//              err = V_KillNamedDataFolder(fname)
4292//              if(err)
4293//                      Print "DataFolder kill err = ",err
4294//              endif
4295               
4296                return(err)
4297
4298        endif
4299End
4300
4301// TODO -- be clear on how this is defined. Units?
4302Function V_writeDet_tubeWidth(fname,detStr,val)
4303        String fname,detStr
4304        Variable val
4305
4306//      String path = "entry:instrument:detector_"+detStr+":tube_width"
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_width"
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
4329End
4330
4331//////////////////////
4332
4333// INSTRUMENT/LENSES    /APERTURES
4334//  lenses (data folder)
4335
4336Function V_writeLensCurvature(fname,val)
4337        String fname
4338        Variable val
4339
4340//      String path = "entry:instrument:lenses:curvature"
4341       
4342        Make/O/D/N=1 wTmpWrite
4343//      Make/O/R/N=1 wTmpWrite
4344        String groupName = "/entry/instrument/lenses"
4345        String varName = "curvature"
4346        wTmpWrite[0] = val
4347
4348        variable err
4349        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4350        if(err)
4351                Print "HDF write err = ",err
4352        endif
4353        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4354//      err = V_KillNamedDataFolder(fname)
4355//      if(err)
4356//              Print "DataFolder kill err = ",err
4357//      endif
4358        return(err)
4359End
4360
4361Function V_writeLensesFocusType(fname,str)
4362        String fname,str
4363
4364//      String path = "entry:instrument:lenses:focus_type"
4365
4366        Make/O/T/N=1 tmpTW
4367        String groupName = "/entry/instrument/lenses"
4368        String varName = "focus_type"
4369        tmpTW[0] = str //
4370
4371        variable err
4372        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4373        if(err)
4374                Print "HDF write err = ",err
4375        endif
4376       
4377        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4378//      err = V_KillNamedDataFolder(fname)
4379//      if(err)
4380//              Print "DataFolder kill err = ",err
4381//      endif
4382               
4383        return(err)
4384End
4385
4386Function V_writeLensDistance(fname,val)
4387        String fname
4388        Variable val
4389
4390//      String path = "entry:instrument:lenses:lens_distance"
4391       
4392        Make/O/D/N=1 wTmpWrite
4393//      Make/O/R/N=1 wTmpWrite
4394        String groupName = "/entry/instrument/lenses"
4395        String varName = "lens_distance"
4396        wTmpWrite[0] = val
4397
4398        variable err
4399        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4400        if(err)
4401                Print "HDF write err = ",err
4402        endif
4403        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4404//      err = V_KillNamedDataFolder(fname)
4405//      if(err)
4406//              Print "DataFolder kill err = ",err
4407//      endif
4408        return(err)
4409End
4410
4411Function V_writeLensGeometry(fname,str)
4412        String fname,str
4413
4414//      String path = "entry:instrument:lenses:lens_geometry"
4415
4416        Make/O/T/N=1 tmpTW
4417        String groupName = "/entry/instrument/lenses"
4418        String varName = "lens_geometry"
4419        tmpTW[0] = str //
4420
4421        variable err
4422        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4423        if(err)
4424                Print "HDF write err = ",err
4425        endif
4426       
4427        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4428//      err = V_KillNamedDataFolder(fname)
4429//      if(err)
4430//              Print "DataFolder kill err = ",err
4431//      endif
4432               
4433        return(err)
4434End
4435
4436Function V_writeLensMaterial(fname,str)
4437        String fname,str
4438
4439//      String path = "entry:instrument:lenses:lens_material"
4440
4441        Make/O/T/N=1 tmpTW
4442        String groupName = "/entry/instrument/lenses"
4443        String varName = "lens_material"
4444        tmpTW[0] = str //
4445
4446        variable err
4447        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4448        if(err)
4449                Print "HDF write err = ",err
4450        endif
4451       
4452        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4453//      err = V_KillNamedDataFolder(fname)
4454//      if(err)
4455//              Print "DataFolder kill err = ",err
4456//      endif
4457               
4458        return(err)
4459End
4460
4461// integer value
4462Function V_writeNumber_of_Lenses(fname,val)
4463        String fname
4464        Variable val
4465
4466//      String path = "entry:instrument:lenses:number_of_lenses"
4467       
4468        Make/O/I/N=1 wTmpWrite
4469//      Make/O/R/N=1 wTmpWrite
4470        String groupName = "/entry/instrument/lenses"
4471        String varName = "number_of_lenses"
4472        wTmpWrite[0] = val
4473
4474        variable err
4475        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4476        if(err)
4477                Print "HDF write err = ",err
4478        endif
4479        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4480//      err = V_KillNamedDataFolder(fname)
4481//      if(err)
4482//              Print "DataFolder kill err = ",err
4483//      endif
4484        return(err)
4485End
4486
4487// integer value
4488Function V_writeNumber_of_prisms(fname,val)
4489        String fname
4490        Variable val
4491
4492//      String path = "entry:instrument:lenses:number_of_prisms"
4493       
4494        Make/O/I/N=1 wTmpWrite
4495//      Make/O/R/N=1 wTmpWrite
4496        String groupName = "/entry/instrument/lenses"
4497        String varName = "number_of_prisms"
4498        wTmpWrite[0] = val
4499
4500        variable err
4501        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4502        if(err)
4503                Print "HDF write err = ",err
4504        endif
4505        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4506//      err = V_KillNamedDataFolder(fname)
4507//      if(err)
4508//              Print "DataFolder kill err = ",err
4509//      endif
4510        return(err)
4511End
4512
4513Function V_writePrism_distance(fname,val)
4514        String fname
4515        Variable val
4516
4517//      String path = "entry:instrument:lenses:prism_distance"
4518       
4519        Make/O/D/N=1 wTmpWrite
4520//      Make/O/R/N=1 wTmpWrite
4521        String groupName = "/entry/instrument/lenses"
4522        String varName = "prism_distance"
4523        wTmpWrite[0] = val
4524
4525        variable err
4526        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4527        if(err)
4528                Print "HDF write err = ",err
4529        endif
4530        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4531//      err = V_KillNamedDataFolder(fname)
4532//      if(err)
4533//              Print "DataFolder kill err = ",err
4534//      endif
4535        return(err)
4536End
4537
4538Function V_writePrismMaterial(fname,str)
4539        String fname,str
4540
4541//      String path = "entry:instrument:lenses:prism_material"
4542
4543        Make/O/T/N=1 tmpTW
4544        String groupName = "/entry/instrument/lenses"
4545        String varName = "prism_material"
4546        tmpTW[0] = str //
4547
4548        variable err
4549        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4550        if(err)
4551                Print "HDF write err = ",err
4552        endif
4553       
4554        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4555//      err = V_KillNamedDataFolder(fname)
4556//      if(err)
4557//              Print "DataFolder kill err = ",err
4558//      endif
4559               
4560        return(err)
4561End
4562
4563// status of lens/prism = lens | prism | both | out
4564Function V_writeLensPrismStatus(fname,str)
4565        String fname,str
4566
4567//      String path = "entry:instrument:lenses:status"
4568
4569        Make/O/T/N=1 tmpTW
4570        String groupName = "/entry/instrument/lenses"
4571        String varName = "status"
4572        tmpTW[0] = str //
4573
4574        variable err
4575        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4576        if(err)
4577                Print "HDF write err = ",err
4578        endif
4579       
4580        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4581//      err = V_KillNamedDataFolder(fname)
4582//      if(err)
4583//              Print "DataFolder kill err = ",err
4584//      endif
4585               
4586        return(err)
4587End
4588       
4589
4590///////  sample_aperture (data folder)
4591
4592Function V_writeSampleAp_Description(fname,str)
4593        String fname,str
4594
4595//      String path = "entry:instrument:sample_aperture:description"
4596
4597        Make/O/T/N=1 tmpTW
4598        String groupName = "/entry/instrument/sample_aperture"
4599        String varName = "description"
4600        tmpTW[0] = str //
4601
4602        variable err
4603        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4604        if(err)
4605                Print "HDF write err = ",err
4606        endif
4607       
4608        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4609//      err = V_KillNamedDataFolder(fname)
4610//      if(err)
4611//              Print "DataFolder kill err = ",err
4612//      endif
4613               
4614        return(err)
4615End
4616
4617Function V_writeSampleAp_distance(fname,val)
4618        String fname
4619        Variable val
4620
4621//      String path = "entry:instrument:sample_aperture:distance"
4622       
4623        Make/O/D/N=1 wTmpWrite
4624//      Make/O/R/N=1 wTmpWrite
4625        String groupName = "/entry/instrument/sample_aperture"
4626        String varName = "distance"
4627        wTmpWrite[0] = val
4628
4629        variable err
4630        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4631        if(err)
4632                Print "HDF write err = ",err
4633        endif
4634        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4635//      err = V_KillNamedDataFolder(fname)
4636//      if(err)
4637//              Print "DataFolder kill err = ",err
4638//      endif
4639        return(err)
4640End
4641
4642//      shape (data folder)
4643
4644Function V_writeSampleAp_shape(fname,str)
4645        String fname,str
4646
4647//      String path = "entry:instrument:sample_aperture:shape:shape"
4648
4649        Make/O/T/N=1 tmpTW
4650        String groupName = "/entry/instrument/sample_aperture/shape"
4651        String varName = "shape"
4652        tmpTW[0] = str //
4653
4654        variable err
4655        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4656        if(err)
4657                Print "HDF write err = ",err
4658        endif
4659       
4660        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4661//      err = V_KillNamedDataFolder(fname)
4662//      if(err)
4663//              Print "DataFolder kill err = ",err
4664//      endif
4665               
4666        return(err)
4667End
4668
4669Function V_writeSampleAp_height(fname,val)
4670        String fname
4671        Variable val
4672
4673//      String path = "entry:instrument:sample_aperture:distance"
4674       
4675        Make/O/D/N=1 wTmpWrite
4676//      Make/O/R/N=1 wTmpWrite
4677        String groupName = "/entry/instrument/sample_aperture/shape"
4678        String varName = "height"
4679        wTmpWrite[0] = val
4680
4681        variable err
4682        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4683        if(err)
4684                Print "HDF write err = ",err
4685        endif
4686        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4687//      err = V_KillNamedDataFolder(fname)
4688//      if(err)
4689//              Print "DataFolder kill err = ",err
4690//      endif
4691        return(err)
4692End
4693
4694Function V_writeSampleAp_size(fname,str)
4695        String fname,str
4696
4697//      String path = "entry:instrument:sample_aperture:shape:shape"
4698
4699        Make/O/T/N=1 tmpTW
4700        String groupName = "/entry/instrument/sample_aperture/shape"
4701        String varName = "size"
4702        tmpTW[0] = str //
4703
4704        variable err
4705        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4706        if(err)
4707                Print "HDF write err = ",err
4708        endif
4709       
4710        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4711//      err = V_KillNamedDataFolder(fname)
4712//      if(err)
4713//              Print "DataFolder kill err = ",err
4714//      endif
4715               
4716        return(err)
4717End
4718
4719Function V_writeSampleAp_width(fname,val)
4720        String fname
4721        Variable val
4722
4723//      String path = "entry:instrument:sample_aperture:distance"
4724       
4725        Make/O/D/N=1 wTmpWrite
4726//      Make/O/R/N=1 wTmpWrite
4727        String groupName = "/entry/instrument/sample_aperture/shape"
4728        String varName = "width"
4729        wTmpWrite[0] = val
4730
4731        variable err
4732        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4733        if(err)
4734                Print "HDF write err = ",err
4735        endif
4736        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4737//      err = V_KillNamedDataFolder(fname)
4738//      if(err)
4739//              Print "DataFolder kill err = ",err
4740//      endif
4741        return(err)
4742End
4743
4744///////  sample_aperture_2 (data folder)
4745
4746Function V_writeSampleAp2_Description(fname,str)
4747        String fname,str
4748
4749//      String path = "entry:instrument:sample_aperture_2:description"
4750
4751        Make/O/T/N=1 tmpTW
4752        String groupName = "/entry/instrument/sample_aperture_2"
4753        String varName = "description"
4754        tmpTW[0] = str //
4755
4756        variable err
4757        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4758        if(err)
4759                Print "HDF write err = ",err
4760        endif
4761       
4762        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4763//      err = V_KillNamedDataFolder(fname)
4764//      if(err)
4765//              Print "DataFolder kill err = ",err
4766//      endif
4767               
4768        return(err)
4769End
4770
4771Function V_writeSampleAp2_distance(fname,val)
4772        String fname
4773        Variable val
4774
4775//      String path = "entry:instrument:sample_aperture_2:distance"
4776       
4777        Make/O/D/N=1 wTmpWrite
4778//      Make/O/R/N=1 wTmpWrite
4779        String groupName = "/entry/instrument/sample_aperture_2"
4780        String varName = "distance"
4781        wTmpWrite[0] = val
4782
4783        variable err
4784        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4785        if(err)
4786                Print "HDF write err = ",err
4787        endif
4788        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4789//      err = V_KillNamedDataFolder(fname)
4790//      if(err)
4791//              Print "DataFolder kill err = ",err
4792//      endif
4793        return(err)
4794End
4795
4796
4797//      shape (data folder)
4798
4799Function V_writeSampleAp2_shape(fname,str)
4800        String fname,str
4801
4802//      String path = "entry:instrument:sample_aperture_2:shape:shape"
4803
4804        Make/O/T/N=1 tmpTW
4805        String groupName = "/entry/instrument/sample_aperture_2/shape"
4806        String varName = "shape"
4807        tmpTW[0] = str //
4808
4809        variable err
4810        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4811        if(err)
4812                Print "HDF write err = ",err
4813        endif
4814       
4815        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4816//      err = V_KillNamedDataFolder(fname)
4817//      if(err)
4818//              Print "DataFolder kill err = ",err
4819//      endif
4820               
4821        return(err)
4822End
4823
4824Function V_writeSampleAp2_height(fname,val)
4825        String fname
4826        Variable val
4827
4828//      String path = "entry:instrument:sample_aperture:distance"
4829       
4830        Make/O/D/N=1 wTmpWrite
4831//      Make/O/R/N=1 wTmpWrite
4832        String groupName = "/entry/instrument/sample_aperture_2/shape"
4833        String varName = "height"
4834        wTmpWrite[0] = val
4835
4836        variable err
4837        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4838        if(err)
4839                Print "HDF write err = ",err
4840        endif
4841        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4842//      err = V_KillNamedDataFolder(fname)
4843//      if(err)
4844//              Print "DataFolder kill err = ",err
4845//      endif
4846        return(err)
4847End
4848
4849Function V_writeSampleAp2_size(fname,val)
4850        String fname
4851        Variable val
4852
4853//      String path = "entry:instrument:sample_aperture:distance"
4854       
4855        Make/O/D/N=1 wTmpWrite
4856//      Make/O/R/N=1 wTmpWrite
4857        String groupName = "/entry/instrument/sample_aperture_2/shape"
4858        String varName = "size"
4859        wTmpWrite[0] = val
4860
4861        variable err
4862        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4863        if(err)
4864                Print "HDF write err = ",err
4865        endif
4866        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4867//      err = V_KillNamedDataFolder(fname)
4868//      if(err)
4869//              Print "DataFolder kill err = ",err
4870//      endif
4871        return(err)
4872End
4873
4874Function V_writeSampleAp2_width(fname,val)
4875        String fname
4876        Variable val
4877
4878//      String path = "entry:instrument:sample_aperture:distance"
4879       
4880        Make/O/D/N=1 wTmpWrite
4881//      Make/O/R/N=1 wTmpWrite
4882        String groupName = "/entry/instrument/sample_aperture_2/shape"
4883        String varName = "width"
4884        wTmpWrite[0] = val
4885
4886        variable err
4887        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4888        if(err)
4889                Print "HDF write err = ",err
4890        endif
4891        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4892//      err = V_KillNamedDataFolder(fname)
4893//      if(err)
4894//              Print "DataFolder kill err = ",err
4895//      endif
4896        return(err)
4897End
4898
4899               
4900//////  sample_table (data folder)
4901// location  = "CHAMBER" or HUBER
4902Function V_writeSampleTableLocation(fname,str)
4903        String fname,str
4904
4905//      String path = "entry:instrument:sample_table:location"
4906
4907        Make/O/T/N=1 tmpTW
4908        String groupName = "/entry/instrument/sample_table"
4909        String varName = "location"
4910        tmpTW[0] = str //
4911
4912        variable err
4913        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4914        if(err)
4915                Print "HDF write err = ",err
4916        endif
4917       
4918        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4919//      err = V_KillNamedDataFolder(fname)
4920//      if(err)
4921//              Print "DataFolder kill err = ",err
4922//      endif
4923               
4924        return(err)
4925End
4926
4927// TODO - verify the meaning
4928//      offset_distance (?? for center of sample table vs. sample position)
4929Function V_writeSampleTableOffset(fname,val)
4930        String fname
4931        Variable val
4932
4933//      String path = "entry:instrument:sample_table:offset_distance"
4934       
4935        Make/O/D/N=1 wTmpWrite
4936//      Make/O/R/N=1 wTmpWrite
4937        String groupName = "/entry/instrument/sample_table"
4938        String varName = "offset_distance"
4939        wTmpWrite[0] = val
4940
4941        variable err
4942        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4943        if(err)
4944                Print "HDF write err = ",err
4945        endif
4946        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4947//      err = V_KillNamedDataFolder(fname)
4948//      if(err)
4949//              Print "DataFolder kill err = ",err
4950//      endif
4951        return(err)
4952End     
4953       
4954//  source (data folder)
4955//name "NCNR"
4956Function V_writeSourceName(fname,str)
4957        String fname,str
4958
4959//      String path = "entry:instrument:source:name"
4960
4961        Make/O/T/N=1 tmpTW
4962        String groupName = "/entry/instrument/source"
4963        String varName = "name"
4964        tmpTW[0] = str //
4965
4966        variable err
4967        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4968        if(err)
4969                Print "HDF write err = ",err
4970        endif
4971       
4972        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4973//      err = V_KillNamedDataFolder(fname)
4974//      if(err)
4975//              Print "DataFolder kill err = ",err
4976//      endif
4977               
4978        return(err)
4979End
4980
4981//      power -- nominal only, not connected to any real number
4982Function V_writeReactorPower(fname,val)
4983        String fname
4984        Variable val
4985
4986//      String path = "entry:instrument:source:power"
4987       
4988        Make/O/D/N=1 wTmpWrite
4989//      Make/O/R/N=1 wTmpWrite
4990        String groupName = "/entry/instrument/source"
4991        String varName = "power"
4992        wTmpWrite[0] = val
4993
4994        variable err
4995        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4996        if(err)
4997                Print "HDF write err = ",err
4998        endif
4999        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5000//      err = V_KillNamedDataFolder(fname)
5001//      if(err)
5002//              Print "DataFolder kill err = ",err
5003//      endif
5004        return(err)
5005End     
5006
5007//probe (wave) "neutron"
5008Function V_writeSourceProbe(fname,str)
5009        String fname,str
5010
5011//      String path = "entry:instrument:source:probe"
5012
5013        Make/O/T/N=1 tmpTW
5014        String groupName = "/entry/instrument/source"
5015        String varName = "probe"
5016        tmpTW[0] = str //
5017
5018        variable err
5019        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5020        if(err)
5021                Print "HDF write err = ",err
5022        endif
5023       
5024        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5025//      err = V_KillNamedDataFolder(fname)
5026//      if(err)
5027//              Print "DataFolder kill err = ",err
5028//      endif
5029               
5030        return(err)
5031End
5032
5033//type (wave) "Reactor Neutron Source"
5034Function V_writeSourceType(fname,str)
5035        String fname,str
5036
5037//      String path = "entry:instrument:source:type"
5038
5039        Make/O/T/N=1 tmpTW
5040        String groupName = "/entry/instrument/source"
5041        String varName = "type"
5042        tmpTW[0] = str //
5043
5044        variable err
5045        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5046        if(err)
5047                Print "HDF write err = ",err
5048        endif
5049       
5050        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5051//      err = V_KillNamedDataFolder(fname)
5052//      if(err)
5053//              Print "DataFolder kill err = ",err
5054//      endif
5055               
5056        return(err)
5057End
5058
5059       
5060///////  source_aperture (data folder)
5061
5062Function V_writeSourceAp_Description(fname,str)
5063        String fname,str
5064
5065//      String path = "entry:instrument:source_aperture:description"
5066
5067        Make/O/T/N=1 tmpTW
5068        String groupName = "/entry/instrument/source_aperture"
5069        String varName = "description"
5070        tmpTW[0] = str //
5071
5072        variable err
5073        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5074        if(err)
5075                Print "HDF write err = ",err
5076        endif
5077       
5078        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5079//      err = V_KillNamedDataFolder(fname)
5080//      if(err)
5081//              Print "DataFolder kill err = ",err
5082//      endif
5083               
5084        return(err)
5085End
5086
5087Function V_writeSourceAp_distance(fname,val)
5088        String fname
5089        Variable val
5090
5091//      String path = "entry:instrument:source_aperture:distance"
5092       
5093        Make/O/D/N=1 wTmpWrite
5094//      Make/O/R/N=1 wTmpWrite
5095        String groupName = "/entry/instrument/source_aperture"
5096        String varName = "distance"
5097        wTmpWrite[0] = val
5098
5099        variable err
5100        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5101        if(err)
5102                Print "HDF write err = ",err
5103        endif
5104        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5105//      err = V_KillNamedDataFolder(fname)
5106//      if(err)
5107//              Print "DataFolder kill err = ",err
5108//      endif
5109        return(err)
5110End
5111//      shape (data folder)
5112
5113Function V_writeSourceAp_shape(fname,str)
5114        String fname,str
5115
5116//      String path = "entry:instrument:source_aperture:shape:shape"
5117
5118        Make/O/T/N=1 tmpTW
5119        String groupName = "/entry/instrument/source_aperture/shape"
5120        String varName = "shape"
5121        tmpTW[0] = str //
5122
5123        variable err
5124        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5125        if(err)
5126                Print "HDF write err = ",err
5127        endif
5128       
5129        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5130//      err = V_KillNamedDataFolder(fname)
5131//      if(err)
5132//              Print "DataFolder kill err = ",err
5133//      endif
5134               
5135        return(err)
5136End
5137
5138Function V_writeSourceAp_size(fname,str)
5139        String fname,str
5140
5141//      String path = "entry:instrument:source_aperture:shape:shape"
5142
5143        Make/O/T/N=1 tmpTW
5144        String groupName = "/entry/instrument/source_aperture/shape"
5145        String varName = "size"
5146        tmpTW[0] = str //
5147
5148        variable err
5149        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5150        if(err)
5151                Print "HDF write err = ",err
5152        endif
5153       
5154        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5155//      err = V_KillNamedDataFolder(fname)
5156//      if(err)
5157//              Print "DataFolder kill err = ",err
5158//      endif
5159               
5160        return(err)
5161End
5162
5163Function V_writeSourceAp_height(fname,val)
5164        String fname
5165        Variable val
5166
5167//      String path = "entry:instrument:sample_aperture:distance"
5168       
5169        Make/O/D/N=1 wTmpWrite
5170//      Make/O/R/N=1 wTmpWrite
5171        String groupName = "/entry/instrument/source_aperture/shape"
5172        String varName = "height"
5173        wTmpWrite[0] = val
5174
5175        variable err
5176        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5177        if(err)
5178                Print "HDF write err = ",err
5179        endif
5180        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5181//      err = V_KillNamedDataFolder(fname)
5182//      if(err)
5183//              Print "DataFolder kill err = ",err
5184//      endif
5185        return(err)
5186End
5187
5188Function V_writeSourceAp_width(fname,val)
5189        String fname
5190        Variable val
5191
5192//      String path = "entry:instrument:sample_aperture:distance"
5193       
5194        Make/O/D/N=1 wTmpWrite
5195//      Make/O/R/N=1 wTmpWrite
5196        String groupName = "/entry/instrument/source_aperture/shape"
5197        String varName = "width"
5198        wTmpWrite[0] = val
5199
5200        variable err
5201        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5202        if(err)
5203                Print "HDF write err = ",err
5204        endif
5205        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5206//      err = V_KillNamedDataFolder(fname)
5207//      if(err)
5208//              Print "DataFolder kill err = ",err
5209//      endif
5210        return(err)
5211End
5212
5213
5214//////// SAMPLE
5215//////// SAMPLE
5216//////// SAMPLE
5217
5218//Sample position in changer
5219Function V_writeSamplePosition(fname,str)
5220        String fname,str
5221
5222//      String path = "entry:sample:changer_position"   
5223
5224        Make/O/T/N=1 tmpTW
5225        String groupName = "/entry/sample"
5226        String varName = "changer_position"
5227        tmpTW[0] = str //
5228
5229        variable err
5230        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5231        if(err)
5232                Print "HDF write err = ",err
5233        endif
5234       
5235        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5236//      err = V_KillNamedDataFolder(fname)
5237//      if(err)
5238//              Print "DataFolder kill err = ",err
5239//      endif
5240               
5241        return(err)
5242End
5243
5244
5245// sample label
5246// TODO: value of num is currently not used
5247Function V_writeSampleDescription(fname,str)
5248        String fname,str
5249
5250//      String path = "entry:sample:description"
5251
5252        Make/O/T/N=1 tmpTW
5253        String groupName = "/entry/sample"
5254        String varName = "description"
5255        tmpTW[0] = str //
5256
5257        variable err
5258        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5259        if(err)
5260                Print "HDF write err = ",err
5261        endif
5262       
5263        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5264//      err = V_KillNamedDataFolder(fname)
5265//      if(err)
5266//              Print "DataFolder kill err = ",err
5267//      endif
5268               
5269        return(err)
5270End
5271
5272// for a z-stage??
5273Function V_writeSample_elevation(fname,val)
5274        String fname
5275        Variable val
5276       
5277//      String path = "entry:sample:elevation" 
5278       
5279        Make/O/D/N=1 wTmpWrite
5280//      Make/O/R/N=1 wTmpWrite
5281        String groupName = "/entry/sample"
5282        String varName = "elevation"
5283        wTmpWrite[0] = val
5284
5285        variable err
5286        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5287        if(err)
5288                Print "HDF write err = ",err
5289        endif
5290        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5291//      err = V_KillNamedDataFolder(fname)
5292//      if(err)
5293//              Print "DataFolder kill err = ",err
5294//      endif
5295        return(err)
5296end
5297
5298//no meaning to this...
5299Function V_writeSample_equatorial_ang(fname,val)
5300        String fname
5301        Variable val
5302       
5303//      String path = "entry:sample:equatorial_angle"   
5304       
5305        Make/O/D/N=1 wTmpWrite
5306//      Make/O/R/N=1 wTmpWrite
5307        String groupName = "/entry/sample"
5308        String varName = "equatorial_angle"
5309        wTmpWrite[0] = val
5310
5311        variable err
5312        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5313        if(err)
5314                Print "HDF write err = ",err
5315        endif
5316        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5317//      err = V_KillNamedDataFolder(fname)
5318//      if(err)
5319//              Print "DataFolder kill err = ",err
5320//      endif
5321        return(err)
5322end
5323
5324// TODO -- do  I need to make sure that this is an integer?
5325// group ID !!! very important for matching up files
5326// integer value
5327Function V_writeSample_GroupID(fname,val)
5328        String fname
5329        Variable val
5330       
5331//      String path = "entry:sample:group_id"   
5332       
5333        Make/O/I/N=1 wTmpWrite
5334//      Make/O/R/N=1 wTmpWrite
5335        String groupName = "/entry/sample"
5336        String varName = "group_id"
5337        wTmpWrite[0] = val
5338
5339        variable err
5340        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5341        if(err)
5342                Print "HDF write err = ",err
5343        endif
5344        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5345//      err = V_KillNamedDataFolder(fname)
5346//      if(err)
5347//              Print "DataFolder kill err = ",err
5348//      endif
5349        return(err)
5350end
5351
5352
5353//Sample Rotation Angle
5354Function V_writeSampleRotationAngle(fname,val)
5355        String fname
5356        Variable val
5357       
5358//      String path = "entry:sample:rotation_angle"     
5359       
5360        Make/O/D/N=1 wTmpWrite
5361//      Make/O/R/N=1 wTmpWrite
5362        String groupName = "/entry/sample"
5363        String varName = "rotation_angle"
5364        wTmpWrite[0] = val
5365
5366        variable err
5367        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5368        if(err)
5369                Print "HDF write err = ",err
5370        endif
5371        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5372//      err = V_KillNamedDataFolder(fname)
5373//      if(err)
5374//              Print "DataFolder kill err = ",err
5375//      endif
5376        return(err)
5377end
5378
5379//?? this is huber/chamber??
5380// TODO -- then where is the description of 10CB, etc...
5381Function V_writeSampleHolderDescription(fname,str)
5382        String fname,str
5383
5384//      String path = "entry:sample:sample_holder_description"
5385
5386        Make/O/T/N=1 tmpTW
5387        String groupName = "/entry/sample"
5388        String varName = "sample_holder_description"
5389        tmpTW[0] = str //
5390
5391        variable err
5392        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5393        if(err)
5394                Print "HDF write err = ",err
5395        endif
5396       
5397        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5398//      err = V_KillNamedDataFolder(fname)
5399//      if(err)
5400//              Print "DataFolder kill err = ",err
5401//      endif
5402               
5403        return(err)
5404End
5405
5406//Sample Thickness
5407// TODO -- somehow, this is not set correctly in the acquisition, so NaN results
5408Function V_writeSampleThickness(fname,val)
5409        String fname
5410        Variable val
5411       
5412//      String path = "entry:sample:thickness" 
5413       
5414        Make/O/D/N=1 wTmpWrite
5415//      Make/O/R/N=1 wTmpWrite
5416        String groupName = "/entry/sample"
5417        String varName = "thickness"
5418        wTmpWrite[0] = val
5419
5420        variable err
5421        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5422        if(err)
5423                Print "HDF write err = ",err
5424        endif
5425        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5426//      err = V_KillNamedDataFolder(fname)
5427//      if(err)
5428//              Print "DataFolder kill err = ",err
5429//      endif
5430        return(err)
5431end
5432
5433//Sample Translation
5434Function V_writeSampleTranslation(fname,val)
5435        String fname
5436        Variable val
5437       
5438//      String path = "entry:sample:translation"       
5439       
5440        Make/O/D/N=1 wTmpWrite
5441//      Make/O/R/N=1 wTmpWrite
5442        String groupName = "/entry/sample"
5443        String varName = "translation"
5444        wTmpWrite[0] = val
5445
5446        variable err
5447        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5448        if(err)
5449                Print "HDF write err = ",err
5450        endif
5451        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5452//      err = V_KillNamedDataFolder(fname)
5453//      if(err)
5454//              Print "DataFolder kill err = ",err
5455//      endif
5456        return(err)
5457end
5458
5459// sample transmission
5460Function V_writeSampleTransmission(fname,val)
5461        String fname
5462        Variable val
5463       
5464        String path = "entry:sample:transmission"       
5465//      String path = "QKK0037737:data:Transmission"   
5466       
5467        Make/O/D/N=1 wTmpWrite
5468//      Make/O/R/N=1 wTmpWrite
5469        String groupName = "/entry/sample"
5470        String varName = "transmission"
5471        wTmpWrite[0] = val
5472
5473        variable err
5474        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5475        if(err)
5476                Print "HDF write err = ",err
5477        endif
5478        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5479//      err = V_KillNamedDataFolder(fname)
5480//      if(err)
5481//              Print "DataFolder kill err = ",err
5482//      endif
5483        return(err)
5484end
5485
5486//transmission error (one sigma)
5487Function V_writeSampleTransError(fname,val)
5488        String fname
5489        Variable val
5490       
5491//      String path = "entry:sample:transmission_error"
5492       
5493        Make/O/D/N=1 wTmpWrite
5494//      Make/O/R/N=1 wTmpWrite
5495        String groupName = "/entry/sample"
5496        String varName = "transmission_error"
5497        wTmpWrite[0] = val
5498
5499        variable err
5500        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5501        if(err)
5502                Print "HDF write err = ",err
5503        endif
5504        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5505//      err = V_KillNamedDataFolder(fname)
5506//      if(err)
5507//              Print "DataFolder kill err = ",err
5508//      endif
5509        return(err)
5510end
5511
5512
5513
5514//// SAMPLE / DATA LOGS
5515// write this generic , call with the name of the environment log desired
5516//
5517// temperature_1
5518// temperature_2
5519// shear_field
5520// pressure
5521// magnetic_field
5522// electric_field
5523//
5524//////// (for example) electric_field (data folder)
5525
5526Function V_writeLog_attachedTo(fname,logStr,str)
5527        String fname,logStr,str
5528
5529//      String path = "entry:sample:"+logstr+":attached_to"
5530
5531        Make/O/T/N=1 tmpTW
5532        String groupName = "/entry/sample/"+logStr
5533        String varName = "attached_to"
5534        tmpTW[0] = str //
5535
5536        variable err
5537        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5538        if(err)
5539                Print "HDF write err = ",err
5540        endif
5541       
5542        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5543//      err = V_KillNamedDataFolder(fname)
5544//      if(err)
5545//              Print "DataFolder kill err = ",err
5546//      endif
5547               
5548        return(err)
5549End
5550
5551
5552Function V_writeLog_measurement(fname,logStr,str)
5553        String fname,logStr,str
5554
5555        String path = "entry:sample:"+logstr+":measurement"
5556
5557        Make/O/T/N=1 tmpTW
5558        String groupName = "/entry/sample/"+logStr
5559        String varName = "measurement"
5560        tmpTW[0] = str //
5561
5562        variable err
5563        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5564        if(err)
5565                Print "HDF write err = ",err
5566        endif
5567       
5568        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5569//      err = V_KillNamedDataFolder(fname)
5570//      if(err)
5571//              Print "DataFolder kill err = ",err
5572//      endif
5573               
5574        return(err)
5575End
5576
5577
5578Function V_writeLog_Name(fname,logStr,str)
5579        String fname,logStr,str
5580
5581//      String path = "entry:sample:"+logstr+":name"
5582
5583        Make/O/T/N=1 tmpTW
5584        String groupName = "/entry/sample/"+logStr
5585        String varName = "name"
5586        tmpTW[0] = str //
5587
5588        variable err
5589        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5590        if(err)
5591                Print "HDF write err = ",err
5592        endif
5593       
5594        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5595//      err = V_KillNamedDataFolder(fname)
5596//      if(err)
5597//              Print "DataFolder kill err = ",err
5598//      endif
5599               
5600        return(err)
5601End
5602
5603
5604// TODO --
5605Function V_writeLog_nomValue(fname,logStr,val)
5606        String fname,logStr
5607        Variable val
5608       
5609//      String path = "entry:sample:"+logstr+":value"
5610       
5611        Make/O/D/N=1 wTmpWrite
5612//      Make/O/R/N=1 wTmpWrite
5613        String groupName = "/entry/sample/"+logStr
5614        String varName = "value"
5615        wTmpWrite[0] = val
5616
5617        variable err
5618        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5619        if(err)
5620                Print "HDF write err = ",err
5621        endif
5622        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5623//      err = V_KillNamedDataFolder(fname)
5624//      if(err)
5625//              Print "DataFolder kill err = ",err
5626//      endif
5627        return(err)
5628end
5629
5630////            value_log (data folder)
5631Function V_writeLog_startTime(fname,logStr,str)
5632        String fname,logStr,str
5633
5634//      String path = "entry:sample:"+logstr+":value_log:start"
5635
5636        Make/O/T/N=1 tmpTW
5637        String groupName = "/entry/sample/"+logStr+"/value_log"
5638        String varName = "start"
5639        tmpTW[0] = str //
5640
5641        variable err
5642        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5643        if(err)
5644                Print "HDF write err = ",err
5645        endif
5646       
5647        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5648//      err = V_KillNamedDataFolder(fname)
5649//      if(err)
5650//              Print "DataFolder kill err = ",err
5651//      endif
5652               
5653        return(err)
5654End
5655
5656// TODO --
5657Function V_writeLog_avgValue(fname,logStr,val)
5658        String fname,logStr
5659        Variable val
5660       
5661//      String path = "entry:sample:"+logstr+":value_log:average_value"
5662       
5663        Make/O/D/N=1 wTmpWrite
5664//      Make/O/R/N=1 wTmpWrite
5665        String groupName = "/entry/sample/"+logStr+"/value_log"
5666        String varName = "average_value"
5667        wTmpWrite[0] = val
5668
5669        variable err
5670        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5671        if(err)
5672                Print "HDF write err = ",err
5673        endif
5674        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5675//      err = V_KillNamedDataFolder(fname)
5676//      if(err)
5677//              Print "DataFolder kill err = ",err
5678//      endif
5679        return(err)
5680end
5681
5682// TODO -- this needs to be a WAVE reference
5683Function V_writeLog_time(fname,logStr,inW)
5684        String fname,logStr
5685        Wave inW
5686       
5687//      String path = "entry:sample:"+logstr+":value_log:time"
5688
5689        Duplicate/O inW wTmpWrite       
5690// then use redimension as needed to cast the wave to write to the specified type
5691// see WaveType for the proper codes
5692//      Redimension/T=() wTmpWrite
5693// -- May also need to check the dimension(s) before writing (don't trust the input)
5694        String groupName = "/entry/sample/"+logStr+"/value_log"
5695        String varName = "time"
5696
5697        variable err
5698        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5699        if(err)
5700                Print "HDF write err = ",err
5701        endif
5702        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5703//      err = V_KillNamedDataFolder(fname)
5704//      if(err)
5705//              Print "DataFolder kill err = ",err
5706//      endif
5707        return(err)
5708end
5709
5710
5711// TODO -- this needs to be a WAVE reference
5712Function V_writeLog_Value(fname,logStr,inW)
5713        String fname,logStr
5714        Wave inW
5715       
5716//      String path = "entry:sample:"+logstr+":value_log:value"
5717
5718        Duplicate/O inW wTmpWrite       
5719// then use redimension as needed to cast the wave to write to the specified type
5720// see WaveType for the proper codes
5721//      Redimension/T=() wTmpWrite
5722// -- May also need to check the dimension(s) before writing (don't trust the input)
5723        String groupName = "/entry/sample/"+logStr+"/value_log"
5724        String varName = "value"
5725
5726        variable err
5727        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5728        if(err)
5729                Print "HDF write err = ",err
5730        endif
5731        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5732//      err = V_KillNamedDataFolder(fname)
5733//      if(err)
5734//              Print "DataFolder kill err = ",err
5735//      endif
5736        return(err)
5737end
5738
5739
5740
5741///////// REDUCTION
5742///////// REDUCTION
5743///////// REDUCTION
5744
5745
5746// TODO -- needs to be a WAVE, and of the proper size and type!!!
5747Function V_writeAbsolute_Scaling(fname,inW)
5748        String fname
5749        Wave inW
5750       
5751//      String path = "entry:reduction:absolute_scaling"
5752       
5753        Duplicate/O inW wTmpWrite       
5754// then use redimension as needed to cast the wave to write to the specified type
5755// see WaveType for the proper codes
5756//      Redimension/T=() wTmpWrite
5757// -- May also need to check the dimension(s) before writing (don't trust the input)
5758        String groupName = "/entry/reduction"   
5759        String varName = "absolute_scaling"
5760
5761        variable err
5762        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5763        if(err)
5764                Print "HDF write err = ",err
5765        endif
5766        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5767//      err = V_KillNamedDataFolder(fname)
5768//      if(err)
5769//              Print "DataFolder kill err = ",err
5770//      endif
5771        return(err)
5772end
5773
5774// TODO -- needs to be a WAVE
5775Function V_writeBoxCoordinates(fname,inW)
5776        String fname
5777        Wave inW
5778       
5779//      String path = "entry:reduction:box_coordinates"
5780               
5781        Duplicate/O inW wTmpWrite       
5782// then use redimension as needed to cast the wave to write to the specified type
5783// see WaveType for the proper codes
5784//      Redimension/T=() wTmpWrite
5785// -- May also need to check the dimension(s) before writing (don't trust the input)
5786        String groupName = "/entry/reduction"   
5787        String varName = "box_coordinates"
5788
5789        variable err
5790        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5791        if(err)
5792                Print "HDF write err = ",err
5793        endif
5794        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5795//      err = V_KillNamedDataFolder(fname)
5796//      if(err)
5797//              Print "DataFolder kill err = ",err
5798//      endif
5799        return(err)
5800end
5801
5802//box counts
5803Function V_writeBoxCounts(fname,val)
5804        String fname
5805        Variable val
5806       
5807//      String path = "entry:reduction:box_count"       
5808       
5809        Make/O/D/N=1 wTmpWrite
5810//      Make/O/R/N=1 wTmpWrite
5811        String groupName = "/entry/reduction"
5812        String varName = "box_count"
5813        wTmpWrite[0] = val
5814
5815        variable err
5816        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5817        if(err)
5818                Print "HDF write err = ",err
5819        endif
5820        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5821//      err = V_KillNamedDataFolder(fname)
5822//      if(err)
5823//              Print "DataFolder kill err = ",err
5824//      endif
5825        return(err)
5826end
5827
5828//box counts error
5829Function V_writeBoxCountsError(fname,val)
5830        String fname
5831        Variable val
5832       
5833//      String path = "entry:reduction:box_count_error"
5834       
5835        Make/O/D/N=1 wTmpWrite
5836//      Make/O/R/N=1 wTmpWrite
5837        String groupName = "/entry/reduction"
5838        String varName = "box_count_error"
5839        wTmpWrite[0] = val
5840
5841        variable err
5842        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5843        if(err)
5844                Print "HDF write err = ",err
5845        endif
5846        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5847//      err = V_KillNamedDataFolder(fname)
5848//      if(err)
5849//              Print "DataFolder kill err = ",err
5850//      endif
5851        return(err)
5852end
5853
5854Function V_writeReductionComments(fname,str)
5855        String fname,str
5856
5857//      String path = "entry:reduction:comments"       
5858
5859        Make/O/T/N=1 tmpTW
5860        String groupName = "/entry/reduction"
5861        String varName = "comments"
5862        tmpTW[0] = str //
5863
5864        variable err
5865        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5866        if(err)
5867                Print "HDF write err = ",err
5868        endif
5869       
5870        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5871//      err = V_KillNamedDataFolder(fname)
5872//      if(err)
5873//              Print "DataFolder kill err = ",err
5874//      endif
5875               
5876        return(err)
5877End
5878
5879
5880Function V_writeReductionIntent(fname,str)
5881        String fname,str
5882
5883//      String path = "entry:reduction:intent" 
5884
5885        Make/O/T/N=1 tmpTW
5886        String groupName = "/entry/reduction"
5887        String varName = "intent"
5888        tmpTW[0] = str //
5889
5890        variable err
5891        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5892        if(err)
5893                Print "HDF write err = ",err
5894        endif
5895       
5896        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5897//      err = V_KillNamedDataFolder(fname)
5898//      if(err)
5899//              Print "DataFolder kill err = ",err
5900//      endif
5901               
5902        return(err)
5903End
5904
5905
5906Function V_writeLogFileName(fname,str)
5907        String fname,str
5908
5909//      String path = "entry:reduction:sans_log_file_name"     
5910
5911        Make/O/T/N=1 tmpTW
5912        String groupName = "/entry/reduction"
5913        String varName = "sans_log_file_name"
5914        tmpTW[0] = str //
5915
5916        variable err
5917        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5918        if(err)
5919                Print "HDF write err = ",err
5920        endif
5921       
5922        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5923//      err = V_KillNamedDataFolder(fname)
5924//      if(err)
5925//              Print "DataFolder kill err = ",err
5926//      endif
5927               
5928        return(err)
5929End
5930
5931
5932Function V_writeSensitivityFileName(fname,str)
5933        String fname,str
5934
5935//      String path = "entry:reduction:sensitivity_file_name"   
5936
5937        Make/O/T/N=1 tmpTW
5938        String groupName = "/entry/reduction"
5939        String varName = "sensitivity_file_name"
5940        tmpTW[0] = str //
5941
5942        variable err
5943        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5944        if(err)
5945                Print "HDF write err = ",err
5946        endif
5947       
5948        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5949//      err = V_KillNamedDataFolder(fname)
5950//      if(err)
5951//              Print "DataFolder kill err = ",err
5952//      endif
5953               
5954        return(err)
5955End
5956
5957Function V_writeTransmissionFileName(fname,str)
5958        String fname,str
5959
5960//      String path = "entry:reduction:transmission_file_name" 
5961
5962        Make/O/T/N=1 tmpTW
5963        String groupName = "/entry/reduction"
5964        String varName = "transmission_file_name"
5965        tmpTW[0] = str //
5966
5967        variable err
5968        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5969        if(err)
5970                Print "HDF write err = ",err
5971        endif
5972       
5973        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5974//      err = V_KillNamedDataFolder(fname)
5975//      if(err)
5976//              Print "DataFolder kill err = ",err
5977//      endif
5978               
5979        return(err)
5980End
5981
5982Function V_writeEmptyBeamFileName(fname,str)
5983        String fname,str
5984
5985//      String path = "entry:reduction:empty_beam_file_name"   
5986
5987        Make/O/T/N=1 tmpTW
5988        String groupName = "/entry/reduction"
5989        String varName = "empty_beam_file_name"
5990        tmpTW[0] = str //
5991
5992        variable err
5993        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5994        if(err)
5995                Print "HDF write err = ",err
5996        endif
5997       
5998        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5999//      err = V_KillNamedDataFolder(fname)
6000//      if(err)
6001//              Print "DataFolder kill err = ",err
6002//      endif
6003               
6004        return(err)
6005End
6006
6007Function V_writeEmptyFileName(fname,str)
6008        String fname,str
6009
6010//      String path = "entry:reduction:empty_beam_file_name"   
6011
6012        Make/O/T/N=1 tmpTW
6013        String groupName = "/entry/reduction"
6014        String varName = "empty_file_name"
6015        tmpTW[0] = str //
6016
6017        variable err
6018        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6019        if(err)
6020                Print "HDF write err = ",err
6021        endif
6022       
6023        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6024//      err = V_KillNamedDataFolder(fname)
6025//      if(err)
6026//              Print "DataFolder kill err = ",err
6027//      endif
6028               
6029        return(err)
6030End
6031
6032Function V_writeMaskFileName(fname,str)
6033        String fname,str
6034
6035//      String path = "entry:reduction:empty_beam_file_name"   
6036
6037        Make/O/T/N=1 tmpTW
6038        String groupName = "/entry/reduction"
6039        String varName = "mask_file_name"
6040        tmpTW[0] = str //
6041
6042        variable err
6043        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6044        if(err)
6045                Print "HDF write err = ",err
6046        endif
6047       
6048        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6049//      err = V_KillNamedDataFolder(fname)
6050//      if(err)
6051//              Print "DataFolder kill err = ",err
6052//      endif
6053               
6054        return(err)
6055End
6056
6057Function V_writeBackgroundFileName(fname,str)
6058        String fname,str
6059
6060//      String path = "entry:reduction:empty_beam_file_name"   
6061
6062        Make/O/T/N=1 tmpTW
6063        String groupName = "/entry/reduction"
6064        String varName = "background_file_name"
6065        tmpTW[0] = str //
6066
6067        variable err
6068        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6069        if(err)
6070                Print "HDF write err = ",err
6071        endif
6072       
6073        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6074//      err = V_KillNamedDataFolder(fname)
6075//      if(err)
6076//              Print "DataFolder kill err = ",err
6077//      endif
6078               
6079        return(err)
6080End
6081
6082//whole detector transmission
6083Function V_writeSampleTransWholeDetector(fname,val)
6084        String fname
6085        Variable val
6086       
6087//      String path = "entry:reduction:whole_trans"     
6088       
6089        Make/O/D/N=1 wTmpWrite
6090//      Make/O/R/N=1 wTmpWrite
6091        String groupName = "/entry/reduction"
6092        String varName = "whole_trans"
6093        wTmpWrite[0] = val
6094
6095        variable err
6096        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6097        if(err)
6098                Print "HDF write err = ",err
6099        endif
6100        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6101//      err = V_KillNamedDataFolder(fname)
6102//      if(err)
6103//              Print "DataFolder kill err = ",err
6104//      endif
6105        return(err)
6106end
6107
6108//whole detector transmission error
6109Function V_writeSampleTransWholeDetErr(fname,val)
6110        String fname
6111        Variable val
6112       
6113//      String path = "entry:reduction:whole_trans_error"       
6114       
6115        Make/O/D/N=1 wTmpWrite
6116//      Make/O/R/N=1 wTmpWrite
6117        String groupName = "/entry/reduction"
6118        String varName = "whole_trans_error"
6119        wTmpWrite[0] = val
6120
6121        variable err
6122        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6123        if(err)
6124                Print "HDF write err = ",err
6125        endif
6126        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6127//      err = V_KillNamedDataFolder(fname)
6128//      if(err)
6129//              Print "DataFolder kill err = ",err
6130//      endif
6131        return(err)
6132end
6133
6134                       
6135/////                   pol_sans (data folder)
6136
6137Function V_writePolSANS_cellName(fname,str)
6138        String fname,str
6139
6140//      String path = "entry:reduction:pol_sans:cell_name"     
6141
6142        Make/O/T/N=1 tmpTW
6143        String groupName = "/entry/reduction/pol_sans"
6144        String varName = "cell_name"
6145        tmpTW[0] = str //
6146
6147        variable err
6148        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6149        if(err)
6150                Print "HDF write err = ",err
6151        endif
6152       
6153        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6154//      err = V_KillNamedDataFolder(fname)
6155//      if(err)
6156//              Print "DataFolder kill err = ",err
6157//      endif
6158               
6159        return(err)
6160End
6161
6162
6163// TODO -- needs to be a WAVE
6164// is this a text wave?? if it's mixed names + values, then what?
6165Function V_writePolSANS_cellParams(fname,inW)
6166        String fname
6167        Wave inW
6168       
6169//      String path = "entry:reduction:pol_sans:cell_parameters"
6170               
6171        Duplicate/O inW wTmpWrite       
6172// then use redimension as needed to cast the wave to write to the specified type
6173// see WaveType for the proper codes
6174//      Redimension/T=() wTmpWrite
6175// -- May also need to check the dimension(s) before writing (don't trust the input)
6176        String groupName = "/entry/reduction/pol_sans" 
6177        String varName = "cell_parameters"
6178
6179        variable err
6180        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6181        if(err)
6182                Print "HDF write err = ",err
6183        endif
6184        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6185//      err = V_KillNamedDataFolder(fname)
6186//      if(err)
6187//              Print "DataFolder kill err = ",err
6188//      endif
6189        return(err)
6190end
6191
6192Function V_writePolSANS_PolSANSPurpose(fname,str)
6193        String fname,str
6194
6195//      String path = "entry:reduction:pol_sans:pol_sans_purpose"       
6196
6197        Make/O/T/N=1 tmpTW
6198        String groupName = "/entry/reduction/pol_sans"
6199        String varName = "pol_sans_purpose"
6200        tmpTW[0] = str //
6201
6202        variable err
6203        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6204        if(err)
6205                Print "HDF write err = ",err
6206        endif
6207       
6208        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6209//      err = V_KillNamedDataFolder(fname)
6210//      if(err)
6211//              Print "DataFolder kill err = ",err
6212//      endif
6213               
6214        return(err)
6215End
6216
6217                               
6218//////// TOP LEVEL DATA REPRESENTATION
6219//
6220// note that here the data is (supposed to be) a link, not the actual data
6221// Igor HDf implementation cannot follow links properly, as far as I know.
6222// so ignore them here, and focus on the image that may be possible to read
6223//
6224
6225//              data_B (data folder)
6226//                      data (wave) 1           //ignore this, it's a link
6227//                      variables (wave) 320
6228//                      thumbnail (data folder)
6229
6230////data (wave) "binary"
6231//// TODO -- this will need to be completely replaced with a function that can
6232//// read the binary image data. should be possible, but I don't know the details on either end...
6233//Function V_writeDataImage(fname,detStr,str)
6234//      String fname,detStr,str
6235//
6236////    String path = "entry:data_"+detStr+":thumbnail:data"   
6237//
6238//      Make/O/T/N=1 tmpTW
6239//      String groupName = "/entry/data_"+detStr+"/thumbnail"
6240//      String varName = "data"
6241//      tmpTW[0] = str //
6242//
6243//      variable err
6244//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6245//      if(err)
6246//              Print "HDF write err = ",err
6247//      endif
6248//     
6249//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6250////    err = V_KillNamedDataFolder(fname)
6251////    if(err)
6252////            Print "DataFolder kill err = ",err
6253////    endif
6254//             
6255//      return(err)
6256//End
6257//
6258//Function V_writeDataImageDescription(fname,detStr,str)
6259//      String fname,detStr,str
6260//
6261////    String path = "entry:data_"+detStr+":thumbnail:description"     
6262//
6263//      Make/O/T/N=1 tmpTW
6264//      String groupName = "/entry/data_"+detStr+"/thumbnail"
6265//      String varName = "description"
6266//      tmpTW[0] = str //
6267//
6268//      variable err
6269//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6270//      if(err)
6271//              Print "HDF write err = ",err
6272//      endif
6273//     
6274//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6275////    err = V_KillNamedDataFolder(fname)
6276////    if(err)
6277////            Print "DataFolder kill err = ",err
6278////    endif
6279//             
6280//      return(err)
6281//End
6282//                                                             
6283//Function V_writeDataImageType(fname,detStr,str)
6284//      String fname,detStr,str
6285//
6286////    String path = "entry:data_"+detStr+":thumbnail:type"   
6287//
6288//      Make/O/T/N=1 tmpTW
6289//      String groupName = "/entry/data_"+detStr+"/thumbnail"
6290//      String varName = "type"
6291//      tmpTW[0] = str //
6292//
6293//      variable err
6294//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6295//      if(err)
6296//              Print "HDF write err = ",err
6297//      endif
6298//     
6299//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6300////    err = V_KillNamedDataFolder(fname)
6301////    if(err)
6302////            Print "DataFolder kill err = ",err
6303////    endif
6304//             
6305//      return(err)
6306//End
6307//
Note: See TracBrowser for help on using the repository browser.