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

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

more additions to the R/W functions to access VSANS data files

File size: 132.5 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_X(fname,detStr,val)
3015        String fname,detStr
3016        Variable val
3017
3018//      String path = "entry:instrument:detector_"+detStr+":PixelFWHM_X"
3019       
3020        Make/O/D/N=1 wTmpWrite
3021//      Make/O/R/N=1 wTmpWrite
3022        String groupName = "/entry/instrument/detector_"+detStr
3023        String varName = "PixelFWHM_X"
3024        wTmpWrite[0] = val
3025
3026        variable err
3027        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3028        if(err)
3029                Print "HDF write err = ",err
3030        endif
3031        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3032        err = V_KillNamedDataFolder(fname)
3033        if(err)
3034                Print "DataFolder kill err = ",err
3035        endif
3036        return(err)
3037End
3038
3039
3040// TODO -- write and X and Y version of this. Pixels are not square
3041// so the FHWM will be different in each direction. May need to return
3042// "dummy" value for "B" detector if pixels there are square
3043Function V_writeDet_PixelFWHM_Y(fname,detStr,val)
3044        String fname,detStr
3045        Variable val
3046
3047//      String path = "entry:instrument:detector_"+detStr+":PixelFWHM_Y"
3048       
3049        Make/O/D/N=1 wTmpWrite
3050//      Make/O/R/N=1 wTmpWrite
3051        String groupName = "/entry/instrument/detector_"+detStr
3052        String varName = "PixelFWHM_Y"
3053        wTmpWrite[0] = val
3054
3055        variable err
3056        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3057        if(err)
3058                Print "HDF write err = ",err
3059        endif
3060        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3061        err = V_KillNamedDataFolder(fname)
3062        if(err)
3063                Print "DataFolder kill err = ",err
3064        endif
3065        return(err)
3066End
3067
3068
3069Function V_writeDet_PixelNumX(fname,detStr,val)
3070        String fname,detStr
3071        Variable val
3072
3073//      String path = "entry:instrument:detector_"+detStr+":PixelNumX"
3074       
3075        Make/O/D/N=1 wTmpWrite
3076//      Make/O/R/N=1 wTmpWrite
3077        String groupName = "/entry/instrument/detector_"+detStr
3078        String varName = "PixelNumX"
3079        wTmpWrite[0] = val
3080
3081        variable err
3082        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3083        if(err)
3084                Print "HDF write err = ",err
3085        endif
3086        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3087        err = V_KillNamedDataFolder(fname)
3088        if(err)
3089                Print "DataFolder kill err = ",err
3090        endif
3091        return(err)
3092End
3093
3094Function V_writeDet_PixelNumY(fname,detStr,val)
3095        String fname,detStr
3096        Variable val
3097
3098//      String path = "entry:instrument:detector_"+detStr+":PixelNumY"
3099       
3100        Make/O/D/N=1 wTmpWrite
3101//      Make/O/R/N=1 wTmpWrite
3102        String groupName = "/entry/instrument/detector_"+detStr
3103        String varName = "PixelNumY"
3104        wTmpWrite[0] = val
3105
3106        variable err
3107        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3108        if(err)
3109                Print "HDF write err = ",err
3110        endif
3111        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3112        err = V_KillNamedDataFolder(fname)
3113        if(err)
3114                Print "DataFolder kill err = ",err
3115        endif
3116        return(err)
3117End
3118
3119// only defined for the "B" detector, and only to satisfy NXsas
3120Function V_writeDet_azimuthalAngle(fname,detStr,val)
3121        String fname,detStr
3122        Variable val
3123
3124        if(cmpstr(detStr,"B") == 0)
3125//              String path = "entry:instrument:detector_"+detStr+":azimuthal_angle"
3126       
3127                Make/O/D/N=1 wTmpWrite
3128        //      Make/O/R/N=1 wTmpWrite
3129                String groupName = "/entry/instrument/detector_"+detStr
3130                String varName = "azimuthal_angle"
3131                wTmpWrite[0] = val
3132
3133                variable err
3134                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3135                if(err)
3136                        Print "HDF write err = ",err
3137                endif
3138                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3139                err = V_KillNamedDataFolder(fname)
3140                if(err)
3141                        Print "DataFolder kill err = ",err
3142                endif
3143                return(err)
3144        else
3145                return(0)
3146        endif
3147End
3148
3149Function V_writeDet_beam_center_x(fname,detStr,val)
3150        String fname,detStr
3151        Variable val
3152
3153//      String path = "entry:instrument:detector_"+detStr+":beam_center_x"
3154       
3155        Make/O/D/N=1 wTmpWrite
3156//      Make/O/R/N=1 wTmpWrite
3157        String groupName = "/entry/instrument/detector_"+detStr
3158        String varName = "beam_center_x"
3159        wTmpWrite[0] = val
3160
3161        variable err
3162        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3163        if(err)
3164                Print "HDF write err = ",err
3165        endif
3166        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3167        err = V_KillNamedDataFolder(fname)
3168        if(err)
3169                Print "DataFolder kill err = ",err
3170        endif
3171        return(err)
3172End
3173
3174Function V_writeDet_beam_center_y(fname,detStr,val)
3175        String fname,detStr
3176        Variable val
3177
3178//      String path = "entry:instrument:detector_"+detStr+":beam_center_y"
3179       
3180        Make/O/D/N=1 wTmpWrite
3181//      Make/O/R/N=1 wTmpWrite
3182        String groupName = "/entry/instrument/detector_"+detStr
3183        String varName = "beam_center_y"
3184        wTmpWrite[0] = val
3185
3186        variable err
3187        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3188        if(err)
3189                Print "HDF write err = ",err
3190        endif
3191        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3192        err = V_KillNamedDataFolder(fname)
3193        if(err)
3194                Print "DataFolder kill err = ",err
3195        endif
3196        return(err)
3197End
3198
3199// TODO -- write this function to return a WAVE with the data
3200// either as a wave reference, or as an input parameter
3201Function V_writeDetectorData(fname,detStr,inW)
3202        String fname,detStr
3203        Wave inW
3204
3205//      String path = "entry:instrument:detector_"+detStr+":data"
3206       
3207        Duplicate/O inW wTmpWrite       
3208// then use redimension as needed to cast the wave to write to the specified type
3209// see WaveType for the proper codes
3210//      Redimension/T=() wTmpWrite
3211// -- May also need to check the dimension(s) before writing (don't trust the input)
3212        String groupName = "/entry/instrument/detector_"+detStr
3213        String varName = "data"
3214
3215        variable err
3216        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3217        if(err)
3218                Print "HDF write err = ",err
3219        endif
3220        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3221        err = V_KillNamedDataFolder(fname)
3222        if(err)
3223                Print "DataFolder kill err = ",err
3224        endif
3225        return(err)
3226End
3227
3228
3229// TODO -- write this function to return a WAVE with the data
3230// either as a wave reference, or as an input parameter
3231// ALSO -- the "B" deadtime will be a single value (probably)
3232//  but the tube banks will be 1D arrays of values, one per tube
3233Function V_writeDetector_deadtime(fname,detStr,inW)
3234        String fname,detStr
3235        Wave inW
3236
3237//      String path = "entry:instrument:detector_"+detStr+":dead_time"
3238       
3239        Duplicate/O inW wTmpWrite       
3240// then use redimension as needed to cast the wave to write to the specified type
3241// see WaveType for the proper codes
3242//      Redimension/T=() wTmpWrite
3243// -- May also need to check the dimension(s) before writing (don't trust the input)
3244        String groupName = "/entry/instrument/detector_"+detStr
3245        String varName = "dead_time"
3246
3247        variable err
3248        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3249        if(err)
3250                Print "HDF write err = ",err
3251        endif
3252        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3253        err = V_KillNamedDataFolder(fname)
3254        if(err)
3255                Print "DataFolder kill err = ",err
3256        endif
3257        return(err)
3258End
3259
3260
3261Function V_writeDetDescription(fname,detStr,str)
3262        String fname,detStr,str
3263
3264//      String path = "entry:instrument:detector_"+detStr+":description"
3265
3266        Make/O/T/N=1 tmpTW
3267        String groupName = "/entry/instrument/detector_"+detStr //     
3268        String varName = "description"
3269        tmpTW[0] = str //
3270
3271        variable err
3272        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3273        if(err)
3274                Print "HDF write err = ",err
3275        endif
3276       
3277        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3278        err = V_KillNamedDataFolder(fname)
3279        if(err)
3280                Print "DataFolder kill err = ",err
3281        endif
3282               
3283        return(err)
3284End
3285
3286Function V_writeDet_distance(fname,detStr,val)
3287        String fname,detStr
3288        variable val
3289
3290//      String path = "entry:instrument:detector_"+detStr+":distance"
3291       
3292        Make/O/D/N=1 wTmpWrite
3293//      Make/O/R/N=1 wTmpWrite
3294        String groupName = "/entry/instrument/detector_"+detStr
3295        String varName = "distance"
3296        wTmpWrite[0] = val
3297
3298        variable err
3299        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3300        if(err)
3301                Print "HDF write err = ",err
3302        endif
3303        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3304        err = V_KillNamedDataFolder(fname)
3305        if(err)
3306                Print "DataFolder kill err = ",err
3307        endif
3308        return(err)
3309End
3310
3311// only defined for the "B" detector, and only to satisfy NXsas
3312Function V_writeDet_equatorial_angle(fname,detStr,val)
3313        String fname,detStr
3314        variable val
3315
3316        if(cmpstr(detStr,"B") == 0)
3317//              String path = "entry:instrument:detector_"+detStr+":equatorial_angle"
3318       
3319                Make/O/D/N=1 wTmpWrite
3320        //      Make/O/R/N=1 wTmpWrite
3321                String groupName = "/entry/instrument/detector_"+detStr
3322                String varName = "equatorial_angle"
3323                wTmpWrite[0] = val
3324
3325                variable err
3326                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3327                if(err)
3328                        Print "HDF write err = ",err
3329                endif
3330                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3331                err = V_KillNamedDataFolder(fname)
3332                if(err)
3333                        Print "DataFolder kill err = ",err
3334                endif
3335                return(err)
3336        else
3337                return(0)
3338        endif
3339End
3340
3341Function V_writeDetEventFileName(fname,detStr,str)
3342        String fname,detStr,str
3343
3344//      String path = "entry:instrument:detector_"+detStr+":event_file_name"
3345
3346        Make/O/T/N=1 tmpTW
3347        String groupName = "/entry/instrument/detector_"+detStr //     
3348        String varName = "event_file_name"
3349        tmpTW[0] = str //
3350
3351        variable err
3352        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3353        if(err)
3354                Print "HDF write err = ",err
3355        endif
3356       
3357        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3358        err = V_KillNamedDataFolder(fname)
3359        if(err)
3360                Print "DataFolder kill err = ",err
3361        endif
3362               
3363        return(err)
3364End
3365
3366Function V_writeDet_IntegratedCount(fname,detStr,val)
3367        String fname,detStr
3368        Variable val
3369
3370//      String path = "entry:instrument:detector_"+detStr+":integrated_count"
3371       
3372        Make/O/D/N=1 wTmpWrite
3373//      Make/O/R/N=1 wTmpWrite
3374        String groupName = "/entry/instrument/detector_"+detStr
3375        String varName = "integrated_count"
3376        wTmpWrite[0] = val
3377
3378        variable err
3379        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3380        if(err)
3381                Print "HDF write err = ",err
3382        endif
3383        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3384        err = V_KillNamedDataFolder(fname)
3385        if(err)
3386                Print "DataFolder kill err = ",err
3387        endif
3388        return(err)
3389End
3390
3391Function V_writeDet_LateralOffset(fname,detStr,val)
3392        String fname,detStr
3393        Variable val
3394
3395//      String path = "entry:instrument:detector_"+detStr+":lateral_offset"
3396       
3397        Make/O/D/N=1 wTmpWrite
3398//      Make/O/R/N=1 wTmpWrite
3399        String groupName = "/entry/instrument/detector_"+detStr
3400        String varName = "lateral_offset"
3401        wTmpWrite[0] = val
3402
3403        variable err
3404        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3405        if(err)
3406                Print "HDF write err = ",err
3407        endif
3408        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3409        err = V_KillNamedDataFolder(fname)
3410        if(err)
3411                Print "DataFolder kill err = ",err
3412        endif
3413        return(err)
3414End
3415
3416// only defined for the "B" detector, and only to satisfy NXsas
3417Function V_writeDet_polar_angle(fname,detStr,val)
3418        String fname,detStr
3419        Variable val
3420
3421        if(cmpstr(detStr,"B") == 0)
3422//              String path = "entry:instrument:detector_"+detStr+":polar_angle"
3423       
3424                Make/O/D/N=1 wTmpWrite
3425        //      Make/O/R/N=1 wTmpWrite
3426                String groupName = "/entry/instrument/detector_"+detStr
3427                String varName = "polar_angle"
3428                wTmpWrite[0] = val
3429
3430                variable err
3431                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3432                if(err)
3433                        Print "HDF write err = ",err
3434                endif
3435                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3436                err = V_KillNamedDataFolder(fname)
3437                if(err)
3438                        Print "DataFolder kill err = ",err
3439                endif
3440                return(err)
3441        else
3442                return(0)
3443        endif
3444End
3445
3446// only defined for the "B" detector, and only to satisfy NXsas
3447Function V_writeDet_rotational_angle(fname,detStr,val)
3448        String fname,detStr
3449        Variable val
3450
3451        if(cmpstr(detStr,"B") == 0)
3452//              String path = "entry:instrument:detector_"+detStr+":rotational_angle"
3453       
3454                Make/O/D/N=1 wTmpWrite
3455        //      Make/O/R/N=1 wTmpWrite
3456                String groupName = "/entry/instrument/detector_"+detStr
3457                String varName = "rotational_angle"
3458                wTmpWrite[0] = val
3459
3460                variable err
3461                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3462                if(err)
3463                        Print "HDF write err = ",err
3464                endif
3465                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3466                err = V_KillNamedDataFolder(fname)
3467                if(err)
3468                        Print "DataFolder kill err = ",err
3469                endif
3470                return(err)
3471        else
3472                return(0)
3473        endif
3474End
3475
3476Function V_writeDetSettings(fname,detStr,str)
3477        String fname,detStr,str
3478
3479//      String path = "entry:instrument:detector_"+detStr+":settings"
3480
3481        Make/O/T/N=1 tmpTW
3482        String groupName = "/entry/instrument/detector_"+detStr //     
3483        String varName = "settings"
3484        tmpTW[0] = str //
3485
3486        variable err
3487        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3488        if(err)
3489                Print "HDF write err = ",err
3490        endif
3491       
3492        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3493        err = V_KillNamedDataFolder(fname)
3494        if(err)
3495                Print "DataFolder kill err = ",err
3496        endif
3497               
3498        return(err)
3499End
3500
3501// really has no meaning at all
3502Function V_writeDet_size(fname,detStr,val)
3503        String fname,detStr
3504        Variable val
3505
3506//      String path = "entry:instrument:detector_"+detStr+":size"
3507       
3508        Make/O/D/N=1 wTmpWrite
3509//      Make/O/R/N=1 wTmpWrite
3510        String groupName = "/entry/instrument/detector_"+detStr
3511        String varName = "size"
3512        wTmpWrite[0] = val
3513
3514        variable err
3515        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3516        if(err)
3517                Print "HDF write err = ",err
3518        endif
3519        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3520        err = V_KillNamedDataFolder(fname)
3521        if(err)
3522                Print "DataFolder kill err = ",err
3523        endif
3524        return(err)
3525End
3526
3527Function V_writeDetType(fname,detStr,str)
3528        String fname,detStr,str
3529
3530//      String path = "entry:instrument:detector_"+detStr+":type"
3531
3532        Make/O/T/N=1 tmpTW
3533        String groupName = "/entry/instrument/detector_"+detStr //     
3534        String varName = "type"
3535        tmpTW[0] = str //
3536
3537        variable err
3538        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3539        if(err)
3540                Print "HDF write err = ",err
3541        endif
3542       
3543        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3544        err = V_KillNamedDataFolder(fname)
3545        if(err)
3546                Print "DataFolder kill err = ",err
3547        endif
3548               
3549        return(err)
3550End
3551
3552Function V_writeDet_x_pixel_size(fname,detStr,val)
3553        String fname,detStr
3554        Variable val
3555
3556//      String path = "entry:instrument:detector_"+detStr+":x_pixel_size"
3557       
3558        Make/O/D/N=1 wTmpWrite
3559//      Make/O/R/N=1 wTmpWrite
3560        String groupName = "/entry/instrument/detector_"+detStr
3561        String varName = "x_pixel_size"
3562        wTmpWrite[0] = val
3563
3564        variable err
3565        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3566        if(err)
3567                Print "HDF write err = ",err
3568        endif
3569        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3570        err = V_KillNamedDataFolder(fname)
3571        if(err)
3572                Print "DataFolder kill err = ",err
3573        endif
3574        return(err)
3575End
3576
3577Function V_writeDet_y_pixel_size(fname,detStr,val)
3578        String fname,detStr
3579        Variable val
3580
3581//      String path = "entry:instrument:detector_"+detStr+":y_pixel_size"
3582       
3583        Make/O/D/N=1 wTmpWrite
3584//      Make/O/R/N=1 wTmpWrite
3585        String groupName = "/entry/instrument/detector_"+detStr
3586        String varName = "y_pixel_size"
3587        wTmpWrite[0] = val
3588
3589        variable err
3590        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3591        if(err)
3592                Print "HDF write err = ",err
3593        endif
3594        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3595        err = V_KillNamedDataFolder(fname)
3596        if(err)
3597                Print "DataFolder kill err = ",err
3598        endif
3599        return(err)
3600End
3601
3602/////////                       detector_FB (data folder) + ALL other PANEL DETECTORS
3603
3604Function V_writeDet_numberOfTubes(fname,detStr,val)
3605        String fname,detStr
3606        Variable val
3607
3608//      String path = "entry:instrument:detector_"+detStr+":number_of_tubes"
3609        if(cmpstr(detStr,"B") == 0)
3610                return(0)
3611        else
3612       
3613                Make/O/D/N=1 wTmpWrite
3614        //      Make/O/R/N=1 wTmpWrite
3615                String groupName = "/entry/instrument/detector_"+detStr
3616                String varName = "number_of_tubes"
3617                wTmpWrite[0] = val
3618
3619                variable err
3620                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3621                if(err)
3622                        Print "HDF write err = ",err
3623                endif
3624                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3625                err = V_KillNamedDataFolder(fname)
3626                if(err)
3627                        Print "DataFolder kill err = ",err
3628                endif
3629                return(err)
3630        endif
3631End
3632
3633// TODO -- be clear on how this is defined. Separation as defined from what point? Units?
3634Function V_writeDetPanelSeparation(fname,detStr,val)
3635        String fname,detStr
3636        Variable val
3637
3638//      String path = "entry:instrument:detector_"+detStr+":separation"
3639        if(cmpstr(detStr,"B") == 0)
3640                return(0)
3641        else
3642       
3643                Make/O/D/N=1 wTmpWrite
3644        //      Make/O/R/N=1 wTmpWrite
3645                String groupName = "/entry/instrument/detector_"+detStr
3646                String varName = "separation"
3647                wTmpWrite[0] = val
3648
3649                variable err
3650                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3651                if(err)
3652                        Print "HDF write err = ",err
3653                endif
3654                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3655                err = V_KillNamedDataFolder(fname)
3656                if(err)
3657                        Print "DataFolder kill err = ",err
3658                endif
3659                return(err)
3660        endif
3661End
3662
3663// TODO -- write this function to return a WAVE with the data
3664// either as a wave reference, or as an input parameter
3665Function V_writeDetTube_spatialCalib(fname,detStr,inW)
3666        String fname,detStr
3667        Wave inW
3668
3669//      String path = "entry:instrument:detector_"+detStr+":spatial_calibration"
3670
3671        if(cmpstr(detStr,"B") == 0)
3672                return(0)
3673        else
3674                Duplicate/O inW wTmpWrite       
3675        // then use redimension as needed to cast the wave to write to the specified type
3676        // see WaveType for the proper codes
3677        //      Redimension/T=() wTmpWrite
3678        // -- May also need to check the dimension(s) before writing (don't trust the input)
3679                String groupName = "/entry/instrument/detector_"+detStr
3680                String varName = "spatial_calibration"
3681
3682                variable err
3683                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3684                if(err)
3685                        Print "HDF write err = ",err
3686                endif
3687                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3688                err = V_KillNamedDataFolder(fname)
3689                if(err)
3690                        Print "DataFolder kill err = ",err
3691                endif
3692                return(err)
3693        endif
3694End
3695
3696// TODO -- be clear on how this is defined.
3697Function V_writeDet_tubeIndex(fname,detStr,val)
3698        String fname,detStr
3699        Variable val
3700
3701//      String path = "entry:instrument:detector_"+detStr+":tube_index"
3702        if(cmpstr(detStr,"B") == 0)
3703                return(0)
3704        else
3705       
3706                Make/O/D/N=1 wTmpWrite
3707        //      Make/O/R/N=1 wTmpWrite
3708                String groupName = "/entry/instrument/detector_"+detStr
3709                String varName = "tube_index"
3710                wTmpWrite[0] = val
3711
3712                variable err
3713                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3714                if(err)
3715                        Print "HDF write err = ",err
3716                endif
3717                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3718                err = V_KillNamedDataFolder(fname)
3719                if(err)
3720                        Print "DataFolder kill err = ",err
3721                endif
3722                return(err)
3723        endif
3724End
3725
3726Function V_writeDet_tubeOrientation(fname,detStr,str)
3727        String fname,detStr,str
3728
3729//      String path = "entry:instrument:detector_"+detStr+":tube_orientation"
3730
3731        if(cmpstr(detStr,"B") == 0)
3732                return(0)
3733        else
3734                Make/O/T/N=1 tmpTW
3735                String groupName = "/entry/instrument/detector_"+detStr //     
3736                String varName = "tube_orientation"
3737                tmpTW[0] = str //
3738
3739                variable err
3740                err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3741                if(err)
3742                        Print "HDF write err = ",err
3743                endif
3744       
3745                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3746                err = V_KillNamedDataFolder(fname)
3747                if(err)
3748                        Print "DataFolder kill err = ",err
3749                endif
3750               
3751                return(err)
3752
3753        endif
3754End
3755
3756// TODO -- be clear on how this is defined. Units?
3757Function V_writeDet_tubeWidth(fname,detStr,val)
3758        String fname,detStr
3759        Variable val
3760
3761//      String path = "entry:instrument:detector_"+detStr+":tube_width"
3762        if(cmpstr(detStr,"B") == 0)
3763                return(0)
3764        else
3765       
3766                Make/O/D/N=1 wTmpWrite
3767        //      Make/O/R/N=1 wTmpWrite
3768                String groupName = "/entry/instrument/detector_"+detStr
3769                String varName = "tube_width"
3770                wTmpWrite[0] = val
3771
3772                variable err
3773                err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3774                if(err)
3775                        Print "HDF write err = ",err
3776                endif
3777                // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3778                err = V_KillNamedDataFolder(fname)
3779                if(err)
3780                        Print "DataFolder kill err = ",err
3781                endif
3782                return(err)
3783        endif
3784End
3785
3786//////////////////////
3787
3788// INSTRUMENT/LENSES    /APERTURES
3789//  lenses (data folder)
3790
3791Function V_writeLensCurvature(fname,val)
3792        String fname
3793        Variable val
3794
3795//      String path = "entry:instrument:lenses:curvature"
3796       
3797        Make/O/D/N=1 wTmpWrite
3798//      Make/O/R/N=1 wTmpWrite
3799        String groupName = "/entry/instrument/lenses"
3800        String varName = "curvature"
3801        wTmpWrite[0] = val
3802
3803        variable err
3804        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3805        if(err)
3806                Print "HDF write err = ",err
3807        endif
3808        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3809        err = V_KillNamedDataFolder(fname)
3810        if(err)
3811                Print "DataFolder kill err = ",err
3812        endif
3813        return(err)
3814End
3815
3816Function V_writeLensesFocusType(fname,str)
3817        String fname,str
3818
3819//      String path = "entry:instrument:lenses:focus_type"
3820
3821        Make/O/T/N=1 tmpTW
3822        String groupName = "/entry/instrument/lenses"
3823        String varName = "focus_type"
3824        tmpTW[0] = str //
3825
3826        variable err
3827        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3828        if(err)
3829                Print "HDF write err = ",err
3830        endif
3831       
3832        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3833        err = V_KillNamedDataFolder(fname)
3834        if(err)
3835                Print "DataFolder kill err = ",err
3836        endif
3837               
3838        return(err)
3839End
3840
3841Function V_writeLensDistance(fname,val)
3842        String fname
3843        Variable val
3844
3845//      String path = "entry:instrument:lenses:lens_distance"
3846       
3847        Make/O/D/N=1 wTmpWrite
3848//      Make/O/R/N=1 wTmpWrite
3849        String groupName = "/entry/instrument/lenses"
3850        String varName = "lens_distance"
3851        wTmpWrite[0] = val
3852
3853        variable err
3854        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3855        if(err)
3856                Print "HDF write err = ",err
3857        endif
3858        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3859        err = V_KillNamedDataFolder(fname)
3860        if(err)
3861                Print "DataFolder kill err = ",err
3862        endif
3863        return(err)
3864End
3865
3866Function V_writeLensGeometry(fname,str)
3867        String fname,str
3868
3869//      String path = "entry:instrument:lenses:lens_geometry"
3870
3871        Make/O/T/N=1 tmpTW
3872        String groupName = "/entry/instrument/lenses"
3873        String varName = "lens_geometry"
3874        tmpTW[0] = str //
3875
3876        variable err
3877        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3878        if(err)
3879                Print "HDF write err = ",err
3880        endif
3881       
3882        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3883        err = V_KillNamedDataFolder(fname)
3884        if(err)
3885                Print "DataFolder kill err = ",err
3886        endif
3887               
3888        return(err)
3889End
3890
3891Function V_writeLensMaterial(fname,str)
3892        String fname,str
3893
3894//      String path = "entry:instrument:lenses:lens_material"
3895
3896        Make/O/T/N=1 tmpTW
3897        String groupName = "/entry/instrument/lenses"
3898        String varName = "lens_material"
3899        tmpTW[0] = str //
3900
3901        variable err
3902        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
3903        if(err)
3904                Print "HDF write err = ",err
3905        endif
3906       
3907        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3908        err = V_KillNamedDataFolder(fname)
3909        if(err)
3910                Print "DataFolder kill err = ",err
3911        endif
3912               
3913        return(err)
3914End
3915
3916Function V_writeNumber_of_Lenses(fname,val)
3917        String fname
3918        Variable val
3919
3920//      String path = "entry:instrument:lenses:number_of_lenses"
3921       
3922        Make/O/D/N=1 wTmpWrite
3923//      Make/O/R/N=1 wTmpWrite
3924        String groupName = "/entry/instrument/lenses"
3925        String varName = "number_of_lenses"
3926        wTmpWrite[0] = val
3927
3928        variable err
3929        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3930        if(err)
3931                Print "HDF write err = ",err
3932        endif
3933        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3934        err = V_KillNamedDataFolder(fname)
3935        if(err)
3936                Print "DataFolder kill err = ",err
3937        endif
3938        return(err)
3939End
3940
3941Function V_writeNumber_of_prisms(fname,val)
3942        String fname
3943        Variable val
3944
3945//      String path = "entry:instrument:lenses:number_of_prisms"
3946       
3947        Make/O/D/N=1 wTmpWrite
3948//      Make/O/R/N=1 wTmpWrite
3949        String groupName = "/entry/instrument/lenses"
3950        String varName = "number_of_prisms"
3951        wTmpWrite[0] = val
3952
3953        variable err
3954        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3955        if(err)
3956                Print "HDF write err = ",err
3957        endif
3958        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3959        err = V_KillNamedDataFolder(fname)
3960        if(err)
3961                Print "DataFolder kill err = ",err
3962        endif
3963        return(err)
3964End
3965
3966Function V_writePrism_distance(fname,val)
3967        String fname
3968        Variable val
3969
3970//      String path = "entry:instrument:lenses:prism_distance"
3971       
3972        Make/O/D/N=1 wTmpWrite
3973//      Make/O/R/N=1 wTmpWrite
3974        String groupName = "/entry/instrument/lenses"
3975        String varName = "prism_distance"
3976        wTmpWrite[0] = val
3977
3978        variable err
3979        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
3980        if(err)
3981                Print "HDF write err = ",err
3982        endif
3983        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
3984        err = V_KillNamedDataFolder(fname)
3985        if(err)
3986                Print "DataFolder kill err = ",err
3987        endif
3988        return(err)
3989End
3990
3991Function V_writePrismMaterial(fname,str)
3992        String fname,str
3993
3994//      String path = "entry:instrument:lenses:prism_material"
3995
3996        Make/O/T/N=1 tmpTW
3997        String groupName = "/entry/instrument/lenses"
3998        String varName = "prism_material"
3999        tmpTW[0] = str //
4000
4001        variable err
4002        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4003        if(err)
4004                Print "HDF write err = ",err
4005        endif
4006       
4007        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4008        err = V_KillNamedDataFolder(fname)
4009        if(err)
4010                Print "DataFolder kill err = ",err
4011        endif
4012               
4013        return(err)
4014End
4015
4016// status of lens/prism = lens | prism | both | out
4017Function V_writeLensPrismStatus(fname,str)
4018        String fname,str
4019
4020//      String path = "entry:instrument:lenses:status"
4021
4022        Make/O/T/N=1 tmpTW
4023        String groupName = "/entry/instrument/lenses"
4024        String varName = "status"
4025        tmpTW[0] = str //
4026
4027        variable err
4028        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4029        if(err)
4030                Print "HDF write err = ",err
4031        endif
4032       
4033        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4034        err = V_KillNamedDataFolder(fname)
4035        if(err)
4036                Print "DataFolder kill err = ",err
4037        endif
4038               
4039        return(err)
4040End
4041       
4042
4043///////  sample_aperture (data folder)
4044
4045Function V_writeSampleAp_Description(fname,str)
4046        String fname,str
4047
4048//      String path = "entry:instrument:sample_aperture:description"
4049
4050        Make/O/T/N=1 tmpTW
4051        String groupName = "/entry/instrument/sample_aperture"
4052        String varName = "description"
4053        tmpTW[0] = str //
4054
4055        variable err
4056        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4057        if(err)
4058                Print "HDF write err = ",err
4059        endif
4060       
4061        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4062        err = V_KillNamedDataFolder(fname)
4063        if(err)
4064                Print "DataFolder kill err = ",err
4065        endif
4066               
4067        return(err)
4068End
4069
4070Function V_writeSampleAp_distance(fname,val)
4071        String fname
4072        Variable val
4073
4074//      String path = "entry:instrument:sample_aperture:distance"
4075       
4076        Make/O/D/N=1 wTmpWrite
4077//      Make/O/R/N=1 wTmpWrite
4078        String groupName = "/entry/instrument/sample_aperture"
4079        String varName = "distance"
4080        wTmpWrite[0] = val
4081
4082        variable err
4083        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4084        if(err)
4085                Print "HDF write err = ",err
4086        endif
4087        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4088        err = V_KillNamedDataFolder(fname)
4089        if(err)
4090                Print "DataFolder kill err = ",err
4091        endif
4092        return(err)
4093End
4094//      shape (data folder)
4095
4096Function V_writeSampleAp_shape(fname,str)
4097        String fname,str
4098
4099//      String path = "entry:instrument:sample_aperture:shape:shape"
4100
4101        Make/O/T/N=1 tmpTW
4102        String groupName = "/entry/instrument/sample_aperture/shape"
4103        String varName = "shape"
4104        tmpTW[0] = str //
4105
4106        variable err
4107        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4108        if(err)
4109                Print "HDF write err = ",err
4110        endif
4111       
4112        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4113        err = V_KillNamedDataFolder(fname)
4114        if(err)
4115                Print "DataFolder kill err = ",err
4116        endif
4117               
4118        return(err)
4119End
4120
4121// TODO -- this needs to return a WAVE, since the shape may be circle, or rectangle
4122// and will need to return more than a single dimension
4123// TODO -- be careful of the UNITS
4124Function V_writeSampleAp_size(fname,inW)
4125        String fname
4126        Wave inW
4127
4128//      String path = "entry:instrument:sample_aperture:shape:size"
4129
4130        Duplicate/O inW wTmpWrite       
4131// then use redimension as needed to cast the wave to write to the specified type
4132// see WaveType for the proper codes
4133//      Redimension/T=() wTmpWrite
4134// -- May also need to check the dimension(s) before writing (don't trust the input)
4135        String groupName = "/entry/instrument/sample_aperture/shape"   
4136        String varName = "size"
4137
4138        variable err
4139        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4140        if(err)
4141                Print "HDF write err = ",err
4142        endif
4143        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4144        err = V_KillNamedDataFolder(fname)
4145        if(err)
4146                Print "DataFolder kill err = ",err
4147        endif
4148        return(err)
4149End             
4150               
4151//////  sample_table (data folder)
4152// location  = "CHAMBER" or HUBER
4153Function V_writeSampleTableLocation(fname,str)
4154        String fname,str
4155
4156//      String path = "entry:instrument:sample_table:location"
4157
4158        Make/O/T/N=1 tmpTW
4159        String groupName = "/entry/instrument/sample_table"
4160        String varName = "location"
4161        tmpTW[0] = str //
4162
4163        variable err
4164        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4165        if(err)
4166                Print "HDF write err = ",err
4167        endif
4168       
4169        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4170        err = V_KillNamedDataFolder(fname)
4171        if(err)
4172                Print "DataFolder kill err = ",err
4173        endif
4174               
4175        return(err)
4176End
4177
4178// TODO - verify the meaning
4179//      offset_distance (?? for center of sample table vs. sample position)
4180Function V_writeSampleTableOffset(fname,val)
4181        String fname
4182        Variable val
4183
4184//      String path = "entry:instrument:sample_table:offset_distance"
4185       
4186        Make/O/D/N=1 wTmpWrite
4187//      Make/O/R/N=1 wTmpWrite
4188        String groupName = "/entry/instrument/sample_table"
4189        String varName = "offset_distance"
4190        wTmpWrite[0] = val
4191
4192        variable err
4193        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4194        if(err)
4195                Print "HDF write err = ",err
4196        endif
4197        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4198        err = V_KillNamedDataFolder(fname)
4199        if(err)
4200                Print "DataFolder kill err = ",err
4201        endif
4202        return(err)
4203End     
4204       
4205//  source (data folder)
4206//name "NCNR"
4207Function V_writeSourceName(fname,str)
4208        String fname,str
4209
4210//      String path = "entry:instrument:source:name"
4211
4212        Make/O/T/N=1 tmpTW
4213        String groupName = "/entry/instrument/source"
4214        String varName = "name"
4215        tmpTW[0] = str //
4216
4217        variable err
4218        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4219        if(err)
4220                Print "HDF write err = ",err
4221        endif
4222       
4223        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4224        err = V_KillNamedDataFolder(fname)
4225        if(err)
4226                Print "DataFolder kill err = ",err
4227        endif
4228               
4229        return(err)
4230End
4231
4232//      power -- nominal only, not connected to any real number
4233Function V_writeReactorPower(fname,val)
4234        String fname
4235        Variable val
4236
4237//      String path = "entry:instrument:source:power"
4238       
4239        Make/O/D/N=1 wTmpWrite
4240//      Make/O/R/N=1 wTmpWrite
4241        String groupName = "/entry/instrument/source"
4242        String varName = "power"
4243        wTmpWrite[0] = val
4244
4245        variable err
4246        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4247        if(err)
4248                Print "HDF write err = ",err
4249        endif
4250        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4251        err = V_KillNamedDataFolder(fname)
4252        if(err)
4253                Print "DataFolder kill err = ",err
4254        endif
4255        return(err)
4256End     
4257
4258//probe (wave) "neutron"
4259Function V_writeSourceProbe(fname,str)
4260        String fname,str
4261
4262//      String path = "entry:instrument:source:probe"
4263
4264        Make/O/T/N=1 tmpTW
4265        String groupName = "/entry/instrument/source"
4266        String varName = "probe"
4267        tmpTW[0] = str //
4268
4269        variable err
4270        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4271        if(err)
4272                Print "HDF write err = ",err
4273        endif
4274       
4275        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4276        err = V_KillNamedDataFolder(fname)
4277        if(err)
4278                Print "DataFolder kill err = ",err
4279        endif
4280               
4281        return(err)
4282End
4283
4284//type (wave) "Reactor Neutron Source"
4285Function V_writeSourceType(fname,str)
4286        String fname,str
4287
4288//      String path = "entry:instrument:source:type"
4289
4290        Make/O/T/N=1 tmpTW
4291        String groupName = "/entry/instrument/source"
4292        String varName = "type"
4293        tmpTW[0] = str //
4294
4295        variable err
4296        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4297        if(err)
4298                Print "HDF write err = ",err
4299        endif
4300       
4301        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4302        err = V_KillNamedDataFolder(fname)
4303        if(err)
4304                Print "DataFolder kill err = ",err
4305        endif
4306               
4307        return(err)
4308End
4309
4310       
4311///////  source_aperture (data folder)
4312
4313Function V_writeSourceAp_Description(fname,str)
4314        String fname,str
4315
4316//      String path = "entry:instrument:source_aperture:description"
4317
4318        Make/O/T/N=1 tmpTW
4319        String groupName = "/entry/instrument/source_aperture"
4320        String varName = "description"
4321        tmpTW[0] = str //
4322
4323        variable err
4324        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4325        if(err)
4326                Print "HDF write err = ",err
4327        endif
4328       
4329        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4330        err = V_KillNamedDataFolder(fname)
4331        if(err)
4332                Print "DataFolder kill err = ",err
4333        endif
4334               
4335        return(err)
4336End
4337
4338Function V_writeSourceAp_distance(fname,val)
4339        String fname
4340        Variable val
4341
4342//      String path = "entry:instrument:source_aperture:distance"
4343       
4344        Make/O/D/N=1 wTmpWrite
4345//      Make/O/R/N=1 wTmpWrite
4346        String groupName = "/entry/instrument/source_aperture"
4347        String varName = "distance"
4348        wTmpWrite[0] = val
4349
4350        variable err
4351        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4352        if(err)
4353                Print "HDF write err = ",err
4354        endif
4355        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4356        err = V_KillNamedDataFolder(fname)
4357        if(err)
4358                Print "DataFolder kill err = ",err
4359        endif
4360        return(err)
4361End
4362//      shape (data folder)
4363
4364Function V_writeSourceAp_shape(fname,str)
4365        String fname,str
4366
4367//      String path = "entry:instrument:source_aperture:shape:shape"
4368
4369        Make/O/T/N=1 tmpTW
4370        String groupName = "/entry/instrument/source_aperture/shape"
4371        String varName = "shape"
4372        tmpTW[0] = str //
4373
4374        variable err
4375        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4376        if(err)
4377                Print "HDF write err = ",err
4378        endif
4379       
4380        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4381        err = V_KillNamedDataFolder(fname)
4382        if(err)
4383                Print "DataFolder kill err = ",err
4384        endif
4385               
4386        return(err)
4387End
4388
4389// TODO -- this needs to return a WAVE, since the shape may be circle, or rectangle
4390// and will need to return more than a single dimension
4391// TODO -- be careful of the UNITS
4392Function V_writeSourceAp_size(fname,inW)
4393        String fname
4394        Wave inW
4395
4396//      String path = "entry:instrument:source_aperture:shape:size"
4397
4398        Duplicate/O inW wTmpWrite       
4399// then use redimension as needed to cast the wave to write to the specified type
4400// see WaveType for the proper codes
4401//      Redimension/T=() wTmpWrite
4402// -- May also need to check the dimension(s) before writing (don't trust the input)
4403        String groupName = "/entry/instrument/source_aperture/shape"   
4404        String varName = "size"
4405
4406        variable err
4407        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4408        if(err)
4409                Print "HDF write err = ",err
4410        endif
4411        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4412        err = V_KillNamedDataFolder(fname)
4413        if(err)
4414                Print "DataFolder kill err = ",err
4415        endif
4416        return(err)
4417End             
4418
4419
4420
4421
4422//////// SAMPLE
4423//////// SAMPLE
4424//////// SAMPLE
4425
4426//Sample position in changer
4427// TODO -- in the NexusWriter, this ends up as a STRING -- which is wrong. it needs to be FP
4428Function V_writeSamplePosition(fname,val)
4429        String fname
4430        Variable val
4431       
4432//      String path = "entry:sample:changer_position"   
4433       
4434        Make/O/D/N=1 wTmpWrite
4435//      Make/O/R/N=1 wTmpWrite
4436        String groupName = "/entry/sample"
4437        String varName = "changer_position"
4438        wTmpWrite[0] = val
4439
4440        variable err
4441        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4442        if(err)
4443                Print "HDF write err = ",err
4444        endif
4445        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4446        err = V_KillNamedDataFolder(fname)
4447        if(err)
4448                Print "DataFolder kill err = ",err
4449        endif
4450        return(err)
4451end
4452
4453// sample label
4454// TODO: value of num is currently not used
4455Function V_writeSampleDescription(fname,str)
4456        String fname,str
4457
4458//      String path = "entry:sample:description"
4459
4460        Make/O/T/N=1 tmpTW
4461        String groupName = "/entry/sample"
4462        String varName = "description"
4463        tmpTW[0] = str //
4464
4465        variable err
4466        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4467        if(err)
4468                Print "HDF write err = ",err
4469        endif
4470       
4471        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4472        err = V_KillNamedDataFolder(fname)
4473        if(err)
4474                Print "DataFolder kill err = ",err
4475        endif
4476               
4477        return(err)
4478End
4479
4480//no meaning to this...
4481Function V_writeSample_equatorial_ang(fname,val)
4482        String fname
4483        Variable val
4484       
4485//      String path = "entry:sample:equatorial_angle"   
4486       
4487        Make/O/D/N=1 wTmpWrite
4488//      Make/O/R/N=1 wTmpWrite
4489        String groupName = "/entry/sample"
4490        String varName = "equatorial_angle"
4491        wTmpWrite[0] = val
4492
4493        variable err
4494        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4495        if(err)
4496                Print "HDF write err = ",err
4497        endif
4498        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4499        err = V_KillNamedDataFolder(fname)
4500        if(err)
4501                Print "DataFolder kill err = ",err
4502        endif
4503        return(err)
4504end
4505
4506// TODO -- do  I need to make sure that this is an integer?
4507// group ID !!! very important for matching up files
4508Function V_writeSample_GroupID(fname,val)
4509        String fname
4510        Variable val
4511       
4512//      String path = "entry:sample:group_id"   
4513       
4514        Make/O/D/N=1 wTmpWrite
4515//      Make/O/R/N=1 wTmpWrite
4516        String groupName = "/entry/sample"
4517        String varName = "group_id"
4518        wTmpWrite[0] = val
4519
4520        variable err
4521        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4522        if(err)
4523                Print "HDF write err = ",err
4524        endif
4525        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4526        err = V_KillNamedDataFolder(fname)
4527        if(err)
4528                Print "DataFolder kill err = ",err
4529        endif
4530        return(err)
4531end
4532
4533
4534//Sample Rotation Angle
4535Function V_writeSampleRotationAngle(fname,val)
4536        String fname
4537        Variable val
4538       
4539//      String path = "entry:sample:rotation_angle"     
4540       
4541        Make/O/D/N=1 wTmpWrite
4542//      Make/O/R/N=1 wTmpWrite
4543        String groupName = "/entry/sample"
4544        String varName = "rotation_angle"
4545        wTmpWrite[0] = val
4546
4547        variable err
4548        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4549        if(err)
4550                Print "HDF write err = ",err
4551        endif
4552        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4553        err = V_KillNamedDataFolder(fname)
4554        if(err)
4555                Print "DataFolder kill err = ",err
4556        endif
4557        return(err)
4558end
4559
4560//?? this is huber/chamber??
4561// TODO -- then where is the description of 10CB, etc...
4562Function V_writeSampleHolderDescription(fname,str)
4563        String fname,str
4564
4565//      String path = "entry:sample:sample_holder_description"
4566
4567        Make/O/T/N=1 tmpTW
4568        String groupName = "/entry/sample"
4569        String varName = "sample_holder_description"
4570        tmpTW[0] = str //
4571
4572        variable err
4573        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4574        if(err)
4575                Print "HDF write err = ",err
4576        endif
4577       
4578        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4579        err = V_KillNamedDataFolder(fname)
4580        if(err)
4581                Print "DataFolder kill err = ",err
4582        endif
4583               
4584        return(err)
4585End
4586
4587//Sample Thickness
4588// TODO -- somehow, this is not set correctly in the acquisition, so NaN results
4589Function V_writeSampleThickness(fname,val)
4590        String fname
4591        Variable val
4592       
4593//      String path = "entry:sample:thickness" 
4594       
4595        Make/O/D/N=1 wTmpWrite
4596//      Make/O/R/N=1 wTmpWrite
4597        String groupName = "/entry/sample"
4598        String varName = "thickness"
4599        wTmpWrite[0] = val
4600
4601        variable err
4602        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4603        if(err)
4604                Print "HDF write err = ",err
4605        endif
4606        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4607        err = V_KillNamedDataFolder(fname)
4608        if(err)
4609                Print "DataFolder kill err = ",err
4610        endif
4611        return(err)
4612end
4613
4614// sample transmission
4615Function V_writeSampleTransmission(fname,val)
4616        String fname
4617        Variable val
4618       
4619        String path = "entry:sample:transmission"       
4620//      String path = "QKK0037737:data:Transmission"   
4621       
4622        Make/O/D/N=1 wTmpWrite
4623//      Make/O/R/N=1 wTmpWrite
4624        String groupName = "/entry/sample"
4625        String varName = "transmission"
4626        wTmpWrite[0] = val
4627
4628        variable err
4629        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4630        if(err)
4631                Print "HDF write err = ",err
4632        endif
4633        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4634        err = V_KillNamedDataFolder(fname)
4635        if(err)
4636                Print "DataFolder kill err = ",err
4637        endif
4638        return(err)
4639end
4640
4641//transmission error (one sigma)
4642Function V_writeSampleTransError(fname,val)
4643        String fname
4644        Variable val
4645       
4646//      String path = "entry:sample:transmission_error"
4647       
4648        Make/O/D/N=1 wTmpWrite
4649//      Make/O/R/N=1 wTmpWrite
4650        String groupName = "/entry/sample"
4651        String varName = "transmission_error"
4652        wTmpWrite[0] = val
4653
4654        variable err
4655        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4656        if(err)
4657                Print "HDF write err = ",err
4658        endif
4659        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4660        err = V_KillNamedDataFolder(fname)
4661        if(err)
4662                Print "DataFolder kill err = ",err
4663        endif
4664        return(err)
4665end
4666
4667
4668
4669//// SAMPLE / DATA LOGS
4670// write this generic , call with the name of the environment log desired
4671//
4672// temperature_1
4673// temperature_2
4674// shear_field
4675// pressure
4676// magnetic_field
4677// electric_field
4678//
4679//////// (for example) electric_field (data folder)
4680
4681Function V_writeLog_attachedTo(fname,logStr,str)
4682        String fname,logStr,str
4683
4684//      String path = "entry:sample:"+logstr+":attached_to"
4685
4686        Make/O/T/N=1 tmpTW
4687        String groupName = "/entry/sample/"+logStr
4688        String varName = "attached_to"
4689        tmpTW[0] = str //
4690
4691        variable err
4692        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4693        if(err)
4694                Print "HDF write err = ",err
4695        endif
4696       
4697        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4698        err = V_KillNamedDataFolder(fname)
4699        if(err)
4700                Print "DataFolder kill err = ",err
4701        endif
4702               
4703        return(err)
4704End
4705
4706
4707Function V_writeLog_measurement(fname,logStr,str)
4708        String fname,logStr,str
4709
4710        String path = "entry:sample:"+logstr+":measurement"
4711
4712        Make/O/T/N=1 tmpTW
4713        String groupName = "/entry/sample/"+logStr
4714        String varName = "measurement"
4715        tmpTW[0] = str //
4716
4717        variable err
4718        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4719        if(err)
4720                Print "HDF write err = ",err
4721        endif
4722       
4723        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4724        err = V_KillNamedDataFolder(fname)
4725        if(err)
4726                Print "DataFolder kill err = ",err
4727        endif
4728               
4729        return(err)
4730End
4731
4732
4733Function V_writeLog_Name(fname,logStr,str)
4734        String fname,logStr,str
4735
4736//      String path = "entry:sample:"+logstr+":name"
4737
4738        Make/O/T/N=1 tmpTW
4739        String groupName = "/entry/sample/"+logStr
4740        String varName = "name"
4741        tmpTW[0] = str //
4742
4743        variable err
4744        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4745        if(err)
4746                Print "HDF write err = ",err
4747        endif
4748       
4749        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4750        err = V_KillNamedDataFolder(fname)
4751        if(err)
4752                Print "DataFolder kill err = ",err
4753        endif
4754               
4755        return(err)
4756End
4757
4758
4759// TODO --
4760Function V_writeLog_nomValue(fname,logStr,val)
4761        String fname,logStr
4762        Variable val
4763       
4764//      String path = "entry:sample:"+logstr+":value"
4765       
4766        Make/O/D/N=1 wTmpWrite
4767//      Make/O/R/N=1 wTmpWrite
4768        String groupName = "/entry/sample/"+logStr
4769        String varName = "value"
4770        wTmpWrite[0] = val
4771
4772        variable err
4773        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4774        if(err)
4775                Print "HDF write err = ",err
4776        endif
4777        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4778        err = V_KillNamedDataFolder(fname)
4779        if(err)
4780                Print "DataFolder kill err = ",err
4781        endif
4782        return(err)
4783end
4784
4785////            value_log (data folder)
4786Function V_writeLog_startTime(fname,logStr,str)
4787        String fname,logStr,str
4788
4789//      String path = "entry:sample:"+logstr+":value_log:start"
4790
4791        Make/O/T/N=1 tmpTW
4792        String groupName = "/entry/sample/"+logStr+"/value_log"
4793        String varName = "start"
4794        tmpTW[0] = str //
4795
4796        variable err
4797        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
4798        if(err)
4799                Print "HDF write err = ",err
4800        endif
4801       
4802        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4803        err = V_KillNamedDataFolder(fname)
4804        if(err)
4805                Print "DataFolder kill err = ",err
4806        endif
4807               
4808        return(err)
4809End
4810
4811// TODO --
4812Function V_writeLog_avgValue(fname,logStr,val)
4813        String fname,logStr
4814        Variable val
4815       
4816//      String path = "entry:sample:"+logstr+":value_log:average_value"
4817       
4818        Make/O/D/N=1 wTmpWrite
4819//      Make/O/R/N=1 wTmpWrite
4820        String groupName = "/entry/sample/"+logStr+"/value_log"
4821        String varName = "average_value"
4822        wTmpWrite[0] = val
4823
4824        variable err
4825        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4826        if(err)
4827                Print "HDF write err = ",err
4828        endif
4829        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4830        err = V_KillNamedDataFolder(fname)
4831        if(err)
4832                Print "DataFolder kill err = ",err
4833        endif
4834        return(err)
4835end
4836
4837// TODO -- this needs to be a WAVE reference
4838Function V_writeLog_time(fname,logStr,inW)
4839        String fname,logStr
4840        Wave inW
4841       
4842//      String path = "entry:sample:"+logstr+":value_log:nx_time"
4843
4844        Duplicate/O inW wTmpWrite       
4845// then use redimension as needed to cast the wave to write to the specified type
4846// see WaveType for the proper codes
4847//      Redimension/T=() wTmpWrite
4848// -- May also need to check the dimension(s) before writing (don't trust the input)
4849        String groupName = "/entry/sample/"+logStr+"/value_log"
4850        String varName = "nx_time"
4851
4852        variable err
4853        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4854        if(err)
4855                Print "HDF write err = ",err
4856        endif
4857        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4858        err = V_KillNamedDataFolder(fname)
4859        if(err)
4860                Print "DataFolder kill err = ",err
4861        endif
4862        return(err)
4863end
4864
4865
4866// TODO -- this needs to be a WAVE reference
4867Function V_writeLog_Value(fname,logStr,inW)
4868        String fname,logStr
4869        Wave inW
4870       
4871//      String path = "entry:sample:"+logstr+":value_log:value"
4872
4873        Duplicate/O inW wTmpWrite       
4874// then use redimension as needed to cast the wave to write to the specified type
4875// see WaveType for the proper codes
4876//      Redimension/T=() wTmpWrite
4877// -- May also need to check the dimension(s) before writing (don't trust the input)
4878        String groupName = "/entry/sample/"+logStr+"/value_log"
4879        String varName = "value"
4880
4881        variable err
4882        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4883        if(err)
4884                Print "HDF write err = ",err
4885        endif
4886        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4887        err = V_KillNamedDataFolder(fname)
4888        if(err)
4889                Print "DataFolder kill err = ",err
4890        endif
4891        return(err)
4892end
4893
4894
4895
4896///////// REDUCTION
4897///////// REDUCTION
4898///////// REDUCTION
4899
4900
4901// TODO -- needs to be a WAVE, and of the proper size and type!!!
4902Function V_writeAbsolute_Scaling(fname,inW)
4903        String fname
4904        Wave inW
4905       
4906//      String path = "entry:reduction:absolute_scaling"
4907       
4908        Duplicate/O inW wTmpWrite       
4909// then use redimension as needed to cast the wave to write to the specified type
4910// see WaveType for the proper codes
4911//      Redimension/T=() wTmpWrite
4912// -- May also need to check the dimension(s) before writing (don't trust the input)
4913        String groupName = "/entry/reduction"   
4914        String varName = "absolute_scaling"
4915
4916        variable err
4917        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4918        if(err)
4919                Print "HDF write err = ",err
4920        endif
4921        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4922        err = V_KillNamedDataFolder(fname)
4923        if(err)
4924                Print "DataFolder kill err = ",err
4925        endif
4926        return(err)
4927end
4928
4929// TODO -- needs to be a WAVE
4930Function V_writeBoxCoordinates(fname,inW)
4931        String fname
4932        Wave inW
4933       
4934//      String path = "entry:reduction:box_coordinates"
4935               
4936        Duplicate/O inW wTmpWrite       
4937// then use redimension as needed to cast the wave to write to the specified type
4938// see WaveType for the proper codes
4939//      Redimension/T=() wTmpWrite
4940// -- May also need to check the dimension(s) before writing (don't trust the input)
4941        String groupName = "/entry/reduction"   
4942        String varName = "box_coordinates"
4943
4944        variable err
4945        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4946        if(err)
4947                Print "HDF write err = ",err
4948        endif
4949        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4950        err = V_KillNamedDataFolder(fname)
4951        if(err)
4952                Print "DataFolder kill err = ",err
4953        endif
4954        return(err)
4955end
4956
4957//box counts
4958Function V_writeBoxCounts(fname,val)
4959        String fname
4960        Variable val
4961       
4962//      String path = "entry:reduction:box_count"       
4963       
4964        Make/O/D/N=1 wTmpWrite
4965//      Make/O/R/N=1 wTmpWrite
4966        String groupName = "/entry/reduction"
4967        String varName = "box_count"
4968        wTmpWrite[0] = val
4969
4970        variable err
4971        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4972        if(err)
4973                Print "HDF write err = ",err
4974        endif
4975        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
4976        err = V_KillNamedDataFolder(fname)
4977        if(err)
4978                Print "DataFolder kill err = ",err
4979        endif
4980        return(err)
4981end
4982
4983//box counts error
4984Function V_writeBoxCountsError(fname,val)
4985        String fname
4986        Variable val
4987       
4988//      String path = "entry:reduction:box_count_error"
4989       
4990        Make/O/D/N=1 wTmpWrite
4991//      Make/O/R/N=1 wTmpWrite
4992        String groupName = "/entry/reduction"
4993        String varName = "box_count_error"
4994        wTmpWrite[0] = val
4995
4996        variable err
4997        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
4998        if(err)
4999                Print "HDF write err = ",err
5000        endif
5001        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5002        err = V_KillNamedDataFolder(fname)
5003        if(err)
5004                Print "DataFolder kill err = ",err
5005        endif
5006        return(err)
5007end
5008
5009Function V_writeReductionComments(fname,str)
5010        String fname,str
5011
5012//      String path = "entry:reduction:comments"       
5013
5014        Make/O/T/N=1 tmpTW
5015        String groupName = "/entry/reduction"
5016        String varName = "comments"
5017        tmpTW[0] = str //
5018
5019        variable err
5020        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5021        if(err)
5022                Print "HDF write err = ",err
5023        endif
5024       
5025        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5026        err = V_KillNamedDataFolder(fname)
5027        if(err)
5028                Print "DataFolder kill err = ",err
5029        endif
5030               
5031        return(err)
5032End
5033
5034
5035Function V_writeReductionIntent(fname,str)
5036        String fname,str
5037
5038//      String path = "entry:reduction:intent" 
5039
5040        Make/O/T/N=1 tmpTW
5041        String groupName = "/entry/reduction"
5042        String varName = "intent"
5043        tmpTW[0] = str //
5044
5045        variable err
5046        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5047        if(err)
5048                Print "HDF write err = ",err
5049        endif
5050       
5051        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5052        err = V_KillNamedDataFolder(fname)
5053        if(err)
5054                Print "DataFolder kill err = ",err
5055        endif
5056               
5057        return(err)
5058End
5059
5060
5061Function V_writeLogFileName(fname,str)
5062        String fname,str
5063
5064//      String path = "entry:reduction:sans_log_file_name"     
5065
5066        Make/O/T/N=1 tmpTW
5067        String groupName = "/entry/reduction"
5068        String varName = "sans_log_file_name"
5069        tmpTW[0] = str //
5070
5071        variable err
5072        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5073        if(err)
5074                Print "HDF write err = ",err
5075        endif
5076       
5077        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5078        err = V_KillNamedDataFolder(fname)
5079        if(err)
5080                Print "DataFolder kill err = ",err
5081        endif
5082               
5083        return(err)
5084End
5085
5086
5087Function V_writeSensitivityFileName(fname,str)
5088        String fname,str
5089
5090//      String path = "entry:reduction:sensitivity_file_name"   
5091
5092        Make/O/T/N=1 tmpTW
5093        String groupName = "/entry/reduction"
5094        String varName = "sensitivity_file_name"
5095        tmpTW[0] = str //
5096
5097        variable err
5098        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5099        if(err)
5100                Print "HDF write err = ",err
5101        endif
5102       
5103        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5104        err = V_KillNamedDataFolder(fname)
5105        if(err)
5106                Print "DataFolder kill err = ",err
5107        endif
5108               
5109        return(err)
5110End
5111
5112Function V_writeTransmissionFileName(fname,str)
5113        String fname,str
5114
5115//      String path = "entry:reduction:transmission_file_name" 
5116
5117        Make/O/T/N=1 tmpTW
5118        String groupName = "/entry/reduction"
5119        String varName = "transmission_file_name"
5120        tmpTW[0] = str //
5121
5122        variable err
5123        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5124        if(err)
5125                Print "HDF write err = ",err
5126        endif
5127       
5128        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5129        err = V_KillNamedDataFolder(fname)
5130        if(err)
5131                Print "DataFolder kill err = ",err
5132        endif
5133               
5134        return(err)
5135End
5136
5137Function V_writeEmptyBeamFileName(fname,str)
5138        String fname,str
5139
5140//      String path = "entry:reduction:empty_beam_file_name"   
5141
5142        Make/O/T/N=1 tmpTW
5143        String groupName = "/entry/reduction"
5144        String varName = "empty_beam_file_name"
5145        tmpTW[0] = str //
5146
5147        variable err
5148        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5149        if(err)
5150                Print "HDF write err = ",err
5151        endif
5152       
5153        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5154        err = V_KillNamedDataFolder(fname)
5155        if(err)
5156                Print "DataFolder kill err = ",err
5157        endif
5158               
5159        return(err)
5160End
5161
5162
5163//whole detector transmission
5164Function V_writeSampleTransWholeDetector(fname,val)
5165        String fname
5166        Variable val
5167       
5168//      String path = "entry:reduction:whole_trans"     
5169       
5170        Make/O/D/N=1 wTmpWrite
5171//      Make/O/R/N=1 wTmpWrite
5172        String groupName = "/entry/reduction"
5173        String varName = "whole_trans"
5174        wTmpWrite[0] = val
5175
5176        variable err
5177        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5178        if(err)
5179                Print "HDF write err = ",err
5180        endif
5181        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5182        err = V_KillNamedDataFolder(fname)
5183        if(err)
5184                Print "DataFolder kill err = ",err
5185        endif
5186        return(err)
5187end
5188
5189//whole detector transmission error
5190Function V_writeSampleTransWholeDetErr(fname,val)
5191        String fname
5192        Variable val
5193       
5194//      String path = "entry:reduction:whole_trans_error"       
5195       
5196        Make/O/D/N=1 wTmpWrite
5197//      Make/O/R/N=1 wTmpWrite
5198        String groupName = "/entry/reduction"
5199        String varName = "whole_trans_error"
5200        wTmpWrite[0] = val
5201
5202        variable err
5203        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5204        if(err)
5205                Print "HDF write err = ",err
5206        endif
5207        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5208        err = V_KillNamedDataFolder(fname)
5209        if(err)
5210                Print "DataFolder kill err = ",err
5211        endif
5212        return(err)
5213end
5214
5215                       
5216/////                   pol_sans (data folder)
5217
5218Function V_writePolSANS_cellName(fname,str)
5219        String fname,str
5220
5221//      String path = "entry:reduction:pol_sans:cell_name"     
5222
5223        Make/O/T/N=1 tmpTW
5224        String groupName = "/entry/reduction/pol_sans"
5225        String varName = "cell_name"
5226        tmpTW[0] = str //
5227
5228        variable err
5229        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5230        if(err)
5231                Print "HDF write err = ",err
5232        endif
5233       
5234        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5235        err = V_KillNamedDataFolder(fname)
5236        if(err)
5237                Print "DataFolder kill err = ",err
5238        endif
5239               
5240        return(err)
5241End
5242
5243
5244// TODO -- needs to be a WAVE
5245// is this a text wave?? if it's mixed names + values, then what?
5246Function V_writePolSANS_cellParams(fname,inW)
5247        String fname
5248        Wave inW
5249       
5250//      String path = "entry:reduction:pol_sans:cell_parameters"
5251               
5252        Duplicate/O inW wTmpWrite       
5253// then use redimension as needed to cast the wave to write to the specified type
5254// see WaveType for the proper codes
5255//      Redimension/T=() wTmpWrite
5256// -- May also need to check the dimension(s) before writing (don't trust the input)
5257        String groupName = "/entry/reduction/pol_sans" 
5258        String varName = "cell_parameters"
5259
5260        variable err
5261        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
5262        if(err)
5263                Print "HDF write err = ",err
5264        endif
5265        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5266        err = V_KillNamedDataFolder(fname)
5267        if(err)
5268                Print "DataFolder kill err = ",err
5269        endif
5270        return(err)
5271end
5272
5273Function V_writePolSANS_PolSANSPurpose(fname,str)
5274        String fname,str
5275
5276//      String path = "entry:reduction:pol_sans:pol_sans_purpose"       
5277
5278        Make/O/T/N=1 tmpTW
5279        String groupName = "/entry/reduction/pol_sans"
5280        String varName = "pol_sans_purpose"
5281        tmpTW[0] = str //
5282
5283        variable err
5284        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5285        if(err)
5286                Print "HDF write err = ",err
5287        endif
5288       
5289        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5290        err = V_KillNamedDataFolder(fname)
5291        if(err)
5292                Print "DataFolder kill err = ",err
5293        endif
5294               
5295        return(err)
5296End
5297
5298                               
5299//////// TOP LEVEL DATA REPRESENTATION
5300//
5301// note that here the data is (supposed to be) a link, not the actual data
5302// Igor HDf implementation cannot follow links properly, as far as I know.
5303// so ignore them here, and focus on the image that may be possible to read
5304//
5305
5306//              data_B (data folder)
5307//                      data (wave) 1           //ignore this, it's a link
5308//                      variables (wave) 320
5309//                      thumbnail (data folder)
5310
5311//data (wave) "binary"
5312// TODO -- this will need to be completely replaced with a function that can
5313// read the binary image data. should be possible, but I don't know the details on either end...
5314Function V_writeDataImage(fname,detStr,str)
5315        String fname,detStr,str
5316
5317//      String path = "entry:data_"+detStr+":thumbnail:data"   
5318
5319        Make/O/T/N=1 tmpTW
5320        String groupName = "/entry/data_"+detStr+"/thumbnail"
5321        String varName = "data"
5322        tmpTW[0] = str //
5323
5324        variable err
5325        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5326        if(err)
5327                Print "HDF write err = ",err
5328        endif
5329       
5330        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5331        err = V_KillNamedDataFolder(fname)
5332        if(err)
5333                Print "DataFolder kill err = ",err
5334        endif
5335               
5336        return(err)
5337End
5338
5339Function V_writeDataImageDescription(fname,detStr,str)
5340        String fname,detStr,str
5341
5342//      String path = "entry:data_"+detStr+":thumbnail:description"     
5343
5344        Make/O/T/N=1 tmpTW
5345        String groupName = "/entry/data_"+detStr+"/thumbnail"
5346        String varName = "description"
5347        tmpTW[0] = str //
5348
5349        variable err
5350        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5351        if(err)
5352                Print "HDF write err = ",err
5353        endif
5354       
5355        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5356        err = V_KillNamedDataFolder(fname)
5357        if(err)
5358                Print "DataFolder kill err = ",err
5359        endif
5360               
5361        return(err)
5362End
5363                                                               
5364Function V_writeDataImageType(fname,detStr,str)
5365        String fname,detStr,str
5366
5367//      String path = "entry:data_"+detStr+":thumbnail:type"   
5368
5369        Make/O/T/N=1 tmpTW
5370        String groupName = "/entry/data_"+detStr+"/thumbnail"
5371        String varName = "type"
5372        tmpTW[0] = str //
5373
5374        variable err
5375        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
5376        if(err)
5377                Print "HDF write err = ",err
5378        endif
5379       
5380        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
5381        err = V_KillNamedDataFolder(fname)
5382        if(err)
5383                Print "DataFolder kill err = ",err
5384        endif
5385               
5386        return(err)
5387End
5388
Note: See TracBrowser for help on using the repository browser.