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

Last change on this file since 1072 was 1072, checked in by srkline, 5 years ago

a few changes to update the calculation of transmission values from the tables, and updating the correct units in a few places. Also updated how a transmission file is matched with a scattering file.

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