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

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

First pass at all of the get() and write() accessors for the Nexus VSANS file. The definition is still incomplete and untested, so these procedures will require complete verification, and some editing.

get and write are separated into their own files, so be sure to make the change in the pair if needed

File size: 130.2 KB
Line 
1#pragma rtGlobals=3             // Use modern global access method and strict wave access.
2
3
4// Start to build up and test the r/w accessors for VSANS
5// (SANS has a template, VSANS does not, so just start from scratch here, since the
6// file structure will be different)
7//
8//
9
10//////////// WRITE FUNCTIONS ////////////////////
11//
12// Each of the individual write functions have both the "write" and "kill" function
13// calls explicitly in each named function to allow flexibility during real implementation.
14// The calls could be streamlined, but writing this way allows for individualized kill/nokill, depending
15// on the details of what is actually being written out, and the possibility of changing the
16// particular "Write" routine, if specific changes need to be made to match the data type (int, fp, etc).
17// Currently, I don't know all of the data types, or what is important in the HDF structure.
18// NOV 2015
19//
20
21
22//////////////////////////////////////////////
23//////////////////////////////////
24// for TESTING of the get functions - to quickly access and se 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
168Function 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)
191End
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// file write time (what is this??)
405// TODO - figure out if this is supposed to be an integer or text (ISO)
406Function V_writeFileWriteTime(fname,val)
407        String fname
408        Variable val
409       
410        String path = "entry:file_time"
411       
412        Make/O/D/N=1 wTmpWrite
413//      Make/O/R/N=1 wTmpWrite
414        String groupName = "/entry"     
415        String varName = "file_time"
416        wTmpWrite[0] = val
417
418        variable err
419        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
420        if(err)
421                Print "HDF write err = ",err
422        endif
423        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
424        err = V_KillNamedDataFolder(fname)
425        if(err)
426                Print "DataFolder kill err = ",err
427        endif
428        return(err)
429End
430               
431//
432Function V_writeHDF_version(fname,str)
433        String fname,str
434       
435//      String path = "entry:hdf_version"       
436
437        Make/O/T/N=1 tmpTW
438        String groupName = "/entry"     //     
439        String varName = "hdf_version"
440        tmpTW[0] = str //
441
442        variable err
443        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
444        if(err)
445                Print "HDF write err = ",err
446        endif
447       
448        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
449        err = V_KillNamedDataFolder(fname)
450        if(err)
451                Print "DataFolder kill err = ",err
452        endif
453               
454        return(err)
455End
456
457// TODO -- not mine, added somewhere by Nexus writer?
458Function V_writeProgram_name(fname,str)
459        String fname,str
460       
461//      String path = "entry:program_name"     
462
463        Make/O/T/N=1 tmpTW
464        String groupName = "/entry"     //     
465        String varName = "program_name"
466        tmpTW[0] = str //
467
468        variable err
469        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
470        if(err)
471                Print "HDF write err = ",err
472        endif
473       
474        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
475        err = V_KillNamedDataFolder(fname)
476        if(err)
477                Print "DataFolder kill err = ",err
478        endif
479               
480        return(err)
481End
482
483// TODO -- not mine, added somewhere by Nexus writer?
484// data collection start time
485Function V_writeDataStartTime(fname,str)
486        String fname,str
487       
488//      String path = "entry:start_time"       
489
490        Make/O/T/N=1 tmpTW
491        String groupName = "/entry"     //     
492        String varName = "start_time"
493        tmpTW[0] = str //
494
495        variable err
496        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
497        if(err)
498                Print "HDF write err = ",err
499        endif
500       
501        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
502        err = V_KillNamedDataFolder(fname)
503        if(err)
504                Print "DataFolder kill err = ",err
505        endif
506               
507        return(err)
508End
509               
510// title of experiment
511Function V_writeTitle(fname,str)
512        String fname,str
513       
514//      String path = "entry:title"     
515
516        Make/O/T/N=1 tmpTW
517        String groupName = "/entry"     //     
518        String varName = "title"
519        tmpTW[0] = str //
520
521        variable err
522        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
523        if(err)
524                Print "HDF write err = ",err
525        endif
526       
527        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
528        err = V_KillNamedDataFolder(fname)
529        if(err)
530                Print "DataFolder kill err = ",err
531        endif
532               
533        return(err)
534end
535       
536       
537               
538////////// USER
539////////// USER
540////////// USER
541
542// list of user names
543// TODO -- currently not written out to data file??
544Function V_writeUserNames(fname,str)
545        String fname,str
546       
547//      String path = "entry:user:name"
548
549        Make/O/T/N=1 tmpTW
550        String groupName = "/entry/user"        //     
551        String varName = "name"
552        tmpTW[0] = str //
553
554        variable err
555        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
556        if(err)
557                Print "HDF write err = ",err
558        endif
559       
560        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
561        err = V_KillNamedDataFolder(fname)
562        if(err)
563                Print "DataFolder kill err = ",err
564        endif
565               
566        return(err)
567end
568
569
570//////// CONTROL
571//////// CONTROL
572//////// CONTROL
573
574// TODO -- for the control section, document each of the fields
575//
576Function V_writeCount_end(fname,val)
577        String fname
578        Variable val
579       
580//      String path = "entry:control:count_end"
581       
582        Make/O/D/N=1 wTmpWrite
583//      Make/O/R/N=1 wTmpWrite
584        String groupName = "/entry/control"     
585        String varName = "count_end"
586        wTmpWrite[0] = val
587
588        variable err
589        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
590        if(err)
591                Print "HDF write err = ",err
592        endif
593        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
594        err = V_KillNamedDataFolder(fname)
595        if(err)
596                Print "DataFolder kill err = ",err
597        endif
598        return(err)
599end
600
601
602Function V_writeCount_start(fname,val)
603        String fname
604        Variable val
605       
606//      String path = "entry:control:count_start"       
607       
608        Make/O/D/N=1 wTmpWrite
609//      Make/O/R/N=1 wTmpWrite
610        String groupName = "/entry/control"     
611        String varName = "count_start"
612        wTmpWrite[0] = val
613
614        variable err
615        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
616        if(err)
617                Print "HDF write err = ",err
618        endif
619        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
620        err = V_KillNamedDataFolder(fname)
621        if(err)
622                Print "DataFolder kill err = ",err
623        endif
624        return(err)
625end
626
627
628Function V_writeCount_time(fname,val)
629        String fname
630        Variable val
631       
632//      String path = "entry:control:count_time"       
633       
634        Make/O/D/N=1 wTmpWrite
635//      Make/O/R/N=1 wTmpWrite
636        String groupName = "/entry/control"     
637        String varName = "count_time"
638        wTmpWrite[0] = val
639
640        variable err
641        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
642        if(err)
643                Print "HDF write err = ",err
644        endif
645        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
646        err = V_KillNamedDataFolder(fname)
647        if(err)
648                Print "DataFolder kill err = ",err
649        endif
650        return(err)
651end
652
653
654Function V_writeCount_time_preset(fname,val)
655        String fname
656        Variable val
657       
658//      String path = "entry:control:count_time_preset"
659       
660        Make/O/D/N=1 wTmpWrite
661//      Make/O/R/N=1 wTmpWrite
662        String groupName = "/entry/control"     
663        String varName = "count_time_preset"
664        wTmpWrite[0] = val
665
666        variable err
667        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
668        if(err)
669                Print "HDF write err = ",err
670        endif
671        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
672        err = V_KillNamedDataFolder(fname)
673        if(err)
674                Print "DataFolder kill err = ",err
675        endif
676        return(err)
677end
678
679
680Function V_writeDetector_counts(fname,val)
681        String fname
682        Variable val
683       
684//      String path = "entry:control:detector_counts"
685       
686        Make/O/D/N=1 wTmpWrite
687//      Make/O/R/N=1 wTmpWrite
688        String groupName = "/entry/control"     
689        String varName = "detector_counts"
690        wTmpWrite[0] = val
691
692        variable err
693        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
694        if(err)
695                Print "HDF write err = ",err
696        endif
697        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
698        err = V_KillNamedDataFolder(fname)
699        if(err)
700                Print "DataFolder kill err = ",err
701        endif
702        return(err)
703end
704
705
706Function V_writeDetector_preset(fname,val)
707        String fname
708        Variable val
709       
710//      String path = "entry:control:detector_preset"   
711       
712        Make/O/D/N=1 wTmpWrite
713//      Make/O/R/N=1 wTmpWrite
714        String groupName = "/entry/control"     
715        String varName = "detector_preset"
716        wTmpWrite[0] = val
717
718        variable err
719        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
720        if(err)
721                Print "HDF write err = ",err
722        endif
723        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
724        err = V_KillNamedDataFolder(fname)
725        if(err)
726                Print "DataFolder kill err = ",err
727        endif
728        return(err)
729end
730
731
732Function V_writeIntegral(fname,val)
733        String fname
734        Variable val
735       
736//      String path = "entry:control:integral"
737       
738        Make/O/D/N=1 wTmpWrite
739//      Make/O/R/N=1 wTmpWrite
740        String groupName = "/entry/control"     
741        String varName = "integral"
742        wTmpWrite[0] = val
743
744        variable err
745        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
746        if(err)
747                Print "HDF write err = ",err
748        endif
749        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
750        err = V_KillNamedDataFolder(fname)
751        if(err)
752                Print "DataFolder kill err = ",err
753        endif
754        return(err)
755end
756
757// control mode for data acquisition, "timer"
758Function V_writeControlMode(fname,str)
759        String fname,str
760       
761//      String path = "entry:control:mode"     
762
763        Make/O/T/N=1 tmpTW
764        String groupName = "/entry/control"     //     
765        String varName = "mode"
766        tmpTW[0] = str //
767
768        variable err
769        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
770        if(err)
771                Print "HDF write err = ",err
772        endif
773       
774        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
775        err = V_KillNamedDataFolder(fname)
776        if(err)
777                Print "DataFolder kill err = ",err
778        endif
779               
780        return(err)
781End
782
783//monitor count
784Function V_writeMonitorCount(fname,val)
785        String fname
786        Variable val
787       
788//      String path = "entry:control:monitor_counts"   
789       
790        Make/O/D/N=1 wTmpWrite
791//      Make/O/R/N=1 wTmpWrite
792        String groupName = "/entry/control"     
793        String varName = "monitor_counts"
794        wTmpWrite[0] = val
795
796        variable err
797        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
798        if(err)
799                Print "HDF write err = ",err
800        endif
801        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
802        err = V_KillNamedDataFolder(fname)
803        if(err)
804                Print "DataFolder kill err = ",err
805        endif
806        return(err)
807end
808
809Function V_writeMonitor_preset(fname,val)
810        String fname
811        Variable val
812       
813//      String path = "entry:control:monitor_preset"
814       
815        Make/O/D/N=1 wTmpWrite
816//      Make/O/R/N=1 wTmpWrite
817        String groupName = "/entry/control"     
818        String varName = "monitor_preset"
819        wTmpWrite[0] = val
820
821        variable err
822        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
823        if(err)
824                Print "HDF write err = ",err
825        endif
826        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
827        err = V_KillNamedDataFolder(fname)
828        if(err)
829                Print "DataFolder kill err = ",err
830        endif
831        return(err)
832end
833
834Function V_writePreset(fname,val)
835        String fname
836        Variable val
837       
838//      String path = "entry:control:preset"
839       
840        Make/O/D/N=1 wTmpWrite
841//      Make/O/R/N=1 wTmpWrite
842        String groupName = "/entry/control"     
843        String varName = "preset"
844        wTmpWrite[0] = val
845
846        variable err
847        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
848        if(err)
849                Print "HDF write err = ",err
850        endif
851        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
852        err = V_KillNamedDataFolder(fname)
853        if(err)
854                Print "DataFolder kill err = ",err
855        endif
856        return(err)
857end
858
859
860
861
862
863//////// INSTRUMENT
864//////// INSTRUMENT
865//////// INSTRUMENT
866
867Function V_writeLocalContact(fname,str)
868        String fname,str
869
870//      String path = "entry:instrument:local_contact"
871
872        Make/O/T/N=1 tmpTW
873        String groupName = "/entry/instrument"  //     
874        String varName = "local_contact"
875        tmpTW[0] = str //
876
877        variable err
878        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
879        if(err)
880                Print "HDF write err = ",err
881        endif
882       
883        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
884        err = V_KillNamedDataFolder(fname)
885        if(err)
886                Print "DataFolder kill err = ",err
887        endif
888               
889        return(err)
890End
891
892Function V_writeInstrumentName(fname,str)
893        String fname,str
894
895//      String path = "entry:instrument:name"
896
897        Make/O/T/N=1 tmpTW
898        String groupName = "/entry/instrument"  //     
899        String varName = "name"
900        tmpTW[0] = str //
901
902        variable err
903        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
904        if(err)
905                Print "HDF write err = ",err
906        endif
907       
908        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
909        err = V_KillNamedDataFolder(fname)
910        if(err)
911                Print "DataFolder kill err = ",err
912        endif
913               
914        return(err)
915End
916
917Function V_writeInstrumentType(fname,str)
918        String fname,str
919
920//      String path = "entry:instrument:type"
921
922        Make/O/T/N=1 tmpTW
923        String groupName = "/entry/instrument"  //     
924        String varName = "type"
925        tmpTW[0] = str //
926
927        variable err
928        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
929        if(err)
930                Print "HDF write err = ",err
931        endif
932       
933        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
934        err = V_KillNamedDataFolder(fname)
935        if(err)
936                Print "DataFolder kill err = ",err
937        endif
938               
939        return(err)
940End
941
942////// INSTRUMENT/ATTENUATOR
943// TODO
944// attenuator number -- for VSANS I think I want this to be some "binary" representation
945// of 4 plates in/out - so this may be an integer-> binary, or a text string (4 char)
946Function V_writeAtten_number(fname,val)
947        String fname
948        Variable val
949       
950//      String path = "entry:instrument:attenuator:atten_number"       
951       
952        Make/O/D/N=1 wTmpWrite
953//      Make/O/R/N=1 wTmpWrite
954        String groupName = "/entry/instrument/attenuator"       
955        String varName = "atten_number"
956        wTmpWrite[0] = val
957
958        variable err
959        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
960        if(err)
961                Print "HDF write err = ",err
962        endif
963        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
964        err = V_KillNamedDataFolder(fname)
965        if(err)
966                Print "DataFolder kill err = ",err
967        endif
968        return(err)
969end
970
971
972// transmission value for the attenuator in the beam
973// use this, but if something wrong, the tables are present
974Function V_writeAttenuator_transmission(fname,val)
975        String fname
976        Variable val
977       
978//      String path = "entry:instrument:attenuator:attenuator_transmission"     
979       
980        Make/O/D/N=1 wTmpWrite
981//      Make/O/R/N=1 wTmpWrite
982        String groupName = "/entry/instrument/attenuator"       
983        String varName = "attenuator_transmission"
984        wTmpWrite[0] = val
985
986        variable err
987        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
988        if(err)
989                Print "HDF write err = ",err
990        endif
991        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
992        err = V_KillNamedDataFolder(fname)
993        if(err)
994                Print "DataFolder kill err = ",err
995        endif
996        return(err)
997end
998
999
1000// distance from the attenuator to the sample (units??)
1001Function V_writeAttenDistance(fname,val)
1002        String fname
1003        Variable val
1004       
1005//      String path = "entry:instrument:attenuator:distance"   
1006       
1007        Make/O/D/N=1 wTmpWrite
1008//      Make/O/R/N=1 wTmpWrite
1009        String groupName = "/entry/instrument/attenuator"       
1010        String varName = "distance"
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
1027// attenuator index, to use in the lookup table of transmission values
1028Function V_writeAttenIndex(fname,val)
1029        String fname
1030        Variable val
1031       
1032//      String path = "entry:instrument:attenuator:index"       
1033       
1034        Make/O/D/N=1 wTmpWrite
1035//      Make/O/R/N=1 wTmpWrite
1036        String groupName = "/entry/instrument/attenuator"       
1037        String varName = "index"
1038        wTmpWrite[0] = val
1039
1040        variable err
1041        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1042        if(err)
1043                Print "HDF write err = ",err
1044        endif
1045        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1046        err = V_KillNamedDataFolder(fname)
1047        if(err)
1048                Print "DataFolder kill err = ",err
1049        endif
1050        return(err)
1051end
1052
1053
1054// table of the attenuation factor
1055Function V_writeAttenIndex_table(fname,inW)
1056        String fname
1057        Wave inW
1058       
1059//      String path = "entry:instrument:attenuator:index_table"
1060       
1061        Duplicate/O inW wTmpWrite       
1062// then use redimension as needed to cast the wave to write to the specified type
1063// see WaveType for the proper codes
1064//      Redimension/T=() wTmpWrite
1065// -- May also need to check the dimension(s) before writing (don't trust the input)
1066        String groupName = "/entry/instrument/attenuator"       
1067        String varName = "index_table"
1068
1069        variable err
1070        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1071        if(err)
1072                Print "HDF write err = ",err
1073        endif
1074        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1075        err = V_KillNamedDataFolder(fname)
1076        if(err)
1077                Print "DataFolder kill err = ",err
1078        endif
1079        return(err)
1080end
1081
1082
1083// status "in or out"
1084Function V_writeAttenStatus(fname,str)
1085        String fname,str
1086
1087//      String path = "entry:instrument:attenuator:status"
1088
1089        Make/O/T/N=1 tmpTW
1090        String groupName = "/entry/instrument/attenuator"       //     
1091        String varName = "status"
1092        tmpTW[0] = str //
1093
1094        variable err
1095        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1096        if(err)
1097                Print "HDF write err = ",err
1098        endif
1099       
1100        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1101        err = V_KillNamedDataFolder(fname)
1102        if(err)
1103                Print "DataFolder kill err = ",err
1104        endif
1105               
1106        return(err)
1107End
1108
1109// thickness of the attenuator (PMMA) - units??
1110Function V_writeAttenThickness(fname,val)
1111        String fname
1112        Variable val
1113       
1114//      String path = "entry:instrument:attenuator:thickness"   
1115       
1116        Make/O/D/N=1 wTmpWrite
1117//      Make/O/R/N=1 wTmpWrite
1118        String groupName = "/entry/instrument/attenuator"       
1119        String varName = "thickness"
1120        wTmpWrite[0] = val
1121
1122        variable err
1123        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1124        if(err)
1125                Print "HDF write err = ",err
1126        endif
1127        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1128        err = V_KillNamedDataFolder(fname)
1129        if(err)
1130                Print "DataFolder kill err = ",err
1131        endif
1132        return(err)
1133end
1134
1135
1136// type of material for the atteunator
1137Function V_writeAttenType(fname,str)
1138        String fname,str
1139
1140//      String path = "entry:instrument:attenuator:type"
1141
1142        Make/O/T/N=1 tmpTW
1143        String groupName = "/entry/instrument/attenuator"       //     
1144        String varName = "type"
1145        tmpTW[0] = str //
1146
1147        variable err
1148        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1149        if(err)
1150                Print "HDF write err = ",err
1151        endif
1152       
1153        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1154        err = V_KillNamedDataFolder(fname)
1155        if(err)
1156                Print "DataFolder kill err = ",err
1157        endif
1158               
1159        return(err)
1160End
1161
1162
1163////// INSTRUMENT/BEAM
1164// instrument/beam/chopper (data folder)
1165Function V_writeChopperAngular_opening(fname,val)
1166        String fname
1167        Variable val
1168       
1169//      String path = "entry:instrument:beam:chopper:angular_opening"
1170       
1171        Make/O/D/N=1 wTmpWrite
1172//      Make/O/R/N=1 wTmpWrite
1173        String groupName = "/entry/instrument/beam/chopper"     
1174        String varName = "angular_opening"
1175        wTmpWrite[0] = val
1176
1177        variable err
1178        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1179        if(err)
1180                Print "HDF write err = ",err
1181        endif
1182        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1183        err = V_KillNamedDataFolder(fname)
1184        if(err)
1185                Print "DataFolder kill err = ",err
1186        endif
1187        return(err)
1188end
1189
1190Function V_writeChopDistance_from_sample(fname,val)
1191        String fname
1192        Variable val
1193       
1194//      String path = "entry:instrument:beam:chopper:distance_from_sample"
1195       
1196        Make/O/D/N=1 wTmpWrite
1197//      Make/O/R/N=1 wTmpWrite
1198        String groupName = "/entry/instrument/beam/chopper"     
1199        String varName = "distance_from_sample"
1200        wTmpWrite[0] = val
1201
1202        variable err
1203        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1204        if(err)
1205                Print "HDF write err = ",err
1206        endif
1207        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1208        err = V_KillNamedDataFolder(fname)
1209        if(err)
1210                Print "DataFolder kill err = ",err
1211        endif
1212        return(err)
1213end
1214
1215Function V_writeChopDistance_from_source(fname,val)
1216        String fname
1217        Variable val
1218       
1219//      String path = "entry:instrument:beam:chopper:distance_from_source"     
1220       
1221        Make/O/D/N=1 wTmpWrite
1222//      Make/O/R/N=1 wTmpWrite
1223        String groupName = "/entry/instrument/beam/chopper"     
1224        String varName = "distance_from_source"
1225        wTmpWrite[0] = val
1226
1227        variable err
1228        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1229        if(err)
1230                Print "HDF write err = ",err
1231        endif
1232        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1233        err = V_KillNamedDataFolder(fname)
1234        if(err)
1235                Print "DataFolder kill err = ",err
1236        endif
1237        return(err)
1238end
1239
1240Function V_writeChopperDuty_cycle(fname,val)
1241        String fname
1242        Variable val
1243       
1244//      String path = "entry:instrument:beam:chopper:duty_cycle"       
1245       
1246        Make/O/D/N=1 wTmpWrite
1247//      Make/O/R/N=1 wTmpWrite
1248        String groupName = "/entry/instrument/beam/chopper"     
1249        String varName = "duty_cycle"
1250        wTmpWrite[0] = val
1251
1252        variable err
1253        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1254        if(err)
1255                Print "HDF write err = ",err
1256        endif
1257        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1258        err = V_KillNamedDataFolder(fname)
1259        if(err)
1260                Print "DataFolder kill err = ",err
1261        endif
1262        return(err)
1263end
1264
1265Function V_writeChopperRotation_speed(fname,val)
1266        String fname
1267        Variable val
1268       
1269//      String path = "entry:instrument:beam:chopper:rotation_speed"   
1270       
1271        Make/O/D/N=1 wTmpWrite
1272//      Make/O/R/N=1 wTmpWrite
1273        String groupName = "/entry/instrument/beam/chopper"     
1274        String varName = "rotation_speed"
1275        wTmpWrite[0] = val
1276
1277        variable err
1278        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1279        if(err)
1280                Print "HDF write err = ",err
1281        endif
1282        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1283        err = V_KillNamedDataFolder(fname)
1284        if(err)
1285                Print "DataFolder kill err = ",err
1286        endif
1287        return(err)
1288end
1289
1290Function V_writeChopperSlits(fname,val)
1291        String fname
1292        Variable val
1293       
1294//      String path = "entry:instrument:beam:chopper:slits"     
1295       
1296        Make/O/D/N=1 wTmpWrite
1297//      Make/O/R/N=1 wTmpWrite
1298        String groupName = "/entry/instrument/beam/chopper"     
1299        String varName = "slits"
1300        wTmpWrite[0] = val
1301
1302        variable err
1303        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1304        if(err)
1305                Print "HDF write err = ",err
1306        endif
1307        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1308        err = V_KillNamedDataFolder(fname)
1309        if(err)
1310                Print "DataFolder kill err = ",err
1311        endif
1312        return(err)
1313end
1314
1315Function V_writeChopperstatus(fname,str)
1316        String fname,str
1317
1318//      String path = "entry:instrument:beam:chopper:status"
1319
1320        Make/O/T/N=1 tmpTW
1321        String groupName = "/entry/instrument/beam/chopper"     //     
1322        String varName = "status"
1323        tmpTW[0] = str //
1324
1325        variable err
1326        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1327        if(err)
1328                Print "HDF write err = ",err
1329        endif
1330       
1331        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1332        err = V_KillNamedDataFolder(fname)
1333        if(err)
1334                Print "DataFolder kill err = ",err
1335        endif
1336               
1337        return(err)
1338End
1339
1340Function V_writeChoppertype(fname,str)
1341        String fname,str
1342
1343//      String path = "entry:instrument:beam:chopper:type"
1344
1345        Make/O/T/N=1 tmpTW
1346        String groupName = "/entry/instrument/beam/chopper"     //     
1347        String varName = "type"
1348        tmpTW[0] = str //
1349
1350        variable err
1351        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1352        if(err)
1353                Print "HDF write err = ",err
1354        endif
1355       
1356        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1357        err = V_KillNamedDataFolder(fname)
1358        if(err)
1359                Print "DataFolder kill err = ",err
1360        endif
1361               
1362        return(err)
1363End
1364
1365
1366// instrument/beam/flipper (data folder)
1367Function V_writeFlipperDriving_current(fname,val)
1368        String fname
1369        Variable val
1370       
1371//      String path = "entry:instrument:beam:flipper:driving_current"   
1372       
1373        Make/O/D/N=1 wTmpWrite
1374//      Make/O/R/N=1 wTmpWrite
1375        String groupName = "/entry/instrument/beam/flipper"     
1376        String varName = "driving_current"
1377        wTmpWrite[0] = val
1378
1379        variable err
1380        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1381        if(err)
1382                Print "HDF write err = ",err
1383        endif
1384        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1385        err = V_KillNamedDataFolder(fname)
1386        if(err)
1387                Print "DataFolder kill err = ",err
1388        endif
1389        return(err)
1390end
1391
1392Function V_writeFlipperFrequency(fname,val)
1393        String fname
1394        Variable val
1395       
1396//      String path = "entry:instrument:beam:flipper:frequency"
1397       
1398        Make/O/D/N=1 wTmpWrite
1399//      Make/O/R/N=1 wTmpWrite
1400        String groupName = "/entry/instrument/beam/flipper"     
1401        String varName = "frequency"
1402        wTmpWrite[0] = val
1403
1404        variable err
1405        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1406        if(err)
1407                Print "HDF write err = ",err
1408        endif
1409        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1410        err = V_KillNamedDataFolder(fname)
1411        if(err)
1412                Print "DataFolder kill err = ",err
1413        endif
1414        return(err)
1415end
1416
1417Function V_writeFlipperstatus(fname,str)
1418        String fname,str
1419
1420//      String path = "entry:instrument:beam:flipper:status"
1421
1422        Make/O/T/N=1 tmpTW
1423        String groupName = "/entry/instrument/beam/flipper"     //     
1424        String varName = "status"
1425        tmpTW[0] = str //
1426
1427        variable err
1428        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1429        if(err)
1430                Print "HDF write err = ",err
1431        endif
1432       
1433        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1434        err = V_KillNamedDataFolder(fname)
1435        if(err)
1436                Print "DataFolder kill err = ",err
1437        endif
1438               
1439        return(err)
1440End
1441
1442Function V_writeFlipperTransmitted_power(fname,val)
1443        String fname
1444        Variable val
1445       
1446//      String path = "entry:instrument:beam:flipper:transmitted_power"
1447
1448        Make/O/D/N=1 wTmpWrite
1449//      Make/O/R/N=1 wTmpWrite
1450        String groupName = "/entry/instrument/beam/flipper"     
1451        String varName = "transmitted_power"
1452        wTmpWrite[0] = val
1453
1454        variable err
1455        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1456        if(err)
1457                Print "HDF write err = ",err
1458        endif
1459        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1460        err = V_KillNamedDataFolder(fname)
1461        if(err)
1462                Print "DataFolder kill err = ",err
1463        endif
1464        return(err)
1465end
1466
1467Function V_writeFlipperWaveform(fname,str)
1468        String fname,str
1469
1470//      String path = "entry:instrument:beam:flipper:waveform"
1471
1472        Make/O/T/N=1 tmpTW
1473        String groupName = "/entry/instrument/beam/flipper"     //     
1474        String varName = "waveform"
1475        tmpTW[0] = str //
1476
1477        variable err
1478        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1479        if(err)
1480                Print "HDF write err = ",err
1481        endif
1482       
1483        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1484        err = V_KillNamedDataFolder(fname)
1485        if(err)
1486                Print "DataFolder kill err = ",err
1487        endif
1488               
1489        return(err)
1490End
1491
1492// instrument/beam/monochromator (data folder)
1493Function V_writeMonochromatorType(fname,str)
1494        String fname,str
1495
1496//      String path = "entry:instrument:beam:monochromator:type"
1497
1498        Make/O/T/N=1 tmpTW
1499        String groupName = "/entry/instrument/beam/monochromator"       //     
1500        String varName = "type"
1501        tmpTW[0] = str //
1502
1503        variable err
1504        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1505        if(err)
1506                Print "HDF write err = ",err
1507        endif
1508       
1509        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1510        err = V_KillNamedDataFolder(fname)
1511        if(err)
1512                Print "DataFolder kill err = ",err
1513        endif
1514               
1515        return(err)
1516End
1517
1518Function V_writeWavelength(fname,val)
1519        String fname
1520        Variable val
1521       
1522//      String path = "entry:instrument:beam:monochromator:wavelength" 
1523       
1524        Make/O/D/N=1 wTmpWrite
1525//      Make/O/R/N=1 wTmpWrite
1526        String groupName = "/entry/instrument/beam/monochromator"       
1527        String varName = "wavelength"
1528        wTmpWrite[0] = val
1529
1530        variable err
1531        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1532        if(err)
1533                Print "HDF write err = ",err
1534        endif
1535        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1536        err = V_KillNamedDataFolder(fname)
1537        if(err)
1538                Print "DataFolder kill err = ",err
1539        endif
1540        return(err)
1541end
1542
1543Function V_writeWavelength_spread(fname,val)
1544        String fname
1545        Variable val
1546       
1547//      String path = "entry:instrument:beam:monochromator:wavelength_spread"   
1548       
1549        Make/O/D/N=1 wTmpWrite
1550//      Make/O/R/N=1 wTmpWrite
1551        String groupName = "/entry/instrument/beam/monochromator"       
1552        String varName = "wavelength_spread"
1553        wTmpWrite[0] = val
1554
1555        variable err
1556        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1557        if(err)
1558                Print "HDF write err = ",err
1559        endif
1560        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1561        err = V_KillNamedDataFolder(fname)
1562        if(err)
1563                Print "DataFolder kill err = ",err
1564        endif
1565        return(err)
1566end
1567
1568// instrument/beam/monochromator/crystal (data folder)
1569Function V_writeCrystalEnergy(fname,val)
1570        String fname
1571        Variable val
1572       
1573//      String path = "entry:instrument:beam:monochromator:crystal:energy"     
1574       
1575        Make/O/D/N=1 wTmpWrite
1576//      Make/O/R/N=1 wTmpWrite
1577        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1578        String varName = "energy"
1579        wTmpWrite[0] = val
1580
1581        variable err
1582        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1583        if(err)
1584                Print "HDF write err = ",err
1585        endif
1586        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1587        err = V_KillNamedDataFolder(fname)
1588        if(err)
1589                Print "DataFolder kill err = ",err
1590        endif
1591        return(err)
1592end
1593
1594Function V_writeCrystalHoriz_apert(fname,val)
1595        String fname
1596        Variable val
1597       
1598//      String path = "entry:instrument:beam:monochromator:crystal:horizontal_aperture"
1599       
1600        Make/O/D/N=1 wTmpWrite
1601//      Make/O/R/N=1 wTmpWrite
1602        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1603        String varName = "horizontal_aperture"
1604        wTmpWrite[0] = val
1605
1606        variable err
1607        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1608        if(err)
1609                Print "HDF write err = ",err
1610        endif
1611        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1612        err = V_KillNamedDataFolder(fname)
1613        if(err)
1614                Print "DataFolder kill err = ",err
1615        endif
1616        return(err)
1617end
1618
1619Function V_writeCrystalHoriz_curvature(fname,val)
1620        String fname
1621        Variable val
1622       
1623//      String path = "entry:instrument:beam:monochromator:crystal:horizontal_curvature"       
1624       
1625        Make/O/D/N=1 wTmpWrite
1626//      Make/O/R/N=1 wTmpWrite
1627        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1628        String varName = "horizontal_curvature"
1629        wTmpWrite[0] = val
1630
1631        variable err
1632        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1633        if(err)
1634                Print "HDF write err = ",err
1635        endif
1636        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1637        err = V_KillNamedDataFolder(fname)
1638        if(err)
1639                Print "DataFolder kill err = ",err
1640        endif
1641        return(err)
1642end
1643
1644Function V_writeCrystalLattice_parameter(fname,val)
1645        String fname
1646        Variable val
1647       
1648//      String path = "entry:instrument:beam:monochromator:crystal:lattice_parameter"   
1649       
1650        Make/O/D/N=1 wTmpWrite
1651//      Make/O/R/N=1 wTmpWrite
1652        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1653        String varName = "lattice_parameter"
1654        wTmpWrite[0] = val
1655
1656        variable err
1657        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1658        if(err)
1659                Print "HDF write err = ",err
1660        endif
1661        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1662        err = V_KillNamedDataFolder(fname)
1663        if(err)
1664                Print "DataFolder kill err = ",err
1665        endif
1666        return(err)
1667end
1668
1669Function V_writeCrystalnx_distance(fname,val)
1670        String fname
1671        Variable val
1672       
1673//      String path = "entry:instrument:beam:monochromator:crystal:nx_distance"
1674       
1675        Make/O/D/N=1 wTmpWrite
1676//      Make/O/R/N=1 wTmpWrite
1677        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1678        String varName = "nx_distance"
1679        wTmpWrite[0] = val
1680
1681        variable err
1682        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1683        if(err)
1684                Print "HDF write err = ",err
1685        endif
1686        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1687        err = V_KillNamedDataFolder(fname)
1688        if(err)
1689                Print "DataFolder kill err = ",err
1690        endif
1691        return(err)
1692end
1693
1694Function V_writeCrystalReflection(fname,val)
1695        String fname
1696        Variable val
1697       
1698//      String path = "entry:instrument:beam:monochromator:crystal:reflection" 
1699       
1700        Make/O/D/N=1 wTmpWrite
1701//      Make/O/R/N=1 wTmpWrite
1702        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1703        String varName = "reflection"
1704        wTmpWrite[0] = val
1705
1706        variable err
1707        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1708        if(err)
1709                Print "HDF write err = ",err
1710        endif
1711        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1712        err = V_KillNamedDataFolder(fname)
1713        if(err)
1714                Print "DataFolder kill err = ",err
1715        endif
1716        return(err)
1717end
1718
1719Function V_writeCrystalRotation(fname,val)
1720        String fname
1721        Variable val
1722       
1723//      String path = "entry:instrument:beam:monochromator:crystal:rotation"   
1724       
1725        Make/O/D/N=1 wTmpWrite
1726//      Make/O/R/N=1 wTmpWrite
1727        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1728        String varName = "rotation"
1729        wTmpWrite[0] = val
1730
1731        variable err
1732        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1733        if(err)
1734                Print "HDF write err = ",err
1735        endif
1736        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1737        err = V_KillNamedDataFolder(fname)
1738        if(err)
1739                Print "DataFolder kill err = ",err
1740        endif
1741        return(err)
1742end
1743
1744Function V_writeCrystalStatus(fname,str)
1745        String fname,str
1746
1747//      String path = "entry:instrument:beam:monochromator:crystal:status"
1748
1749        Make/O/T/N=1 tmpTW
1750        String groupName = "/entry/instrument/beam/monochromator/crystal"       //     
1751        String varName = "status"
1752        tmpTW[0] = str //
1753
1754        variable err
1755        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1756        if(err)
1757                Print "HDF write err = ",err
1758        endif
1759       
1760        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1761        err = V_KillNamedDataFolder(fname)
1762        if(err)
1763                Print "DataFolder kill err = ",err
1764        endif
1765               
1766        return(err)
1767End
1768
1769Function V_writeCrystalVertical_aperture(fname,val)
1770        String fname
1771        Variable val
1772       
1773//      String path = "entry:instrument:beam:monochromator:crystal:vertical_aperture"   
1774       
1775        Make/O/D/N=1 wTmpWrite
1776//      Make/O/R/N=1 wTmpWrite
1777        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1778        String varName = "vertical_aperture"
1779        wTmpWrite[0] = val
1780
1781        variable err
1782        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1783        if(err)
1784                Print "HDF write err = ",err
1785        endif
1786        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1787        err = V_KillNamedDataFolder(fname)
1788        if(err)
1789                Print "DataFolder kill err = ",err
1790        endif
1791        return(err)
1792end
1793
1794Function V_writeCrystalVertical_curv(fname,val)
1795        String fname
1796        Variable val
1797       
1798//      String path = "entry:instrument:beam:monochromator:crystal:vertical_curvature" 
1799       
1800        Make/O/D/N=1 wTmpWrite
1801//      Make/O/R/N=1 wTmpWrite
1802        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1803        String varName = "vertical_curvature"
1804        wTmpWrite[0] = val
1805
1806        variable err
1807        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1808        if(err)
1809                Print "HDF write err = ",err
1810        endif
1811        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1812        err = V_KillNamedDataFolder(fname)
1813        if(err)
1814                Print "DataFolder kill err = ",err
1815        endif
1816        return(err)
1817end
1818
1819Function V_writeCrystalWavelength(fname,val)
1820        String fname
1821        Variable val
1822       
1823//      String path = "entry:instrument:beam:monochromator:crystal:wavelength" 
1824       
1825        Make/O/D/N=1 wTmpWrite
1826//      Make/O/R/N=1 wTmpWrite
1827        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1828        String varName = "wavelength"
1829        wTmpWrite[0] = val
1830
1831        variable err
1832        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1833        if(err)
1834                Print "HDF write err = ",err
1835        endif
1836        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1837        err = V_KillNamedDataFolder(fname)
1838        if(err)
1839                Print "DataFolder kill err = ",err
1840        endif
1841        return(err)
1842end
1843
1844Function V_writeCrystalWavelength_spread(fname,val)
1845        String fname
1846        Variable val
1847       
1848//      String path = "entry:instrument:beam:monochromator:crystal:wavelength_spread"   
1849       
1850        Make/O/D/N=1 wTmpWrite
1851//      Make/O/R/N=1 wTmpWrite
1852        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1853        String varName = "wavelength_spread"
1854        wTmpWrite[0] = val
1855
1856        variable err
1857        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1858        if(err)
1859                Print "HDF write err = ",err
1860        endif
1861        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1862        err = V_KillNamedDataFolder(fname)
1863        if(err)
1864                Print "DataFolder kill err = ",err
1865        endif
1866        return(err)
1867end
1868
1869Function V_writeCrystalWavevector(fname,val)
1870        String fname
1871        Variable val
1872       
1873//      String path = "entry:instrument:beam:monochromator:crystal:wavevector" 
1874       
1875        Make/O/D/N=1 wTmpWrite
1876//      Make/O/R/N=1 wTmpWrite
1877        String groupName = "/entry/instrument/beam/monochromator/crystal"       
1878        String varName = "wavevector"
1879        wTmpWrite[0] = val
1880
1881        variable err
1882        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1883        if(err)
1884                Print "HDF write err = ",err
1885        endif
1886        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1887        err = V_KillNamedDataFolder(fname)
1888        if(err)
1889                Print "DataFolder kill err = ",err
1890        endif
1891        return(err)
1892end
1893
1894// instrument/beam/monochromator/velocity_selector (data folder)
1895Function V_writeVSnx_distance(fname,val)
1896        String fname
1897        Variable val
1898       
1899//      String path = "entry:instrument:beam:monochromator:velocity_selector:nx_distance"       
1900       
1901        Make/O/D/N=1 wTmpWrite
1902//      Make/O/R/N=1 wTmpWrite
1903        String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     
1904        String varName = "nx_distance"
1905        wTmpWrite[0] = val
1906
1907        variable err
1908        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1909        if(err)
1910                Print "HDF write err = ",err
1911        endif
1912        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1913        err = V_KillNamedDataFolder(fname)
1914        if(err)
1915                Print "DataFolder kill err = ",err
1916        endif
1917        return(err)
1918end
1919
1920Function V_writeVSRotation_speed(fname,val)
1921        String fname
1922        Variable val
1923       
1924//      String path = "entry:instrument:beam:monochromator:velocity_selector:rotation_speed"   
1925       
1926        Make/O/D/N=1 wTmpWrite
1927//      Make/O/R/N=1 wTmpWrite
1928        String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     
1929        String varName = "rotation_speed"
1930        wTmpWrite[0] = val
1931
1932        variable err
1933        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1934        if(err)
1935                Print "HDF write err = ",err
1936        endif
1937        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1938        err = V_KillNamedDataFolder(fname)
1939        if(err)
1940                Print "DataFolder kill err = ",err
1941        endif
1942        return(err)
1943end
1944
1945Function V_writeVelSelStatus(fname,str)
1946        String fname,str
1947
1948//      String path = "entry:instrument:beam:monochromator:velocity_selector:status"
1949
1950        Make/O/T/N=1 tmpTW
1951        String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     //     
1952        String varName = "status"
1953        tmpTW[0] = str //
1954
1955        variable err
1956        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1957        if(err)
1958                Print "HDF write err = ",err
1959        endif
1960       
1961        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1962        err = V_KillNamedDataFolder(fname)
1963        if(err)
1964                Print "DataFolder kill err = ",err
1965        endif
1966               
1967        return(err)
1968End
1969
1970Function V_writeVSTable(fname,inW)
1971        String fname
1972        Wave inW
1973       
1974//      String path = "entry:instrument:beam:monochromator:velocity_selector:table"     
1975
1976        Duplicate/O inW wTmpWrite       
1977// then use redimension as needed to cast the wave to write to the specified type
1978// see WaveType for the proper codes
1979//      Redimension/T=() wTmpWrite
1980// -- May also need to check the dimension(s) before writing (don't trust the input)
1981        String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     
1982        String varName = "table"
1983
1984        variable err
1985        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1986        if(err)
1987                Print "HDF write err = ",err
1988        endif
1989        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1990        err = V_KillNamedDataFolder(fname)
1991        if(err)
1992                Print "DataFolder kill err = ",err
1993        endif
1994        return(err)
1995end
1996
1997// TODO -- this is not the correct data type??? what does this mean??
1998Function V_writeVSTable_parameters(fname,val)
1999        String fname
2000        Variable val
2001       
2002        String path = "entry:instrument:beam:monochromator:velocity_selector:table_parameters" 
2003       
2004        Make/O/D/N=1 wTmpWrite
2005//      Make/O/R/N=1 wTmpWrite
2006        String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     
2007        String varName = "table_parameters"
2008        wTmpWrite[0] = val
2009
2010        variable err
2011        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2012        if(err)
2013                Print "HDF write err = ",err
2014        endif
2015        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2016        err = V_KillNamedDataFolder(fname)
2017        if(err)
2018                Print "DataFolder kill err = ",err
2019        endif
2020        return(err)
2021end
2022
2023Function V_writeVS_tilt(fname,val)
2024        String fname
2025        Variable val
2026       
2027//      String path = "entry:instrument:beam:monochromator:velocity_selector:vs_tilt"   
2028       
2029        Make/O/D/N=1 wTmpWrite
2030//      Make/O/R/N=1 wTmpWrite
2031        String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     
2032        String varName = "vs_tilt"
2033        wTmpWrite[0] = val
2034
2035        variable err
2036        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2037        if(err)
2038                Print "HDF write err = ",err
2039        endif
2040        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2041        err = V_KillNamedDataFolder(fname)
2042        if(err)
2043                Print "DataFolder kill err = ",err
2044        endif
2045        return(err)
2046end
2047
2048Function V_writeVSWavelength(fname,val)
2049        String fname
2050        Variable val
2051       
2052//      String path = "entry:instrument:beam:monochromator:velocity_selector:wavelength"       
2053       
2054        Make/O/D/N=1 wTmpWrite
2055//      Make/O/R/N=1 wTmpWrite
2056        String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     
2057        String varName = "wavelength"
2058        wTmpWrite[0] = val
2059
2060        variable err
2061        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2062        if(err)
2063                Print "HDF write err = ",err
2064        endif
2065        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2066        err = V_KillNamedDataFolder(fname)
2067        if(err)
2068                Print "DataFolder kill err = ",err
2069        endif
2070        return(err)
2071end
2072
2073Function V_writeVSWavelength_spread(fname,val)
2074        String fname
2075        Variable val
2076       
2077//      String path = "entry:instrument:beam:monochromator:velocity_selector:wavelength_spread"
2078       
2079        Make/O/D/N=1 wTmpWrite
2080//      Make/O/R/N=1 wTmpWrite
2081        String groupName = "/entry/instrument/beam/monochromator/velocity_selector"     
2082        String varName = "wavelength_spread"
2083        wTmpWrite[0] = val
2084
2085        variable err
2086        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2087        if(err)
2088                Print "HDF write err = ",err
2089        endif
2090        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2091        err = V_KillNamedDataFolder(fname)
2092        if(err)
2093                Print "DataFolder kill err = ",err
2094        endif
2095        return(err)
2096end
2097
2098// instrument/beam/monochromator/white_beam (data folder)
2099Function V_writeWhiteBeamStatus(fname,str)
2100        String fname,str
2101
2102//      String path = "entry:instrument:beam:monochromator:white_beam:status"
2103
2104        Make/O/T/N=1 tmpTW
2105        String groupName = "/entry/instrument/beam/monochromator/white_beam"    //     
2106        String varName = "status"
2107        tmpTW[0] = str //
2108
2109        variable err
2110        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2111        if(err)
2112                Print "HDF write err = ",err
2113        endif
2114       
2115        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2116        err = V_KillNamedDataFolder(fname)
2117        if(err)
2118                Print "DataFolder kill err = ",err
2119        endif
2120               
2121        return(err)
2122End
2123
2124Function V_writeWhiteBeamWavelength(fname,val)
2125        String fname
2126        Variable val
2127       
2128//      String path = "entry:instrument:beam:monochromator:white_beam:wavelength"       
2129       
2130        Make/O/D/N=1 wTmpWrite
2131//      Make/O/R/N=1 wTmpWrite
2132        String groupName = "/entry/instrument/beam/monochromator/white_beam"   
2133        String varName = "wavelength"
2134        wTmpWrite[0] = val
2135
2136        variable err
2137        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2138        if(err)
2139                Print "HDF write err = ",err
2140        endif
2141        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2142        err = V_KillNamedDataFolder(fname)
2143        if(err)
2144                Print "DataFolder kill err = ",err
2145        endif
2146        return(err)
2147end
2148
2149Function V_writeWhiteBeamWavel_spread(fname,val)
2150        String fname
2151        Variable val
2152       
2153//      String path = "entry:instrument:beam:monochromator:white_beam:wavelength_spread"       
2154       
2155        Make/O/D/N=1 wTmpWrite
2156//      Make/O/R/N=1 wTmpWrite
2157        String groupName = "/entry/instrument/beam/monochromator/white_beam"   
2158        String varName = "wavelength_spread"
2159        wTmpWrite[0] = val
2160
2161        variable err
2162        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2163        if(err)
2164                Print "HDF write err = ",err
2165        endif
2166        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2167        err = V_KillNamedDataFolder(fname)
2168        if(err)
2169                Print "DataFolder kill err = ",err
2170        endif
2171        return(err)
2172end
2173
2174// instrument/beam/polarizer (data folder)
2175Function V_writePolarizerComposition(fname,str)
2176        String fname,str
2177
2178//      String path = "entry:instrument:beam:polarizer:composition"
2179
2180        Make/O/T/N=1 tmpTW
2181        String groupName = "/entry/instrument/beam/polarizer"   //     
2182        String varName = "composition"
2183        tmpTW[0] = str //
2184
2185        variable err
2186        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2187        if(err)
2188                Print "HDF write err = ",err
2189        endif
2190       
2191        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2192        err = V_KillNamedDataFolder(fname)
2193        if(err)
2194                Print "DataFolder kill err = ",err
2195        endif
2196               
2197        return(err)
2198End
2199
2200Function V_writePolarizerEfficiency(fname,val)
2201        String fname
2202        Variable val
2203       
2204//      String path = "entry:instrument:beam:polarizer:efficiency"     
2205       
2206        Make/O/D/N=1 wTmpWrite
2207//      Make/O/R/N=1 wTmpWrite
2208        String groupName = "/entry/instrument/beam/polarizer"   
2209        String varName = "efficiency"
2210        wTmpWrite[0] = val
2211
2212        variable err
2213        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2214        if(err)
2215                Print "HDF write err = ",err
2216        endif
2217        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2218        err = V_KillNamedDataFolder(fname)
2219        if(err)
2220                Print "DataFolder kill err = ",err
2221        endif
2222        return(err)
2223end
2224
2225Function V_writePolarizerStatus(fname,str)
2226        String fname,str
2227
2228//      String path = "entry:instrument:beam:polarizer:status"
2229
2230        Make/O/T/N=1 tmpTW
2231        String groupName = "/entry/instrument/beam/polarizer"   //     
2232        String varName = "status"
2233        tmpTW[0] = str //
2234
2235        variable err
2236        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2237        if(err)
2238                Print "HDF write err = ",err
2239        endif
2240       
2241        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2242        err = V_KillNamedDataFolder(fname)
2243        if(err)
2244                Print "DataFolder kill err = ",err
2245        endif
2246               
2247        return(err)
2248End
2249
2250Function V_writePolarizerType(fname,str)
2251        String fname,str
2252
2253//      String path = "entry:instrument:beam:polarizer:type"
2254
2255        Make/O/T/N=1 tmpTW
2256        String groupName = "/entry/instrument/beam/polarizer"   //     
2257        String varName = "type"
2258        tmpTW[0] = str //
2259
2260        variable err
2261        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2262        if(err)
2263                Print "HDF write err = ",err
2264        endif
2265       
2266        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2267        err = V_KillNamedDataFolder(fname)
2268        if(err)
2269                Print "DataFolder kill err = ",err
2270        endif
2271               
2272        return(err)
2273End
2274
2275// instrument/beam/polarizer_analyzer (data folder)
2276Function V_writePolAnaCell_index(fname,val)
2277        String fname
2278        Variable val
2279
2280//      String path = "entry:instrument:beam:polarizer_analyzer:cell_index"
2281       
2282        Make/O/D/N=1 wTmpWrite
2283//      Make/O/R/N=1 wTmpWrite
2284        String groupName = "/entry/instrument/beam/polarizer_analyzer" 
2285        String varName = "cell_index"
2286        wTmpWrite[0] = val
2287
2288        variable err
2289        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2290        if(err)
2291                Print "HDF write err = ",err
2292        endif
2293        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2294        err = V_KillNamedDataFolder(fname)
2295        if(err)
2296                Print "DataFolder kill err = ",err
2297        endif
2298        return(err)
2299End
2300
2301Function V_writePolAnaCell_name(fname,str)
2302        String fname,str
2303
2304//      String path = "entry:instrument:beam:polarizer_analyzer:cell_name"
2305
2306        Make/O/T/N=1 tmpTW
2307        String groupName = "/entry/instrument/beam/polarizer_analyzer"  //     
2308        String varName = "cell_name"
2309        tmpTW[0] = str //
2310
2311        variable err
2312        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2313        if(err)
2314                Print "HDF write err = ",err
2315        endif
2316       
2317        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2318        err = V_KillNamedDataFolder(fname)
2319        if(err)
2320                Print "DataFolder kill err = ",err
2321        endif
2322               
2323        return(err)
2324End
2325
2326Function V_writePolAnaCell_parameters(fname,inW)
2327        String fname
2328        Wave inW
2329
2330//      String path = "entry:instrument:beam:polarizer_analyzer:cell_parameters"
2331
2332        Duplicate/O inW wTmpWrite       
2333// then use redimension as needed to cast the wave to write to the specified type
2334// see WaveType for the proper codes
2335//      Redimension/T=() wTmpWrite
2336// -- May also need to check the dimension(s) before writing (don't trust the input)
2337        String groupName = "/entry/instrument//beam/polarizer_analyzer"
2338        String varName = "cell_parameters"
2339
2340        variable err
2341        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2342        if(err)
2343                Print "HDF write err = ",err
2344        endif
2345        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2346        err = V_KillNamedDataFolder(fname)
2347        if(err)
2348                Print "DataFolder kill err = ",err
2349        endif
2350        return(err)
2351End
2352
2353Function V_writePolAnaGuideFieldCur_1(fname,val)
2354        String fname
2355        Variable val
2356
2357//      String path = "entry:instrument:beam:polarizer_analyzer:guide_field_current_1"
2358       
2359        Make/O/D/N=1 wTmpWrite
2360//      Make/O/R/N=1 wTmpWrite
2361        String groupName = "/entry/instrument/beam/polarizer_analyzer" 
2362        String varName = "guide_field_current_1"
2363        wTmpWrite[0] = val
2364
2365        variable err
2366        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2367        if(err)
2368                Print "HDF write err = ",err
2369        endif
2370        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2371        err = V_KillNamedDataFolder(fname)
2372        if(err)
2373                Print "DataFolder kill err = ",err
2374        endif
2375        return(err)
2376End
2377
2378Function V_writePolAnaGuideFieldCur_2(fname,val)
2379        String fname
2380        Variable val
2381
2382//      String path = "entry:instrument:beam:polarizer_analyzer:guide_field_current_2"
2383       
2384        Make/O/D/N=1 wTmpWrite
2385//      Make/O/R/N=1 wTmpWrite
2386        String groupName = "/entry/instrument/beam/polarizer_analyzer" 
2387        String varName = "guide_field_current_2"
2388        wTmpWrite[0] = val
2389
2390        variable err
2391        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2392        if(err)
2393                Print "HDF write err = ",err
2394        endif
2395        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2396        err = V_KillNamedDataFolder(fname)
2397        if(err)
2398                Print "DataFolder kill err = ",err
2399        endif
2400        return(err)
2401End
2402
2403Function V_writePolAnaSolenoid_current(fname,val)
2404        String fname
2405        Variable val
2406
2407//      String path = "entry:instrument:beam:polarizer_analyzer:solenoid_current"
2408       
2409        Make/O/D/N=1 wTmpWrite
2410//      Make/O/R/N=1 wTmpWrite
2411        String groupName = "/entry/instrument/beam/polarizer_analyzer" 
2412        String varName = "solenoid_current"
2413        wTmpWrite[0] = val
2414
2415        variable err
2416        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2417        if(err)
2418                Print "HDF write err = ",err
2419        endif
2420        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2421        err = V_KillNamedDataFolder(fname)
2422        if(err)
2423                Print "DataFolder kill err = ",err
2424        endif
2425        return(err)
2426End
2427
2428Function V_writePolAnaStatus(fname,str)
2429        String fname,str
2430
2431//      String path = "entry:instrument:beam:polarizer_analyzer:status"
2432
2433        Make/O/T/N=1 tmpTW
2434        String groupName = "/entry/instrument/beam/polarizer_analyzer"  //     
2435        String varName = "status"
2436        tmpTW[0] = str //
2437
2438        variable err
2439        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2440        if(err)
2441                Print "HDF write err = ",err
2442        endif
2443       
2444        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2445        err = V_KillNamedDataFolder(fname)
2446        if(err)
2447                Print "DataFolder kill err = ",err
2448        endif
2449               
2450        return(err)
2451End
2452
2453                                       
2454/////// INSTRUMENT/BEAM MONITORS
2455
2456//beam_monitor_low (data folder)
2457Function V_writeBeamMonLowData(fname,val)
2458        String fname
2459        Variable val
2460
2461//      String path = "entry:instrument:beam_monitor_low:data"
2462       
2463        Make/O/D/N=1 wTmpWrite
2464//      Make/O/R/N=1 wTmpWrite
2465        String groupName = "/entry/instrument/beam_monitor_low"
2466        String varName = "data"
2467        wTmpWrite[0] = val
2468
2469        variable err
2470        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2471        if(err)
2472                Print "HDF write err = ",err
2473        endif
2474        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2475        err = V_KillNamedDataFolder(fname)
2476        if(err)
2477                Print "DataFolder kill err = ",err
2478        endif
2479        return(err)
2480End
2481
2482Function V_writeBeamMonLowEfficiency(fname,val)
2483        String fname
2484        Variable val
2485
2486//      String path = "entry:instrument:beam_monitor_low:efficiency"
2487       
2488        Make/O/D/N=1 wTmpWrite
2489//      Make/O/R/N=1 wTmpWrite
2490        String groupName = "/entry/instrument/beam_monitor_low"
2491        String varName = "efficiency"
2492        wTmpWrite[0] = val
2493
2494        variable err
2495        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2496        if(err)
2497                Print "HDF write err = ",err
2498        endif
2499        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2500        err = V_KillNamedDataFolder(fname)
2501        if(err)
2502                Print "DataFolder kill err = ",err
2503        endif
2504        return(err)
2505End
2506
2507Function V_writeBeamMonLownx_distance(fname,val)
2508        String fname
2509        Variable val
2510
2511//      String path = "entry:instrument:beam_monitor_low:nx_distance"
2512       
2513        Make/O/D/N=1 wTmpWrite
2514//      Make/O/R/N=1 wTmpWrite
2515        String groupName = "/entry/instrument/beam_monitor_low"
2516        String varName = "nx_distance"
2517        wTmpWrite[0] = val
2518
2519        variable err
2520        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2521        if(err)
2522                Print "HDF write err = ",err
2523        endif
2524        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2525        err = V_KillNamedDataFolder(fname)
2526        if(err)
2527                Print "DataFolder kill err = ",err
2528        endif
2529        return(err)
2530End
2531
2532Function V_writeBeamMonLowSaved_count(fname,val)
2533        String fname
2534        Variable val
2535
2536//      String path = "entry:instrument:beam_monitor_low:saved_count"
2537       
2538        Make/O/D/N=1 wTmpWrite
2539//      Make/O/R/N=1 wTmpWrite
2540        String groupName = "/entry/instrument/beam_monitor_low"
2541        String varName = "saved_count"
2542        wTmpWrite[0] = val
2543
2544        variable err
2545        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2546        if(err)
2547                Print "HDF write err = ",err
2548        endif
2549        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2550        err = V_KillNamedDataFolder(fname)
2551        if(err)
2552                Print "DataFolder kill err = ",err
2553        endif
2554        return(err)
2555End
2556
2557Function V_writeBeamMonLowType(fname,str)
2558        String fname,str
2559
2560//      String path = "entry:instrument:beam_monitor_low:type"
2561
2562        Make/O/T/N=1 tmpTW
2563        String groupName = "/entry/instrument/beam_monitor_low" //     
2564        String varName = "type"
2565        tmpTW[0] = str //
2566
2567        variable err
2568        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2569        if(err)
2570                Print "HDF write err = ",err
2571        endif
2572       
2573        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2574        err = V_KillNamedDataFolder(fname)
2575        if(err)
2576                Print "DataFolder kill err = ",err
2577        endif
2578               
2579        return(err)
2580End
2581
2582//beam_monitor_norm (data folder)
2583Function V_writeBeamMonNormData(fname,val)
2584        String fname
2585        Variable val
2586
2587//      String path = "entry:instrument:beam_monitor_norm:data"
2588       
2589        Make/O/D/N=1 wTmpWrite
2590//      Make/O/R/N=1 wTmpWrite
2591        String groupName = "/entry/instrument/beam_monitor_norm"       
2592        String varName = "data"
2593        wTmpWrite[0] = val
2594
2595        variable err
2596        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2597        if(err)
2598                Print "HDF write err = ",err
2599        endif
2600        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2601        err = V_KillNamedDataFolder(fname)
2602        if(err)
2603                Print "DataFolder kill err = ",err
2604        endif
2605        return(err)
2606End
2607
2608Function V_writeBeamMonNormEfficiency(fname,val)
2609        String fname
2610        Variable val
2611
2612//      String path = "entry:instrument:beam_monitor_norm:efficiency"
2613       
2614        Make/O/D/N=1 wTmpWrite
2615//      Make/O/R/N=1 wTmpWrite
2616        String groupName = "/entry/instrument/beam_monitor_norm"       
2617        String varName = "efficiency"
2618        wTmpWrite[0] = val
2619
2620        variable err
2621        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2622        if(err)
2623                Print "HDF write err = ",err
2624        endif
2625        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2626        err = V_KillNamedDataFolder(fname)
2627        if(err)
2628                Print "DataFolder kill err = ",err
2629        endif
2630        return(err)
2631End
2632
2633Function V_writeBeamMonNormnx_distance(fname,val)
2634        String fname
2635        Variable val
2636
2637//      String path = "entry:instrument:beam_monitor_norm:nx_distance"
2638       
2639        Make/O/D/N=1 wTmpWrite
2640//      Make/O/R/N=1 wTmpWrite
2641        String groupName = "/entry/instrument/beam_monitor_norm"       
2642        String varName = "nx_distance"
2643        wTmpWrite[0] = val
2644
2645        variable err
2646        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2647        if(err)
2648                Print "HDF write err = ",err
2649        endif
2650        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2651        err = V_KillNamedDataFolder(fname)
2652        if(err)
2653                Print "DataFolder kill err = ",err
2654        endif
2655        return(err)
2656End
2657
2658Function V_writeBeamMonNormSaved_count(fname,val)
2659        String fname
2660        Variable val
2661
2662//      String path = "entry:instrument:beam_monitor_norm:saved_count"
2663       
2664        Make/O/D/N=1 wTmpWrite
2665//      Make/O/R/N=1 wTmpWrite
2666        String groupName = "/entry/instrument/beam_monitor_norm"       
2667        String varName = "saved_count"
2668        wTmpWrite[0] = val
2669
2670        variable err
2671        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2672        if(err)
2673                Print "HDF write err = ",err
2674        endif
2675        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2676        err = V_KillNamedDataFolder(fname)
2677        if(err)
2678                Print "DataFolder kill err = ",err
2679        endif
2680        return(err)
2681End
2682
2683Function V_writeBeamMonNormType(fname,str)
2684        String fname,str
2685
2686//      String path = "entry:instrument:beam_monitor_norm:type"
2687
2688        Make/O/T/N=1 tmpTW
2689        String groupName = "/entry/instrument/beam_monitor_norm"        //     
2690        String varName = "type"
2691        tmpTW[0] = str //
2692
2693        variable err
2694        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2695        if(err)
2696                Print "HDF write err = ",err
2697        endif
2698       
2699        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2700        err = V_KillNamedDataFolder(fname)
2701        if(err)
2702                Print "DataFolder kill err = ",err
2703        endif
2704               
2705        return(err)
2706End
2707
2708//beam_stop (data folder)
2709Function V_writeBeamStopDescription(fname,str)
2710        String fname,str
2711
2712//      String path = "entry:instrument:beam_stop:description"
2713
2714        Make/O/T/N=1 tmpTW
2715        String groupName = "/entry/instrument/beam_stop"        //     
2716        String varName = "description"
2717        tmpTW[0] = str //
2718
2719        variable err
2720        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2721        if(err)
2722                Print "HDF write err = ",err
2723        endif
2724       
2725        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2726        err = V_KillNamedDataFolder(fname)
2727        if(err)
2728                Print "DataFolder kill err = ",err
2729        endif
2730               
2731        return(err)
2732End
2733
2734Function V_writeBeamStopDist_to_det(fname,val)
2735        String fname
2736        Variable val
2737
2738//      String path = "entry:instrument:beam_stop:distance_to_detector"
2739       
2740        Make/O/D/N=1 wTmpWrite
2741//      Make/O/R/N=1 wTmpWrite
2742        String groupName = "/entry/instrument/beam_monitor_norm"       
2743        String varName = "distance_to_detector"
2744        wTmpWrite[0] = val
2745
2746        variable err
2747        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2748        if(err)
2749                Print "HDF write err = ",err
2750        endif
2751        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2752        err = V_KillNamedDataFolder(fname)
2753        if(err)
2754                Print "DataFolder kill err = ",err
2755        endif
2756        return(err)
2757End
2758
2759Function V_writeBeamStop_x0(fname,val)
2760        String fname
2761        Variable val
2762
2763//      String path = "entry:instrument:beam_stop:x0"
2764       
2765        Make/O/D/N=1 wTmpWrite
2766//      Make/O/R/N=1 wTmpWrite
2767        String groupName = "/entry/instrument/beam_stop"       
2768        String varName = "x0"
2769        wTmpWrite[0] = val
2770
2771        variable err
2772        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2773        if(err)
2774                Print "HDF write err = ",err
2775        endif
2776        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2777        err = V_KillNamedDataFolder(fname)
2778        if(err)
2779                Print "DataFolder kill err = ",err
2780        endif
2781        return(err)
2782End
2783
2784Function V_writeBeamStop_y0(fname,val)
2785        String fname
2786        Variable val
2787
2788//      String path = "entry:instrument:beam_stop:y0"
2789       
2790        Make/O/D/N=1 wTmpWrite
2791//      Make/O/R/N=1 wTmpWrite
2792        String groupName = "/entry/instrument/beam_stop"       
2793        String varName = "y0"
2794        wTmpWrite[0] = val
2795
2796        variable err
2797        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2798        if(err)
2799                Print "HDF write err = ",err
2800        endif
2801        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2802        err = V_KillNamedDataFolder(fname)
2803        if(err)
2804                Print "DataFolder kill err = ",err
2805        endif
2806        return(err)
2807End
2808
2809//// INSTRUMENT/COLLIMATOR
2810//collimator (data folder)
2811Function V_writeNumberOfGuides(fname,val)
2812        String fname
2813        Variable val
2814       
2815//      String path = "entry:instrument:collimator:number_guides"
2816       
2817        Make/O/D/N=1 wTmpWrite
2818//      Make/O/R/N=1 wTmpWrite
2819        String groupName = "/entry/instrument/collimator"       
2820        String varName = "number_guides"
2821        wTmpWrite[0] = val
2822
2823        variable err
2824        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2825        if(err)
2826                Print "HDF write err = ",err
2827        endif
2828        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2829        err = V_KillNamedDataFolder(fname)
2830        if(err)
2831                Print "DataFolder kill err = ",err
2832        endif
2833        return(err)
2834End
2835
2836//                              geometry (data folder)
2837//                                      shape (data folder)
2838Function V_writeGuideShape(fname,str)
2839        String fname,str
2840
2841//      String path = "entry:instrument:collimator:geometry:shape:shape"
2842
2843        Make/O/T/N=1 tmpTW
2844        String groupName = "/entry/instrument/collimator/geometry/shape"        //     
2845        String varName = "shape"
2846        tmpTW[0] = str //
2847
2848        variable err
2849        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2850        if(err)
2851                Print "HDF write err = ",err
2852        endif
2853       
2854        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2855        err = V_KillNamedDataFolder(fname)
2856        if(err)
2857                Print "DataFolder kill err = ",err
2858        endif
2859               
2860        return(err)
2861End
2862
2863// TODO -- this may need to be a wave to properly describe the dimensions
2864Function V_writeGuideSize(fname,val)
2865        String fname
2866        Variable val
2867
2868//      String path = "entry:instrument:collimator:geometry:shape:size"
2869       
2870        Make/O/D/N=1 wTmpWrite
2871//      Make/O/R/N=1 wTmpWrite
2872        String groupName = "/entry/instrument/collimator/geometry/shape"       
2873        String varName = "size"
2874        wTmpWrite[0] = val
2875
2876        variable err
2877        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2878        if(err)
2879                Print "HDF write err = ",err
2880        endif
2881        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2882        err = V_KillNamedDataFolder(fname)
2883        if(err)
2884                Print "DataFolder kill err = ",err
2885        endif
2886        return(err)
2887End
2888
2889//                      converging_pinholes (data folder)
2890Function V_writeConvPinholeStatus(fname,str)
2891        String fname,str
2892
2893//      String path = "entry:instrument:converging_pinholes:status"
2894
2895        Make/O/T/N=1 tmpTW
2896        String groupName = "/entry/instrument/converging_pinholes"      //     
2897        String varName = "status"
2898        tmpTW[0] = str //
2899
2900        variable err
2901        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2902        if(err)
2903                Print "HDF write err = ",err
2904        endif
2905       
2906        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2907        err = V_KillNamedDataFolder(fname)
2908        if(err)
2909                Print "DataFolder kill err = ",err
2910        endif
2911               
2912        return(err)
2913End
2914
2915//                      converging_slits (data folder)
2916Function V_writeConvSlitStatus(fname,str)
2917        String fname,str
2918
2919//      String path = "entry:instrument:converging_slits:status"
2920
2921        Make/O/T/N=1 tmpTW
2922        String groupName = "/entry/instrument/converging_slits" //     
2923        String varName = "status"
2924        tmpTW[0] = str //
2925
2926        variable err
2927        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
2928        if(err)
2929                Print "HDF write err = ",err
2930        endif
2931       
2932        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2933        err = V_KillNamedDataFolder(fname)
2934        if(err)
2935                Print "DataFolder kill err = ",err
2936        endif
2937               
2938        return(err)
2939End
2940
2941
2942////// INSTRUMENT/DETECTORS
2943//                      detector_B (data folder)
2944//
2945// only defined for the "B" detector, and may not be necessary?
2946// TODO -- write to return an ARRAY
2947Function V_writeDet_CALX(fname,detStr,inW)
2948        String fname,detStr
2949        Wave inW
2950
2951        if(cmpstr(detStr,"B") == 0)
2952//              String path = "entry:instrument:detector_"+detStr+":CALX"
2953               
2954                Duplicate/O inW wTmpWrite       
2955        // then use redimension as needed to cast the wave to write to the specified type
2956        // see WaveType for the proper codes
2957        //      Redimension/T=() wTmpWrite
2958        // -- May also need to check the dimension(s) before writing (don't trust the input)
2959                String groupName = "/entry/instrument/detector_"+detStr
2960                String varName = "CALX"
2961
2962                variable err
2963                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2964                if(err)
2965                        Print "HDF write err = ",err
2966                endif
2967                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
2968                err = V_KillNamedDataFolder(fname)
2969                if(err)
2970                        Print "DataFolder kill err = ",err
2971                endif
2972                return(err)
2973        else
2974                return(0)
2975        endif
2976End
2977
2978// only defined for the "B" detector, and may not be necessary?
2979// TODO -- write to return an ARRAY
2980Function V_writeDet_CALY(fname,detStr,inW)
2981        String fname,detStr
2982        Wave inW
2983
2984        if(cmpstr(detStr,"B") == 0)
2985//              String path = "entry:instrument:detector_"+detStr+":CALY"
2986
2987                Duplicate/O inW wTmpWrite       
2988        // then use redimension as needed to cast the wave to write to the specified type
2989        // see WaveType for the proper codes
2990        //      Redimension/T=() wTmpWrite
2991        // -- May also need to check the dimension(s) before writing (don't trust the input)
2992                String groupName = "/entry/instrument/detector_"+detStr
2993                String varName = "CALY"
2994
2995                variable err
2996                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
2997                if(err)
2998                        Print "HDF write err = ",err
2999                endif
3000                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3001                err = V_KillNamedDataFolder(fname)
3002                if(err)
3003                        Print "DataFolder kill err = ",err
3004                endif
3005                return(err)
3006        else
3007                return(0)
3008        endif
3009End
3010
3011// TODO -- write and X and Y version of this. Pixels are not square
3012// so the FHWM will be different in each direction. May need to return
3013// "dummy" value for "B" detector if pixels there are square
3014Function V_writeDet_PixelFWHM(fname,detStr)
3015        String fname,detStr
3016
3017        String path = "entry:instrument:detector_"+detStr+":PixelFWHM"
3018
3019// TODO -- different behavior for "B"
3020        if(cmpstr(detStr,"B") == 0)
3021//              return(V_writeRealValueFromHDF5(fname,path))
3022                return(-99999)
3023        else
3024//              return(V_writeRealValueFromHDF5(fname,path))
3025                return(-99999)
3026        endif
3027End
3028
3029Function V_writeDet_PixelNumX(fname,detStr,val)
3030        String fname,detStr
3031        Variable val
3032
3033//      String path = "entry:instrument:detector_"+detStr+":PixelNumX"
3034       
3035        Make/O/D/N=1 wTmpWrite
3036//      Make/O/R/N=1 wTmpWrite
3037        String groupName = "/entry/instrument/detector_"+detStr
3038        String varName = "PixelNumX"
3039        wTmpWrite[0] = val
3040
3041        variable err
3042        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3043        if(err)
3044                Print "HDF write err = ",err
3045        endif
3046        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3047        err = V_KillNamedDataFolder(fname)
3048        if(err)
3049                Print "DataFolder kill err = ",err
3050        endif
3051        return(err)
3052End
3053
3054Function V_writeDet_PixelNumY(fname,detStr,val)
3055        String fname,detStr
3056        Variable val
3057
3058//      String path = "entry:instrument:detector_"+detStr+":PixelNumY"
3059       
3060        Make/O/D/N=1 wTmpWrite
3061//      Make/O/R/N=1 wTmpWrite
3062        String groupName = "/entry/instrument/detector_"+detStr
3063        String varName = "PixelNumY"
3064        wTmpWrite[0] = val
3065
3066        variable err
3067        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3068        if(err)
3069                Print "HDF write err = ",err
3070        endif
3071        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3072        err = V_KillNamedDataFolder(fname)
3073        if(err)
3074                Print "DataFolder kill err = ",err
3075        endif
3076        return(err)
3077End
3078
3079// only defined for the "B" detector, and only to satisfy NXsas
3080Function V_writeDet_azimuthalAngle(fname,detStr,val)
3081        String fname,detStr
3082        Variable val
3083
3084        if(cmpstr(detStr,"B") == 0)
3085//              String path = "entry:instrument:detector_"+detStr+":azimuthal_angle"
3086       
3087                Make/O/D/N=1 wTmpWrite
3088        //      Make/O/R/N=1 wTmpWrite
3089                String groupName = "/entry/instrument/detector_"+detStr
3090                String varName = "azimuthal_angle"
3091                wTmpWrite[0] = val
3092
3093                variable err
3094                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3095                if(err)
3096                        Print "HDF write err = ",err
3097                endif
3098                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3099                err = V_KillNamedDataFolder(fname)
3100                if(err)
3101                        Print "DataFolder kill err = ",err
3102                endif
3103                return(err)
3104        else
3105                return(0)
3106        endif
3107End
3108
3109Function V_writeDet_beam_center_x(fname,detStr,val)
3110        String fname,detStr
3111        Variable val
3112
3113//      String path = "entry:instrument:detector_"+detStr+":beam_center_x"
3114       
3115        Make/O/D/N=1 wTmpWrite
3116//      Make/O/R/N=1 wTmpWrite
3117        String groupName = "/entry/instrument/detector_"+detStr
3118        String varName = "beam_center_x"
3119        wTmpWrite[0] = val
3120
3121        variable err
3122        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3123        if(err)
3124                Print "HDF write err = ",err
3125        endif
3126        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3127        err = V_KillNamedDataFolder(fname)
3128        if(err)
3129                Print "DataFolder kill err = ",err
3130        endif
3131        return(err)
3132End
3133
3134Function V_writeDet_beam_center_y(fname,detStr,val)
3135        String fname,detStr
3136        Variable val
3137
3138//      String path = "entry:instrument:detector_"+detStr+":beam_center_y"
3139       
3140        Make/O/D/N=1 wTmpWrite
3141//      Make/O/R/N=1 wTmpWrite
3142        String groupName = "/entry/instrument/detector_"+detStr
3143        String varName = "beam_center_y"
3144        wTmpWrite[0] = val
3145
3146        variable err
3147        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3148        if(err)
3149                Print "HDF write err = ",err
3150        endif
3151        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3152        err = V_KillNamedDataFolder(fname)
3153        if(err)
3154                Print "DataFolder kill err = ",err
3155        endif
3156        return(err)
3157End
3158
3159// TODO -- write this function to return a WAVE with the data
3160// either as a wave reference, or as an input parameter
3161Function V_writeDetectorData(fname,detStr,inW)
3162        String fname,detStr
3163        Wave inW
3164
3165//      String path = "entry:instrument:detector_"+detStr+":data"
3166       
3167        Duplicate/O inW wTmpWrite       
3168// then use redimension as needed to cast the wave to write to the specified type
3169// see WaveType for the proper codes
3170//      Redimension/T=() wTmpWrite
3171// -- May also need to check the dimension(s) before writing (don't trust the input)
3172        String groupName = "/entry/instrument/detector_"+detStr
3173        String varName = "data"
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
3188
3189// TODO -- write this function to return a WAVE with the data
3190// either as a wave reference, or as an input parameter
3191// ALSO -- the "B" deadtime will be a single value (probably)
3192//  but the tube banks will be 1D arrays of values, one per tube
3193Function V_writeDetector_deadtime(fname,detStr,inW)
3194        String fname,detStr
3195        Wave inW
3196
3197//      String path = "entry:instrument:detector_"+detStr+":dead_time"
3198       
3199        Duplicate/O inW wTmpWrite       
3200// then use redimension as needed to cast the wave to write to the specified type
3201// see WaveType for the proper codes
3202//      Redimension/T=() wTmpWrite
3203// -- May also need to check the dimension(s) before writing (don't trust the input)
3204        String groupName = "/entry/instrument/detector_"+detStr
3205        String varName = "dead_time"
3206
3207        variable err
3208        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3209        if(err)
3210                Print "HDF write err = ",err
3211        endif
3212        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3213        err = V_KillNamedDataFolder(fname)
3214        if(err)
3215                Print "DataFolder kill err = ",err
3216        endif
3217        return(err)
3218End
3219
3220
3221Function V_writeDetDescription(fname,detStr,str)
3222        String fname,detStr,str
3223
3224//      String path = "entry:instrument:detector_"+detStr+":description"
3225
3226        Make/O/T/N=1 tmpTW
3227        String groupName = "/entry/instrument/detector_"+detStr //     
3228        String varName = "description"
3229        tmpTW[0] = str //
3230
3231        variable err
3232        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3233        if(err)
3234                Print "HDF write err = ",err
3235        endif
3236       
3237        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3238        err = V_KillNamedDataFolder(fname)
3239        if(err)
3240                Print "DataFolder kill err = ",err
3241        endif
3242               
3243        return(err)
3244End
3245
3246Function V_writeDet_distance(fname,detStr,val)
3247        String fname,detStr
3248        variable val
3249
3250//      String path = "entry:instrument:detector_"+detStr+":distance"
3251       
3252        Make/O/D/N=1 wTmpWrite
3253//      Make/O/R/N=1 wTmpWrite
3254        String groupName = "/entry/instrument/detector_"+detStr
3255        String varName = "distance"
3256        wTmpWrite[0] = val
3257
3258        variable err
3259        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3260        if(err)
3261                Print "HDF write err = ",err
3262        endif
3263        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3264        err = V_KillNamedDataFolder(fname)
3265        if(err)
3266                Print "DataFolder kill err = ",err
3267        endif
3268        return(err)
3269End
3270
3271// only defined for the "B" detector, and only to satisfy NXsas
3272Function V_writeDet_equatorial_angle(fname,detStr,val)
3273        String fname,detStr
3274        variable val
3275
3276        if(cmpstr(detStr,"B") == 0)
3277//              String path = "entry:instrument:detector_"+detStr+":equatorial_angle"
3278       
3279                Make/O/D/N=1 wTmpWrite
3280        //      Make/O/R/N=1 wTmpWrite
3281                String groupName = "/entry/instrument/detector_"+detStr
3282                String varName = "equatorial_angle"
3283                wTmpWrite[0] = val
3284
3285                variable err
3286                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3287                if(err)
3288                        Print "HDF write err = ",err
3289                endif
3290                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3291                err = V_KillNamedDataFolder(fname)
3292                if(err)
3293                        Print "DataFolder kill err = ",err
3294                endif
3295                return(err)
3296        else
3297                return(0)
3298        endif
3299End
3300
3301Function V_writeDetEventFileName(fname,detStr,str)
3302        String fname,detStr,str
3303
3304//      String path = "entry:instrument:detector_"+detStr+":event_file_name"
3305
3306        Make/O/T/N=1 tmpTW
3307        String groupName = "/entry/instrument/detector_"+detStr //     
3308        String varName = "event_file_name"
3309        tmpTW[0] = str //
3310
3311        variable err
3312        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3313        if(err)
3314                Print "HDF write err = ",err
3315        endif
3316       
3317        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3318        err = V_KillNamedDataFolder(fname)
3319        if(err)
3320                Print "DataFolder kill err = ",err
3321        endif
3322               
3323        return(err)
3324End
3325
3326Function V_writeDet_IntegratedCount(fname,detStr,val)
3327        String fname,detStr
3328        Variable val
3329
3330//      String path = "entry:instrument:detector_"+detStr+":integrated_count"
3331       
3332        Make/O/D/N=1 wTmpWrite
3333//      Make/O/R/N=1 wTmpWrite
3334        String groupName = "/entry/instrument/detector_"+detStr
3335        String varName = "integrated_count"
3336        wTmpWrite[0] = val
3337
3338        variable err
3339        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3340        if(err)
3341                Print "HDF write err = ",err
3342        endif
3343        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3344        err = V_KillNamedDataFolder(fname)
3345        if(err)
3346                Print "DataFolder kill err = ",err
3347        endif
3348        return(err)
3349End
3350
3351Function V_writeDet_LateralOffset(fname,detStr,val)
3352        String fname,detStr
3353        Variable val
3354
3355//      String path = "entry:instrument:detector_"+detStr+":lateral_offset"
3356       
3357        Make/O/D/N=1 wTmpWrite
3358//      Make/O/R/N=1 wTmpWrite
3359        String groupName = "/entry/instrument/detector_"+detStr
3360        String varName = "lateral_offset"
3361        wTmpWrite[0] = val
3362
3363        variable err
3364        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3365        if(err)
3366                Print "HDF write err = ",err
3367        endif
3368        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3369        err = V_KillNamedDataFolder(fname)
3370        if(err)
3371                Print "DataFolder kill err = ",err
3372        endif
3373        return(err)
3374End
3375
3376// only defined for the "B" detector, and only to satisfy NXsas
3377Function V_writeDet_polar_angle(fname,detStr,val)
3378        String fname,detStr
3379        Variable val
3380
3381        if(cmpstr(detStr,"B") == 0)
3382//              String path = "entry:instrument:detector_"+detStr+":polar_angle"
3383       
3384                Make/O/D/N=1 wTmpWrite
3385        //      Make/O/R/N=1 wTmpWrite
3386                String groupName = "/entry/instrument/detector_"+detStr
3387                String varName = "polar_angle"
3388                wTmpWrite[0] = val
3389
3390                variable err
3391                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3392                if(err)
3393                        Print "HDF write err = ",err
3394                endif
3395                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3396                err = V_KillNamedDataFolder(fname)
3397                if(err)
3398                        Print "DataFolder kill err = ",err
3399                endif
3400                return(err)
3401        else
3402                return(0)
3403        endif
3404End
3405
3406// only defined for the "B" detector, and only to satisfy NXsas
3407Function V_writeDet_rotational_angle(fname,detStr,val)
3408        String fname,detStr
3409        Variable val
3410
3411        if(cmpstr(detStr,"B") == 0)
3412//              String path = "entry:instrument:detector_"+detStr+":rotational_angle"
3413       
3414                Make/O/D/N=1 wTmpWrite
3415        //      Make/O/R/N=1 wTmpWrite
3416                String groupName = "/entry/instrument/detector_"+detStr
3417                String varName = "rotational_angle"
3418                wTmpWrite[0] = val
3419
3420                variable err
3421                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3422                if(err)
3423                        Print "HDF write err = ",err
3424                endif
3425                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3426                err = V_KillNamedDataFolder(fname)
3427                if(err)
3428                        Print "DataFolder kill err = ",err
3429                endif
3430                return(err)
3431        else
3432                return(0)
3433        endif
3434End
3435
3436Function V_writeDetSettings(fname,detStr,str)
3437        String fname,detStr,str
3438
3439//      String path = "entry:instrument:detector_"+detStr+":settings"
3440
3441        Make/O/T/N=1 tmpTW
3442        String groupName = "/entry/instrument/detector_"+detStr //     
3443        String varName = "settings"
3444        tmpTW[0] = str //
3445
3446        variable err
3447        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3448        if(err)
3449                Print "HDF write err = ",err
3450        endif
3451       
3452        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3453        err = V_KillNamedDataFolder(fname)
3454        if(err)
3455                Print "DataFolder kill err = ",err
3456        endif
3457               
3458        return(err)
3459End
3460
3461// really has no meaning at all
3462Function V_writeDet_size(fname,detStr,val)
3463        String fname,detStr
3464        Variable val
3465
3466//      String path = "entry:instrument:detector_"+detStr+":size"
3467       
3468        Make/O/D/N=1 wTmpWrite
3469//      Make/O/R/N=1 wTmpWrite
3470        String groupName = "/entry/instrument/detector_"+detStr
3471        String varName = "size"
3472        wTmpWrite[0] = val
3473
3474        variable err
3475        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3476        if(err)
3477                Print "HDF write err = ",err
3478        endif
3479        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3480        err = V_KillNamedDataFolder(fname)
3481        if(err)
3482                Print "DataFolder kill err = ",err
3483        endif
3484        return(err)
3485End
3486
3487Function V_writeDetType(fname,detStr,str)
3488        String fname,detStr,str
3489
3490//      String path = "entry:instrument:detector_"+detStr+":type"
3491
3492        Make/O/T/N=1 tmpTW
3493        String groupName = "/entry/instrument/detector_"+detStr //     
3494        String varName = "type"
3495        tmpTW[0] = str //
3496
3497        variable err
3498        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3499        if(err)
3500                Print "HDF write err = ",err
3501        endif
3502       
3503        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3504        err = V_KillNamedDataFolder(fname)
3505        if(err)
3506                Print "DataFolder kill err = ",err
3507        endif
3508               
3509        return(err)
3510End
3511
3512Function V_writeDet_x_pixel_size(fname,detStr,val)
3513        String fname,detStr
3514        Variable val
3515
3516//      String path = "entry:instrument:detector_"+detStr+":x_pixel_size"
3517       
3518        Make/O/D/N=1 wTmpWrite
3519//      Make/O/R/N=1 wTmpWrite
3520        String groupName = "/entry/instrument/detector_"+detStr
3521        String varName = "x_pixel_size"
3522        wTmpWrite[0] = val
3523
3524        variable err
3525        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3526        if(err)
3527                Print "HDF write err = ",err
3528        endif
3529        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3530        err = V_KillNamedDataFolder(fname)
3531        if(err)
3532                Print "DataFolder kill err = ",err
3533        endif
3534        return(err)
3535End
3536
3537Function V_writeDet_y_pixel_size(fname,detStr,val)
3538        String fname,detStr
3539        Variable val
3540
3541//      String path = "entry:instrument:detector_"+detStr+":y_pixel_size"
3542       
3543        Make/O/D/N=1 wTmpWrite
3544//      Make/O/R/N=1 wTmpWrite
3545        String groupName = "/entry/instrument/detector_"+detStr
3546        String varName = "y_pixel_size"
3547        wTmpWrite[0] = val
3548
3549        variable err
3550        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3551        if(err)
3552                Print "HDF write err = ",err
3553        endif
3554        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3555        err = V_KillNamedDataFolder(fname)
3556        if(err)
3557                Print "DataFolder kill err = ",err
3558        endif
3559        return(err)
3560End
3561
3562/////////                       detector_FB (data folder) + ALL other PANEL DETECTORS
3563
3564Function V_writeDet_numberOfTubes(fname,detStr,val)
3565        String fname,detStr
3566        Variable val
3567
3568//      String path = "entry:instrument:detector_"+detStr+":number_of_tubes"
3569        if(cmpstr(detStr,"B") == 0)
3570                return(0)
3571        else
3572       
3573                Make/O/D/N=1 wTmpWrite
3574        //      Make/O/R/N=1 wTmpWrite
3575                String groupName = "/entry/instrument/detector_"+detStr
3576                String varName = "number_of_tubes"
3577                wTmpWrite[0] = val
3578
3579                variable err
3580                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3581                if(err)
3582                        Print "HDF write err = ",err
3583                endif
3584                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3585                err = V_KillNamedDataFolder(fname)
3586                if(err)
3587                        Print "DataFolder kill err = ",err
3588                endif
3589                return(err)
3590        endif
3591End
3592
3593// TODO -- be clear on how this is defined. Separation as defined from what point? Units?
3594Function V_writeDetPanelSeparation(fname,detStr,val)
3595        String fname,detStr
3596        Variable val
3597
3598//      String path = "entry:instrument:detector_"+detStr+":separation"
3599        if(cmpstr(detStr,"B") == 0)
3600                return(0)
3601        else
3602       
3603                Make/O/D/N=1 wTmpWrite
3604        //      Make/O/R/N=1 wTmpWrite
3605                String groupName = "/entry/instrument/detector_"+detStr
3606                String varName = "separation"
3607                wTmpWrite[0] = val
3608
3609                variable err
3610                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3611                if(err)
3612                        Print "HDF write err = ",err
3613                endif
3614                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3615                err = V_KillNamedDataFolder(fname)
3616                if(err)
3617                        Print "DataFolder kill err = ",err
3618                endif
3619                return(err)
3620        endif
3621End
3622
3623// TODO -- write this function to return a WAVE with the data
3624// either as a wave reference, or as an input parameter
3625Function V_writeDetTube_spatialCalib(fname,detStr,inW)
3626        String fname,detStr
3627        Wave inW
3628
3629//      String path = "entry:instrument:detector_"+detStr+":spatial_calibration"
3630
3631        if(cmpstr(detStr,"B") == 0)
3632                return(0)
3633        else
3634                Duplicate/O inW wTmpWrite       
3635        // then use redimension as needed to cast the wave to write to the specified type
3636        // see WaveType for the proper codes
3637        //      Redimension/T=() wTmpWrite
3638        // -- May also need to check the dimension(s) before writing (don't trust the input)
3639                String groupName = "/entry/instrument/detector_"+detStr
3640                String varName = "spatial_calibration"
3641
3642                variable err
3643                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3644                if(err)
3645                        Print "HDF write err = ",err
3646                endif
3647                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3648                err = V_KillNamedDataFolder(fname)
3649                if(err)
3650                        Print "DataFolder kill err = ",err
3651                endif
3652                return(err)
3653        endif
3654End
3655
3656// TODO -- be clear on how this is defined.
3657Function V_writeDet_tubeIndex(fname,detStr,val)
3658        String fname,detStr
3659        Variable val
3660
3661//      String path = "entry:instrument:detector_"+detStr+":tube_index"
3662        if(cmpstr(detStr,"B") == 0)
3663                return(0)
3664        else
3665       
3666                Make/O/D/N=1 wTmpWrite
3667        //      Make/O/R/N=1 wTmpWrite
3668                String groupName = "/entry/instrument/detector_"+detStr
3669                String varName = "tube_index"
3670                wTmpWrite[0] = val
3671
3672                variable err
3673                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3674                if(err)
3675                        Print "HDF write err = ",err
3676                endif
3677                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3678                err = V_KillNamedDataFolder(fname)
3679                if(err)
3680                        Print "DataFolder kill err = ",err
3681                endif
3682                return(err)
3683        endif
3684End
3685
3686Function V_writeDet_tubeOrientation(fname,detStr,str)
3687        String fname,detStr,str
3688
3689//      String path = "entry:instrument:detector_"+detStr+":tube_orientation"
3690
3691        if(cmpstr(detStr,"B") == 0)
3692                return(0)
3693        else
3694                Make/O/T/N=1 tmpTW
3695                String groupName = "/entry/instrument/detector_"+detStr //     
3696                String varName = "tube_orientation"
3697                tmpTW[0] = str //
3698
3699                variable err
3700                err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3701                if(err)
3702                        Print "HDF write err = ",err
3703                endif
3704       
3705                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3706                err = V_KillNamedDataFolder(fname)
3707                if(err)
3708                        Print "DataFolder kill err = ",err
3709                endif
3710               
3711                return(err)
3712
3713        endif
3714End
3715
3716// TODO -- be clear on how this is defined. Units?
3717Function V_writeDet_tubeWidth(fname,detStr,val)
3718        String fname,detStr
3719        Variable val
3720
3721//      String path = "entry:instrument:detector_"+detStr+":tube_width"
3722        if(cmpstr(detStr,"B") == 0)
3723                return(0)
3724        else
3725       
3726                Make/O/D/N=1 wTmpWrite
3727        //      Make/O/R/N=1 wTmpWrite
3728                String groupName = "/entry/instrument/detector_"+detStr
3729                String varName = "tube_width"
3730                wTmpWrite[0] = val
3731
3732                variable err
3733                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3734                if(err)
3735                        Print "HDF write err = ",err
3736                endif
3737                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3738                err = V_KillNamedDataFolder(fname)
3739                if(err)
3740                        Print "DataFolder kill err = ",err
3741                endif
3742                return(err)
3743        endif
3744End
3745
3746//////////////////////
3747
3748// INSTRUMENT/LENSES    /APERTURES
3749//  lenses (data folder)
3750
3751Function V_writeLensCurvature(fname,val)
3752        String fname
3753        Variable val
3754
3755//      String path = "entry:instrument:lenses:curvature"
3756       
3757        Make/O/D/N=1 wTmpWrite
3758//      Make/O/R/N=1 wTmpWrite
3759        String groupName = "/entry/instrument/lenses"
3760        String varName = "curvature"
3761        wTmpWrite[0] = val
3762
3763        variable err
3764        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3765        if(err)
3766                Print "HDF write err = ",err
3767        endif
3768        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3769        err = V_KillNamedDataFolder(fname)
3770        if(err)
3771                Print "DataFolder kill err = ",err
3772        endif
3773        return(err)
3774End
3775
3776Function V_writeLensesFocusType(fname,str)
3777        String fname,str
3778
3779//      String path = "entry:instrument:lenses:focus_type"
3780
3781        Make/O/T/N=1 tmpTW
3782        String groupName = "/entry/instrument/lenses"
3783        String varName = "focus_type"
3784        tmpTW[0] = str //
3785
3786        variable err
3787        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3788        if(err)
3789                Print "HDF write err = ",err
3790        endif
3791       
3792        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3793        err = V_KillNamedDataFolder(fname)
3794        if(err)
3795                Print "DataFolder kill err = ",err
3796        endif
3797               
3798        return(err)
3799End
3800
3801Function V_writeLensDistance(fname,val)
3802        String fname
3803        Variable val
3804
3805//      String path = "entry:instrument:lenses:lens_distance"
3806       
3807        Make/O/D/N=1 wTmpWrite
3808//      Make/O/R/N=1 wTmpWrite
3809        String groupName = "/entry/instrument/lenses"
3810        String varName = "lens_distance"
3811        wTmpWrite[0] = val
3812
3813        variable err
3814        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3815        if(err)
3816                Print "HDF write err = ",err
3817        endif
3818        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3819        err = V_KillNamedDataFolder(fname)
3820        if(err)
3821                Print "DataFolder kill err = ",err
3822        endif
3823        return(err)
3824End
3825
3826Function V_writeLensGeometry(fname,str)
3827        String fname,str
3828
3829//      String path = "entry:instrument:lenses:lens_geometry"
3830
3831        Make/O/T/N=1 tmpTW
3832        String groupName = "/entry/instrument/lenses"
3833        String varName = "lens_geometry"
3834        tmpTW[0] = str //
3835
3836        variable err
3837        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3838        if(err)
3839                Print "HDF write err = ",err
3840        endif
3841       
3842        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3843        err = V_KillNamedDataFolder(fname)
3844        if(err)
3845                Print "DataFolder kill err = ",err
3846        endif
3847               
3848        return(err)
3849End
3850
3851Function V_writeLensMaterial(fname,str)
3852        String fname,str
3853
3854//      String path = "entry:instrument:lenses:lens_material"
3855
3856        Make/O/T/N=1 tmpTW
3857        String groupName = "/entry/instrument/lenses"
3858        String varName = "lens_material"
3859        tmpTW[0] = str //
3860
3861        variable err
3862        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3863        if(err)
3864                Print "HDF write err = ",err
3865        endif
3866       
3867        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3868        err = V_KillNamedDataFolder(fname)
3869        if(err)
3870                Print "DataFolder kill err = ",err
3871        endif
3872               
3873        return(err)
3874End
3875
3876Function V_writeNumber_of_Lenses(fname,val)
3877        String fname
3878        Variable val
3879
3880//      String path = "entry:instrument:lenses:number_of_lenses"
3881       
3882        Make/O/D/N=1 wTmpWrite
3883//      Make/O/R/N=1 wTmpWrite
3884        String groupName = "/entry/instrument/lenses"
3885        String varName = "number_of_lenses"
3886        wTmpWrite[0] = val
3887
3888        variable err
3889        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3890        if(err)
3891                Print "HDF write err = ",err
3892        endif
3893        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3894        err = V_KillNamedDataFolder(fname)
3895        if(err)
3896                Print "DataFolder kill err = ",err
3897        endif
3898        return(err)
3899End
3900
3901Function V_writeNumber_of_prisms(fname,val)
3902        String fname
3903        Variable val
3904
3905//      String path = "entry:instrument:lenses:number_of_prisms"
3906       
3907        Make/O/D/N=1 wTmpWrite
3908//      Make/O/R/N=1 wTmpWrite
3909        String groupName = "/entry/instrument/lenses"
3910        String varName = "number_of_prisms"
3911        wTmpWrite[0] = val
3912
3913        variable err
3914        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3915        if(err)
3916                Print "HDF write err = ",err
3917        endif
3918        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3919        err = V_KillNamedDataFolder(fname)
3920        if(err)
3921                Print "DataFolder kill err = ",err
3922        endif
3923        return(err)
3924End
3925
3926Function V_writePrism_distance(fname,val)
3927        String fname
3928        Variable val
3929
3930//      String path = "entry:instrument:lenses:prism_distance"
3931       
3932        Make/O/D/N=1 wTmpWrite
3933//      Make/O/R/N=1 wTmpWrite
3934        String groupName = "/entry/instrument/lenses"
3935        String varName = "prism_distance"
3936        wTmpWrite[0] = val
3937
3938        variable err
3939        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3940        if(err)
3941                Print "HDF write err = ",err
3942        endif
3943        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3944        err = V_KillNamedDataFolder(fname)
3945        if(err)
3946                Print "DataFolder kill err = ",err
3947        endif
3948        return(err)
3949End
3950
3951Function V_writePrismMaterial(fname,str)
3952        String fname,str
3953
3954//      String path = "entry:instrument:lenses:prism_material"
3955
3956        Make/O/T/N=1 tmpTW
3957        String groupName = "/entry/instrument/lenses"
3958        String varName = "prism_material"
3959        tmpTW[0] = str //
3960
3961        variable err
3962        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3963        if(err)
3964                Print "HDF write err = ",err
3965        endif
3966       
3967        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3968        err = V_KillNamedDataFolder(fname)
3969        if(err)
3970                Print "DataFolder kill err = ",err
3971        endif
3972               
3973        return(err)
3974End
3975
3976// status of lens/prism = lens | prism | both | out
3977Function V_writeLensPrismStatus(fname,str)
3978        String fname,str
3979
3980//      String path = "entry:instrument:lenses:status"
3981
3982        Make/O/T/N=1 tmpTW
3983        String groupName = "/entry/instrument/lenses"
3984        String varName = "status"
3985        tmpTW[0] = str //
3986
3987        variable err
3988        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3989        if(err)
3990                Print "HDF write err = ",err
3991        endif
3992       
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               
3999        return(err)
4000End
4001       
4002
4003///////  sample_aperture (data folder)
4004
4005Function V_writeSampleAp_Description(fname,str)
4006        String fname,str
4007
4008//      String path = "entry:instrument:sample_aperture:description"
4009
4010        Make/O/T/N=1 tmpTW
4011        String groupName = "/entry/instrument/sample_aperture"
4012        String varName = "description"
4013        tmpTW[0] = str //
4014
4015        variable err
4016        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4017        if(err)
4018                Print "HDF write err = ",err
4019        endif
4020       
4021        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4022        err = V_KillNamedDataFolder(fname)
4023        if(err)
4024                Print "DataFolder kill err = ",err
4025        endif
4026               
4027        return(err)
4028End
4029
4030Function V_writeSampleAp_distance(fname,val)
4031        String fname
4032        Variable val
4033
4034//      String path = "entry:instrument:sample_aperture:distance"
4035       
4036        Make/O/D/N=1 wTmpWrite
4037//      Make/O/R/N=1 wTmpWrite
4038        String groupName = "/entry/instrument/sample_aperture"
4039        String varName = "distance"
4040        wTmpWrite[0] = val
4041
4042        variable err
4043        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4044        if(err)
4045                Print "HDF write err = ",err
4046        endif
4047        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4048        err = V_KillNamedDataFolder(fname)
4049        if(err)
4050                Print "DataFolder kill err = ",err
4051        endif
4052        return(err)
4053End
4054//      shape (data folder)
4055
4056Function V_writeSampleAp_shape(fname,str)
4057        String fname,str
4058
4059//      String path = "entry:instrument:sample_aperture:shape:shape"
4060
4061        Make/O/T/N=1 tmpTW
4062        String groupName = "/entry/instrument/sample_aperture/shape"
4063        String varName = "shape"
4064        tmpTW[0] = str //
4065
4066        variable err
4067        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4068        if(err)
4069                Print "HDF write err = ",err
4070        endif
4071       
4072        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4073        err = V_KillNamedDataFolder(fname)
4074        if(err)
4075                Print "DataFolder kill err = ",err
4076        endif
4077               
4078        return(err)
4079End
4080
4081// TODO -- this needs to return a WAVE, since the shape may be circle, or rectangle
4082// and will need to return more than a single dimension
4083// TODO -- be careful of the UNITS
4084Function V_writeSampleAp_size(fname,inW)
4085        String fname
4086        Wave inW
4087
4088//      String path = "entry:instrument:sample_aperture:shape:size"
4089
4090        Duplicate/O inW wTmpWrite       
4091// then use redimension as needed to cast the wave to write to the specified type
4092// see WaveType for the proper codes
4093//      Redimension/T=() wTmpWrite
4094// -- May also need to check the dimension(s) before writing (don't trust the input)
4095        String groupName = "/entry/instrument/sample_aperture/shape"   
4096        String varName = "size"
4097
4098        variable err
4099        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4100        if(err)
4101                Print "HDF write err = ",err
4102        endif
4103        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4104        err = V_KillNamedDataFolder(fname)
4105        if(err)
4106                Print "DataFolder kill err = ",err
4107        endif
4108        return(err)
4109End             
4110               
4111//////  sample_table (data folder)
4112// location  = "CHAMBER" or HUBER
4113Function V_writeSampleTableLocation(fname,str)
4114        String fname,str
4115
4116//      String path = "entry:instrument:sample_table:location"
4117
4118        Make/O/T/N=1 tmpTW
4119        String groupName = "/entry/instrument/sample_table"
4120        String varName = "location"
4121        tmpTW[0] = str //
4122
4123        variable err
4124        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4125        if(err)
4126                Print "HDF write err = ",err
4127        endif
4128       
4129        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4130        err = V_KillNamedDataFolder(fname)
4131        if(err)
4132                Print "DataFolder kill err = ",err
4133        endif
4134               
4135        return(err)
4136End
4137
4138// TODO - verify the meaning
4139//      offset_distance (?? for center of sample table vs. sample position)
4140Function V_writeSampleTableOffset(fname,val)
4141        String fname
4142        Variable val
4143
4144//      String path = "entry:instrument:sample_table:offset_distance"
4145       
4146        Make/O/D/N=1 wTmpWrite
4147//      Make/O/R/N=1 wTmpWrite
4148        String groupName = "/entry/instrument/sample_table"
4149        String varName = "offset_distance"
4150        wTmpWrite[0] = val
4151
4152        variable err
4153        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4154        if(err)
4155                Print "HDF write err = ",err
4156        endif
4157        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4158        err = V_KillNamedDataFolder(fname)
4159        if(err)
4160                Print "DataFolder kill err = ",err
4161        endif
4162        return(err)
4163End     
4164       
4165//  source (data folder)
4166//name "NCNR"
4167Function V_writeSourceName(fname,str)
4168        String fname,str
4169
4170//      String path = "entry:instrument:source:name"
4171
4172        Make/O/T/N=1 tmpTW
4173        String groupName = "/entry/instrument/source"
4174        String varName = "name"
4175        tmpTW[0] = str //
4176
4177        variable err
4178        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4179        if(err)
4180                Print "HDF write err = ",err
4181        endif
4182       
4183        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4184        err = V_KillNamedDataFolder(fname)
4185        if(err)
4186                Print "DataFolder kill err = ",err
4187        endif
4188               
4189        return(err)
4190End
4191
4192//      power -- nominal only, not connected to any real number
4193Function V_writeReactorPower(fname,val)
4194        String fname
4195        Variable val
4196
4197//      String path = "entry:instrument:source:power"
4198       
4199        Make/O/D/N=1 wTmpWrite
4200//      Make/O/R/N=1 wTmpWrite
4201        String groupName = "/entry/instrument/source"
4202        String varName = "power"
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)
4216End     
4217
4218//probe (wave) "neutron"
4219Function V_writeSourceProbe(fname,str)
4220        String fname,str
4221
4222//      String path = "entry:instrument:source:probe"
4223
4224        Make/O/T/N=1 tmpTW
4225        String groupName = "/entry/instrument/source"
4226        String varName = "probe"
4227        tmpTW[0] = str //
4228
4229        variable err
4230        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4231        if(err)
4232                Print "HDF write err = ",err
4233        endif
4234       
4235        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4236        err = V_KillNamedDataFolder(fname)
4237        if(err)
4238                Print "DataFolder kill err = ",err
4239        endif
4240               
4241        return(err)
4242End
4243
4244//type (wave) "Reactor Neutron Source"
4245Function V_writeSourceType(fname,str)
4246        String fname,str
4247
4248//      String path = "entry:instrument:source:type"
4249
4250        Make/O/T/N=1 tmpTW
4251        String groupName = "/entry/instrument/source"
4252        String varName = "type"
4253        tmpTW[0] = str //
4254
4255        variable err
4256        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4257        if(err)
4258                Print "HDF write err = ",err
4259        endif
4260       
4261        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4262        err = V_KillNamedDataFolder(fname)
4263        if(err)
4264                Print "DataFolder kill err = ",err
4265        endif
4266               
4267        return(err)
4268End
4269
4270       
4271///////  source_aperture (data folder)
4272
4273Function V_writeSourceAp_Description(fname,str)
4274        String fname,str
4275
4276//      String path = "entry:instrument:source_aperture:description"
4277
4278        Make/O/T/N=1 tmpTW
4279        String groupName = "/entry/instrument/source_aperture"
4280        String varName = "description"
4281        tmpTW[0] = str //
4282
4283        variable err
4284        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4285        if(err)
4286                Print "HDF write err = ",err
4287        endif
4288       
4289        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4290        err = V_KillNamedDataFolder(fname)
4291        if(err)
4292                Print "DataFolder kill err = ",err
4293        endif
4294               
4295        return(err)
4296End
4297
4298Function V_writeSourceAp_distance(fname,val)
4299        String fname
4300        Variable val
4301
4302//      String path = "entry:instrument:source_aperture:distance"
4303       
4304        Make/O/D/N=1 wTmpWrite
4305//      Make/O/R/N=1 wTmpWrite
4306        String groupName = "/entry/instrument/source_aperture"
4307        String varName = "distance"
4308        wTmpWrite[0] = val
4309
4310        variable err
4311        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4312        if(err)
4313                Print "HDF write err = ",err
4314        endif
4315        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4316        err = V_KillNamedDataFolder(fname)
4317        if(err)
4318                Print "DataFolder kill err = ",err
4319        endif
4320        return(err)
4321End
4322//      shape (data folder)
4323
4324Function V_writeSourceAp_shape(fname,str)
4325        String fname,str
4326
4327//      String path = "entry:instrument:source_aperture:shape:shape"
4328
4329        Make/O/T/N=1 tmpTW
4330        String groupName = "/entry/instrument/source_aperture/shape"
4331        String varName = "shape"
4332        tmpTW[0] = str //
4333
4334        variable err
4335        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4336        if(err)
4337                Print "HDF write err = ",err
4338        endif
4339       
4340        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4341        err = V_KillNamedDataFolder(fname)
4342        if(err)
4343                Print "DataFolder kill err = ",err
4344        endif
4345               
4346        return(err)
4347End
4348
4349// TODO -- this needs to return a WAVE, since the shape may be circle, or rectangle
4350// and will need to return more than a single dimension
4351// TODO -- be careful of the UNITS
4352Function V_writeSourceAp_size(fname,inW)
4353        String fname
4354        Wave inW
4355
4356//      String path = "entry:instrument:source_aperture:shape:size"
4357
4358        Duplicate/O inW wTmpWrite       
4359// then use redimension as needed to cast the wave to write to the specified type
4360// see WaveType for the proper codes
4361//      Redimension/T=() wTmpWrite
4362// -- May also need to check the dimension(s) before writing (don't trust the input)
4363        String groupName = "/entry/instrument/source_aperture/shape"   
4364        String varName = "size"
4365
4366        variable err
4367        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4368        if(err)
4369                Print "HDF write err = ",err
4370        endif
4371        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4372        err = V_KillNamedDataFolder(fname)
4373        if(err)
4374                Print "DataFolder kill err = ",err
4375        endif
4376        return(err)
4377End             
4378
4379
4380
4381
4382//////// SAMPLE
4383//////// SAMPLE
4384//////// SAMPLE
4385
4386//Sample position in changer
4387// TODO -- in the NexusWriter, this ends up as a STRING -- which is wrong. it needs to be FP
4388Function V_writeSamplePosition(fname,val)
4389        String fname
4390        Variable val
4391       
4392//      String path = "entry:sample:changer_position"   
4393       
4394        Make/O/D/N=1 wTmpWrite
4395//      Make/O/R/N=1 wTmpWrite
4396        String groupName = "/entry/sample"
4397        String varName = "changer_position"
4398        wTmpWrite[0] = val
4399
4400        variable err
4401        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4402        if(err)
4403                Print "HDF write err = ",err
4404        endif
4405        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4406        err = V_KillNamedDataFolder(fname)
4407        if(err)
4408                Print "DataFolder kill err = ",err
4409        endif
4410        return(err)
4411end
4412
4413// sample label
4414// TODO: value of num is currently not used
4415Function V_writeSampleDescription(fname,str)
4416        String fname,str
4417
4418//      String path = "entry:sample:description"
4419
4420        Make/O/T/N=1 tmpTW
4421        String groupName = "/entry/sample"
4422        String varName = "description"
4423        tmpTW[0] = str //
4424
4425        variable err
4426        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4427        if(err)
4428                Print "HDF write err = ",err
4429        endif
4430       
4431        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4432        err = V_KillNamedDataFolder(fname)
4433        if(err)
4434                Print "DataFolder kill err = ",err
4435        endif
4436               
4437        return(err)
4438End
4439
4440//no meaning to this...
4441Function V_writeSample_equatorial_ang(fname,val)
4442        String fname
4443        Variable val
4444       
4445//      String path = "entry:sample:equatorial_angle"   
4446       
4447        Make/O/D/N=1 wTmpWrite
4448//      Make/O/R/N=1 wTmpWrite
4449        String groupName = "/entry/sample"
4450        String varName = "equatorial_angle"
4451        wTmpWrite[0] = val
4452
4453        variable err
4454        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4455        if(err)
4456                Print "HDF write err = ",err
4457        endif
4458        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4459        err = V_KillNamedDataFolder(fname)
4460        if(err)
4461                Print "DataFolder kill err = ",err
4462        endif
4463        return(err)
4464end
4465
4466// TODO -- do  I need to make sure that this is an integer?
4467// group ID !!! very important for matching up files
4468Function V_writeSample_GroupID(fname,val)
4469        String fname
4470        Variable val
4471       
4472//      String path = "entry:sample:group_id"   
4473       
4474        Make/O/D/N=1 wTmpWrite
4475//      Make/O/R/N=1 wTmpWrite
4476        String groupName = "/entry/sample"
4477        String varName = "group_id"
4478        wTmpWrite[0] = val
4479
4480        variable err
4481        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4482        if(err)
4483                Print "HDF write err = ",err
4484        endif
4485        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4486        err = V_KillNamedDataFolder(fname)
4487        if(err)
4488                Print "DataFolder kill err = ",err
4489        endif
4490        return(err)
4491end
4492
4493
4494//Sample Rotation Angle
4495Function V_writeSampleRotationAngle(fname,val)
4496        String fname
4497        Variable val
4498       
4499//      String path = "entry:sample:rotation_angle"     
4500       
4501        Make/O/D/N=1 wTmpWrite
4502//      Make/O/R/N=1 wTmpWrite
4503        String groupName = "/entry/sample"
4504        String varName = "rotation_angle"
4505        wTmpWrite[0] = val
4506
4507        variable err
4508        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4509        if(err)
4510                Print "HDF write err = ",err
4511        endif
4512        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4513        err = V_KillNamedDataFolder(fname)
4514        if(err)
4515                Print "DataFolder kill err = ",err
4516        endif
4517        return(err)
4518end
4519
4520//?? this is huber/chamber??
4521// TODO -- then where is the description of 10CB, etc...
4522Function V_writeSampleHolderDescription(fname,str)
4523        String fname,str
4524
4525//      String path = "entry:sample:sample_holder_description"
4526
4527        Make/O/T/N=1 tmpTW
4528        String groupName = "/entry/sample"
4529        String varName = "sample_holder_description"
4530        tmpTW[0] = str //
4531
4532        variable err
4533        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4534        if(err)
4535                Print "HDF write err = ",err
4536        endif
4537       
4538        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4539        err = V_KillNamedDataFolder(fname)
4540        if(err)
4541                Print "DataFolder kill err = ",err
4542        endif
4543               
4544        return(err)
4545End
4546
4547//Sample Thickness
4548// TODO -- somehow, this is not set correctly in the acquisition, so NaN results
4549Function V_writeSampleThickness(fname,val)
4550        String fname
4551        Variable val
4552       
4553//      String path = "entry:sample:thickness" 
4554       
4555        Make/O/D/N=1 wTmpWrite
4556//      Make/O/R/N=1 wTmpWrite
4557        String groupName = "/entry/sample"
4558        String varName = "thickness"
4559        wTmpWrite[0] = val
4560
4561        variable err
4562        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4563        if(err)
4564                Print "HDF write err = ",err
4565        endif
4566        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4567        err = V_KillNamedDataFolder(fname)
4568        if(err)
4569                Print "DataFolder kill err = ",err
4570        endif
4571        return(err)
4572end
4573
4574// sample transmission
4575Function V_writeSampleTransmission(fname,val)
4576        String fname
4577        Variable val
4578       
4579        String path = "entry:sample:transmission"       
4580//      String path = "QKK0037737:data:Transmission"   
4581       
4582        Make/O/D/N=1 wTmpWrite
4583//      Make/O/R/N=1 wTmpWrite
4584        String groupName = "/entry/sample"
4585        String varName = "transmission"
4586        wTmpWrite[0] = val
4587
4588        variable err
4589        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4590        if(err)
4591                Print "HDF write err = ",err
4592        endif
4593        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4594        err = V_KillNamedDataFolder(fname)
4595        if(err)
4596                Print "DataFolder kill err = ",err
4597        endif
4598        return(err)
4599end
4600
4601//transmission error (one sigma)
4602Function V_writeSampleTransError(fname,val)
4603        String fname
4604        Variable val
4605       
4606//      String path = "entry:sample:transmission_error"
4607       
4608        Make/O/D/N=1 wTmpWrite
4609//      Make/O/R/N=1 wTmpWrite
4610        String groupName = "/entry/sample"
4611        String varName = "transmission_error"
4612        wTmpWrite[0] = val
4613
4614        variable err
4615        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4616        if(err)
4617                Print "HDF write err = ",err
4618        endif
4619        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4620        err = V_KillNamedDataFolder(fname)
4621        if(err)
4622                Print "DataFolder kill err = ",err
4623        endif
4624        return(err)
4625end
4626
4627
4628
4629//// SAMPLE / DATA LOGS
4630// write this generic , call with the name of the environment log desired
4631//
4632// temperature_1
4633// temperature_2
4634// shear_field
4635// pressure
4636// magnetic_field
4637// electric_field
4638//
4639//////// (for example) electric_field (data folder)
4640
4641Function V_writeLog_attachedTo(fname,logStr,str)
4642        String fname,logStr,str
4643
4644//      String path = "entry:sample:"+logstr+":attached_to"
4645
4646        Make/O/T/N=1 tmpTW
4647        String groupName = "/entry/sample/"+logStr
4648        String varName = "attached_to"
4649        tmpTW[0] = str //
4650
4651        variable err
4652        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4653        if(err)
4654                Print "HDF write err = ",err
4655        endif
4656       
4657        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4658        err = V_KillNamedDataFolder(fname)
4659        if(err)
4660                Print "DataFolder kill err = ",err
4661        endif
4662               
4663        return(err)
4664End
4665
4666
4667Function V_writeLog_measurement(fname,logStr,str)
4668        String fname,logStr,str
4669
4670        String path = "entry:sample:"+logstr+":measurement"
4671
4672        Make/O/T/N=1 tmpTW
4673        String groupName = "/entry/sample/"+logStr
4674        String varName = "measurement"
4675        tmpTW[0] = str //
4676
4677        variable err
4678        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4679        if(err)
4680                Print "HDF write err = ",err
4681        endif
4682       
4683        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4684        err = V_KillNamedDataFolder(fname)
4685        if(err)
4686                Print "DataFolder kill err = ",err
4687        endif
4688               
4689        return(err)
4690End
4691
4692
4693Function V_writeLog_Name(fname,logStr,str)
4694        String fname,logStr,str
4695
4696//      String path = "entry:sample:"+logstr+":name"
4697
4698        Make/O/T/N=1 tmpTW
4699        String groupName = "/entry/sample/"+logStr
4700        String varName = "name"
4701        tmpTW[0] = str //
4702
4703        variable err
4704        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4705        if(err)
4706                Print "HDF write err = ",err
4707        endif
4708       
4709        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4710        err = V_KillNamedDataFolder(fname)
4711        if(err)
4712                Print "DataFolder kill err = ",err
4713        endif
4714               
4715        return(err)
4716End
4717
4718
4719// TODO --
4720Function V_writeLog_nomValue(fname,logStr,val)
4721        String fname,logStr
4722        Variable val
4723       
4724//      String path = "entry:sample:"+logstr+":value"
4725       
4726        Make/O/D/N=1 wTmpWrite
4727//      Make/O/R/N=1 wTmpWrite
4728        String groupName = "/entry/sample/"+logStr
4729        String varName = "value"
4730        wTmpWrite[0] = val
4731
4732        variable err
4733        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4734        if(err)
4735                Print "HDF write err = ",err
4736        endif
4737        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4738        err = V_KillNamedDataFolder(fname)
4739        if(err)
4740                Print "DataFolder kill err = ",err
4741        endif
4742        return(err)
4743end
4744
4745////            value_log (data folder)
4746Function V_writeLog_startTime(fname,logStr,str)
4747        String fname,logStr,str
4748
4749//      String path = "entry:sample:"+logstr+":value_log:start"
4750
4751        Make/O/T/N=1 tmpTW
4752        String groupName = "/entry/sample/"+logStr+"/value_log"
4753        String varName = "start"
4754        tmpTW[0] = str //
4755
4756        variable err
4757        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4758        if(err)
4759                Print "HDF write err = ",err
4760        endif
4761       
4762        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4763        err = V_KillNamedDataFolder(fname)
4764        if(err)
4765                Print "DataFolder kill err = ",err
4766        endif
4767               
4768        return(err)
4769End
4770
4771// TODO --
4772Function V_writeLog_avgValue(fname,logStr,val)
4773        String fname,logStr
4774        Variable val
4775       
4776//      String path = "entry:sample:"+logstr+":value_log:average_value"
4777       
4778        Make/O/D/N=1 wTmpWrite
4779//      Make/O/R/N=1 wTmpWrite
4780        String groupName = "/entry/sample/"+logStr+"/value_log"
4781        String varName = "average_value"
4782        wTmpWrite[0] = val
4783
4784        variable err
4785        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4786        if(err)
4787                Print "HDF write err = ",err
4788        endif
4789        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4790        err = V_KillNamedDataFolder(fname)
4791        if(err)
4792                Print "DataFolder kill err = ",err
4793        endif
4794        return(err)
4795end
4796
4797// TODO -- this needs to be a WAVE reference
4798Function V_writeLog_time(fname,logStr,inW)
4799        String fname,logStr
4800        Wave inW
4801       
4802//      String path = "entry:sample:"+logstr+":value_log:nx_time"
4803
4804        Duplicate/O inW wTmpWrite       
4805// then use redimension as needed to cast the wave to write to the specified type
4806// see WaveType for the proper codes
4807//      Redimension/T=() wTmpWrite
4808// -- May also need to check the dimension(s) before writing (don't trust the input)
4809        String groupName = "/entry/sample/"+logStr+"/value_log"
4810        String varName = "nx_time"
4811
4812        variable err
4813        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4814        if(err)
4815                Print "HDF write err = ",err
4816        endif
4817        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4818        err = V_KillNamedDataFolder(fname)
4819        if(err)
4820                Print "DataFolder kill err = ",err
4821        endif
4822        return(err)
4823end
4824
4825
4826// TODO -- this needs to be a WAVE reference
4827Function V_writeLog_Value(fname,logStr,inW)
4828        String fname,logStr
4829        Wave inW
4830       
4831//      String path = "entry:sample:"+logstr+":value_log:value"
4832
4833        Duplicate/O inW wTmpWrite       
4834// then use redimension as needed to cast the wave to write to the specified type
4835// see WaveType for the proper codes
4836//      Redimension/T=() wTmpWrite
4837// -- May also need to check the dimension(s) before writing (don't trust the input)
4838        String groupName = "/entry/sample/"+logStr+"/value_log"
4839        String varName = "value"
4840
4841        variable err
4842        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4843        if(err)
4844                Print "HDF write err = ",err
4845        endif
4846        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4847        err = V_KillNamedDataFolder(fname)
4848        if(err)
4849                Print "DataFolder kill err = ",err
4850        endif
4851        return(err)
4852end
4853
4854
4855
4856///////// REDUCTION
4857///////// REDUCTION
4858///////// REDUCTION
4859
4860
4861// TODO -- needs to be a WAVE, and of the proper size and type!!!
4862Function V_writeAbsolute_Scaling(fname,inW)
4863        String fname
4864        Wave inW
4865       
4866//      String path = "entry:reduction:absolute_scaling"
4867       
4868        Duplicate/O inW wTmpWrite       
4869// then use redimension as needed to cast the wave to write to the specified type
4870// see WaveType for the proper codes
4871//      Redimension/T=() wTmpWrite
4872// -- May also need to check the dimension(s) before writing (don't trust the input)
4873        String groupName = "/entry/reduction"   
4874        String varName = "absolute_scaling"
4875
4876        variable err
4877        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4878        if(err)
4879                Print "HDF write err = ",err
4880        endif
4881        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4882        err = V_KillNamedDataFolder(fname)
4883        if(err)
4884                Print "DataFolder kill err = ",err
4885        endif
4886        return(err)
4887end
4888
4889// TODO -- needs to be a WAVE
4890Function V_writeBoxCoordinates(fname,inW)
4891        String fname
4892        Wave inW
4893       
4894//      String path = "entry:reduction:box_coordinates"
4895               
4896        Duplicate/O inW wTmpWrite       
4897// then use redimension as needed to cast the wave to write to the specified type
4898// see WaveType for the proper codes
4899//      Redimension/T=() wTmpWrite
4900// -- May also need to check the dimension(s) before writing (don't trust the input)
4901        String groupName = "/entry/reduction"   
4902        String varName = "box_coordinates"
4903
4904        variable err
4905        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4906        if(err)
4907                Print "HDF write err = ",err
4908        endif
4909        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4910        err = V_KillNamedDataFolder(fname)
4911        if(err)
4912                Print "DataFolder kill err = ",err
4913        endif
4914        return(err)
4915end
4916
4917//box counts
4918Function V_writeBoxCounts(fname,val)
4919        String fname
4920        Variable val
4921       
4922//      String path = "entry:reduction:box_count"       
4923       
4924        Make/O/D/N=1 wTmpWrite
4925//      Make/O/R/N=1 wTmpWrite
4926        String groupName = "/entry/reduction"
4927        String varName = "box_count"
4928        wTmpWrite[0] = val
4929
4930        variable err
4931        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4932        if(err)
4933                Print "HDF write err = ",err
4934        endif
4935        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4936        err = V_KillNamedDataFolder(fname)
4937        if(err)
4938                Print "DataFolder kill err = ",err
4939        endif
4940        return(err)
4941end
4942
4943//box counts error
4944Function V_writeBoxCountsError(fname,val)
4945        String fname
4946        Variable val
4947       
4948//      String path = "entry:reduction:box_count_error"
4949       
4950        Make/O/D/N=1 wTmpWrite
4951//      Make/O/R/N=1 wTmpWrite
4952        String groupName = "/entry/reduction"
4953        String varName = "box_count_error"
4954        wTmpWrite[0] = val
4955
4956        variable err
4957        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4958        if(err)
4959                Print "HDF write err = ",err
4960        endif
4961        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4962        err = V_KillNamedDataFolder(fname)
4963        if(err)
4964                Print "DataFolder kill err = ",err
4965        endif
4966        return(err)
4967end
4968
4969Function V_writeReductionComments(fname,str)
4970        String fname,str
4971
4972//      String path = "entry:reduction:comments"       
4973
4974        Make/O/T/N=1 tmpTW
4975        String groupName = "/entry/reduction"
4976        String varName = "comments"
4977        tmpTW[0] = str //
4978
4979        variable err
4980        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4981        if(err)
4982                Print "HDF write err = ",err
4983        endif
4984       
4985        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4986        err = V_KillNamedDataFolder(fname)
4987        if(err)
4988                Print "DataFolder kill err = ",err
4989        endif
4990               
4991        return(err)
4992End
4993
4994
4995Function V_writeReductionIntent(fname,str)
4996        String fname,str
4997
4998//      String path = "entry:reduction:intent" 
4999
5000        Make/O/T/N=1 tmpTW
5001        String groupName = "/entry/reduction"
5002        String varName = "intent"
5003        tmpTW[0] = str //
5004
5005        variable err
5006        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5007        if(err)
5008                Print "HDF write err = ",err
5009        endif
5010       
5011        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5012        err = V_KillNamedDataFolder(fname)
5013        if(err)
5014                Print "DataFolder kill err = ",err
5015        endif
5016               
5017        return(err)
5018End
5019
5020
5021Function V_writeLogFileName(fname,str)
5022        String fname,str
5023
5024//      String path = "entry:reduction:sans_log_file_name"     
5025
5026        Make/O/T/N=1 tmpTW
5027        String groupName = "/entry/reduction"
5028        String varName = "sans_log_file_name"
5029        tmpTW[0] = str //
5030
5031        variable err
5032        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5033        if(err)
5034                Print "HDF write err = ",err
5035        endif
5036       
5037        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5038        err = V_KillNamedDataFolder(fname)
5039        if(err)
5040                Print "DataFolder kill err = ",err
5041        endif
5042               
5043        return(err)
5044End
5045
5046
5047Function V_writeSensitivityFileName(fname,str)
5048        String fname,str
5049
5050//      String path = "entry:reduction:sensitivity_file_name"   
5051
5052        Make/O/T/N=1 tmpTW
5053        String groupName = "/entry/reduction"
5054        String varName = "sensitivity_file_name"
5055        tmpTW[0] = str //
5056
5057        variable err
5058        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5059        if(err)
5060                Print "HDF write err = ",err
5061        endif
5062       
5063        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5064        err = V_KillNamedDataFolder(fname)
5065        if(err)
5066                Print "DataFolder kill err = ",err
5067        endif
5068               
5069        return(err)
5070End
5071
5072
5073//whole detector transmission
5074Function V_writeSampleTransWholeDetector(fname,val)
5075        String fname
5076        Variable val
5077       
5078//      String path = "entry:reduction:whole_trans"     
5079       
5080        Make/O/D/N=1 wTmpWrite
5081//      Make/O/R/N=1 wTmpWrite
5082        String groupName = "/entry/reduction"
5083        String varName = "whole_trans"
5084        wTmpWrite[0] = val
5085
5086        variable err
5087        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5088        if(err)
5089                Print "HDF write err = ",err
5090        endif
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        return(err)
5097end
5098
5099//whole detector transmission error
5100Function V_writeSampleTransWholeDetErr(fname,val)
5101        String fname
5102        Variable val
5103       
5104//      String path = "entry:reduction:whole_trans_error"       
5105       
5106        Make/O/D/N=1 wTmpWrite
5107//      Make/O/R/N=1 wTmpWrite
5108        String groupName = "/entry/reduction"
5109        String varName = "whole_trans_error"
5110        wTmpWrite[0] = val
5111
5112        variable err
5113        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5114        if(err)
5115                Print "HDF write err = ",err
5116        endif
5117        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5118        err = V_KillNamedDataFolder(fname)
5119        if(err)
5120                Print "DataFolder kill err = ",err
5121        endif
5122        return(err)
5123end
5124
5125                       
5126/////                   pol_sans (data folder)
5127
5128Function V_writePolSANS_cellName(fname,str)
5129        String fname,str
5130
5131//      String path = "entry:reduction:pol_sans:cell_name"     
5132
5133        Make/O/T/N=1 tmpTW
5134        String groupName = "/entry/reduction/pol_sans"
5135        String varName = "cell_name"
5136        tmpTW[0] = str //
5137
5138        variable err
5139        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5140        if(err)
5141                Print "HDF write err = ",err
5142        endif
5143       
5144        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5145        err = V_KillNamedDataFolder(fname)
5146        if(err)
5147                Print "DataFolder kill err = ",err
5148        endif
5149               
5150        return(err)
5151End
5152
5153
5154// TODO -- needs to be a WAVE
5155// is this a text wave?? if it's mixed names + values, then what?
5156Function V_writePolSANS_cellParams(fname,inW)
5157        String fname
5158        Wave inW
5159       
5160//      String path = "entry:reduction:pol_sans:cell_parameters"
5161               
5162        Duplicate/O inW wTmpWrite       
5163// then use redimension as needed to cast the wave to write to the specified type
5164// see WaveType for the proper codes
5165//      Redimension/T=() wTmpWrite
5166// -- May also need to check the dimension(s) before writing (don't trust the input)
5167        String groupName = "/entry/reduction/pol_sans" 
5168        String varName = "cell_parameters"
5169
5170        variable err
5171        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5172        if(err)
5173                Print "HDF write err = ",err
5174        endif
5175        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5176        err = V_KillNamedDataFolder(fname)
5177        if(err)
5178                Print "DataFolder kill err = ",err
5179        endif
5180        return(err)
5181end
5182
5183Function V_writePolSANS_PolSANSPurpose(fname,str)
5184        String fname,str
5185
5186//      String path = "entry:reduction:pol_sans:pol_sans_purpose"       
5187
5188        Make/O/T/N=1 tmpTW
5189        String groupName = "/entry/reduction/pol_sans"
5190        String varName = "pol_sans_purpose"
5191        tmpTW[0] = str //
5192
5193        variable err
5194        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5195        if(err)
5196                Print "HDF write err = ",err
5197        endif
5198       
5199        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5200        err = V_KillNamedDataFolder(fname)
5201        if(err)
5202                Print "DataFolder kill err = ",err
5203        endif
5204               
5205        return(err)
5206End
5207
5208                               
5209//////// TOP LEVEL DATA REPRESENTATION
5210//
5211// note that here the data is (supposed to be) a link, not the actual data
5212// Igor HDf implementation cannot follow links properly, as far as I know.
5213// so ignore them here, and focus on the image that may be possible to read
5214//
5215
5216//              data_B (data folder)
5217//                      data (wave) 1           //ignore this, it's a link
5218//                      variables (wave) 320
5219//                      thumbnail (data folder)
5220
5221//data (wave) "binary"
5222// TODO -- this will need to be completely replaced with a function that can
5223// read the binary image data. should be possible, but I don't know the details on either end...
5224Function V_writeDataImage(fname,detStr,str)
5225        String fname,detStr,str
5226
5227//      String path = "entry:data_"+detStr+":thumbnail:data"   
5228
5229        Make/O/T/N=1 tmpTW
5230        String groupName = "/entry/data_"+detStr+"/thumbnail"
5231        String varName = "data"
5232        tmpTW[0] = str //
5233
5234        variable err
5235        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5236        if(err)
5237                Print "HDF write err = ",err
5238        endif
5239       
5240        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5241        err = V_KillNamedDataFolder(fname)
5242        if(err)
5243                Print "DataFolder kill err = ",err
5244        endif
5245               
5246        return(err)
5247End
5248
5249Function V_writeDataImageDescription(fname,detStr,str)
5250        String fname,detStr,str
5251
5252//      String path = "entry:data_"+detStr+":thumbnail:description"     
5253
5254        Make/O/T/N=1 tmpTW
5255        String groupName = "/entry/data_"+detStr+"/thumbnail"
5256        String varName = "description"
5257        tmpTW[0] = str //
5258
5259        variable err
5260        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5261        if(err)
5262                Print "HDF write err = ",err
5263        endif
5264       
5265        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5266        err = V_KillNamedDataFolder(fname)
5267        if(err)
5268                Print "DataFolder kill err = ",err
5269        endif
5270               
5271        return(err)
5272End
5273                                                               
5274Function V_writeDataImageType(fname,detStr,str)
5275        String fname,detStr,str
5276
5277//      String path = "entry:data_"+detStr+":thumbnail:type"   
5278
5279        Make/O/T/N=1 tmpTW
5280        String groupName = "/entry/data_"+detStr+"/thumbnail"
5281        String varName = "type"
5282        tmpTW[0] = str //
5283
5284        variable err
5285        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5286        if(err)
5287                Print "HDF write err = ",err
5288        endif
5289       
5290        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5291        err = V_KillNamedDataFolder(fname)
5292        if(err)
5293                Print "DataFolder kill err = ",err
5294        endif
5295               
5296        return(err)
5297End
5298
Note: See TracBrowser for help on using the repository browser.