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

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

more changes, lots of files.

File size: 156.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//// DONE - this does not exist for VSANS - per JGB 4/2016
2111//Function V_writeVS_tilt(fname,val)
2112//      String fname
2113//      Variable val
2114//     
2115////    String path = "entry:instrument:beam:monochromator:velocity_selector:vs_tilt"   
2116//     
2117//      Make/O/D/N=1 wTmpWrite
2118////    Make/O/R/N=1 wTmpWrite
2119//      String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     
2120//      String varName = "vs_tilt"
2121//      wTmpWrite[0] = val
2122//
2123//      variable err
2124//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2125//      if(err)
2126//              Print "HDF write err = ",err
2127//      endif
2128//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2129////    err = V_KillNamedDataFolder(fname)
2130////    if(err)
2131////            Print "DataFolder kill err = ",err
2132////    endif
2133//      return(err)
2134//end
2135
2136Function V_writeVSWavelength(fname,val)
2137        String fname
2138        Variable val
2139       
2140//      String path = "entry:instrument:beam:monochromator:velocity_selector:wavelength"       
2141       
2142        Make/O/D/N=1 wTmpWrite
2143//      Make/O/R/N=1 wTmpWrite
2144        String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     
2145        String varName = "wavelength"
2146        wTmpWrite[0] = val
2147
2148        variable err
2149        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2150        if(err)
2151                Print "HDF write err = ",err
2152        endif
2153        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2154//      err = V_KillNamedDataFolder(fname)
2155//      if(err)
2156//              Print "DataFolder kill err = ",err
2157//      endif
2158        return(err)
2159end
2160
2161Function V_writeVSWavelength_spread(fname,val)
2162        String fname
2163        Variable val
2164       
2165//      String path = "entry:instrument:beam:monochromator:velocity_selector:wavelength_spread"
2166       
2167        Make/O/D/N=1 wTmpWrite
2168//      Make/O/R/N=1 wTmpWrite
2169        String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     
2170        String varName = "wavelength_spread"
2171        wTmpWrite[0] = val
2172
2173        variable err
2174        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2175        if(err)
2176                Print "HDF write err = ",err
2177        endif
2178        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2179//      err = V_KillNamedDataFolder(fname)
2180//      if(err)
2181//              Print "DataFolder kill err = ",err
2182//      endif
2183        return(err)
2184end
2185
2186// instrument/beam/monochromator/white_beam (data folder)
2187Function V_writeWhiteBeamStatus(fname,str)
2188        String fname,str
2189
2190//      String path = "entry:instrument:beam:monochromator:white_beam:status"
2191
2192        Make/O/T/N=1 tmpTW
2193        String groupName = "/entry/instrument/beam/monochromator/white_beam"    //     
2194        String varName = "status"
2195        tmpTW[0] = str //
2196
2197        variable err
2198        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2199        if(err)
2200                Print "HDF write err = ",err
2201        endif
2202       
2203        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2204//      err = V_KillNamedDataFolder(fname)
2205//      if(err)
2206//              Print "DataFolder kill err = ",err
2207//      endif
2208               
2209        return(err)
2210End
2211
2212Function V_writeWhiteBeamWavelength(fname,val)
2213        String fname
2214        Variable val
2215       
2216//      String path = "entry:instrument:beam:monochromator:white_beam:wavelength"       
2217       
2218        Make/O/D/N=1 wTmpWrite
2219//      Make/O/R/N=1 wTmpWrite
2220        String groupName = "/entry/instrument/beam/monochromator/white_beam"   
2221        String varName = "wavelength"
2222        wTmpWrite[0] = val
2223
2224        variable err
2225        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2226        if(err)
2227                Print "HDF write err = ",err
2228        endif
2229        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2230//      err = V_KillNamedDataFolder(fname)
2231//      if(err)
2232//              Print "DataFolder kill err = ",err
2233//      endif
2234        return(err)
2235end
2236
2237Function V_writeWhiteBeamWavel_spread(fname,val)
2238        String fname
2239        Variable val
2240       
2241//      String path = "entry:instrument:beam:monochromator:white_beam:wavelength_spread"       
2242       
2243        Make/O/D/N=1 wTmpWrite
2244//      Make/O/R/N=1 wTmpWrite
2245        String groupName = "/entry/instrument/beam/monochromator/white_beam"   
2246        String varName = "wavelength_spread"
2247        wTmpWrite[0] = val
2248
2249        variable err
2250        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2251        if(err)
2252                Print "HDF write err = ",err
2253        endif
2254        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2255//      err = V_KillNamedDataFolder(fname)
2256//      if(err)
2257//              Print "DataFolder kill err = ",err
2258//      endif
2259        return(err)
2260end
2261
2262// instrument/beam/polarizer (data folder)
2263Function V_writePolarizerComposition(fname,str)
2264        String fname,str
2265
2266//      String path = "entry:instrument:beam:polarizer:composition"
2267
2268        Make/O/T/N=1 tmpTW
2269        String groupName = "/entry/instrument/beam/polarizer"   //     
2270        String varName = "composition"
2271        tmpTW[0] = str //
2272
2273        variable err
2274        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2275        if(err)
2276                Print "HDF write err = ",err
2277        endif
2278       
2279        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2280//      err = V_KillNamedDataFolder(fname)
2281//      if(err)
2282//              Print "DataFolder kill err = ",err
2283//      endif
2284               
2285        return(err)
2286End
2287
2288Function V_writePolarizerEfficiency(fname,val)
2289        String fname
2290        Variable val
2291       
2292//      String path = "entry:instrument:beam:polarizer:efficiency"     
2293       
2294        Make/O/D/N=1 wTmpWrite
2295//      Make/O/R/N=1 wTmpWrite
2296        String groupName = "/entry/instrument/beam/polarizer"   
2297        String varName = "efficiency"
2298        wTmpWrite[0] = val
2299
2300        variable err
2301        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2302        if(err)
2303                Print "HDF write err = ",err
2304        endif
2305        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2306//      err = V_KillNamedDataFolder(fname)
2307//      if(err)
2308//              Print "DataFolder kill err = ",err
2309//      endif
2310        return(err)
2311end
2312
2313Function V_writePolarizerStatus(fname,str)
2314        String fname,str
2315
2316//      String path = "entry:instrument:beam:polarizer:status"
2317
2318        Make/O/T/N=1 tmpTW
2319        String groupName = "/entry/instrument/beam/polarizer"   //     
2320        String varName = "status"
2321        tmpTW[0] = str //
2322
2323        variable err
2324        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2325        if(err)
2326                Print "HDF write err = ",err
2327        endif
2328       
2329        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2330//      err = V_KillNamedDataFolder(fname)
2331//      if(err)
2332//              Print "DataFolder kill err = ",err
2333//      endif
2334               
2335        return(err)
2336End
2337
2338Function V_writePolarizerType(fname,str)
2339        String fname,str
2340
2341//      String path = "entry:instrument:beam:polarizer:type"
2342
2343        Make/O/T/N=1 tmpTW
2344        String groupName = "/entry/instrument/beam/polarizer"   //     
2345        String varName = "type"
2346        tmpTW[0] = str //
2347
2348        variable err
2349        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2350        if(err)
2351                Print "HDF write err = ",err
2352        endif
2353       
2354        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2355//      err = V_KillNamedDataFolder(fname)
2356//      if(err)
2357//              Print "DataFolder kill err = ",err
2358//      endif
2359               
2360        return(err)
2361End
2362
2363// instrument/beam/polarizer_analyzer (data folder)
2364// integer value
2365Function V_writePolAnaCell_index(fname,val)
2366        String fname
2367        Variable val
2368
2369//      String path = "entry:instrument:beam:polarizer_analyzer:cell_index"
2370       
2371        Make/O/I/N=1 wTmpWrite
2372//      Make/O/R/N=1 wTmpWrite
2373        String groupName = "/entry/instrument/beam/polarizer_analyzer" 
2374        String varName = "cell_index"
2375        wTmpWrite[0] = val
2376
2377        variable err
2378        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2379        if(err)
2380                Print "HDF write err = ",err
2381        endif
2382        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2383//      err = V_KillNamedDataFolder(fname)
2384//      if(err)
2385//              Print "DataFolder kill err = ",err
2386//      endif
2387        return(err)
2388End
2389
2390Function V_writePolAnaCell_name(fname,str)
2391        String fname,str
2392
2393//      String path = "entry:instrument:beam:polarizer_analyzer:cell_name"
2394
2395        Make/O/T/N=1 tmpTW
2396        String groupName = "/entry/instrument/beam/polarizer_analyzer"  //     
2397        String varName = "cell_name"
2398        tmpTW[0] = str //
2399
2400        variable err
2401        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2402        if(err)
2403                Print "HDF write err = ",err
2404        endif
2405       
2406        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2407//      err = V_KillNamedDataFolder(fname)
2408//      if(err)
2409//              Print "DataFolder kill err = ",err
2410//      endif
2411               
2412        return(err)
2413End
2414
2415Function V_writePolAnaCell_parameters(fname,inW)
2416        String fname
2417        Wave inW
2418
2419//      String path = "entry:instrument:beam:polarizer_analyzer:cell_parameters"
2420
2421        Duplicate/O inW wTmpWrite       
2422// then use redimension as needed to cast the wave to write to the specified type
2423// see WaveType for the proper codes
2424//      Redimension/T=() wTmpWrite
2425// -- May also need to check the dimension(s) before writing (don't trust the input)
2426        String groupName = "/entry/instrument//beam/polarizer_analyzer"
2427        String varName = "cell_parameters"
2428
2429        variable err
2430        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2431        if(err)
2432                Print "HDF write err = ",err
2433        endif
2434        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2435//      err = V_KillNamedDataFolder(fname)
2436//      if(err)
2437//              Print "DataFolder kill err = ",err
2438//      endif
2439        return(err)
2440End
2441
2442Function V_writePolAnaGuideFieldCur_1(fname,val)
2443        String fname
2444        Variable val
2445
2446//      String path = "entry:instrument:beam:polarizer_analyzer:guide_field_current_1"
2447       
2448        Make/O/D/N=1 wTmpWrite
2449//      Make/O/R/N=1 wTmpWrite
2450        String groupName = "/entry/instrument/beam/polarizer_analyzer" 
2451        String varName = "guide_field_current_1"
2452        wTmpWrite[0] = val
2453
2454        variable err
2455        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2456        if(err)
2457                Print "HDF write err = ",err
2458        endif
2459        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2460//      err = V_KillNamedDataFolder(fname)
2461//      if(err)
2462//              Print "DataFolder kill err = ",err
2463//      endif
2464        return(err)
2465End
2466
2467Function V_writePolAnaGuideFieldCur_2(fname,val)
2468        String fname
2469        Variable val
2470
2471//      String path = "entry:instrument:beam:polarizer_analyzer:guide_field_current_2"
2472       
2473        Make/O/D/N=1 wTmpWrite
2474//      Make/O/R/N=1 wTmpWrite
2475        String groupName = "/entry/instrument/beam/polarizer_analyzer" 
2476        String varName = "guide_field_current_2"
2477        wTmpWrite[0] = val
2478
2479        variable err
2480        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2481        if(err)
2482                Print "HDF write err = ",err
2483        endif
2484        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2485//      err = V_KillNamedDataFolder(fname)
2486//      if(err)
2487//              Print "DataFolder kill err = ",err
2488//      endif
2489        return(err)
2490End
2491
2492Function V_writePolAnaSolenoid_current(fname,val)
2493        String fname
2494        Variable val
2495
2496//      String path = "entry:instrument:beam:polarizer_analyzer:solenoid_current"
2497       
2498        Make/O/D/N=1 wTmpWrite
2499//      Make/O/R/N=1 wTmpWrite
2500        String groupName = "/entry/instrument/beam/polarizer_analyzer" 
2501        String varName = "solenoid_current"
2502        wTmpWrite[0] = val
2503
2504        variable err
2505        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2506        if(err)
2507                Print "HDF write err = ",err
2508        endif
2509        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2510//      err = V_KillNamedDataFolder(fname)
2511//      if(err)
2512//              Print "DataFolder kill err = ",err
2513//      endif
2514        return(err)
2515End
2516
2517Function V_writePolAnaStatus(fname,str)
2518        String fname,str
2519
2520//      String path = "entry:instrument:beam:polarizer_analyzer:status"
2521
2522        Make/O/T/N=1 tmpTW
2523        String groupName = "/entry/instrument/beam/polarizer_analyzer"  //     
2524        String varName = "status"
2525        tmpTW[0] = str //
2526
2527        variable err
2528        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2529        if(err)
2530                Print "HDF write err = ",err
2531        endif
2532       
2533        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2534//      err = V_KillNamedDataFolder(fname)
2535//      if(err)
2536//              Print "DataFolder kill err = ",err
2537//      endif
2538               
2539        return(err)
2540End
2541
2542
2543
2544
2545                                       
2546/////// INSTRUMENT/BEAM MONITORS
2547
2548//beam_monitor_low (data folder)
2549// integer value
2550Function V_writeBeamMonLowData(fname,val)
2551        String fname
2552        Variable val
2553
2554//      String path = "entry:instrument:beam_monitor_low:data"
2555       
2556        Make/O/I/N=1 wTmpWrite
2557//      Make/O/R/N=1 wTmpWrite
2558        String groupName = "/entry/instrument/beam_monitor_low"
2559        String varName = "data"
2560        wTmpWrite[0] = val
2561
2562        variable err
2563        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2564        if(err)
2565                Print "HDF write err = ",err
2566        endif
2567        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2568//      err = V_KillNamedDataFolder(fname)
2569//      if(err)
2570//              Print "DataFolder kill err = ",err
2571//      endif
2572        return(err)
2573End
2574
2575Function V_writeBeamMonLowEfficiency(fname,val)
2576        String fname
2577        Variable val
2578
2579//      String path = "entry:instrument:beam_monitor_low:efficiency"
2580       
2581        Make/O/D/N=1 wTmpWrite
2582//      Make/O/R/N=1 wTmpWrite
2583        String groupName = "/entry/instrument/beam_monitor_low"
2584        String varName = "efficiency"
2585        wTmpWrite[0] = val
2586
2587        variable err
2588        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2589        if(err)
2590                Print "HDF write err = ",err
2591        endif
2592        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2593//      err = V_KillNamedDataFolder(fname)
2594//      if(err)
2595//              Print "DataFolder kill err = ",err
2596//      endif
2597        return(err)
2598End
2599
2600Function V_writeBeamMonLowDistance(fname,val)
2601        String fname
2602        Variable val
2603
2604//      String path = "entry:instrument:beam_monitor_low:distance"
2605       
2606        Make/O/D/N=1 wTmpWrite
2607//      Make/O/R/N=1 wTmpWrite
2608        String groupName = "/entry/instrument/beam_monitor_low"
2609        String varName = "distance"
2610        wTmpWrite[0] = val
2611
2612        variable err
2613        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2614        if(err)
2615                Print "HDF write err = ",err
2616        endif
2617        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2618//      err = V_KillNamedDataFolder(fname)
2619//      if(err)
2620//              Print "DataFolder kill err = ",err
2621//      endif
2622        return(err)
2623End
2624
2625Function V_writeBeamMonLowSaved_count(fname,val)
2626        String fname
2627        Variable val
2628
2629//      String path = "entry:instrument:beam_monitor_low:saved_count"
2630       
2631        Make/O/D/N=1 wTmpWrite
2632//      Make/O/R/N=1 wTmpWrite
2633        String groupName = "/entry/instrument/beam_monitor_low"
2634        String varName = "saved_count"
2635        wTmpWrite[0] = val
2636
2637        variable err
2638        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2639        if(err)
2640                Print "HDF write err = ",err
2641        endif
2642        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2643//      err = V_KillNamedDataFolder(fname)
2644//      if(err)
2645//              Print "DataFolder kill err = ",err
2646//      endif
2647        return(err)
2648End
2649
2650Function V_writeBeamMonLowType(fname,str)
2651        String fname,str
2652
2653//      String path = "entry:instrument:beam_monitor_low:type"
2654
2655        Make/O/T/N=1 tmpTW
2656        String groupName = "/entry/instrument/beam_monitor_low" //     
2657        String varName = "type"
2658        tmpTW[0] = str //
2659
2660        variable err
2661        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2662        if(err)
2663                Print "HDF write err = ",err
2664        endif
2665       
2666        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2667//      err = V_KillNamedDataFolder(fname)
2668//      if(err)
2669//              Print "DataFolder kill err = ",err
2670//      endif
2671               
2672        return(err)
2673End
2674
2675//beam_monitor_norm (data folder)
2676// integer value
2677Function V_writeBeamMonNormData(fname,val)
2678        String fname
2679        Variable val
2680
2681//      String path = "entry:instrument:beam_monitor_norm:data"
2682       
2683        Make/O/I/N=1 wTmpWrite
2684//      Make/O/R/N=1 wTmpWrite
2685        String groupName = "/entry/instrument/beam_monitor_norm"       
2686        String varName = "data"
2687        wTmpWrite[0] = val
2688
2689        variable err
2690        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2691        if(err)
2692                Print "HDF write err = ",err
2693        endif
2694        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2695//      err = V_KillNamedDataFolder(fname)
2696//      if(err)
2697//              Print "DataFolder kill err = ",err
2698//      endif
2699        return(err)
2700End
2701
2702Function V_writeBeamMonNormEfficiency(fname,val)
2703        String fname
2704        Variable val
2705
2706//      String path = "entry:instrument:beam_monitor_norm:efficiency"
2707       
2708        Make/O/D/N=1 wTmpWrite
2709//      Make/O/R/N=1 wTmpWrite
2710        String groupName = "/entry/instrument/beam_monitor_norm"       
2711        String varName = "efficiency"
2712        wTmpWrite[0] = val
2713
2714        variable err
2715        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2716        if(err)
2717                Print "HDF write err = ",err
2718        endif
2719        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2720//      err = V_KillNamedDataFolder(fname)
2721//      if(err)
2722//              Print "DataFolder kill err = ",err
2723//      endif
2724        return(err)
2725End
2726
2727Function V_writeBeamMonNormDistance(fname,val)
2728        String fname
2729        Variable val
2730
2731//      String path = "entry:instrument:beam_monitor_norm:distance"
2732       
2733        Make/O/D/N=1 wTmpWrite
2734//      Make/O/R/N=1 wTmpWrite
2735        String groupName = "/entry/instrument/beam_monitor_norm"       
2736        String varName = "distance"
2737        wTmpWrite[0] = val
2738
2739        variable err
2740        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2741        if(err)
2742                Print "HDF write err = ",err
2743        endif
2744        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2745//      err = V_KillNamedDataFolder(fname)
2746//      if(err)
2747//              Print "DataFolder kill err = ",err
2748//      endif
2749        return(err)
2750End
2751
2752Function V_writeBeamMonNormSaved_count(fname,val)
2753        String fname
2754        Variable val
2755
2756//      String path = "entry:instrument:beam_monitor_norm:saved_count"
2757       
2758        Make/O/D/N=1 wTmpWrite
2759//      Make/O/R/N=1 wTmpWrite
2760        String groupName = "/entry/instrument/beam_monitor_norm"       
2761        String varName = "saved_count"
2762        wTmpWrite[0] = val
2763
2764        variable err
2765        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2766        if(err)
2767                Print "HDF write err = ",err
2768        endif
2769        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2770//      err = V_KillNamedDataFolder(fname)
2771//      if(err)
2772//              Print "DataFolder kill err = ",err
2773//      endif
2774        return(err)
2775End
2776
2777Function V_writeBeamMonNormType(fname,str)
2778        String fname,str
2779
2780//      String path = "entry:instrument:beam_monitor_norm:type"
2781
2782        Make/O/T/N=1 tmpTW
2783        String groupName = "/entry/instrument/beam_monitor_norm"        //     
2784        String varName = "type"
2785        tmpTW[0] = str //
2786
2787        variable err
2788        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2789        if(err)
2790                Print "HDF write err = ",err
2791        endif
2792       
2793        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2794//      err = V_KillNamedDataFolder(fname)
2795//      if(err)
2796//              Print "DataFolder kill err = ",err
2797//      endif
2798               
2799        return(err)
2800End
2801
2802
2803//beam_stop C2 (data folder)
2804Function V_writeBeamStopC2Description(fname,str)
2805        String fname,str
2806
2807//      String path = "entry:instrument:beam_stop:description"
2808
2809        Make/O/T/N=1 tmpTW
2810        String groupName = "/entry/instrument/beam_stop_C2"     //     
2811        String varName = "description"
2812        tmpTW[0] = str //
2813
2814        variable err
2815        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2816        if(err)
2817                Print "HDF write err = ",err
2818        endif
2819       
2820        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2821//      err = V_KillNamedDataFolder(fname)
2822//      if(err)
2823//              Print "DataFolder kill err = ",err
2824//      endif
2825               
2826        return(err)
2827End
2828
2829Function V_writeBeamStopC2Dist_to_det(fname,val)
2830        String fname
2831        Variable val
2832
2833//      String path = "entry:instrument:beam_stop:distance_to_detector"
2834       
2835        Make/O/D/N=1 wTmpWrite
2836//      Make/O/R/N=1 wTmpWrite
2837        String groupName = "/entry/instrument/beam_stop_C2"     
2838        String varName = "distance_to_detector"
2839        wTmpWrite[0] = val
2840
2841        variable err
2842        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2843        if(err)
2844                Print "HDF write err = ",err
2845        endif
2846        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2847//      err = V_KillNamedDataFolder(fname)
2848//      if(err)
2849//              Print "DataFolder kill err = ",err
2850//      endif
2851        return(err)
2852End
2853
2854// is this the index of which size beam stop is in position?
2855// integer value
2856Function V_writeBeamStopC2num_stop(fname,val)
2857        String fname
2858        Variable val
2859
2860//      String path = "entry:instrument:beam_stop:distance_to_detector"
2861       
2862        Make/O/I/N=1 wTmpWrite
2863//      Make/O/R/N=1 wTmpWrite
2864        String groupName = "/entry/instrument/beam_stop_C2"     
2865        String varName = "num_beamstops"
2866        wTmpWrite[0] = val
2867
2868        variable err
2869        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2870        if(err)
2871                Print "HDF write err = ",err
2872        endif
2873        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2874//      err = V_KillNamedDataFolder(fname)
2875//      if(err)
2876//              Print "DataFolder kill err = ",err
2877//      endif
2878        return(err)
2879End
2880
2881Function V_writeBeamStopC2_x_pos(fname,val)
2882        String fname
2883        Variable val
2884
2885//      String path = "entry:instrument:beam_stop:x0"
2886       
2887        Make/O/D/N=1 wTmpWrite
2888//      Make/O/R/N=1 wTmpWrite
2889        String groupName = "/entry/instrument/beam_stop_C2"     
2890        String varName = "x_pos"
2891        wTmpWrite[0] = val
2892
2893        variable err
2894        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2895        if(err)
2896                Print "HDF write err = ",err
2897        endif
2898        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2899//      err = V_KillNamedDataFolder(fname)
2900//      if(err)
2901//              Print "DataFolder kill err = ",err
2902//      endif
2903        return(err)
2904End
2905
2906Function V_writeBeamStopC2_y_pos(fname,val)
2907        String fname
2908        Variable val
2909
2910//      String path = "entry:instrument:beam_stop:y0"
2911       
2912        Make/O/D/N=1 wTmpWrite
2913//      Make/O/R/N=1 wTmpWrite
2914        String groupName = "/entry/instrument/beam_stop_C2"     
2915        String varName = "y_pos"
2916        wTmpWrite[0] = val
2917
2918        variable err
2919        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2920        if(err)
2921                Print "HDF write err = ",err
2922        endif
2923        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2924//      err = V_KillNamedDataFolder(fname)
2925//      if(err)
2926//              Print "DataFolder kill err = ",err
2927//      endif
2928        return(err)
2929End
2930
2931
2932// beam stop C2 (shape)
2933Function V_writeBeamStopC2_height(fname,val)
2934        String fname
2935        Variable val
2936
2937//      String path = "entry:instrument:beam_stop:y0"
2938       
2939        Make/O/D/N=1 wTmpWrite
2940//      Make/O/R/N=1 wTmpWrite
2941        String groupName = "/entry/instrument/beam_stop_C2/shape"       
2942        String varName = "height"
2943        wTmpWrite[0] = val
2944
2945        variable err
2946        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2947        if(err)
2948                Print "HDF write err = ",err
2949        endif
2950        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2951//      err = V_KillNamedDataFolder(fname)
2952//      if(err)
2953//              Print "DataFolder kill err = ",err
2954//      endif
2955        return(err)
2956End
2957
2958Function V_writeBeamStopC2_shape(fname,str)
2959        String fname,str
2960
2961//      String path = "entry:instrument:beam_stop:description"
2962
2963        Make/O/T/N=1 tmpTW
2964        String groupName = "/entry/instrument/beam_stop_C2/shape"       //     
2965        String varName = "shape"
2966        tmpTW[0] = str //
2967
2968        variable err
2969        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2970        if(err)
2971                Print "HDF write err = ",err
2972        endif
2973       
2974        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2975//      err = V_KillNamedDataFolder(fname)
2976//      if(err)
2977//              Print "DataFolder kill err = ",err
2978//      endif
2979               
2980        return(err)
2981End
2982
2983// this is diameter if shape=CIRCLE
2984Function V_writeBeamStopC2_size(fname,val)
2985        String fname
2986        Variable val
2987
2988//      String path = "entry:instrument:beam_stop:y0"
2989       
2990        Make/O/D/N=1 wTmpWrite
2991//      Make/O/R/N=1 wTmpWrite
2992        String groupName = "/entry/instrument/beam_stop_C2/shape"       
2993        String varName = "size"
2994        wTmpWrite[0] = val
2995
2996        variable err
2997        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2998        if(err)
2999                Print "HDF write err = ",err
3000        endif
3001        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3002//      err = V_KillNamedDataFolder(fname)
3003//      if(err)
3004//              Print "DataFolder kill err = ",err
3005//      endif
3006        return(err)
3007End
3008
3009Function V_writeBeamStopC2_width(fname,val)
3010        String fname
3011        Variable val
3012
3013//      String path = "entry:instrument:beam_stop:y0"
3014       
3015        Make/O/D/N=1 wTmpWrite
3016//      Make/O/R/N=1 wTmpWrite
3017        String groupName = "/entry/instrument/beam_stop_C2/shape"       
3018        String varName = "width"
3019        wTmpWrite[0] = val
3020
3021        variable err
3022        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3023        if(err)
3024                Print "HDF write err = ",err
3025        endif
3026        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3027//      err = V_KillNamedDataFolder(fname)
3028//      if(err)
3029//              Print "DataFolder kill err = ",err
3030//      endif
3031        return(err)
3032End
3033
3034// beam stop C3 (data folder)
3035Function V_writeBeamStopC3Description(fname,str)
3036        String fname,str
3037
3038//      String path = "entry:instrument:beam_stop:description"
3039
3040        Make/O/T/N=1 tmpTW
3041        String groupName = "/entry/instrument/beam_stop_C3"     //     
3042        String varName = "description"
3043        tmpTW[0] = str //
3044
3045        variable err
3046        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3047        if(err)
3048                Print "HDF write err = ",err
3049        endif
3050       
3051        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3052//      err = V_KillNamedDataFolder(fname)
3053//      if(err)
3054//              Print "DataFolder kill err = ",err
3055//      endif
3056               
3057        return(err)
3058End
3059
3060Function V_writeBeamStopC3Dist_to_det(fname,val)
3061        String fname
3062        Variable val
3063
3064//      String path = "entry:instrument:beam_stop:distance_to_detector"
3065       
3066        Make/O/D/N=1 wTmpWrite
3067//      Make/O/R/N=1 wTmpWrite
3068        String groupName = "/entry/instrument/beam_stop_C3"     
3069        String varName = "distance_to_detector"
3070        wTmpWrite[0] = val
3071
3072        variable err
3073        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3074        if(err)
3075                Print "HDF write err = ",err
3076        endif
3077        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3078//      err = V_KillNamedDataFolder(fname)
3079//      if(err)
3080//              Print "DataFolder kill err = ",err
3081//      endif
3082        return(err)
3083End
3084
3085// integer value
3086Function V_writeBeamStopC3num_stop(fname,val)
3087        String fname
3088        Variable val
3089
3090//      String path = "entry:instrument:beam_stop:distance_to_detector"
3091       
3092        Make/O/I/N=1 wTmpWrite
3093//      Make/O/R/N=1 wTmpWrite
3094        String groupName = "/entry/instrument/beam_stop_C3"     
3095        String varName = "num_beamstops"
3096        wTmpWrite[0] = val
3097
3098        variable err
3099        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3100        if(err)
3101                Print "HDF write err = ",err
3102        endif
3103        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3104//      err = V_KillNamedDataFolder(fname)
3105//      if(err)
3106//              Print "DataFolder kill err = ",err
3107//      endif
3108        return(err)
3109End
3110
3111Function V_writeBeamStopC3_x_pos(fname,val)
3112        String fname
3113        Variable val
3114
3115//      String path = "entry:instrument:beam_stop:x0"
3116       
3117        Make/O/D/N=1 wTmpWrite
3118//      Make/O/R/N=1 wTmpWrite
3119        String groupName = "/entry/instrument/beam_stop_C3"     
3120        String varName = "x_pos"
3121        wTmpWrite[0] = val
3122
3123        variable err
3124        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3125        if(err)
3126                Print "HDF write err = ",err
3127        endif
3128        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3129//      err = V_KillNamedDataFolder(fname)
3130//      if(err)
3131//              Print "DataFolder kill err = ",err
3132//      endif
3133        return(err)
3134End
3135
3136Function V_writeBeamStopC3_y_pos(fname,val)
3137        String fname
3138        Variable val
3139
3140//      String path = "entry:instrument:beam_stop:y0"
3141       
3142        Make/O/D/N=1 wTmpWrite
3143//      Make/O/R/N=1 wTmpWrite
3144        String groupName = "/entry/instrument/beam_stop_C3"     
3145        String varName = "y_pos"
3146        wTmpWrite[0] = val
3147
3148        variable err
3149        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3150        if(err)
3151                Print "HDF write err = ",err
3152        endif
3153        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3154//      err = V_KillNamedDataFolder(fname)
3155//      if(err)
3156//              Print "DataFolder kill err = ",err
3157//      endif
3158        return(err)
3159End
3160
3161
3162// beam stop C3 (shape)
3163Function V_writeBeamStopC3_height(fname,val)
3164        String fname
3165        Variable val
3166
3167//      String path = "entry:instrument:beam_stop:y0"
3168       
3169        Make/O/D/N=1 wTmpWrite
3170//      Make/O/R/N=1 wTmpWrite
3171        String groupName = "/entry/instrument/beam_stop_C3/shape"       
3172        String varName = "height"
3173        wTmpWrite[0] = val
3174
3175        variable err
3176        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3177        if(err)
3178                Print "HDF write err = ",err
3179        endif
3180        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3181//      err = V_KillNamedDataFolder(fname)
3182//      if(err)
3183//              Print "DataFolder kill err = ",err
3184//      endif
3185        return(err)
3186End
3187
3188Function V_writeBeamStopC3_shape(fname,str)
3189        String fname,str
3190
3191//      String path = "entry:instrument:beam_stop:description"
3192
3193        Make/O/T/N=1 tmpTW
3194        String groupName = "/entry/instrument/beam_stop_C3/shape"       //     
3195        String varName = "shape"
3196        tmpTW[0] = str //
3197
3198        variable err
3199        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3200        if(err)
3201                Print "HDF write err = ",err
3202        endif
3203       
3204        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3205//      err = V_KillNamedDataFolder(fname)
3206//      if(err)
3207//              Print "DataFolder kill err = ",err
3208//      endif
3209               
3210        return(err)
3211End
3212
3213// this is diameter if shape=CIRCLE
3214Function V_writeBeamStopC3_size(fname,val)
3215        String fname
3216        Variable val
3217
3218//      String path = "entry:instrument:beam_stop:y0"
3219       
3220        Make/O/D/N=1 wTmpWrite
3221//      Make/O/R/N=1 wTmpWrite
3222        String groupName = "/entry/instrument/beam_stop_C3/shape"       
3223        String varName = "size"
3224        wTmpWrite[0] = val
3225
3226        variable err
3227        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3228        if(err)
3229                Print "HDF write err = ",err
3230        endif
3231        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3232//      err = V_KillNamedDataFolder(fname)
3233//      if(err)
3234//              Print "DataFolder kill err = ",err
3235//      endif
3236        return(err)
3237End
3238
3239Function V_writeBeamStopC3_width(fname,val)
3240        String fname
3241        Variable val
3242
3243//      String path = "entry:instrument:beam_stop:y0"
3244       
3245        Make/O/D/N=1 wTmpWrite
3246//      Make/O/R/N=1 wTmpWrite
3247        String groupName = "/entry/instrument/beam_stop_C3/shape"       
3248        String varName = "width"
3249        wTmpWrite[0] = val
3250
3251        variable err
3252        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3253        if(err)
3254                Print "HDF write err = ",err
3255        endif
3256        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3257//      err = V_KillNamedDataFolder(fname)
3258//      if(err)
3259//              Print "DataFolder kill err = ",err
3260//      endif
3261        return(err)
3262End
3263
3264
3265
3266//// INSTRUMENT/COLLIMATOR
3267//collimator (data folder) -- this is a TEXT field
3268Function V_writeNumberOfGuides(fname,str)
3269        String fname,str
3270
3271//      String path = "entry:instrument:collimator:number_guides"
3272
3273        Make/O/T/N=1 tmpTW
3274        String groupName = "/entry/instrument/collimator"       
3275        String varName = "number_guides"
3276        tmpTW[0] = str //
3277
3278        variable err
3279        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3280        if(err)
3281                Print "HDF write err = ",err
3282        endif
3283       
3284        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3285//      err = V_KillNamedDataFolder(fname)
3286//      if(err)
3287//              Print "DataFolder kill err = ",err
3288//      endif
3289               
3290        return(err)
3291End
3292
3293
3294//                              geometry (data folder)
3295//                                      shape (data folder)
3296Function V_writeGuideShape(fname,str)
3297        String fname,str
3298
3299//      String path = "entry:instrument:collimator:geometry:shape:shape"
3300
3301        Make/O/T/N=1 tmpTW
3302        String groupName = "/entry/instrument/collimator/geometry/shape"        //     
3303        String varName = "shape"
3304        tmpTW[0] = str //
3305
3306        variable err
3307        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3308        if(err)
3309                Print "HDF write err = ",err
3310        endif
3311       
3312        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3313//      err = V_KillNamedDataFolder(fname)
3314//      if(err)
3315//              Print "DataFolder kill err = ",err
3316//      endif
3317               
3318        return(err)
3319End
3320
3321// TODO -- this may need to be a wave to properly describe the dimensions
3322Function V_writeGuideSize(fname,val)
3323        String fname
3324        Variable val
3325
3326//      String path = "entry:instrument:collimator:geometry:shape:size"
3327       
3328        Make/O/D/N=1 wTmpWrite
3329//      Make/O/R/N=1 wTmpWrite
3330        String groupName = "/entry/instrument/collimator/geometry/shape"       
3331        String varName = "size"
3332        wTmpWrite[0] = val
3333
3334        variable err
3335        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3336        if(err)
3337                Print "HDF write err = ",err
3338        endif
3339        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3340//      err = V_KillNamedDataFolder(fname)
3341//      if(err)
3342//              Print "DataFolder kill err = ",err
3343//      endif
3344        return(err)
3345End
3346
3347//                      converging_pinholes (data folder)
3348Function V_writeConvPinholeStatus(fname,str)
3349        String fname,str
3350
3351//      String path = "entry:instrument:converging_pinholes:status"
3352
3353        Make/O/T/N=1 tmpTW
3354        String groupName = "/entry/instrument/converging_pinholes"      //     
3355        String varName = "status"
3356        tmpTW[0] = str //
3357
3358        variable err
3359        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3360        if(err)
3361                Print "HDF write err = ",err
3362        endif
3363       
3364        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3365//      err = V_KillNamedDataFolder(fname)
3366//      if(err)
3367//              Print "DataFolder kill err = ",err
3368//      endif
3369               
3370        return(err)
3371End
3372
3373//                      converging_slits (not used)
3374
3375
3376
3377
3378
3379
3380////// INSTRUMENT/DETECTORS
3381//                      detector_B (data folder)
3382//
3383// only defined for the "B" detector, and may not be necessary?
3384// TODO -- write to return an ARRAY
3385Function V_writeDet_cal_x(fname,detStr,inW)
3386        String fname,detStr
3387        Wave inW
3388
3389        if(cmpstr(detStr,"B") == 0)
3390//              String path = "entry:instrument:detector_"+detStr+":CALX"
3391               
3392                Duplicate/O inW wTmpWrite       
3393        // then use redimension as needed to cast the wave to write to the specified type
3394        // see WaveType for the proper codes
3395        //      Redimension/T=() wTmpWrite
3396        // -- May also need to check the dimension(s) before writing (don't trust the input)
3397                String groupName = "/entry/instrument/detector_"+detStr
3398                String varName = "cal_x"
3399
3400                variable err
3401                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3402                if(err)
3403                        Print "HDF write err = ",err
3404                endif
3405                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3406//              err = V_KillNamedDataFolder(fname)
3407//              if(err)
3408//                      Print "DataFolder kill err = ",err
3409//              endif
3410                return(err)
3411        else
3412                return(0)
3413        endif
3414End
3415
3416// only defined for the "B" detector, and may not be necessary?
3417// TODO -- write to return an ARRAY
3418Function V_writeDet_cal_y(fname,detStr,inW)
3419        String fname,detStr
3420        Wave inW
3421
3422        if(cmpstr(detStr,"B") == 0)
3423//              String path = "entry:instrument:detector_"+detStr+":CALY"
3424
3425                Duplicate/O inW wTmpWrite       
3426        // then use redimension as needed to cast the wave to write to the specified type
3427        // see WaveType for the proper codes
3428        //      Redimension/T=() wTmpWrite
3429        // -- May also need to check the dimension(s) before writing (don't trust the input)
3430                String groupName = "/entry/instrument/detector_"+detStr
3431                String varName = "cal_y"
3432
3433                variable err
3434                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3435                if(err)
3436                        Print "HDF write err = ",err
3437                endif
3438                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3439//              err = V_KillNamedDataFolder(fname)
3440//              if(err)
3441//                      Print "DataFolder kill err = ",err
3442//              endif
3443                return(err)
3444        else
3445                return(0)
3446        endif
3447End
3448
3449// TODO -- write and X and Y version of this. Pixels are not square
3450// so the FHWM will be different in each direction. May need to return
3451// "dummy" value for "B" detector if pixels there are square
3452Function V_writeDet_pixel_fwhm_x(fname,detStr,val)
3453        String fname,detStr
3454        Variable val
3455
3456//      String path = "entry:instrument:detector_"+detStr+":pixel_fwhm_x"
3457       
3458        Make/O/D/N=1 wTmpWrite
3459//      Make/O/R/N=1 wTmpWrite
3460        String groupName = "/entry/instrument/detector_"+detStr
3461        String varName = "pixel_fwhm_x"
3462        wTmpWrite[0] = val
3463
3464        variable err
3465        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3466        if(err)
3467                Print "HDF write err = ",err
3468        endif
3469        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3470//      err = V_KillNamedDataFolder(fname)
3471//      if(err)
3472//              Print "DataFolder kill err = ",err
3473//      endif
3474        return(err)
3475End
3476
3477
3478// TODO -- write and X and Y version of this. Pixels are not square
3479// so the FHWM will be different in each direction. May need to return
3480// "dummy" value for "B" detector if pixels there are square
3481Function V_writeDet_pixel_fwhm_y(fname,detStr,val)
3482        String fname,detStr
3483        Variable val
3484
3485//      String path = "entry:instrument:detector_"+detStr+":pixel_fwhm_y"
3486       
3487        Make/O/D/N=1 wTmpWrite
3488//      Make/O/R/N=1 wTmpWrite
3489        String groupName = "/entry/instrument/detector_"+detStr
3490        String varName = "pixel_fwhm_y"
3491        wTmpWrite[0] = val
3492
3493        variable err
3494        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3495        if(err)
3496                Print "HDF write err = ",err
3497        endif
3498        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3499//      err = V_KillNamedDataFolder(fname)
3500//      if(err)
3501//              Print "DataFolder kill err = ",err
3502//      endif
3503        return(err)
3504End
3505
3506// integer value
3507Function V_writeDet_pixel_num_x(fname,detStr,val)
3508        String fname,detStr
3509        Variable val
3510
3511//      String path = "entry:instrument:detector_"+detStr+":pixel_nnum_x"
3512       
3513        Make/O/I/N=1 wTmpWrite
3514//      Make/O/R/N=1 wTmpWrite
3515        String groupName = "/entry/instrument/detector_"+detStr
3516        String varName = "pixel_num_x"
3517        wTmpWrite[0] = val
3518
3519        variable err
3520        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3521        if(err)
3522                Print "HDF write err = ",err
3523        endif
3524        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3525//      err = V_KillNamedDataFolder(fname)
3526//      if(err)
3527//              Print "DataFolder kill err = ",err
3528//      endif
3529        return(err)
3530End
3531
3532// integer value
3533Function V_writeDet_pixel_num_y(fname,detStr,val)
3534        String fname,detStr
3535        Variable val
3536
3537//      String path = "entry:instrument:detector_"+detStr+":pixel_num_y"
3538       
3539        Make/O/I/N=1 wTmpWrite
3540//      Make/O/R/N=1 wTmpWrite
3541        String groupName = "/entry/instrument/detector_"+detStr
3542        String varName = "pixel_num_y"
3543        wTmpWrite[0] = val
3544
3545        variable err
3546        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3547        if(err)
3548                Print "HDF write err = ",err
3549        endif
3550        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3551//      err = V_KillNamedDataFolder(fname)
3552//      if(err)
3553//              Print "DataFolder kill err = ",err
3554//      endif
3555        return(err)
3556End
3557
3558//// only defined for the "B" detector, and only to satisfy NXsas
3559//Function V_writeDet_azimuthalAngle(fname,detStr,val)
3560//      String fname,detStr
3561//      Variable val
3562//
3563//      if(cmpstr(detStr,"B") == 0)
3564////            String path = "entry:instrument:detector_"+detStr+":azimuthal_angle"
3565//     
3566//              Make/O/D/N=1 wTmpWrite
3567//      //      Make/O/R/N=1 wTmpWrite
3568//              String groupName = "/entry/instrument/detector_"+detStr
3569//              String varName = "azimuthal_angle"
3570//              wTmpWrite[0] = val
3571//
3572//              variable err
3573//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3574//              if(err)
3575//                      Print "HDF write err = ",err
3576//              endif
3577//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3578////            err = V_KillNamedDataFolder(fname)
3579////            if(err)
3580////                    Print "DataFolder kill err = ",err
3581////            endif
3582//              return(err)
3583//      else
3584//              return(0)
3585//      endif
3586//End
3587
3588Function V_writeDet_beam_center_x(fname,detStr,val)
3589        String fname,detStr
3590        Variable val
3591
3592//      String path = "entry:instrument:detector_"+detStr+":beam_center_x"
3593       
3594        Make/O/D/N=1 wTmpWrite
3595//      Make/O/R/N=1 wTmpWrite
3596        String groupName = "/entry/instrument/detector_"+detStr
3597        String varName = "beam_center_x"
3598        wTmpWrite[0] = val
3599
3600        variable err
3601        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3602        if(err)
3603                Print "HDF write err = ",err
3604        endif
3605        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3606//      err = V_KillNamedDataFolder(fname)
3607//      if(err)
3608//              Print "DataFolder kill err = ",err
3609//      endif
3610        return(err)
3611End
3612
3613// fname is a local WORK folder
3614Function V_putDet_beam_center_x(fname,detStr,val)
3615        String fname,detStr
3616        Variable val
3617
3618//root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:beam_center_x
3619        String path = "root:Packages:NIST:VSANS:"+fname+":"
3620        path += "entry:instrument:detector_"+detStr+":beam_center_x"
3621       
3622        Wave/Z w = $path
3623        if(waveExists(w) == 0)
3624                return(1)
3625        else
3626        w[0] = val
3627                return(0)
3628        endif
3629
3630End
3631
3632Function V_writeDet_beam_center_y(fname,detStr,val)
3633        String fname,detStr
3634        Variable val
3635
3636//      String path = "entry:instrument:detector_"+detStr+":beam_center_y"
3637       
3638        Make/O/D/N=1 wTmpWrite
3639//      Make/O/R/N=1 wTmpWrite
3640        String groupName = "/entry/instrument/detector_"+detStr
3641        String varName = "beam_center_y"
3642        wTmpWrite[0] = val
3643
3644        variable err
3645        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3646        if(err)
3647                Print "HDF write err = ",err
3648        endif
3649        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3650//      err = V_KillNamedDataFolder(fname)
3651//      if(err)
3652//              Print "DataFolder kill err = ",err
3653//      endif
3654        return(err)
3655End
3656
3657
3658// fname is a local WORK folder
3659Function V_putDet_beam_center_y(fname,detStr,val)
3660        String fname,detStr
3661        Variable val
3662
3663//root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:beam_center_y
3664        String path = "root:Packages:NIST:VSANS:"+fname+":"
3665        path += "entry:instrument:detector_"+detStr+":beam_center_y"
3666       
3667        Wave/Z w = $path
3668        if(waveExists(w) == 0)
3669                return(1)
3670        else
3671        w[0] = val
3672                return(0)
3673        endif
3674
3675End
3676
3677
3678// TODO -- write this function to return a WAVE with the data
3679// either as a wave reference, or as an input parameter
3680Function V_writeDetectorData(fname,detStr,inW)
3681        String fname,detStr
3682        Wave inW
3683
3684//      String path = "entry:instrument:detector_"+detStr+":data"
3685       
3686        Duplicate/O inW wTmpWrite       
3687// then use redimension as needed to cast the wave to write to the specified type
3688// see WaveType for the proper codes
3689//      Redimension/T=() wTmpWrite
3690// -- May also need to check the dimension(s) before writing (don't trust the input)
3691        String groupName = "/entry/instrument/detector_"+detStr
3692        String varName = "data"
3693
3694        variable err
3695        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3696        if(err)
3697                Print "HDF write err = ",err
3698        endif
3699        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3700//      err = V_KillNamedDataFolder(fname)
3701//      if(err)
3702//              Print "DataFolder kill err = ",err
3703//      endif
3704        return(err)
3705End
3706
3707
3708
3709/////////////////////////
3710
3711
3712// TODO -- write this function to return a WAVE with the data
3713// either as a wave reference, or as an input parameter
3714// ALSO -- the "B" deadtime will be a single value (probably)
3715//  but the tube banks will be 1D arrays of values, one per tube
3716Function V_writeDetector_deadtime(fname,detStr,inW)
3717        String fname,detStr
3718        Wave inW
3719
3720//      String path = "entry:instrument:detector_"+detStr+":dead_time"
3721        if(cmpstr(detStr,"B") == 0)
3722                DoAlert 0,"Bad call to V_writeDetector_deadtime"
3723                return(0)
3724        else
3725
3726                Duplicate/O inW wTmpWrite       
3727        // then use redimension as needed to cast the wave to write to the specified type
3728        // see WaveType for the proper codes
3729        //      Redimension/T=() wTmpWrite
3730        // -- May also need to check the dimension(s) before writing (don't trust the input)
3731                String groupName = "/entry/instrument/detector_"+detStr
3732                String varName = "dead_time"
3733       
3734                variable err
3735                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3736                if(err)
3737                        Print "HDF write err = ",err
3738                endif
3739                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3740        //      err = V_KillNamedDataFolder(fname)
3741        //      if(err)
3742        //              Print "DataFolder kill err = ",err
3743        //      endif
3744                return(err)
3745        endif
3746End
3747
3748// dead time, a single value, only for detB
3749Function V_writeDetector_deadtime_B(fname,detStr,val)
3750        String fname,detStr
3751        variable val
3752
3753//      String path = "entry:instrument:detector_"+detStr+":dead_time"
3754        if(cmpstr(detStr,"B") == 0)
3755       
3756                Make/O/D/N=1 wTmpWrite
3757        //      Make/O/R/N=1 wTmpWrite
3758                String groupName = "/entry/instrument/detector_"+detStr
3759                String varName = "dead_time"
3760                wTmpWrite[0] = val
3761       
3762                variable err
3763                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3764                if(err)
3765                        Print "HDF write err = ",err
3766                endif
3767                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3768        //      err = V_KillNamedDataFolder(fname)
3769        //      if(err)
3770        //              Print "DataFolder kill err = ",err
3771        //      endif
3772       
3773                return(err)     
3774        else
3775                DoAlert 0,"Bad call to V_writeDetector_deadtime_B"
3776                return(0)
3777        endif
3778End
3779
3780Function V_writeDetDescription(fname,detStr,str)
3781        String fname,detStr,str
3782
3783//      String path = "entry:instrument:detector_"+detStr+":description"
3784
3785        Make/O/T/N=1 tmpTW
3786        String groupName = "/entry/instrument/detector_"+detStr //     
3787        String varName = "description"
3788        tmpTW[0] = str //
3789
3790        variable err
3791        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3792        if(err)
3793                Print "HDF write err = ",err
3794        endif
3795       
3796        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3797//      err = V_KillNamedDataFolder(fname)
3798//      if(err)
3799//              Print "DataFolder kill err = ",err
3800//      endif
3801               
3802        return(err)
3803End
3804
3805Function V_writeDet_distance(fname,detStr,val)
3806        String fname,detStr
3807        variable val
3808
3809//      String path = "entry:instrument:detector_"+detStr+":distance"
3810       
3811        Make/O/D/N=1 wTmpWrite
3812//      Make/O/R/N=1 wTmpWrite
3813        String groupName = "/entry/instrument/detector_"+detStr
3814        String varName = "distance"
3815        wTmpWrite[0] = val
3816
3817        variable err
3818        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3819        if(err)
3820                Print "HDF write err = ",err
3821        endif
3822        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3823//      err = V_KillNamedDataFolder(fname)
3824//      if(err)
3825//              Print "DataFolder kill err = ",err
3826//      endif
3827        return(err)
3828End
3829
3830//// only defined for the "B" detector, and only to satisfy NXsas
3831//Function V_writeDet_equatorial_angle(fname,detStr,val)
3832//      String fname,detStr
3833//      variable val
3834//
3835//      if(cmpstr(detStr,"B") == 0)
3836////            String path = "entry:instrument:detector_"+detStr+":equatorial_angle"
3837//     
3838//              Make/O/D/N=1 wTmpWrite
3839//      //      Make/O/R/N=1 wTmpWrite
3840//              String groupName = "/entry/instrument/detector_"+detStr
3841//              String varName = "equatorial_angle"
3842//              wTmpWrite[0] = val
3843//
3844//              variable err
3845//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3846//              if(err)
3847//                      Print "HDF write err = ",err
3848//              endif
3849//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3850////            err = V_KillNamedDataFolder(fname)
3851////            if(err)
3852////                    Print "DataFolder kill err = ",err
3853////            endif
3854//              return(err)
3855//      else
3856//              return(0)
3857//      endif
3858//End
3859
3860Function V_writeDetEventFileName(fname,detStr,str)
3861        String fname,detStr,str
3862
3863//      String path = "entry:instrument:detector_"+detStr+":event_file_name"
3864
3865        Make/O/T/N=1 tmpTW
3866        String groupName = "/entry/instrument/detector_"+detStr //     
3867        String varName = "event_file_name"
3868        tmpTW[0] = str //
3869
3870        variable err
3871        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3872        if(err)
3873                Print "HDF write err = ",err
3874        endif
3875       
3876        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3877//      err = V_KillNamedDataFolder(fname)
3878//      if(err)
3879//              Print "DataFolder kill err = ",err
3880//      endif
3881               
3882        return(err)
3883End
3884
3885Function V_writeDet_IntegratedCount(fname,detStr,val)
3886        String fname,detStr
3887        Variable val
3888
3889//      String path = "entry:instrument:detector_"+detStr+":integrated_count"
3890       
3891        Make/O/D/N=1 wTmpWrite
3892//      Make/O/R/N=1 wTmpWrite
3893        String groupName = "/entry/instrument/detector_"+detStr
3894        String varName = "integrated_count"
3895        wTmpWrite[0] = val
3896
3897        variable err
3898        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3899        if(err)
3900                Print "HDF write err = ",err
3901        endif
3902        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3903//      err = V_KillNamedDataFolder(fname)
3904//      if(err)
3905//              Print "DataFolder kill err = ",err
3906//      endif
3907        return(err)
3908End
3909
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
3936// TODO - be sure that this is defined correctly
3937// -- it needs to exist in the data file, and only for TB detector panels
3938Function V_writeDet_TBSetback(fname,detStr,val)
3939        String fname,detStr
3940        Variable val
3941
3942//      String path = "entry:instrument:detector_"+detStr+":setback"
3943       
3944        if(cmpstr(detStr,"B") == 0)
3945                return(0)
3946        endif
3947        if(cmpstr(detStr,"FR") == 0 || cmpstr(detStr,"FL") == 0)
3948                return(0)
3949        endif
3950        if(cmpstr(detStr,"MR") == 0 || cmpstr(detStr,"ML") == 0)
3951                return(0)
3952        endif   
3953       
3954        Make/O/D/N=1 wTmpWrite
3955//      Make/O/R/N=1 wTmpWrite
3956        String groupName = "/entry/instrument/detector_"+detStr
3957        String varName = "setback"
3958        wTmpWrite[0] = val
3959
3960        variable err
3961        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3962        if(err)
3963                Print "HDF write err = ",err
3964        endif
3965        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3966//      err = V_KillNamedDataFolder(fname)
3967//      if(err)
3968//              Print "DataFolder kill err = ",err
3969//      endif
3970        return(err)
3971End
3972
3973
3974       
3975
3976//Function V_writeDet_VerticalOffset(fname,detStr,val)
3977//      String fname,detStr
3978//      Variable val
3979//
3980////    String path = "entry:instrument:detector_"+detStr+":vertical_offset"
3981//     
3982//      Make/O/D/N=1 wTmpWrite
3983////    Make/O/R/N=1 wTmpWrite
3984//      String groupName = "/entry/instrument/detector_"+detStr
3985//      String varName = "vertical_offset"
3986//      wTmpWrite[0] = val
3987//
3988//      variable err
3989//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3990//      if(err)
3991//              Print "HDF write err = ",err
3992//      endif
3993//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3994////    err = V_KillNamedDataFolder(fname)
3995////    if(err)
3996////            Print "DataFolder kill err = ",err
3997////    endif
3998//      return(err)
3999//End
4000
4001//// only defined for the "B" detector, and only to satisfy NXsas
4002//Function V_writeDet_polar_angle(fname,detStr,val)
4003//      String fname,detStr
4004//      Variable val
4005//
4006//      if(cmpstr(detStr,"B") == 0)
4007////            String path = "entry:instrument:detector_"+detStr+":polar_angle"
4008//     
4009//              Make/O/D/N=1 wTmpWrite
4010//      //      Make/O/R/N=1 wTmpWrite
4011//              String groupName = "/entry/instrument/detector_"+detStr
4012//              String varName = "polar_angle"
4013//              wTmpWrite[0] = val
4014//
4015//              variable err
4016//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4017//              if(err)
4018//                      Print "HDF write err = ",err
4019//              endif
4020//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4021////            err = V_KillNamedDataFolder(fname)
4022////            if(err)
4023////                    Print "DataFolder kill err = ",err
4024////            endif
4025//              return(err)
4026//      else
4027//              return(0)
4028//      endif
4029//End
4030
4031//// only defined for the "B" detector, and only to satisfy NXsas
4032//Function V_writeDet_rotational_angle(fname,detStr,val)
4033//      String fname,detStr
4034//      Variable val
4035//
4036//      if(cmpstr(detStr,"B") == 0)
4037////            String path = "entry:instrument:detector_"+detStr+":rotational_angle"
4038//     
4039//              Make/O/D/N=1 wTmpWrite
4040//      //      Make/O/R/N=1 wTmpWrite
4041//              String groupName = "/entry/instrument/detector_"+detStr
4042//              String varName = "rotational_angle"
4043//              wTmpWrite[0] = val
4044//
4045//              variable err
4046//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4047//              if(err)
4048//                      Print "HDF write err = ",err
4049//              endif
4050//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4051////            err = V_KillNamedDataFolder(fname)
4052////            if(err)
4053////                    Print "DataFolder kill err = ",err
4054////            endif
4055//              return(err)
4056//      else
4057//              return(0)
4058//      endif
4059//End
4060
4061Function V_writeDetSettings(fname,detStr,str)
4062        String fname,detStr,str
4063
4064//      String path = "entry:instrument:detector_"+detStr+":settings"
4065
4066        Make/O/T/N=1 tmpTW
4067        String groupName = "/entry/instrument/detector_"+detStr //     
4068        String varName = "settings"
4069        tmpTW[0] = str //
4070
4071        variable err
4072        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4073        if(err)
4074                Print "HDF write err = ",err
4075        endif
4076       
4077        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4078//      err = V_KillNamedDataFolder(fname)
4079//      if(err)
4080//              Print "DataFolder kill err = ",err
4081//      endif
4082               
4083        return(err)
4084End
4085
4086//// really has no meaning at all
4087//Function V_writeDet_size(fname,detStr,val)
4088//      String fname,detStr
4089//      Variable val
4090//
4091////    String path = "entry:instrument:detector_"+detStr+":size"
4092//     
4093//      Make/O/D/N=1 wTmpWrite
4094////    Make/O/R/N=1 wTmpWrite
4095//      String groupName = "/entry/instrument/detector_"+detStr
4096//      String varName = "size"
4097//      wTmpWrite[0] = val
4098//
4099//      variable err
4100//      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4101//      if(err)
4102//              Print "HDF write err = ",err
4103//      endif
4104//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4105////    err = V_KillNamedDataFolder(fname)
4106////    if(err)
4107////            Print "DataFolder kill err = ",err
4108////    endif
4109//      return(err)
4110//End
4111
4112Function V_writeDetType(fname,detStr,str)
4113        String fname,detStr,str
4114
4115//      String path = "entry:instrument:detector_"+detStr+":type"
4116
4117        Make/O/T/N=1 tmpTW
4118        String groupName = "/entry/instrument/detector_"+detStr //     
4119        String varName = "type"
4120        tmpTW[0] = str //
4121
4122        variable err
4123        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4124        if(err)
4125                Print "HDF write err = ",err
4126        endif
4127       
4128        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4129//      err = V_KillNamedDataFolder(fname)
4130//      if(err)
4131//              Print "DataFolder kill err = ",err
4132//      endif
4133               
4134        return(err)
4135End
4136
4137Function V_writeDet_x_pixel_size(fname,detStr,val)
4138        String fname,detStr
4139        Variable val
4140
4141//      String path = "entry:instrument:detector_"+detStr+":x_pixel_size"
4142       
4143        Make/O/D/N=1 wTmpWrite
4144//      Make/O/R/N=1 wTmpWrite
4145        String groupName = "/entry/instrument/detector_"+detStr
4146        String varName = "x_pixel_size"
4147        wTmpWrite[0] = val
4148
4149        variable err
4150        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4151        if(err)
4152                Print "HDF write err = ",err
4153        endif
4154        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4155//      err = V_KillNamedDataFolder(fname)
4156//      if(err)
4157//              Print "DataFolder kill err = ",err
4158//      endif
4159        return(err)
4160End
4161
4162Function V_writeDet_y_pixel_size(fname,detStr,val)
4163        String fname,detStr
4164        Variable val
4165
4166//      String path = "entry:instrument:detector_"+detStr+":y_pixel_size"
4167       
4168        Make/O/D/N=1 wTmpWrite
4169//      Make/O/R/N=1 wTmpWrite
4170        String groupName = "/entry/instrument/detector_"+detStr
4171        String varName = "y_pixel_size"
4172        wTmpWrite[0] = val
4173
4174        variable err
4175        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4176        if(err)
4177                Print "HDF write err = ",err
4178        endif
4179        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4180//      err = V_KillNamedDataFolder(fname)
4181//      if(err)
4182//              Print "DataFolder kill err = ",err
4183//      endif
4184        return(err)
4185End
4186
4187/////////                       detector_FB (data folder) + ALL other PANEL DETECTORS
4188
4189// integer value
4190Function V_writeDet_numberOfTubes(fname,detStr,val)
4191        String fname,detStr
4192        Variable val
4193
4194//      String path = "entry:instrument:detector_"+detStr+":number_of_tubes"
4195        if(cmpstr(detStr,"B") == 0)
4196                return(0)
4197        else
4198       
4199                Make/O/I/N=1 wTmpWrite
4200        //      Make/O/R/N=1 wTmpWrite
4201                String groupName = "/entry/instrument/detector_"+detStr
4202                String varName = "number_of_tubes"
4203                wTmpWrite[0] = val
4204
4205                variable err
4206                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4207                if(err)
4208                        Print "HDF write err = ",err
4209                endif
4210                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4211//              err = V_KillNamedDataFolder(fname)
4212//              if(err)
4213//                      Print "DataFolder kill err = ",err
4214//              endif
4215                return(err)
4216        endif
4217End
4218
4219// TODO -- be clear on how this is defined. Separation as defined from what point? Units?
4220Function V_writeDetPanelSeparation(fname,detStr,val)
4221        String fname,detStr
4222        Variable val
4223
4224//      String path = "entry:instrument:detector_"+detStr+":separation"
4225        if(cmpstr(detStr,"B") == 0)
4226                return(0)
4227        else
4228       
4229                Make/O/D/N=1 wTmpWrite
4230        //      Make/O/R/N=1 wTmpWrite
4231                String groupName = "/entry/instrument/detector_"+detStr
4232                String varName = "separation"
4233                wTmpWrite[0] = val
4234
4235                variable err
4236                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4237                if(err)
4238                        Print "HDF write err = ",err
4239                endif
4240                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4241//              err = V_KillNamedDataFolder(fname)
4242//              if(err)
4243//                      Print "DataFolder kill err = ",err
4244//              endif
4245                return(err)
4246        endif
4247End
4248
4249// TODO -- write this function to return a WAVE with the data
4250// either as a wave reference, or as an input parameter
4251Function V_writeDetTube_spatialCalib(fname,detStr,inW)
4252        String fname,detStr
4253        Wave inW
4254
4255//      String path = "entry:instrument:detector_"+detStr+":spatial_calibration"
4256
4257        if(cmpstr(detStr,"B") == 0)
4258                return(0)
4259        else
4260                Duplicate/O inW wTmpWrite       
4261        // then use redimension as needed to cast the wave to write to the specified type
4262        // see WaveType for the proper codes
4263        //      Redimension/T=() wTmpWrite
4264        // -- May also need to check the dimension(s) before writing (don't trust the input)
4265                String groupName = "/entry/instrument/detector_"+detStr
4266                String varName = "spatial_calibration"
4267
4268                variable err
4269                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4270                if(err)
4271                        Print "HDF write err = ",err
4272                endif
4273                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4274//              err = V_KillNamedDataFolder(fname)
4275//              if(err)
4276//                      Print "DataFolder kill err = ",err
4277//              endif
4278                return(err)
4279        endif
4280End
4281
4282//// TODO -- be clear on how this is defined.
4283//Function V_writeDet_tubeIndex(fname,detStr,val)
4284//      String fname,detStr
4285//      Variable val
4286//
4287////    String path = "entry:instrument:detector_"+detStr+":tube_index"
4288//      if(cmpstr(detStr,"B") == 0)
4289//              return(0)
4290//      else
4291//     
4292//              Make/O/D/N=1 wTmpWrite
4293//      //      Make/O/R/N=1 wTmpWrite
4294//              String groupName = "/entry/instrument/detector_"+detStr
4295//              String varName = "tube_index"
4296//              wTmpWrite[0] = val
4297//
4298//              variable err
4299//              err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4300//              if(err)
4301//                      Print "HDF write err = ",err
4302//              endif
4303//              // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4304////            err = V_KillNamedDataFolder(fname)
4305////            if(err)
4306////                    Print "DataFolder kill err = ",err
4307////            endif
4308//              return(err)
4309//      endif
4310//End
4311
4312Function V_writeDet_tubeOrientation(fname,detStr,str)
4313        String fname,detStr,str
4314
4315//      String path = "entry:instrument:detector_"+detStr+":tube_orientation"
4316
4317        if(cmpstr(detStr,"B") == 0)
4318                return(0)
4319        else
4320                Make/O/T/N=1 tmpTW
4321                String groupName = "/entry/instrument/detector_"+detStr //     
4322                String varName = "tube_orientation"
4323                tmpTW[0] = str //
4324
4325                variable err
4326                err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4327                if(err)
4328                        Print "HDF write err = ",err
4329                endif
4330       
4331                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4332//              err = V_KillNamedDataFolder(fname)
4333//              if(err)
4334//                      Print "DataFolder kill err = ",err
4335//              endif
4336               
4337                return(err)
4338
4339        endif
4340End
4341
4342// TODO -- be clear on how this is defined. Units?
4343Function V_writeDet_tubeWidth(fname,detStr,val)
4344        String fname,detStr
4345        Variable val
4346
4347//      String path = "entry:instrument:detector_"+detStr+":tube_width"
4348        if(cmpstr(detStr,"B") == 0)
4349                return(0)
4350        else
4351       
4352                Make/O/D/N=1 wTmpWrite
4353        //      Make/O/R/N=1 wTmpWrite
4354                String groupName = "/entry/instrument/detector_"+detStr
4355                String varName = "tube_width"
4356                wTmpWrite[0] = val
4357
4358                variable err
4359                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4360                if(err)
4361                        Print "HDF write err = ",err
4362                endif
4363                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4364//              err = V_KillNamedDataFolder(fname)
4365//              if(err)
4366//                      Print "DataFolder kill err = ",err
4367//              endif
4368                return(err)
4369        endif
4370End
4371
4372//////////////////////
4373
4374// INSTRUMENT/LENSES    /APERTURES
4375//  lenses (data folder)
4376
4377Function V_writeLensCurvature(fname,val)
4378        String fname
4379        Variable val
4380
4381//      String path = "entry:instrument:lenses:curvature"
4382       
4383        Make/O/D/N=1 wTmpWrite
4384//      Make/O/R/N=1 wTmpWrite
4385        String groupName = "/entry/instrument/lenses"
4386        String varName = "curvature"
4387        wTmpWrite[0] = val
4388
4389        variable err
4390        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4391        if(err)
4392                Print "HDF write err = ",err
4393        endif
4394        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4395//      err = V_KillNamedDataFolder(fname)
4396//      if(err)
4397//              Print "DataFolder kill err = ",err
4398//      endif
4399        return(err)
4400End
4401
4402Function V_writeLensesFocusType(fname,str)
4403        String fname,str
4404
4405//      String path = "entry:instrument:lenses:focus_type"
4406
4407        Make/O/T/N=1 tmpTW
4408        String groupName = "/entry/instrument/lenses"
4409        String varName = "focus_type"
4410        tmpTW[0] = str //
4411
4412        variable err
4413        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4414        if(err)
4415                Print "HDF write err = ",err
4416        endif
4417       
4418        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4419//      err = V_KillNamedDataFolder(fname)
4420//      if(err)
4421//              Print "DataFolder kill err = ",err
4422//      endif
4423               
4424        return(err)
4425End
4426
4427Function V_writeLensDistance(fname,val)
4428        String fname
4429        Variable val
4430
4431//      String path = "entry:instrument:lenses:lens_distance"
4432       
4433        Make/O/D/N=1 wTmpWrite
4434//      Make/O/R/N=1 wTmpWrite
4435        String groupName = "/entry/instrument/lenses"
4436        String varName = "lens_distance"
4437        wTmpWrite[0] = val
4438
4439        variable err
4440        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4441        if(err)
4442                Print "HDF write err = ",err
4443        endif
4444        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4445//      err = V_KillNamedDataFolder(fname)
4446//      if(err)
4447//              Print "DataFolder kill err = ",err
4448//      endif
4449        return(err)
4450End
4451
4452Function V_writeLensGeometry(fname,str)
4453        String fname,str
4454
4455//      String path = "entry:instrument:lenses:lens_geometry"
4456
4457        Make/O/T/N=1 tmpTW
4458        String groupName = "/entry/instrument/lenses"
4459        String varName = "lens_geometry"
4460        tmpTW[0] = str //
4461
4462        variable err
4463        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4464        if(err)
4465                Print "HDF write err = ",err
4466        endif
4467       
4468        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4469//      err = V_KillNamedDataFolder(fname)
4470//      if(err)
4471//              Print "DataFolder kill err = ",err
4472//      endif
4473               
4474        return(err)
4475End
4476
4477Function V_writeLensMaterial(fname,str)
4478        String fname,str
4479
4480//      String path = "entry:instrument:lenses:lens_material"
4481
4482        Make/O/T/N=1 tmpTW
4483        String groupName = "/entry/instrument/lenses"
4484        String varName = "lens_material"
4485        tmpTW[0] = str //
4486
4487        variable err
4488        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4489        if(err)
4490                Print "HDF write err = ",err
4491        endif
4492       
4493        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4494//      err = V_KillNamedDataFolder(fname)
4495//      if(err)
4496//              Print "DataFolder kill err = ",err
4497//      endif
4498               
4499        return(err)
4500End
4501
4502// integer value
4503Function V_writeNumber_of_Lenses(fname,val)
4504        String fname
4505        Variable val
4506
4507//      String path = "entry:instrument:lenses:number_of_lenses"
4508       
4509        Make/O/I/N=1 wTmpWrite
4510//      Make/O/R/N=1 wTmpWrite
4511        String groupName = "/entry/instrument/lenses"
4512        String varName = "number_of_lenses"
4513        wTmpWrite[0] = val
4514
4515        variable err
4516        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4517        if(err)
4518                Print "HDF write err = ",err
4519        endif
4520        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4521//      err = V_KillNamedDataFolder(fname)
4522//      if(err)
4523//              Print "DataFolder kill err = ",err
4524//      endif
4525        return(err)
4526End
4527
4528// integer value
4529Function V_writeNumber_of_prisms(fname,val)
4530        String fname
4531        Variable val
4532
4533//      String path = "entry:instrument:lenses:number_of_prisms"
4534       
4535        Make/O/I/N=1 wTmpWrite
4536//      Make/O/R/N=1 wTmpWrite
4537        String groupName = "/entry/instrument/lenses"
4538        String varName = "number_of_prisms"
4539        wTmpWrite[0] = val
4540
4541        variable err
4542        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4543        if(err)
4544                Print "HDF write err = ",err
4545        endif
4546        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4547//      err = V_KillNamedDataFolder(fname)
4548//      if(err)
4549//              Print "DataFolder kill err = ",err
4550//      endif
4551        return(err)
4552End
4553
4554Function V_writePrism_distance(fname,val)
4555        String fname
4556        Variable val
4557
4558//      String path = "entry:instrument:lenses:prism_distance"
4559       
4560        Make/O/D/N=1 wTmpWrite
4561//      Make/O/R/N=1 wTmpWrite
4562        String groupName = "/entry/instrument/lenses"
4563        String varName = "prism_distance"
4564        wTmpWrite[0] = val
4565
4566        variable err
4567        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4568        if(err)
4569                Print "HDF write err = ",err
4570        endif
4571        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4572//      err = V_KillNamedDataFolder(fname)
4573//      if(err)
4574//              Print "DataFolder kill err = ",err
4575//      endif
4576        return(err)
4577End
4578
4579Function V_writePrismMaterial(fname,str)
4580        String fname,str
4581
4582//      String path = "entry:instrument:lenses:prism_material"
4583
4584        Make/O/T/N=1 tmpTW
4585        String groupName = "/entry/instrument/lenses"
4586        String varName = "prism_material"
4587        tmpTW[0] = str //
4588
4589        variable err
4590        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4591        if(err)
4592                Print "HDF write err = ",err
4593        endif
4594       
4595        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4596//      err = V_KillNamedDataFolder(fname)
4597//      if(err)
4598//              Print "DataFolder kill err = ",err
4599//      endif
4600               
4601        return(err)
4602End
4603
4604// status of lens/prism = lens | prism | both | out
4605Function V_writeLensPrismStatus(fname,str)
4606        String fname,str
4607
4608//      String path = "entry:instrument:lenses:status"
4609
4610        Make/O/T/N=1 tmpTW
4611        String groupName = "/entry/instrument/lenses"
4612        String varName = "status"
4613        tmpTW[0] = str //
4614
4615        variable err
4616        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4617        if(err)
4618                Print "HDF write err = ",err
4619        endif
4620       
4621        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4622//      err = V_KillNamedDataFolder(fname)
4623//      if(err)
4624//              Print "DataFolder kill err = ",err
4625//      endif
4626               
4627        return(err)
4628End
4629       
4630
4631///////  sample_aperture (data folder)
4632
4633Function V_writeSampleAp_Description(fname,str)
4634        String fname,str
4635
4636//      String path = "entry:instrument:sample_aperture:description"
4637
4638        Make/O/T/N=1 tmpTW
4639        String groupName = "/entry/instrument/sample_aperture"
4640        String varName = "description"
4641        tmpTW[0] = str //
4642
4643        variable err
4644        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4645        if(err)
4646                Print "HDF write err = ",err
4647        endif
4648       
4649        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4650//      err = V_KillNamedDataFolder(fname)
4651//      if(err)
4652//              Print "DataFolder kill err = ",err
4653//      endif
4654               
4655        return(err)
4656End
4657
4658Function V_writeSampleAp_distance(fname,val)
4659        String fname
4660        Variable val
4661
4662//      String path = "entry:instrument:sample_aperture:distance"
4663       
4664        Make/O/D/N=1 wTmpWrite
4665//      Make/O/R/N=1 wTmpWrite
4666        String groupName = "/entry/instrument/sample_aperture"
4667        String varName = "distance"
4668        wTmpWrite[0] = val
4669
4670        variable err
4671        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4672        if(err)
4673                Print "HDF write err = ",err
4674        endif
4675        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4676//      err = V_KillNamedDataFolder(fname)
4677//      if(err)
4678//              Print "DataFolder kill err = ",err
4679//      endif
4680        return(err)
4681End
4682
4683//      shape (data folder)
4684
4685Function V_writeSampleAp_shape(fname,str)
4686        String fname,str
4687
4688//      String path = "entry:instrument:sample_aperture:shape:shape"
4689
4690        Make/O/T/N=1 tmpTW
4691        String groupName = "/entry/instrument/sample_aperture/shape"
4692        String varName = "shape"
4693        tmpTW[0] = str //
4694
4695        variable err
4696        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4697        if(err)
4698                Print "HDF write err = ",err
4699        endif
4700       
4701        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4702//      err = V_KillNamedDataFolder(fname)
4703//      if(err)
4704//              Print "DataFolder kill err = ",err
4705//      endif
4706               
4707        return(err)
4708End
4709
4710Function V_writeSampleAp_height(fname,val)
4711        String fname
4712        Variable val
4713
4714//      String path = "entry:instrument:sample_aperture:distance"
4715       
4716        Make/O/D/N=1 wTmpWrite
4717//      Make/O/R/N=1 wTmpWrite
4718        String groupName = "/entry/instrument/sample_aperture/shape"
4719        String varName = "height"
4720        wTmpWrite[0] = val
4721
4722        variable err
4723        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4724        if(err)
4725                Print "HDF write err = ",err
4726        endif
4727        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4728//      err = V_KillNamedDataFolder(fname)
4729//      if(err)
4730//              Print "DataFolder kill err = ",err
4731//      endif
4732        return(err)
4733End
4734
4735Function V_writeSampleAp_size(fname,str)
4736        String fname,str
4737
4738//      String path = "entry:instrument:sample_aperture:shape:shape"
4739
4740        Make/O/T/N=1 tmpTW
4741        String groupName = "/entry/instrument/sample_aperture/shape"
4742        String varName = "size"
4743        tmpTW[0] = str //
4744
4745        variable err
4746        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4747        if(err)
4748                Print "HDF write err = ",err
4749        endif
4750       
4751        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4752//      err = V_KillNamedDataFolder(fname)
4753//      if(err)
4754//              Print "DataFolder kill err = ",err
4755//      endif
4756               
4757        return(err)
4758End
4759
4760Function V_writeSampleAp_width(fname,val)
4761        String fname
4762        Variable val
4763
4764//      String path = "entry:instrument:sample_aperture:distance"
4765       
4766        Make/O/D/N=1 wTmpWrite
4767//      Make/O/R/N=1 wTmpWrite
4768        String groupName = "/entry/instrument/sample_aperture/shape"
4769        String varName = "width"
4770        wTmpWrite[0] = val
4771
4772        variable err
4773        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4774        if(err)
4775                Print "HDF write err = ",err
4776        endif
4777        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4778//      err = V_KillNamedDataFolder(fname)
4779//      if(err)
4780//              Print "DataFolder kill err = ",err
4781//      endif
4782        return(err)
4783End
4784
4785///////  sample_aperture_2 (data folder)
4786
4787Function V_writeSampleAp2_Description(fname,str)
4788        String fname,str
4789
4790//      String path = "entry:instrument:sample_aperture_2:description"
4791
4792        Make/O/T/N=1 tmpTW
4793        String groupName = "/entry/instrument/sample_aperture_2"
4794        String varName = "description"
4795        tmpTW[0] = str //
4796
4797        variable err
4798        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4799        if(err)
4800                Print "HDF write err = ",err
4801        endif
4802       
4803        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4804//      err = V_KillNamedDataFolder(fname)
4805//      if(err)
4806//              Print "DataFolder kill err = ",err
4807//      endif
4808               
4809        return(err)
4810End
4811
4812Function V_writeSampleAp2_distance(fname,val)
4813        String fname
4814        Variable val
4815
4816//      String path = "entry:instrument:sample_aperture_2:distance"
4817       
4818        Make/O/D/N=1 wTmpWrite
4819//      Make/O/R/N=1 wTmpWrite
4820        String groupName = "/entry/instrument/sample_aperture_2"
4821        String varName = "distance"
4822        wTmpWrite[0] = val
4823
4824        variable err
4825        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4826        if(err)
4827                Print "HDF write err = ",err
4828        endif
4829        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4830//      err = V_KillNamedDataFolder(fname)
4831//      if(err)
4832//              Print "DataFolder kill err = ",err
4833//      endif
4834        return(err)
4835End
4836
4837
4838//      shape (data folder)
4839
4840Function V_writeSampleAp2_shape(fname,str)
4841        String fname,str
4842
4843//      String path = "entry:instrument:sample_aperture_2:shape:shape"
4844
4845        Make/O/T/N=1 tmpTW
4846        String groupName = "/entry/instrument/sample_aperture_2/shape"
4847        String varName = "shape"
4848        tmpTW[0] = str //
4849
4850        variable err
4851        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4852        if(err)
4853                Print "HDF write err = ",err
4854        endif
4855       
4856        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4857//      err = V_KillNamedDataFolder(fname)
4858//      if(err)
4859//              Print "DataFolder kill err = ",err
4860//      endif
4861               
4862        return(err)
4863End
4864
4865Function V_writeSampleAp2_height(fname,val)
4866        String fname
4867        Variable val
4868
4869//      String path = "entry:instrument:sample_aperture:distance"
4870       
4871        Make/O/D/N=1 wTmpWrite
4872//      Make/O/R/N=1 wTmpWrite
4873        String groupName = "/entry/instrument/sample_aperture_2/shape"
4874        String varName = "height"
4875        wTmpWrite[0] = val
4876
4877        variable err
4878        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4879        if(err)
4880                Print "HDF write err = ",err
4881        endif
4882        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4883//      err = V_KillNamedDataFolder(fname)
4884//      if(err)
4885//              Print "DataFolder kill err = ",err
4886//      endif
4887        return(err)
4888End
4889
4890Function V_writeSampleAp2_size(fname,val)
4891        String fname
4892        Variable val
4893
4894//      String path = "entry:instrument:sample_aperture:distance"
4895       
4896        Make/O/D/N=1 wTmpWrite
4897//      Make/O/R/N=1 wTmpWrite
4898        String groupName = "/entry/instrument/sample_aperture_2/shape"
4899        String varName = "size"
4900        wTmpWrite[0] = val
4901
4902        variable err
4903        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4904        if(err)
4905                Print "HDF write err = ",err
4906        endif
4907        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4908//      err = V_KillNamedDataFolder(fname)
4909//      if(err)
4910//              Print "DataFolder kill err = ",err
4911//      endif
4912        return(err)
4913End
4914
4915Function V_writeSampleAp2_width(fname,val)
4916        String fname
4917        Variable val
4918
4919//      String path = "entry:instrument:sample_aperture:distance"
4920       
4921        Make/O/D/N=1 wTmpWrite
4922//      Make/O/R/N=1 wTmpWrite
4923        String groupName = "/entry/instrument/sample_aperture_2/shape"
4924        String varName = "width"
4925        wTmpWrite[0] = val
4926
4927        variable err
4928        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4929        if(err)
4930                Print "HDF write err = ",err
4931        endif
4932        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4933//      err = V_KillNamedDataFolder(fname)
4934//      if(err)
4935//              Print "DataFolder kill err = ",err
4936//      endif
4937        return(err)
4938End
4939
4940               
4941//////  sample_table (data folder)
4942// location  = "CHAMBER" or HUBER
4943Function V_writeSampleTableLocation(fname,str)
4944        String fname,str
4945
4946//      String path = "entry:instrument:sample_table:location"
4947
4948        Make/O/T/N=1 tmpTW
4949        String groupName = "/entry/instrument/sample_table"
4950        String varName = "location"
4951        tmpTW[0] = str //
4952
4953        variable err
4954        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4955        if(err)
4956                Print "HDF write err = ",err
4957        endif
4958       
4959        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4960//      err = V_KillNamedDataFolder(fname)
4961//      if(err)
4962//              Print "DataFolder kill err = ",err
4963//      endif
4964               
4965        return(err)
4966End
4967
4968// TODO - verify the meaning
4969//      offset_distance (?? for center of sample table vs. sample position)
4970Function V_writeSampleTableOffset(fname,val)
4971        String fname
4972        Variable val
4973
4974//      String path = "entry:instrument:sample_table:offset_distance"
4975       
4976        Make/O/D/N=1 wTmpWrite
4977//      Make/O/R/N=1 wTmpWrite
4978        String groupName = "/entry/instrument/sample_table"
4979        String varName = "offset_distance"
4980        wTmpWrite[0] = val
4981
4982        variable err
4983        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4984        if(err)
4985                Print "HDF write err = ",err
4986        endif
4987        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4988//      err = V_KillNamedDataFolder(fname)
4989//      if(err)
4990//              Print "DataFolder kill err = ",err
4991//      endif
4992        return(err)
4993End     
4994       
4995//  source (data folder)
4996//name "NCNR"
4997Function V_writeSourceName(fname,str)
4998        String fname,str
4999
5000//      String path = "entry:instrument:source:name"
5001
5002        Make/O/T/N=1 tmpTW
5003        String groupName = "/entry/instrument/source"
5004        String varName = "name"
5005        tmpTW[0] = str //
5006
5007        variable err
5008        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5009        if(err)
5010                Print "HDF write err = ",err
5011        endif
5012       
5013        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5014//      err = V_KillNamedDataFolder(fname)
5015//      if(err)
5016//              Print "DataFolder kill err = ",err
5017//      endif
5018               
5019        return(err)
5020End
5021
5022//      power -- nominal only, not connected to any real number
5023Function V_writeReactorPower(fname,val)
5024        String fname
5025        Variable val
5026
5027//      String path = "entry:instrument:source:power"
5028       
5029        Make/O/D/N=1 wTmpWrite
5030//      Make/O/R/N=1 wTmpWrite
5031        String groupName = "/entry/instrument/source"
5032        String varName = "power"
5033        wTmpWrite[0] = val
5034
5035        variable err
5036        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5037        if(err)
5038                Print "HDF write err = ",err
5039        endif
5040        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5041//      err = V_KillNamedDataFolder(fname)
5042//      if(err)
5043//              Print "DataFolder kill err = ",err
5044//      endif
5045        return(err)
5046End     
5047
5048//probe (wave) "neutron"
5049Function V_writeSourceProbe(fname,str)
5050        String fname,str
5051
5052//      String path = "entry:instrument:source:probe"
5053
5054        Make/O/T/N=1 tmpTW
5055        String groupName = "/entry/instrument/source"
5056        String varName = "probe"
5057        tmpTW[0] = str //
5058
5059        variable err
5060        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5061        if(err)
5062                Print "HDF write err = ",err
5063        endif
5064       
5065        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5066//      err = V_KillNamedDataFolder(fname)
5067//      if(err)
5068//              Print "DataFolder kill err = ",err
5069//      endif
5070               
5071        return(err)
5072End
5073
5074//type (wave) "Reactor Neutron Source"
5075Function V_writeSourceType(fname,str)
5076        String fname,str
5077
5078//      String path = "entry:instrument:source:type"
5079
5080        Make/O/T/N=1 tmpTW
5081        String groupName = "/entry/instrument/source"
5082        String varName = "type"
5083        tmpTW[0] = str //
5084
5085        variable err
5086        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5087        if(err)
5088                Print "HDF write err = ",err
5089        endif
5090       
5091        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5092//      err = V_KillNamedDataFolder(fname)
5093//      if(err)
5094//              Print "DataFolder kill err = ",err
5095//      endif
5096               
5097        return(err)
5098End
5099
5100       
5101///////  source_aperture (data folder)
5102
5103Function V_writeSourceAp_Description(fname,str)
5104        String fname,str
5105
5106//      String path = "entry:instrument:source_aperture:description"
5107
5108        Make/O/T/N=1 tmpTW
5109        String groupName = "/entry/instrument/source_aperture"
5110        String varName = "description"
5111        tmpTW[0] = str //
5112
5113        variable err
5114        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5115        if(err)
5116                Print "HDF write err = ",err
5117        endif
5118       
5119        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5120//      err = V_KillNamedDataFolder(fname)
5121//      if(err)
5122//              Print "DataFolder kill err = ",err
5123//      endif
5124               
5125        return(err)
5126End
5127
5128Function V_writeSourceAp_distance(fname,val)
5129        String fname
5130        Variable val
5131
5132//      String path = "entry:instrument:source_aperture:distance"
5133       
5134        Make/O/D/N=1 wTmpWrite
5135//      Make/O/R/N=1 wTmpWrite
5136        String groupName = "/entry/instrument/source_aperture"
5137        String varName = "distance"
5138        wTmpWrite[0] = val
5139
5140        variable err
5141        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5142        if(err)
5143                Print "HDF write err = ",err
5144        endif
5145        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5146//      err = V_KillNamedDataFolder(fname)
5147//      if(err)
5148//              Print "DataFolder kill err = ",err
5149//      endif
5150        return(err)
5151End
5152//      shape (data folder)
5153
5154Function V_writeSourceAp_shape(fname,str)
5155        String fname,str
5156
5157//      String path = "entry:instrument:source_aperture:shape:shape"
5158
5159        Make/O/T/N=1 tmpTW
5160        String groupName = "/entry/instrument/source_aperture/shape"
5161        String varName = "shape"
5162        tmpTW[0] = str //
5163
5164        variable err
5165        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5166        if(err)
5167                Print "HDF write err = ",err
5168        endif
5169       
5170        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5171//      err = V_KillNamedDataFolder(fname)
5172//      if(err)
5173//              Print "DataFolder kill err = ",err
5174//      endif
5175               
5176        return(err)
5177End
5178
5179Function V_writeSourceAp_size(fname,str)
5180        String fname,str
5181
5182//      String path = "entry:instrument:source_aperture:shape:shape"
5183
5184        Make/O/T/N=1 tmpTW
5185        String groupName = "/entry/instrument/source_aperture/shape"
5186        String varName = "size"
5187        tmpTW[0] = str //
5188
5189        variable err
5190        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5191        if(err)
5192                Print "HDF write err = ",err
5193        endif
5194       
5195        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5196//      err = V_KillNamedDataFolder(fname)
5197//      if(err)
5198//              Print "DataFolder kill err = ",err
5199//      endif
5200               
5201        return(err)
5202End
5203
5204Function V_writeSourceAp_height(fname,val)
5205        String fname
5206        Variable val
5207
5208//      String path = "entry:instrument:sample_aperture:distance"
5209       
5210        Make/O/D/N=1 wTmpWrite
5211//      Make/O/R/N=1 wTmpWrite
5212        String groupName = "/entry/instrument/source_aperture/shape"
5213        String varName = "height"
5214        wTmpWrite[0] = val
5215
5216        variable err
5217        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5218        if(err)
5219                Print "HDF write err = ",err
5220        endif
5221        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5222//      err = V_KillNamedDataFolder(fname)
5223//      if(err)
5224//              Print "DataFolder kill err = ",err
5225//      endif
5226        return(err)
5227End
5228
5229Function V_writeSourceAp_width(fname,val)
5230        String fname
5231        Variable val
5232
5233//      String path = "entry:instrument:sample_aperture:distance"
5234       
5235        Make/O/D/N=1 wTmpWrite
5236//      Make/O/R/N=1 wTmpWrite
5237        String groupName = "/entry/instrument/source_aperture/shape"
5238        String varName = "width"
5239        wTmpWrite[0] = val
5240
5241        variable err
5242        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5243        if(err)
5244                Print "HDF write err = ",err
5245        endif
5246        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5247//      err = V_KillNamedDataFolder(fname)
5248//      if(err)
5249//              Print "DataFolder kill err = ",err
5250//      endif
5251        return(err)
5252End
5253
5254
5255//////// SAMPLE
5256//////// SAMPLE
5257//////// SAMPLE
5258
5259//Sample position in changer
5260Function V_writeSamplePosition(fname,str)
5261        String fname,str
5262
5263//      String path = "entry:sample:changer_position"   
5264
5265        Make/O/T/N=1 tmpTW
5266        String groupName = "/entry/sample"
5267        String varName = "changer_position"
5268        tmpTW[0] = str //
5269
5270        variable err
5271        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5272        if(err)
5273                Print "HDF write err = ",err
5274        endif
5275       
5276        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5277//      err = V_KillNamedDataFolder(fname)
5278//      if(err)
5279//              Print "DataFolder kill err = ",err
5280//      endif
5281               
5282        return(err)
5283End
5284
5285
5286// sample label
5287// TODO: value of num is currently not used
5288Function V_writeSampleDescription(fname,str)
5289        String fname,str
5290
5291//      String path = "entry:sample:description"
5292
5293        Make/O/T/N=1 tmpTW
5294        String groupName = "/entry/sample"
5295        String varName = "description"
5296        tmpTW[0] = str //
5297
5298        variable err
5299        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5300        if(err)
5301                Print "HDF write err = ",err
5302        endif
5303       
5304        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5305//      err = V_KillNamedDataFolder(fname)
5306//      if(err)
5307//              Print "DataFolder kill err = ",err
5308//      endif
5309               
5310        return(err)
5311End
5312
5313// for a z-stage??
5314Function V_writeSample_elevation(fname,val)
5315        String fname
5316        Variable val
5317       
5318//      String path = "entry:sample:elevation" 
5319       
5320        Make/O/D/N=1 wTmpWrite
5321//      Make/O/R/N=1 wTmpWrite
5322        String groupName = "/entry/sample"
5323        String varName = "elevation"
5324        wTmpWrite[0] = val
5325
5326        variable err
5327        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5328        if(err)
5329                Print "HDF write err = ",err
5330        endif
5331        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5332//      err = V_KillNamedDataFolder(fname)
5333//      if(err)
5334//              Print "DataFolder kill err = ",err
5335//      endif
5336        return(err)
5337end
5338
5339//no meaning to this...
5340Function V_writeSample_equatorial_ang(fname,val)
5341        String fname
5342        Variable val
5343       
5344//      String path = "entry:sample:equatorial_angle"   
5345       
5346        Make/O/D/N=1 wTmpWrite
5347//      Make/O/R/N=1 wTmpWrite
5348        String groupName = "/entry/sample"
5349        String varName = "equatorial_angle"
5350        wTmpWrite[0] = val
5351
5352        variable err
5353        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5354        if(err)
5355                Print "HDF write err = ",err
5356        endif
5357        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5358//      err = V_KillNamedDataFolder(fname)
5359//      if(err)
5360//              Print "DataFolder kill err = ",err
5361//      endif
5362        return(err)
5363end
5364
5365// TODO -- do  I need to make sure that this is an integer?
5366// group ID !!! very important for matching up files
5367// integer value
5368Function V_writeSample_GroupID(fname,val)
5369        String fname
5370        Variable val
5371       
5372//      String path = "entry:sample:group_id"   
5373       
5374        Make/O/I/N=1 wTmpWrite
5375//      Make/O/R/N=1 wTmpWrite
5376        String groupName = "/entry/sample"
5377        String varName = "group_id"
5378        wTmpWrite[0] = val
5379
5380        variable err
5381        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5382        if(err)
5383                Print "HDF write err = ",err
5384        endif
5385        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5386//      err = V_KillNamedDataFolder(fname)
5387//      if(err)
5388//              Print "DataFolder kill err = ",err
5389//      endif
5390        return(err)
5391end
5392
5393
5394//Sample Rotation Angle
5395Function V_writeSampleRotationAngle(fname,val)
5396        String fname
5397        Variable val
5398       
5399//      String path = "entry:sample:rotation_angle"     
5400       
5401        Make/O/D/N=1 wTmpWrite
5402//      Make/O/R/N=1 wTmpWrite
5403        String groupName = "/entry/sample"
5404        String varName = "rotation_angle"
5405        wTmpWrite[0] = val
5406
5407        variable err
5408        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5409        if(err)
5410                Print "HDF write err = ",err
5411        endif
5412        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5413//      err = V_KillNamedDataFolder(fname)
5414//      if(err)
5415//              Print "DataFolder kill err = ",err
5416//      endif
5417        return(err)
5418end
5419
5420//?? this is huber/chamber??
5421// TODO -- then where is the description of 10CB, etc...
5422Function V_writeSampleHolderDescription(fname,str)
5423        String fname,str
5424
5425//      String path = "entry:sample:sample_holder_description"
5426
5427        Make/O/T/N=1 tmpTW
5428        String groupName = "/entry/sample"
5429        String varName = "sample_holder_description"
5430        tmpTW[0] = str //
5431
5432        variable err
5433        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5434        if(err)
5435                Print "HDF write err = ",err
5436        endif
5437       
5438        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5439//      err = V_KillNamedDataFolder(fname)
5440//      if(err)
5441//              Print "DataFolder kill err = ",err
5442//      endif
5443               
5444        return(err)
5445End
5446
5447//Sample Thickness
5448// TODO -- somehow, this is not set correctly in the acquisition, so NaN results
5449Function V_writeSampleThickness(fname,val)
5450        String fname
5451        Variable val
5452       
5453//      String path = "entry:sample:thickness" 
5454       
5455        Make/O/D/N=1 wTmpWrite
5456//      Make/O/R/N=1 wTmpWrite
5457        String groupName = "/entry/sample"
5458        String varName = "thickness"
5459        wTmpWrite[0] = val
5460
5461        variable err
5462        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5463        if(err)
5464                Print "HDF write err = ",err
5465        endif
5466        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5467//      err = V_KillNamedDataFolder(fname)
5468//      if(err)
5469//              Print "DataFolder kill err = ",err
5470//      endif
5471        return(err)
5472end
5473
5474//Sample Translation
5475Function V_writeSampleTranslation(fname,val)
5476        String fname
5477        Variable val
5478       
5479//      String path = "entry:sample:translation"       
5480       
5481        Make/O/D/N=1 wTmpWrite
5482//      Make/O/R/N=1 wTmpWrite
5483        String groupName = "/entry/sample"
5484        String varName = "translation"
5485        wTmpWrite[0] = val
5486
5487        variable err
5488        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5489        if(err)
5490                Print "HDF write err = ",err
5491        endif
5492        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5493//      err = V_KillNamedDataFolder(fname)
5494//      if(err)
5495//              Print "DataFolder kill err = ",err
5496//      endif
5497        return(err)
5498end
5499
5500// sample transmission
5501Function V_writeSampleTransmission(fname,val)
5502        String fname
5503        Variable val
5504       
5505        String path = "entry:sample:transmission"       
5506//      String path = "QKK0037737:data:Transmission"   
5507       
5508        Make/O/D/N=1 wTmpWrite
5509//      Make/O/R/N=1 wTmpWrite
5510        String groupName = "/entry/sample"
5511        String varName = "transmission"
5512        wTmpWrite[0] = val
5513
5514        variable err
5515        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5516        if(err)
5517                Print "HDF write err = ",err
5518        endif
5519        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5520//      err = V_KillNamedDataFolder(fname)
5521//      if(err)
5522//              Print "DataFolder kill err = ",err
5523//      endif
5524        return(err)
5525end
5526
5527//transmission error (one sigma)
5528Function V_writeSampleTransError(fname,val)
5529        String fname
5530        Variable val
5531       
5532//      String path = "entry:sample:transmission_error"
5533       
5534        Make/O/D/N=1 wTmpWrite
5535//      Make/O/R/N=1 wTmpWrite
5536        String groupName = "/entry/sample"
5537        String varName = "transmission_error"
5538        wTmpWrite[0] = val
5539
5540        variable err
5541        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5542        if(err)
5543                Print "HDF write err = ",err
5544        endif
5545        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5546//      err = V_KillNamedDataFolder(fname)
5547//      if(err)
5548//              Print "DataFolder kill err = ",err
5549//      endif
5550        return(err)
5551end
5552
5553
5554
5555//// SAMPLE / DATA LOGS
5556// write this generic , call with the name of the environment log desired
5557//
5558// temperature_1
5559// temperature_2
5560// shear_field
5561// pressure
5562// magnetic_field
5563// electric_field
5564//
5565//////// (for example) electric_field (data folder)
5566
5567Function V_writeLog_attachedTo(fname,logStr,str)
5568        String fname,logStr,str
5569
5570//      String path = "entry:sample:"+logstr+":attached_to"
5571
5572        Make/O/T/N=1 tmpTW
5573        String groupName = "/entry/sample/"+logStr
5574        String varName = "attached_to"
5575        tmpTW[0] = str //
5576
5577        variable err
5578        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5579        if(err)
5580                Print "HDF write err = ",err
5581        endif
5582       
5583        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5584//      err = V_KillNamedDataFolder(fname)
5585//      if(err)
5586//              Print "DataFolder kill err = ",err
5587//      endif
5588               
5589        return(err)
5590End
5591
5592
5593Function V_writeLog_measurement(fname,logStr,str)
5594        String fname,logStr,str
5595
5596        String path = "entry:sample:"+logstr+":measurement"
5597
5598        Make/O/T/N=1 tmpTW
5599        String groupName = "/entry/sample/"+logStr
5600        String varName = "measurement"
5601        tmpTW[0] = str //
5602
5603        variable err
5604        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5605        if(err)
5606                Print "HDF write err = ",err
5607        endif
5608       
5609        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5610//      err = V_KillNamedDataFolder(fname)
5611//      if(err)
5612//              Print "DataFolder kill err = ",err
5613//      endif
5614               
5615        return(err)
5616End
5617
5618
5619Function V_writeLog_Name(fname,logStr,str)
5620        String fname,logStr,str
5621
5622//      String path = "entry:sample:"+logstr+":name"
5623
5624        Make/O/T/N=1 tmpTW
5625        String groupName = "/entry/sample/"+logStr
5626        String varName = "name"
5627        tmpTW[0] = str //
5628
5629        variable err
5630        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5631        if(err)
5632                Print "HDF write err = ",err
5633        endif
5634       
5635        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5636//      err = V_KillNamedDataFolder(fname)
5637//      if(err)
5638//              Print "DataFolder kill err = ",err
5639//      endif
5640               
5641        return(err)
5642End
5643
5644
5645// TODO --
5646Function V_writeLog_nomValue(fname,logStr,val)
5647        String fname,logStr
5648        Variable val
5649       
5650//      String path = "entry:sample:"+logstr+":value"
5651       
5652        Make/O/D/N=1 wTmpWrite
5653//      Make/O/R/N=1 wTmpWrite
5654        String groupName = "/entry/sample/"+logStr
5655        String varName = "value"
5656        wTmpWrite[0] = val
5657
5658        variable err
5659        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5660        if(err)
5661                Print "HDF write err = ",err
5662        endif
5663        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5664//      err = V_KillNamedDataFolder(fname)
5665//      if(err)
5666//              Print "DataFolder kill err = ",err
5667//      endif
5668        return(err)
5669end
5670
5671////            value_log (data folder)
5672Function V_writeLog_startTime(fname,logStr,str)
5673        String fname,logStr,str
5674
5675//      String path = "entry:sample:"+logstr+":value_log:start"
5676
5677        Make/O/T/N=1 tmpTW
5678        String groupName = "/entry/sample/"+logStr+"/value_log"
5679        String varName = "start"
5680        tmpTW[0] = str //
5681
5682        variable err
5683        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5684        if(err)
5685                Print "HDF write err = ",err
5686        endif
5687       
5688        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5689//      err = V_KillNamedDataFolder(fname)
5690//      if(err)
5691//              Print "DataFolder kill err = ",err
5692//      endif
5693               
5694        return(err)
5695End
5696
5697// TODO --
5698Function V_writeLog_avgValue(fname,logStr,val)
5699        String fname,logStr
5700        Variable val
5701       
5702//      String path = "entry:sample:"+logstr+":value_log:average_value"
5703       
5704        Make/O/D/N=1 wTmpWrite
5705//      Make/O/R/N=1 wTmpWrite
5706        String groupName = "/entry/sample/"+logStr+"/value_log"
5707        String varName = "average_value"
5708        wTmpWrite[0] = val
5709
5710        variable err
5711        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5712        if(err)
5713                Print "HDF write err = ",err
5714        endif
5715        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5716//      err = V_KillNamedDataFolder(fname)
5717//      if(err)
5718//              Print "DataFolder kill err = ",err
5719//      endif
5720        return(err)
5721end
5722
5723// TODO -- this needs to be a WAVE reference
5724Function V_writeLog_time(fname,logStr,inW)
5725        String fname,logStr
5726        Wave inW
5727       
5728//      String path = "entry:sample:"+logstr+":value_log:time"
5729
5730        Duplicate/O inW wTmpWrite       
5731// then use redimension as needed to cast the wave to write to the specified type
5732// see WaveType for the proper codes
5733//      Redimension/T=() wTmpWrite
5734// -- May also need to check the dimension(s) before writing (don't trust the input)
5735        String groupName = "/entry/sample/"+logStr+"/value_log"
5736        String varName = "time"
5737
5738        variable err
5739        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5740        if(err)
5741                Print "HDF write err = ",err
5742        endif
5743        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5744//      err = V_KillNamedDataFolder(fname)
5745//      if(err)
5746//              Print "DataFolder kill err = ",err
5747//      endif
5748        return(err)
5749end
5750
5751
5752// TODO -- this needs to be a WAVE reference
5753Function V_writeLog_Value(fname,logStr,inW)
5754        String fname,logStr
5755        Wave inW
5756       
5757//      String path = "entry:sample:"+logstr+":value_log:value"
5758
5759        Duplicate/O inW wTmpWrite       
5760// then use redimension as needed to cast the wave to write to the specified type
5761// see WaveType for the proper codes
5762//      Redimension/T=() wTmpWrite
5763// -- May also need to check the dimension(s) before writing (don't trust the input)
5764        String groupName = "/entry/sample/"+logStr+"/value_log"
5765        String varName = "value"
5766
5767        variable err
5768        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5769        if(err)
5770                Print "HDF write err = ",err
5771        endif
5772        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5773//      err = V_KillNamedDataFolder(fname)
5774//      if(err)
5775//              Print "DataFolder kill err = ",err
5776//      endif
5777        return(err)
5778end
5779
5780
5781
5782///////// REDUCTION
5783///////// REDUCTION
5784///////// REDUCTION
5785
5786
5787// TODO -- needs to be a WAVE, and of the proper size and type!!!
5788Function V_writeAbsolute_Scaling(fname,inW)
5789        String fname
5790        Wave inW
5791       
5792//      String path = "entry:reduction:absolute_scaling"
5793       
5794        Duplicate/O inW wTmpWrite       
5795// then use redimension as needed to cast the wave to write to the specified type
5796// see WaveType for the proper codes
5797//      Redimension/T=() wTmpWrite
5798// -- May also need to check the dimension(s) before writing (don't trust the input)
5799        String groupName = "/entry/reduction"   
5800        String varName = "absolute_scaling"
5801
5802        variable err
5803        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5804        if(err)
5805                Print "HDF write err = ",err
5806        endif
5807        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5808//      err = V_KillNamedDataFolder(fname)
5809//      if(err)
5810//              Print "DataFolder kill err = ",err
5811//      endif
5812        return(err)
5813end
5814
5815// TODO -- needs to be a WAVE
5816Function V_writeBoxCoordinates(fname,inW)
5817        String fname
5818        Wave inW
5819       
5820//      String path = "entry:reduction:box_coordinates"
5821               
5822        Duplicate/O inW wTmpWrite       
5823// then use redimension as needed to cast the wave to write to the specified type
5824// see WaveType for the proper codes
5825//      Redimension/T=() wTmpWrite
5826// -- May also need to check the dimension(s) before writing (don't trust the input)
5827        String groupName = "/entry/reduction"   
5828        String varName = "box_coordinates"
5829
5830        variable err
5831        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5832        if(err)
5833                Print "HDF write err = ",err
5834        endif
5835        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5836//      err = V_KillNamedDataFolder(fname)
5837//      if(err)
5838//              Print "DataFolder kill err = ",err
5839//      endif
5840        return(err)
5841end
5842
5843//box counts
5844Function V_writeBoxCounts(fname,val)
5845        String fname
5846        Variable val
5847       
5848//      String path = "entry:reduction:box_count"       
5849       
5850        Make/O/D/N=1 wTmpWrite
5851//      Make/O/R/N=1 wTmpWrite
5852        String groupName = "/entry/reduction"
5853        String varName = "box_count"
5854        wTmpWrite[0] = val
5855
5856        variable err
5857        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5858        if(err)
5859                Print "HDF write err = ",err
5860        endif
5861        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5862//      err = V_KillNamedDataFolder(fname)
5863//      if(err)
5864//              Print "DataFolder kill err = ",err
5865//      endif
5866        return(err)
5867end
5868
5869//box counts error
5870Function V_writeBoxCountsError(fname,val)
5871        String fname
5872        Variable val
5873       
5874//      String path = "entry:reduction:box_count_error"
5875       
5876        Make/O/D/N=1 wTmpWrite
5877//      Make/O/R/N=1 wTmpWrite
5878        String groupName = "/entry/reduction"
5879        String varName = "box_count_error"
5880        wTmpWrite[0] = val
5881
5882        variable err
5883        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5884        if(err)
5885                Print "HDF write err = ",err
5886        endif
5887        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5888//      err = V_KillNamedDataFolder(fname)
5889//      if(err)
5890//              Print "DataFolder kill err = ",err
5891//      endif
5892        return(err)
5893end
5894
5895Function V_writeReductionComments(fname,str)
5896        String fname,str
5897
5898//      String path = "entry:reduction:comments"       
5899
5900        Make/O/T/N=1 tmpTW
5901        String groupName = "/entry/reduction"
5902        String varName = "comments"
5903        tmpTW[0] = str //
5904
5905        variable err
5906        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5907        if(err)
5908                Print "HDF write err = ",err
5909        endif
5910       
5911        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5912//      err = V_KillNamedDataFolder(fname)
5913//      if(err)
5914//              Print "DataFolder kill err = ",err
5915//      endif
5916               
5917        return(err)
5918End
5919
5920
5921Function V_writeReductionIntent(fname,str)
5922        String fname,str
5923
5924//      String path = "entry:reduction:intent" 
5925
5926        Make/O/T/N=1 tmpTW
5927        String groupName = "/entry/reduction"
5928        String varName = "intent"
5929        tmpTW[0] = str //
5930
5931        variable err
5932        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5933        if(err)
5934                Print "HDF write err = ",err
5935        endif
5936       
5937        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5938//      err = V_KillNamedDataFolder(fname)
5939//      if(err)
5940//              Print "DataFolder kill err = ",err
5941//      endif
5942               
5943        return(err)
5944End
5945
5946
5947Function V_writeLogFileName(fname,str)
5948        String fname,str
5949
5950//      String path = "entry:reduction:sans_log_file_name"     
5951
5952        Make/O/T/N=1 tmpTW
5953        String groupName = "/entry/reduction"
5954        String varName = "sans_log_file_name"
5955        tmpTW[0] = str //
5956
5957        variable err
5958        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5959        if(err)
5960                Print "HDF write err = ",err
5961        endif
5962       
5963        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5964//      err = V_KillNamedDataFolder(fname)
5965//      if(err)
5966//              Print "DataFolder kill err = ",err
5967//      endif
5968               
5969        return(err)
5970End
5971
5972
5973Function V_writeSensitivityFileName(fname,str)
5974        String fname,str
5975
5976//      String path = "entry:reduction:sensitivity_file_name"   
5977
5978        Make/O/T/N=1 tmpTW
5979        String groupName = "/entry/reduction"
5980        String varName = "sensitivity_file_name"
5981        tmpTW[0] = str //
5982
5983        variable err
5984        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5985        if(err)
5986                Print "HDF write err = ",err
5987        endif
5988       
5989        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5990//      err = V_KillNamedDataFolder(fname)
5991//      if(err)
5992//              Print "DataFolder kill err = ",err
5993//      endif
5994               
5995        return(err)
5996End
5997
5998Function V_writeTransmissionFileName(fname,str)
5999        String fname,str
6000
6001//      String path = "entry:reduction:transmission_file_name" 
6002
6003        Make/O/T/N=1 tmpTW
6004        String groupName = "/entry/reduction"
6005        String varName = "transmission_file_name"
6006        tmpTW[0] = str //
6007
6008        variable err
6009        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6010        if(err)
6011                Print "HDF write err = ",err
6012        endif
6013       
6014        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6015//      err = V_KillNamedDataFolder(fname)
6016//      if(err)
6017//              Print "DataFolder kill err = ",err
6018//      endif
6019               
6020        return(err)
6021End
6022
6023Function V_writeEmptyBeamFileName(fname,str)
6024        String fname,str
6025
6026//      String path = "entry:reduction:empty_beam_file_name"   
6027
6028        Make/O/T/N=1 tmpTW
6029        String groupName = "/entry/reduction"
6030        String varName = "empty_beam_file_name"
6031        tmpTW[0] = str //
6032
6033        variable err
6034        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6035        if(err)
6036                Print "HDF write err = ",err
6037        endif
6038       
6039        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6040//      err = V_KillNamedDataFolder(fname)
6041//      if(err)
6042//              Print "DataFolder kill err = ",err
6043//      endif
6044               
6045        return(err)
6046End
6047
6048Function V_writeEmptyFileName(fname,str)
6049        String fname,str
6050
6051//      String path = "entry:reduction:empty_beam_file_name"   
6052
6053        Make/O/T/N=1 tmpTW
6054        String groupName = "/entry/reduction"
6055        String varName = "empty_file_name"
6056        tmpTW[0] = str //
6057
6058        variable err
6059        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6060        if(err)
6061                Print "HDF write err = ",err
6062        endif
6063       
6064        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6065//      err = V_KillNamedDataFolder(fname)
6066//      if(err)
6067//              Print "DataFolder kill err = ",err
6068//      endif
6069               
6070        return(err)
6071End
6072
6073Function V_writeMaskFileName(fname,str)
6074        String fname,str
6075
6076//      String path = "entry:reduction:empty_beam_file_name"   
6077
6078        Make/O/T/N=1 tmpTW
6079        String groupName = "/entry/reduction"
6080        String varName = "mask_file_name"
6081        tmpTW[0] = str //
6082
6083        variable err
6084        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6085        if(err)
6086                Print "HDF write err = ",err
6087        endif
6088       
6089        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6090//      err = V_KillNamedDataFolder(fname)
6091//      if(err)
6092//              Print "DataFolder kill err = ",err
6093//      endif
6094               
6095        return(err)
6096End
6097
6098Function V_writeBackgroundFileName(fname,str)
6099        String fname,str
6100
6101//      String path = "entry:reduction:empty_beam_file_name"   
6102
6103        Make/O/T/N=1 tmpTW
6104        String groupName = "/entry/reduction"
6105        String varName = "background_file_name"
6106        tmpTW[0] = str //
6107
6108        variable err
6109        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6110        if(err)
6111                Print "HDF write err = ",err
6112        endif
6113       
6114        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6115//      err = V_KillNamedDataFolder(fname)
6116//      if(err)
6117//              Print "DataFolder kill err = ",err
6118//      endif
6119               
6120        return(err)
6121End
6122
6123//whole detector transmission
6124Function V_writeSampleTransWholeDetector(fname,val)
6125        String fname
6126        Variable val
6127       
6128//      String path = "entry:reduction:whole_trans"     
6129       
6130        Make/O/D/N=1 wTmpWrite
6131//      Make/O/R/N=1 wTmpWrite
6132        String groupName = "/entry/reduction"
6133        String varName = "whole_trans"
6134        wTmpWrite[0] = val
6135
6136        variable err
6137        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6138        if(err)
6139                Print "HDF write err = ",err
6140        endif
6141        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6142//      err = V_KillNamedDataFolder(fname)
6143//      if(err)
6144//              Print "DataFolder kill err = ",err
6145//      endif
6146        return(err)
6147end
6148
6149//whole detector transmission error
6150Function V_writeSampleTransWholeDetErr(fname,val)
6151        String fname
6152        Variable val
6153       
6154//      String path = "entry:reduction:whole_trans_error"       
6155       
6156        Make/O/D/N=1 wTmpWrite
6157//      Make/O/R/N=1 wTmpWrite
6158        String groupName = "/entry/reduction"
6159        String varName = "whole_trans_error"
6160        wTmpWrite[0] = val
6161
6162        variable err
6163        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6164        if(err)
6165                Print "HDF write err = ",err
6166        endif
6167        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6168//      err = V_KillNamedDataFolder(fname)
6169//      if(err)
6170//              Print "DataFolder kill err = ",err
6171//      endif
6172        return(err)
6173end
6174
6175                       
6176/////                   pol_sans (data folder)
6177
6178Function V_writePolSANS_cellName(fname,str)
6179        String fname,str
6180
6181//      String path = "entry:reduction:pol_sans:cell_name"     
6182
6183        Make/O/T/N=1 tmpTW
6184        String groupName = "/entry/reduction/pol_sans"
6185        String varName = "cell_name"
6186        tmpTW[0] = str //
6187
6188        variable err
6189        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6190        if(err)
6191                Print "HDF write err = ",err
6192        endif
6193       
6194        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6195//      err = V_KillNamedDataFolder(fname)
6196//      if(err)
6197//              Print "DataFolder kill err = ",err
6198//      endif
6199               
6200        return(err)
6201End
6202
6203
6204// TODO -- needs to be a WAVE
6205// is this a text wave?? if it's mixed names + values, then what?
6206Function V_writePolSANS_cellParams(fname,inW)
6207        String fname
6208        Wave inW
6209       
6210//      String path = "entry:reduction:pol_sans:cell_parameters"
6211               
6212        Duplicate/O inW wTmpWrite       
6213// then use redimension as needed to cast the wave to write to the specified type
6214// see WaveType for the proper codes
6215//      Redimension/T=() wTmpWrite
6216// -- May also need to check the dimension(s) before writing (don't trust the input)
6217        String groupName = "/entry/reduction/pol_sans" 
6218        String varName = "cell_parameters"
6219
6220        variable err
6221        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
6222        if(err)
6223                Print "HDF write err = ",err
6224        endif
6225        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6226//      err = V_KillNamedDataFolder(fname)
6227//      if(err)
6228//              Print "DataFolder kill err = ",err
6229//      endif
6230        return(err)
6231end
6232
6233Function V_writePolSANS_PolSANSPurpose(fname,str)
6234        String fname,str
6235
6236//      String path = "entry:reduction:pol_sans:pol_sans_purpose"       
6237
6238        Make/O/T/N=1 tmpTW
6239        String groupName = "/entry/reduction/pol_sans"
6240        String varName = "pol_sans_purpose"
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)
6256End
6257
6258                               
6259//////// TOP LEVEL DATA REPRESENTATION
6260//
6261// note that here the data is (supposed to be) a link, not the actual data
6262// Igor HDf implementation cannot follow links properly, as far as I know.
6263// so ignore them here, and focus on the image that may be possible to read
6264//
6265
6266//              data_B (data folder)
6267//                      data (wave) 1           //ignore this, it's a link
6268//                      variables (wave) 320
6269//                      thumbnail (data folder)
6270
6271////data (wave) "binary"
6272//// TODO -- this will need to be completely replaced with a function that can
6273//// read the binary image data. should be possible, but I don't know the details on either end...
6274//Function V_writeDataImage(fname,detStr,str)
6275//      String fname,detStr,str
6276//
6277////    String path = "entry:data_"+detStr+":thumbnail:data"   
6278//
6279//      Make/O/T/N=1 tmpTW
6280//      String groupName = "/entry/data_"+detStr+"/thumbnail"
6281//      String varName = "data"
6282//      tmpTW[0] = str //
6283//
6284//      variable err
6285//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6286//      if(err)
6287//              Print "HDF write err = ",err
6288//      endif
6289//     
6290//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6291////    err = V_KillNamedDataFolder(fname)
6292////    if(err)
6293////            Print "DataFolder kill err = ",err
6294////    endif
6295//             
6296//      return(err)
6297//End
6298//
6299//Function V_writeDataImageDescription(fname,detStr,str)
6300//      String fname,detStr,str
6301//
6302////    String path = "entry:data_"+detStr+":thumbnail:description"     
6303//
6304//      Make/O/T/N=1 tmpTW
6305//      String groupName = "/entry/data_"+detStr+"/thumbnail"
6306//      String varName = "description"
6307//      tmpTW[0] = str //
6308//
6309//      variable err
6310//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6311//      if(err)
6312//              Print "HDF write err = ",err
6313//      endif
6314//     
6315//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6316////    err = V_KillNamedDataFolder(fname)
6317////    if(err)
6318////            Print "DataFolder kill err = ",err
6319////    endif
6320//             
6321//      return(err)
6322//End
6323//                                                             
6324//Function V_writeDataImageType(fname,detStr,str)
6325//      String fname,detStr,str
6326//
6327////    String path = "entry:data_"+detStr+":thumbnail:type"   
6328//
6329//      Make/O/T/N=1 tmpTW
6330//      String groupName = "/entry/data_"+detStr+"/thumbnail"
6331//      String varName = "type"
6332//      tmpTW[0] = str //
6333//
6334//      variable err
6335//      err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
6336//      if(err)
6337//              Print "HDF write err = ",err
6338//      endif
6339//     
6340//      // now be sure to kill the data folder to force a re-read of the data next time this file is read in
6341////    err = V_KillNamedDataFolder(fname)
6342////    if(err)
6343////            Print "DataFolder kill err = ",err
6344////    endif
6345//             
6346//      return(err)
6347//End
6348//
Note: See TracBrowser for help on using the repository browser.