source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Read.ipf @ 1109

Last change on this file since 1109 was 1109, checked in by srkline, 4 years ago

Many changes:

Made the VCALC panel aware of all of the binning options
Corrected the behavior of the VCALC preset conditions
Adjusted how the Slit data is binned so that there are not duplicated q-values in the output

Made Absolute scaling aware of the back detector. Now the ABS String in the protocol has a second
set of scaling constants tagged with "_B" for the back detector. There is an added button
on the protocol panel to set the second set of constants. For the back detector, the read noise
is subtracted by reading it from the empty beam file (shifting over to the right by one box width)
All of the associated abs procedures are now aware of this.
More error checking needs to be added.

Back detector image is now shifted upon loading of the data. the default mask takes this into account
and masks out the padded (zero) regions.

in the protocol, DIV and MSK do not use grep any longer. it was just way too slow. Now it depends on

the file name having DIV or MASK respectively.



Raw data files can now be added together, in the usual way from the protocol panel.



File size: 64.7 KB
Line 
1#pragma rtGlobals=3             // Use modern global access method and strict wave access.
2
3
4//////////// READ (GET) FUNCTIONS ////////////////////
5
6
7//////////////////////////////////////////////
8//////////////////////////////////
9// for TESTING of the get functions - to quickly access and se if there are errors
10//
11// -- not sure how to test the string functions -- can't seem to get a FUNCREF to a string function
12// to work -- maybe it's not alllowed?
13//
14// -- also, now I have get_functions that take a detStr input with the detector information, so that the
15//    functions didn't need to be repeated
16//
17//      -- Not sure how to test the "write" functions. writing the wrong data type to the wrong data field will be a disaster
18//    Writing odd, dummy values will also be a mess - no way to know if I'm doing anything correctly
19//
20Function proto_V_get_FP(str)
21        String str
22        return(0)
23end
24
25Function proto_V_get_FP2(str,str2)
26        String str,str2
27        return(0)
28end
29
30Function/S proto_V_get_STR(str)
31        String str
32        return("")
33end
34
35Proc Dump_V_getFP(fname)
36        String fname
37       
38        Test_V_get_FP("V_get*",fname)
39end
40
41Function Test_V_get_FP(str,fname)
42        String str,fname
43       
44        Variable ii,num
45        String list,item
46       
47       
48        list=FunctionList(str,";","NPARAMS:1,VALTYPE:1") //,VALTYPE:1 gives real return values, not strings
49//      Print list
50        num = ItemsInlist(list)
51       
52       
53        for(ii=0;ii<num;ii+=1)
54                item = StringFromList(ii, list , ";")
55                FUNCREF proto_V_get_FP f = $item
56                Print item ," = ", f(fname)
57        endfor
58       
59        return(0)
60end
61
62Proc Dump_V_getFP_Det(fname,detStr)
63        String fname,detStr="FL"
64       
65        Test_V_get_FP2("V_get*",fname,detStr)
66end
67
68Function Test_V_get_FP2(str,fname,detStr)
69        String str,fname,detStr
70       
71        Variable ii,num
72        String list,item
73       
74       
75        list=FunctionList(str,";","NPARAMS:2,VALTYPE:1") //,VALTYPE:1 gives real return values, not strings
76//      Print list
77        num = ItemsInlist(list)
78       
79       
80        for(ii=0;ii<num;ii+=1)
81                item = StringFromList(ii, list , ";")
82                FUNCREF proto_V_get_FP2 f = $item
83                Print item ," = ", f(fname,detStr)
84        endfor
85       
86        return(0)
87end
88
89
90Proc Dump_V_getSTR(fname)
91        String fname
92       
93        Test_V_get_STR("V_get*",fname)
94end
95
96Function Test_V_get_STR(str,fname)
97        String str,fname
98       
99        Variable ii,num
100        String list,item,strToEx
101       
102       
103        list=FunctionList(str,";","NPARAMS:1,VALTYPE:4")
104//      Print list
105        num = ItemsInlist(list)
106       
107       
108        for(ii=0;ii<num;ii+=1)
109                item = StringFromList(ii, list , ";")
110        //      FUNCREF proto_V_get_STR f = $item
111                printf "%s = ",item
112                sprintf strToEx,"Print %s(\"%s\")",item,fname
113                Execute strToEx
114//              print strToEx
115//              Print item ," = ", f(fname)
116        endfor
117       
118        return(0)
119end
120
121Proc Dump_V_getSTR_Det(fname,detStr)
122        String fname,detStr="FL"
123       
124        Test_V_get_STR2("V_get*",fname,detStr)
125end
126
127Function Test_V_get_STR2(str,fname,detStr)
128        String str,fname,detStr
129       
130        Variable ii,num
131        String list,item,strToEx
132       
133       
134        list=FunctionList(str,";","NPARAMS:2,VALTYPE:4")
135//      Print list
136        num = ItemsInlist(list)
137       
138       
139        for(ii=0;ii<num;ii+=1)
140                item = StringFromList(ii, list , ";")
141        //      FUNCREF proto_V_get_STR f = $item
142                printf "%s = ",item
143                sprintf strToEx,"Print %s(\"%s\",\"%s\")",item,fname,detStr
144                Execute strToEx
145//              print strToEx
146//              Print item ," = ", f(fname)
147        endfor
148       
149        return(0)
150end
151///////////////////////////////////////
152
153
154//////////////////////////////////////////////
155
156
157///////////////////////
158//
159// *These are the specific bits of information to retrieve (or write) to the data file
160// *These functions use the path to the file as input, and each has the specific
161//   path to the variable srting, or wave hard-coded into the access function
162// *They call the generic worker functions to get the values, either from the local copy if present,
163//   or the full file is loaded.
164//
165// *Since the path is the important bit, these are written as get/write pairs to make it easier to
166//   keep up with any changes in path
167//
168//
169// TODO -- verify the paths, and add more as needed
170// TODO -- for all of the String functions -- "num" does nothing right now -
171//         -- if it ever does, or needs to, a lot of locations will need to be corrected
172//
173
174
175//////// TOP LEVEL
176//////// TOP LEVEL
177//////// TOP LEVEL
178
179//// nexus version used for definitions
180//Function/S V_getNeXus_version(fname)
181//      String fname
182//     
183//      String path = "entry:NeXus_version"     
184//      Variable num=60
185//      return(V_getStringFromHDF5(fname,path,num))
186//End
187
188// TODO -- not mine, added somewhere by Nexus writer?
189// data collection time (! this is the true counting time??)
190Function V_getCollectionTime(fname)
191        String fname
192       
193        String path = "entry:collection_time"   
194        return(V_getRealValueFromHDF5(fname,path))
195End
196
197// data directory where data files are stored (for user access, not archive)
198Function/S V_getData_directory(fname)
199        String fname
200       
201        String path = "entry:data_directory"   
202        Variable num=60
203        return(V_getStringFromHDF5(fname,path,num))
204End
205
206// Base class of Nexus definition (=NXsas)
207Function/S V_getNexusDefinition(fname)
208        String fname
209       
210        String path = "entry:definition"       
211        Variable num=60
212        return(V_getStringFromHDF5(fname,path,num))
213End
214
215// TODO -- not mine, added somewhere by Nexus writer?
216// data collection duration (may include pauses, other "dead" time)
217Function V_getDataDuration(fname)
218        String fname
219       
220        String path = "entry:duration" 
221        return(V_getRealValueFromHDF5(fname,path))
222End
223
224// TODO -- not mine, added somewhere by Nexus writer?
225// data collection end time
226Function/S V_getDataEndTime(fname)
227        String fname
228       
229        String path = "entry:end_time" 
230        Variable num=60
231        return(V_getStringFromHDF5(fname,path,num))
232End
233
234// experiment description
235Function/S V_getExperiment_description(fname)
236        String fname
237       
238        String path = "entry:experiment_description"   
239        Variable num=60
240        return(V_getStringFromHDF5(fname,path,num))
241End
242
243// experiment identifier? used only by NICE?
244Function/S V_getExperiment_identifier(fname)
245        String fname
246       
247        String path = "entry:experiment_identifier"     
248        Variable num=60
249        return(V_getStringFromHDF5(fname,path,num))
250End
251
252// name of facility = NCNR
253Function/S V_getFacility(fname)
254        String fname
255       
256        String path = "entry:facility" 
257        Variable num=60
258        return(V_getStringFromHDF5(fname,path,num))
259End
260
261// **cut in JUNE 2017
262////  x- should be the file name as saved on disk, currently it's not
263//Function/S V_getFile_name(fname)
264//      String fname
265//     
266//      String path = "entry:file_name"
267//      Variable num=60
268//      return(V_getStringFromHDF5(fname,path,num))
269//End
270
271// **cut in JUNE 2017           
272////
273//Function/S V_getHDF_version(fname)
274//      String fname
275//     
276//      String path = "entry:hdf_version"       
277//      Variable num=60
278//      return(V_getStringFromHDF5(fname,path,num))
279//End
280
281// TODO -- not mine, added somewhere by Nexus writer?
282Function/S V_getProgram_name(fname)
283        String fname
284       
285        String path = "entry:program_name"     
286        Variable num=60
287        return(V_getStringFromHDF5(fname,path,num))
288End
289
290// TODO -- not mine, added somewhere by Nexus writer?
291// data collection start time
292Function/S V_getDataStartTime(fname)
293        String fname
294       
295        String path = "entry:start_time"       
296        Variable num=60
297        return(V_getStringFromHDF5(fname,path,num))
298End
299               
300// title of experiment
301Function/S V_getTitle(fname)
302        String fname
303       
304        String path = "entry:title"     
305        Variable num=60
306        return(V_getStringFromHDF5(fname,path,num))
307end
308       
309       
310               
311////////// USER
312////////// USER
313////////// USER
314
315// list of user names
316//  x- currently not written out to data file??
317Function/S V_getUserNames(fname)
318        String fname
319       
320        String path = "entry:user:name"
321        Variable num=60
322        return(V_getStringFromHDF5(fname,path,num))
323end
324
325
326//////// CONTROL
327//////// CONTROL
328//////// CONTROL
329
330// TODO -- for the control section, document each of the fields
331
332// **cut in JUNE 2017
333//Function/S V_getCount_end(fname)
334//      String fname
335//     
336//      Variable num
337//      String path = "entry:control:count_end"
338//      return(V_getStringFromHDF5(fname,path,num))
339//end
340
341// **cut in JUNE 2017
342//
343//Function/S V_getCount_start(fname)
344//      String fname
345//     
346//      Variable num
347//      String path = "entry:control:count_start"       
348//      return(V_getStringFromHDF5(fname,path,num))
349//end
350
351
352Function V_getCount_time(fname)
353        String fname
354       
355        String path = "entry:control:count_time"       
356        return(V_getRealValueFromHDF5(fname,path))
357end
358
359
360Function V_getCount_time_preset(fname)
361        String fname
362       
363        String path = "entry:control:count_time_preset"
364        return(V_getRealValueFromHDF5(fname,path))
365end
366
367
368Function V_getDetector_counts(fname)
369        String fname
370       
371        String path = "entry:control:detector_counts"   
372        return(V_getRealValueFromHDF5(fname,path))
373end
374
375
376Function V_getDetector_preset(fname)
377        String fname
378       
379        String path = "entry:control:detector_preset"   
380        return(V_getRealValueFromHDF5(fname,path))
381end
382
383// **cut in JUNE 2017
384//
385//Function V_getIntegral(fname)
386//      String fname
387//     
388//      String path = "entry:control:integral" 
389//      return(V_getRealValueFromHDF5(fname,path))
390//end
391
392// control mode for data acquisition, "timer"
393// TODO - what are the enumerated types for this?
394Function/S V_getControlMode(fname)
395        String fname
396       
397        String path = "entry:control:mode"     
398        Variable num=60
399        return(V_getStringFromHDF5(fname,path,num))
400End
401
402//monitor count
403// TODO - verify that this is the correct monitor
404Function V_getControlMonitorCount(fname)
405        String fname
406       
407        String path = "entry:control:monitor_counts"   
408        return(V_getRealValueFromHDF5(fname,path))
409end
410
411Function V_getControlMonitor_preset(fname)
412        String fname
413       
414        String path = "entry:control:monitor_preset"   
415        return(V_getRealValueFromHDF5(fname,path))
416end
417
418// **cut in JUNE 2017
419//  - what are the enumerated types for this?
420//Function/S V_getPreset(fname)
421//      String fname
422//     
423//      Variable num
424//      String path = "entry:control:preset"   
425//      return(V_getStringFromHDF5(fname,path,num))
426//end
427
428
429
430
431
432//////// INSTRUMENT
433//////// INSTRUMENT
434//////// INSTRUMENT
435
436// x- this does not appear to be written out
437Function/S V_getLocalContact(fname)
438        String fname
439
440        String path = "entry:instrument:local_contact"
441        Variable num=60
442        return(V_getStringFromHDF5(fname,path,num))
443End
444
445Function/S V_getInstrumentName(fname)
446        String fname
447
448        String path = "entry:instrument:name"
449        Variable num=60
450        return(V_getStringFromHDF5(fname,path,num))
451End
452
453Function/S V_getInstrumentType(fname)
454        String fname
455
456        String path = "entry:instrument:type"
457        Variable num=60
458        return(V_getStringFromHDF5(fname,path,num))
459End
460
461////// INSTRUMENT/ATTENUATOR
462// TODO - be sure of the definition of these terms
463//
464
465// transmission value for the attenuator in the beam
466// use this, but if something wrong, the tables are present
467Function V_getAttenuator_transmission(fname)
468        String fname
469       
470        Print "Atten read - diverted to calculation"
471        return(V_CalculateAttenuationFactor(fname))
472       
473//      String path = "entry:instrument:attenuator:attenuator_transmission"     
474//      return(V_getRealValueFromHDF5(fname,path))
475
476end
477
478// transmission value (error) for the attenuator in the beam
479// use this, but if something wrong, the tables are present
480Function V_getAttenuator_trans_err(fname)
481        String fname
482       
483        Print "Atten_err read - diverted to calculation"
484        return(V_CalculateAttenuationError(fname))
485       
486//      String path = "entry:instrument:attenuator:attenuator_transmission_error"       
487//      return(V_getRealValueFromHDF5(fname,path))
488       
489end
490
491// desired thickness
492Function V_getAtten_desired_thickness(fname)
493        String fname
494       
495        String path = "entry:instrument:attenuator:desired_thickness"   
496        return(V_getRealValueFromHDF5(fname,path))
497end
498
499
500// distance from the attenuator to the sample (units??)
501Function V_getAttenDistance(fname)
502        String fname
503       
504        String path = "entry:instrument:attenuator:distance"   
505        return(V_getRealValueFromHDF5(fname,path))
506end
507
508
509
510// table of the attenuation factor error
511Function/WAVE V_getAttenIndex_error_table(fname)
512        String fname
513       
514        String path = "entry:instrument:attenuator:index_error_table"
515        WAVE w = V_getRealWaveFromHDF5(fname,path)
516       
517        return w
518end
519
520// table of the attenuation factor
521Function/WAVE V_getAttenIndex_table(fname)
522        String fname
523       
524        String path = "entry:instrument:attenuator:index_table"
525        WAVE w = V_getRealWaveFromHDF5(fname,path)
526
527        return w
528end
529
530//
531//// status "in or out"
532//Function/S V_getAttenStatus(fname)
533//      String fname
534//
535//      String path = "entry:instrument:attenuator:status"
536//      Variable num=60
537//      return(V_getStringFromHDF5(fname,path,num))
538//End
539
540//// this is the "number" of attenuators dropped in the beam - and should be
541// what I can use to lookup the actual attenuator transmission
542Function V_getAtten_number(fname)
543        String fname
544       
545        String path = "entry:instrument:attenuator:num_atten_dropped"   
546        return(V_getRealValueFromHDF5(fname,path))
547end
548
549// thickness of the attenuator (PMMA) - units??
550Function V_getAttenThickness(fname)
551        String fname
552       
553        String path = "entry:instrument:attenuator:thickness"   
554        return(V_getRealValueFromHDF5(fname,path))
555end
556
557
558// type of material for the atteunator
559Function/S V_getAttenType(fname)
560        String fname
561
562        String path = "entry:instrument:attenuator:type"
563        Variable num=60
564        return(V_getStringFromHDF5(fname,path,num))
565End
566
567
568////// INSTRUMENT/BEAM
569// instrument/beam/analyzer (data folder)
570// this is the He3 analyzer, after the sample (but first alphabetically)
571// TODO -- document what all of the fields represent, and what are the most important to "key" on to read
572//
573Function V_getAnalyzer_depth(fname)
574        String fname
575       
576        String path = "entry:instrument:beam:analyzer:depth"   
577        return(V_getRealValueFromHDF5(fname,path))
578end
579
580Function/S V_getAnalyzer_direction(fname)
581        String fname
582
583        String path = "entry:instrument:beam:analyzer:direction"
584        Variable num=60
585        return(V_getStringFromHDF5(fname,path,num))
586End
587
588Function V_getAnalyzer_height(fname)
589        String fname
590       
591        String path = "entry:instrument:beam:analyzer:height"   
592        return(V_getRealValueFromHDF5(fname,path))
593end
594
595// ?? TODO is this equivalent to "status" -- ?? 0|1
596Function V_getAnalyzer_inBeam(fname)
597        String fname
598       
599        String path = "entry:instrument:beam:analyzer:inBeam"   
600        return(V_getRealValueFromHDF5(fname,path))
601end
602
603Function V_getAnalyzer_innerDiameter(fname)
604        String fname
605       
606        String path = "entry:instrument:beam:analyzer:innerDiameter"   
607        return(V_getRealValueFromHDF5(fname,path))
608end
609
610// one of the most important
611Function/S V_getAnalyzer_name(fname)
612        String fname
613
614        String path = "entry:instrument:beam:analyzer:name"
615        Variable num=60
616        return(V_getStringFromHDF5(fname,path,num))
617End
618
619Function V_getAnalyzer_opacityAt1Ang(fname)
620        String fname
621       
622        String path = "entry:instrument:beam:analyzer:opacityAt1Ang"   
623        return(V_getRealValueFromHDF5(fname,path))
624end
625
626Function V_getAnalyzer_opacityAt1Ang_err(fname)
627        String fname
628       
629        String path = "entry:instrument:beam:analyzer:opacityAt1AngStd"
630        return(V_getRealValueFromHDF5(fname,path))
631end
632
633Function V_getAnalyzer_outerDiameter(fname)
634        String fname
635       
636        String path = "entry:instrument:beam:analyzer:outerDiameter"   
637        return(V_getRealValueFromHDF5(fname,path))
638end
639
640Function/S V_getAnalyzer_shape(fname)
641        String fname
642
643        String path = "entry:instrument:beam:analyzer:shape"
644        Variable num=60
645        return(V_getStringFromHDF5(fname,path,num))
646End
647
648Function V_getAnalyzer_tE(fname)
649        String fname
650       
651        String path = "entry:instrument:beam:analyzer:tE"       
652        return(V_getRealValueFromHDF5(fname,path))
653end
654
655Function V_getAnalyzer_tE_err(fname)
656        String fname
657       
658        String path = "entry:instrument:beam:analyzer:tEStd"   
659        return(V_getRealValueFromHDF5(fname,path))
660end
661
662Function/S V_getAnalyzer_type(fname)
663        String fname
664
665        String path = "entry:instrument:beam:analyzer:type"
666        Variable num=60
667        return(V_getStringFromHDF5(fname,path,num))
668End
669
670
671Function V_getAnalyzer_width(fname)
672        String fname
673       
674        String path = "entry:instrument:beam:analyzer:width"   
675        return(V_getRealValueFromHDF5(fname,path))
676end
677
678
679// instrument/beam/chopper (data folder)
680Function V_getChopperAngular_opening(fname)
681        String fname
682       
683        String path = "entry:instrument:beam:chopper:angular_opening"   
684        return(V_getRealValueFromHDF5(fname,path))
685end
686
687Function V_getChopDistance_from_sample(fname)
688        String fname
689       
690        String path = "entry:instrument:beam:chopper:distance_from_sample"     
691        return(V_getRealValueFromHDF5(fname,path))
692end
693
694Function V_getChopDistance_from_source(fname)
695        String fname
696       
697        String path = "entry:instrument:beam:chopper:distance_from_source"     
698        return(V_getRealValueFromHDF5(fname,path))
699end
700
701Function V_getChopperDuty_cycle(fname)
702        String fname
703       
704        String path = "entry:instrument:beam:chopper:duty_cycle"       
705        return(V_getRealValueFromHDF5(fname,path))
706end
707
708Function V_getChopperRotation_speed(fname)
709        String fname
710       
711        String path = "entry:instrument:beam:chopper:rotation_speed"   
712        return(V_getRealValueFromHDF5(fname,path))
713end
714
715Function V_getChopperSlits(fname)
716        String fname
717       
718        String path = "entry:instrument:beam:chopper:slits"     
719        return(V_getRealValueFromHDF5(fname,path))
720end
721
722Function/S V_getChopperStatus(fname)
723        String fname
724
725        String path = "entry:instrument:beam:chopper:status"
726        Variable num=60
727        return(V_getStringFromHDF5(fname,path,num))
728End
729
730Function/S V_getChopperType(fname)
731        String fname
732
733        String path = "entry:instrument:beam:chopper:type"
734        Variable num=60
735        return(V_getStringFromHDF5(fname,path,num))
736End
737
738
739// instrument/beam/flipperPolarizer (data folder)
740// this is upstream, after the supermirror but before the sample
741
742Function/S V_getflipperPolarizer_Direction(fname)
743        String fname
744
745        String path = "entry:instrument:beam:flipperPolarizer:direction"
746        Variable num=60
747        return(V_getStringFromHDF5(fname,path,num))
748End
749
750Function V_getflipperPolarizer_inBeam(fname)
751        String fname
752       
753        String path = "entry:instrument:beam:flipperPolarizer:inBeam"   
754        return(V_getRealValueFromHDF5(fname,path))
755end
756
757Function/S V_getflipperPolarizer_Type(fname)
758        String fname
759
760        String path = "entry:instrument:beam:flipperPolarizer:type"
761        Variable num=60
762        return(V_getStringFromHDF5(fname,path,num))
763End
764
765
766
767//Function V_getFlipperDriving_current(fname)
768//      String fname
769//     
770//      String path = "entry:instrument:beam:flipper:driving_current"   
771//      return(V_getRealValueFromHDF5(fname,path))
772//end
773//
774//Function V_getFlipperFrequency(fname)
775//      String fname
776//     
777//      String path = "entry:instrument:beam:flipper:frequency"
778//      return(V_getRealValueFromHDF5(fname,path))
779//end
780//
781//Function/S V_getFlipperstatus(fname)
782//      String fname
783//
784//      String path = "entry:instrument:beam:flipper:status"
785//      Variable num=60
786//      return(V_getStringFromHDF5(fname,path,num))
787//End
788//
789//Function V_getFlipperTransmitted_power(fname)
790//      String fname
791//     
792//      String path = "entry:instrument:beam:flipper:transmitted_power"
793//      return(V_getRealValueFromHDF5(fname,path))
794//end
795//
796//Function/S V_getFlipperWaveform(fname)
797//      String fname
798//
799//      String path = "entry:instrument:beam:flipper:waveform"
800//      Variable num=60
801//      return(V_getStringFromHDF5(fname,path,num))
802//End
803
804
805
806// instrument/beam/monochromator (data folder)
807Function/S V_getMonochromatorType(fname)
808        String fname
809
810        String path = "entry:instrument:beam:monochromator:type"
811        Variable num=60
812        return(V_getStringFromHDF5(fname,path,num))
813End
814
815Function V_getWavelength(fname)
816        String fname
817       
818        String path = "entry:instrument:beam:monochromator:wavelength" 
819        return(V_getRealValueFromHDF5(fname,path))
820end
821
822Function V_getWavelength_spread(fname)
823        String fname
824       
825        String path = "entry:instrument:beam:monochromator:wavelength_spread"   
826        return(V_getRealValueFromHDF5(fname,path))
827end
828
829// instrument/beam/monochromator/crystal (data folder)
830Function V_getCrystalDistance(fname)
831        String fname
832       
833        String path = "entry:instrument:beam:monochromator:crystal:distance"   
834        return(V_getRealValueFromHDF5(fname,path))
835end
836
837Function V_getCrystalEnergy(fname)
838        String fname
839       
840        String path = "entry:instrument:beam:monochromator:crystal:energy"     
841        return(V_getRealValueFromHDF5(fname,path))
842end
843
844Function V_getCrystalHorizontal_aperture(fname)
845        String fname
846       
847        String path = "entry:instrument:beam:monochromator:crystal:horizontal_aperture"
848        return(V_getRealValueFromHDF5(fname,path))
849end
850
851Function V_getCrystalHoriz_curvature(fname)
852        String fname
853       
854        String path = "entry:instrument:beam:monochromator:crystal:horizontal_curvature"       
855        return(V_getRealValueFromHDF5(fname,path))
856end
857
858Function V_getCrystalLattice_parameter(fname)
859        String fname
860       
861        String path = "entry:instrument:beam:monochromator:crystal:lattice_parameter"   
862        return(V_getRealValueFromHDF5(fname,path))
863end
864
865Function V_getCrystalReflection(fname)
866        String fname
867       
868        String path = "entry:instrument:beam:monochromator:crystal:reflection" 
869        return(V_getRealValueFromHDF5(fname,path))
870end
871
872Function V_getCrystalRotation(fname)
873        String fname
874       
875        String path = "entry:instrument:beam:monochromator:crystal:rotation"   
876        return(V_getRealValueFromHDF5(fname,path))
877end
878
879Function/S V_getCrystalStatus(fname)
880        String fname
881
882        String path = "entry:instrument:beam:monochromator:crystal:status"
883        Variable num=60
884        return(V_getStringFromHDF5(fname,path,num))
885End
886
887Function V_getCrystalVertical_aperture(fname)
888        String fname
889       
890        String path = "entry:instrument:beam:monochromator:crystal:vertical_aperture"   
891        return(V_getRealValueFromHDF5(fname,path))
892end
893
894Function V_getCrystalVertical_curvature(fname)
895        String fname
896       
897        String path = "entry:instrument:beam:monochromator:crystal:vertical_curvature" 
898        return(V_getRealValueFromHDF5(fname,path))
899end
900
901Function V_getCrystalWavelength(fname)
902        String fname
903       
904        String path = "entry:instrument:beam:monochromator:crystal:wavelength" 
905        return(V_getRealValueFromHDF5(fname,path))
906end
907
908Function V_getCrystalWavelength_spread(fname)
909        String fname
910       
911        String path = "entry:instrument:beam:monochromator:crystal:wavelength_spread"   
912        return(V_getRealValueFromHDF5(fname,path))
913end
914
915Function V_getCrystalWavevector(fname)
916        String fname
917       
918        String path = "entry:instrument:beam:monochromator:crystal:wavevector" 
919        return(V_getRealValueFromHDF5(fname,path))
920end
921
922// instrument/beam/monochromator/velocity_selector (data folder)
923Function V_getVSDistance(fname)
924        String fname
925       
926        String path = "entry:instrument:beam:monochromator:velocity_selector:distance" 
927        return(V_getRealValueFromHDF5(fname,path))
928end
929
930Function V_getVSRotation_speed(fname)
931        String fname
932       
933        String path = "entry:instrument:beam:monochromator:velocity_selector:rotation_speed"   
934        return(V_getRealValueFromHDF5(fname,path))
935end
936
937Function/S V_getVelSelStatus(fname)
938        String fname
939
940        String path = "entry:instrument:beam:monochromator:velocity_selector:status"
941        Variable num=60
942        return(V_getStringFromHDF5(fname,path,num))
943End
944
945Function/WAVE V_getVSTable_parameters(fname)
946        String fname
947       
948        String path = "entry:instrument:beam:monochromator:velocity_selector:table_parameters" 
949        WAVE w = V_getRealWaveFromHDF5(fname,path)
950
951        return w
952end
953
954//// DONE - this does not exist for VSANS - per JGB 4/2016
955//Function V_getVS_tilt(fname)
956//      String fname
957//     
958//      String path = "entry:instrument:beam:monochromator:velocity_selector:vs_tilt"   
959//      return(V_getRealValueFromHDF5(fname,path))
960//end
961
962Function V_getVSWavelength(fname)
963        String fname
964       
965        String path = "entry:instrument:beam:monochromator:velocity_selector:wavelength"       
966        return(V_getRealValueFromHDF5(fname,path))
967end
968
969Function V_getVSWavelength_spread(fname)
970        String fname
971       
972        String path = "entry:instrument:beam:monochromator:velocity_selector:wavelength_spread"
973        return(V_getRealValueFromHDF5(fname,path))
974end
975
976// instrument/beam/monochromator/white_beam (data folder)
977Function/S V_getWhiteBeamStatus(fname)
978        String fname
979
980        String path = "entry:instrument:beam:monochromator:white_beam:status"
981        Variable num=60
982        return(V_getStringFromHDF5(fname,path,num))
983End
984
985Function V_getWhiteBeamWavelength(fname)
986        String fname
987       
988        String path = "entry:instrument:beam:monochromator:white_beam:wavelength"       
989        return(V_getRealValueFromHDF5(fname,path))
990end
991
992Function V_getWhiteBeamWavelength_spread(fname)
993        String fname
994       
995        String path = "entry:instrument:beam:monochromator:white_beam:wavelength_spread"       
996        return(V_getRealValueFromHDF5(fname,path))
997end
998
999// instrument/beam/superMirror (data folder)
1000// This is the upstream polarizer. There are no other choices for polarizer on VSANS
1001Function/S V_getPolarizerComposition(fname)
1002        String fname
1003
1004        String path = "entry:instrument:beam:superMirror:composition"
1005        Variable num=60
1006        return(V_getStringFromHDF5(fname,path,num))
1007End
1008
1009Function V_getPolarizerEfficiency(fname)
1010        String fname
1011       
1012        String path = "entry:instrument:beam:superMirror:efficiency"   
1013        return(V_getRealValueFromHDF5(fname,path))
1014end
1015
1016Function/S V_getPolarizerState(fname)
1017        String fname
1018
1019        String path = "entry:instrument:beam:superMirror:state"
1020        Variable num=60
1021        return(V_getStringFromHDF5(fname,path,num))
1022End
1023
1024//Function/S V_getPolarizerType(fname)
1025//      String fname
1026//
1027//      String path = "entry:instrument:beam:polarizer:type"
1028//      Variable num=60
1029//      return(V_getStringFromHDF5(fname,path,num))
1030//End
1031
1032//// instrument/beam/polarizer_analyzer (data folder)
1033//Function V_getPolAnaCell_index(fname)
1034//      String fname
1035//
1036//      String path = "entry:instrument:beam:polarizer_analyzer:cell_index"
1037//      return(V_getRealValueFromHDF5(fname,path))
1038//End
1039//
1040//Function/S V_getPolAnaCell_name(fname)
1041//      String fname
1042//
1043//      String path = "entry:instrument:beam:polarizer_analyzer:cell_name"
1044//      Variable num=60
1045//      return(V_getStringFromHDF5(fname,path,num))
1046//End
1047//
1048//Function/WAVE V_getPolAnaCell_parameters(fname)
1049//      String fname
1050//
1051//      String path = "entry:instrument:beam:polarizer_analyzer:cell_parameters"
1052//      WAVE w = V_getRealWaveFromHDF5(fname,path)
1053//
1054//      return w
1055//End
1056//
1057//Function V_getPolAnaGuideFieldCur_1(fname)
1058//      String fname
1059//
1060//      String path = "entry:instrument:beam:polarizer_analyzer:guide_field_current_1"
1061//      return(V_getRealValueFromHDF5(fname,path))
1062//End
1063//
1064//Function V_getPolAnaGuideFieldCur_2(fname)
1065//      String fname
1066//
1067//      String path = "entry:instrument:beam:polarizer_analyzer:guide_field_current_2"
1068//      return(V_getRealValueFromHDF5(fname,path))
1069//End
1070//
1071//Function V_getPolAnaSolenoid_current(fname)
1072//      String fname
1073//
1074//      String path = "entry:instrument:beam:polarizer_analyzer:solenoid_current"
1075//      return(V_getRealValueFromHDF5(fname,path))
1076//End
1077//
1078//Function/S V_getPolAnaStatus(fname)
1079//      String fname
1080//
1081//      String path = "entry:instrument:beam:polarizer_analyzer:status"
1082//      Variable num=60
1083//      return(V_getStringFromHDF5(fname,path,num))
1084//End
1085
1086                                       
1087/////// INSTRUMENT/BEAM MONITORS
1088
1089//beam_monitor_low (data folder)
1090Function V_getBeamMonLowData(fname)
1091        String fname
1092
1093        String path = "entry:instrument:beam_monitor_low:data"
1094        return(V_getRealValueFromHDF5(fname,path))
1095End
1096
1097Function V_getBeamMonLowDistance(fname)
1098        String fname
1099
1100        String path = "entry:instrument:beam_monitor_low:distance"
1101        return(V_getRealValueFromHDF5(fname,path))
1102End
1103
1104Function V_getBeamMonLowEfficiency(fname)
1105        String fname
1106
1107        String path = "entry:instrument:beam_monitor_low:efficiency"
1108        return(V_getRealValueFromHDF5(fname,path))
1109End
1110
1111Function V_getBeamMonLowSaved_count(fname)
1112        String fname
1113
1114        String path = "entry:instrument:beam_monitor_low:saved_count"
1115        return(V_getRealValueFromHDF5(fname,path))
1116End
1117
1118Function/S V_getBeamMonLowType(fname)
1119        String fname
1120
1121        String path = "entry:instrument:beam_monitor_low:type"
1122        Variable num=60
1123        return(V_getStringFromHDF5(fname,path,num))
1124End
1125
1126//beam_monitor_norm (data folder)
1127Function V_getBeamMonNormData(fname)
1128        String fname
1129
1130        String path = "entry:instrument:beam_monitor_norm:data"
1131        return(V_getRealValueFromHDF5(fname,path))
1132End
1133
1134Function V_getBeamMonNormDistance(fname)
1135        String fname
1136
1137        String path = "entry:instrument:beam_monitor_norm:distance"
1138        return(V_getRealValueFromHDF5(fname,path))
1139End
1140
1141Function V_getBeamMonNormEfficiency(fname)
1142        String fname
1143
1144        String path = "entry:instrument:beam_monitor_norm:efficiency"
1145        return(V_getRealValueFromHDF5(fname,path))
1146End
1147
1148Function V_getBeamMonNormSaved_count(fname)
1149        String fname
1150
1151        String path = "entry:instrument:beam_monitor_norm:saved_count"
1152        return(V_getRealValueFromHDF5(fname,path))
1153End
1154
1155Function/S V_getBeamMonNormType(fname)
1156        String fname
1157
1158        String path = "entry:instrument:beam_monitor_norm:type"
1159        Variable num=60
1160        return(V_getStringFromHDF5(fname,path,num))
1161End
1162
1163//beam_stop C2 (data folder)
1164Function/S V_getBeamStopC2Description(fname)
1165        String fname
1166
1167        String path = "entry:instrument:beam_stop_C2:description"
1168        Variable num=60
1169        return(V_getStringFromHDF5(fname,path,num))
1170End
1171
1172Function V_getBeamStopC2Dist_to_det(fname)
1173        String fname
1174
1175        String path = "entry:instrument:beam_stop_C2:distance_to_detector"
1176        return(V_getRealValueFromHDF5(fname,path))
1177End
1178
1179//TODO -- not sure what this really means
1180Function V_getBeamStopC2num_beamstops(fname)
1181        String fname
1182
1183        String path = "entry:instrument:beam_stop_C2:num_beamstops"
1184        return(V_getRealValueFromHDF5(fname,path))
1185End
1186
1187Function V_getBeamStopC2_x_pos(fname)
1188        String fname
1189
1190        String path = "entry:instrument:beam_stop_C2:x_pos"
1191        return(V_getRealValueFromHDF5(fname,path))
1192End
1193
1194Function V_getBeamStopC2_y_pos(fname)
1195        String fname
1196
1197        String path = "entry:instrument:beam_stop_C2:y_pos"
1198        return(V_getRealValueFromHDF5(fname,path))
1199End
1200
1201// beam stop shape parameters
1202Function V_getBeamStopC2_height(fname)
1203        String fname
1204
1205        String path = "entry:instrument:beam_stop_C2:shape:height"
1206        return(V_getRealValueFromHDF5(fname,path))
1207End
1208
1209Function/S V_getBeamStopC2_shape(fname)
1210        String fname
1211
1212        Variable num=60
1213        String path = "entry:instrument:beam_stop_C2:shape:shape"
1214        return(V_getStringFromHDF5(fname,path,num))
1215End
1216
1217// == diameter if shape = CIRCLE
1218// value is expected in [mm] diameter
1219Function V_getBeamStopC2_size(fname)
1220        String fname
1221
1222        String path = "entry:instrument:beam_stop_C2:shape:size"
1223        return(V_getRealValueFromHDF5(fname,path))
1224End
1225
1226Function V_getBeamStopC2_width(fname)
1227        String fname
1228
1229        String path = "entry:instrument:beam_stop_C2:shape:width"
1230        return(V_getRealValueFromHDF5(fname,path))
1231End
1232
1233
1234
1235//beam_stop C3 (data folder)
1236Function/S V_getBeamStopC3Description(fname)
1237        String fname
1238
1239        String path = "entry:instrument:beam_stop_C3:description"
1240        Variable num=60
1241        return(V_getStringFromHDF5(fname,path,num))
1242End
1243
1244Function V_getBeamStopC3Dist_to_det(fname)
1245        String fname
1246
1247        String path = "entry:instrument:beam_stop_C3:distance_to_detector"
1248        return(V_getRealValueFromHDF5(fname,path))
1249End
1250
1251//TODO -- not sure what this really means
1252Function V_getBeamStopC3num_beamstops(fname)
1253        String fname
1254
1255        String path = "entry:instrument:beam_stop_C3:num_beamstops"
1256        return(V_getRealValueFromHDF5(fname,path))
1257End
1258
1259Function V_getBeamStopC3_x_pos(fname)
1260        String fname
1261
1262        String path = "entry:instrument:beam_stop_C3:x_pos"
1263        return(V_getRealValueFromHDF5(fname,path))
1264End
1265
1266Function V_getBeamStopC3_y_pos(fname)
1267        String fname
1268
1269        String path = "entry:instrument:beam_stop_C3:y_pos"
1270        return(V_getRealValueFromHDF5(fname,path))
1271End
1272
1273// beam stop shape parameters
1274Function V_getBeamStopC3_height(fname)
1275        String fname
1276
1277        String path = "entry:instrument:beam_stop_C3:shape:height"
1278        return(V_getRealValueFromHDF5(fname,path))
1279End
1280
1281Function/S V_getBeamStopC3_shape(fname)
1282        String fname
1283
1284        Variable num=60
1285        String path = "entry:instrument:beam_stop_C3:shape:shape"
1286        return(V_getStringFromHDF5(fname,path,num))
1287End
1288
1289// == diameter if shape = CIRCLE
1290Function V_getBeamStopC3_size(fname)
1291        String fname
1292
1293        String path = "entry:instrument:beam_stop_C3:shape:size"
1294        return(V_getRealValueFromHDF5(fname,path))
1295End
1296
1297Function V_getBeamStopC3_width(fname)
1298        String fname
1299
1300        String path = "entry:instrument:beam_stop_C3:shape:width"
1301        return(V_getRealValueFromHDF5(fname,path))
1302End
1303
1304
1305
1306
1307//// INSTRUMENT/COLLIMATOR
1308//collimator (data folder)
1309
1310// this is now defined as text, due to selections from GUI
1311Function/S V_getNumberOfGuides(fname)
1312        String fname
1313
1314        Variable num=60
1315        String path = "entry:instrument:collimator:number_guides"
1316        return(V_getStringFromHDF5(fname,path,num))
1317End
1318
1319//                              geometry (data folder)
1320//                                      shape (data folder)
1321Function/S V_getGuideShape(fname)
1322        String fname
1323
1324        String path = "entry:instrument:collimator:geometry:shape:shape"
1325        Variable num=60
1326        return(V_getStringFromHDF5(fname,path,num))
1327End
1328
1329Function V_getGuideSize(fname)
1330        String fname
1331
1332        String path = "entry:instrument:collimator:geometry:shape:size"
1333        return(V_getRealValueFromHDF5(fname,path))
1334End
1335
1336
1337//                      converging_pinholes (data folder)
1338Function/S V_getConvPinholeStatus(fname)
1339        String fname
1340
1341        String path = "entry:instrument:converging_pinholes:status"
1342        Variable num=60
1343        return(V_getStringFromHDF5(fname,path,num))
1344End
1345
1346//                      converging_slits (not used)
1347
1348////// INSTRUMENT/DETECTORS
1349//                      detector_B (data folder)
1350//
1351// only defined for the "B" detector, and may not be necessary?
1352// DONE -- write to return an ARRAY
1353Function/WAVE V_getDet_cal_x(fname,detStr)
1354        String fname,detStr
1355
1356        if(cmpstr(detStr,"B") == 0)
1357                String path = "entry:instrument:detector_"+detStr+":cal_x"
1358                WAVE w = V_getRealWaveFromHDF5(fname,path)
1359
1360                return w
1361        else
1362                return $""
1363        endif
1364End
1365
1366// only defined for the "B" detector, and may not be necessary?
1367// TODO -- write to return an ARRAY
1368Function/WAVE V_getDet_cal_y(fname,detStr)
1369        String fname,detStr
1370
1371        if(cmpstr(detStr,"B") == 0)
1372                String path = "entry:instrument:detector_"+detStr+":cal_y"
1373                WAVE w = V_getRealWaveFromHDF5(fname,path)
1374       
1375                return w
1376        else
1377                return $""
1378        endif
1379End
1380
1381//  Pixels are not square
1382// so the FHWM will be different in each direction. May need to return
1383// "dummy" value for "B" detector if pixels there are square
1384Function V_getDet_pixel_fwhm_x(fname,detStr)
1385        String fname,detStr
1386
1387        String path = "entry:instrument:detector_"+detStr+":pixel_fwhm_x"
1388
1389        return(V_getRealValueFromHDF5(fname,path))
1390End
1391
1392// Pixels are not square
1393// so the FHWM will be different in each direction. May need to return
1394// "dummy" value for "B" detector if pixels there are square
1395Function V_getDet_pixel_fwhm_y(fname,detStr)
1396        String fname,detStr
1397
1398        String path = "entry:instrument:detector_"+detStr+":pixel_fwhm_y"
1399
1400        return(V_getRealValueFromHDF5(fname,path))
1401End
1402
1403Function V_getDet_pixel_num_x(fname,detStr)
1404        String fname,detStr
1405
1406        String path = "entry:instrument:detector_"+detStr+":pixel_num_x"
1407        return(V_getRealValueFromHDF5(fname,path))
1408End
1409
1410Function V_getDet_pixel_num_y(fname,detStr)
1411        String fname,detStr
1412
1413        String path = "entry:instrument:detector_"+detStr+":pixel_num_y"
1414        return(V_getRealValueFromHDF5(fname,path))
1415End
1416
1417//// only defined for the "B" detector, and only to satisfy NXsas
1418//Function V_getDet_azimuthalAngle(fname,detStr)
1419//      String fname,detStr
1420//
1421//      if(cmpstr(detStr,"B") == 0)
1422//              String path = "entry:instrument:detector_"+detStr+":azimuthal_angle"
1423//              return(V_getRealValueFromHDF5(fname,path))
1424//      else
1425//              return(0)
1426//      endif
1427//End
1428
1429Function V_getDet_beam_center_x(fname,detStr)
1430        String fname,detStr
1431
1432        String path = "entry:instrument:detector_"+detStr+":beam_center_x"
1433        return(V_getRealValueFromHDF5(fname,path))
1434End
1435
1436Function V_getDet_beam_center_y(fname,detStr)
1437        String fname,detStr
1438
1439        String path = "entry:instrument:detector_"+detStr+":beam_center_y"
1440        return(V_getRealValueFromHDF5(fname,path))
1441End
1442
1443
1444//TODO
1445//
1446// x and y center in mm is currently not part of the Nexus definition
1447//  does it need to be?
1448// these lookups will fail if they have not been generated locally!
1449Function V_getDet_beam_center_x_mm(fname,detStr)
1450        String fname,detStr
1451
1452        String path = "entry:instrument:detector_"+detStr+":beam_center_x_mm"
1453        return(V_getRealValueFromHDF5(fname,path))
1454End
1455
1456//TODO
1457//
1458// x and y center in mm is currently not part of the Nexus definition
1459//  does it need to be?
1460// these lookups will fail if they have not been generated locally!
1461Function V_getDet_beam_center_y_mm(fname,detStr)
1462        String fname,detStr
1463
1464        String path = "entry:instrument:detector_"+detStr+":beam_center_y_mm"
1465        return(V_getRealValueFromHDF5(fname,path))
1466End
1467
1468//TODO
1469//
1470// x and y center in pix is currently not part of the Nexus definition
1471//  does it need to be?
1472// these lookups will fail if they have not been generated locally!
1473Function V_getDet_beam_center_x_pix(fname,detStr)
1474        String fname,detStr
1475
1476        String path = "entry:instrument:detector_"+detStr+":beam_center_x_pix"
1477        return(V_getRealValueFromHDF5(fname,path))
1478End
1479
1480//TODO
1481//
1482// x and y center in pix is currently not part of the Nexus definition
1483//  does it need to be?
1484// these lookups will fail if they have not been generated locally!
1485Function V_getDet_beam_center_y_pix(fname,detStr)
1486        String fname,detStr
1487
1488        String path = "entry:instrument:detector_"+detStr+":beam_center_y_pix"
1489        return(V_getRealValueFromHDF5(fname,path))
1490End
1491
1492Function/WAVE V_getDetectorDataW(fname,detStr)
1493        String fname,detStr
1494
1495        String path = "entry:instrument:detector_"+detStr+":data"
1496        WAVE w = V_getRealWaveFromHDF5(fname,path)
1497
1498        return w
1499End
1500
1501// NOTE - this is not part of the file as written
1502// it is generated when the RAW data is loaded (when the error wave is generated)
1503Function/WAVE V_getDetectorLinearDataW(fname,detStr)
1504        String fname,detStr
1505
1506        String path = "entry:instrument:detector_"+detStr+":linear_data"
1507        WAVE w = V_getRealWaveFromHDF5(fname,path)
1508
1509        return w
1510End
1511
1512//
1513// TODO -- this does not exist in the raw data, but does in the processed data
1514// !!! how to handle this?? Binning routines need the error wave
1515//
1516Function/WAVE V_getDetectorLinearDataErrW(fname,detStr)
1517        String fname,detStr
1518
1519        String path = "entry:instrument:detector_"+detStr+":linear_data_error"
1520        WAVE w = V_getRealWaveFromHDF5(fname,path)
1521
1522        return w
1523End
1524
1525
1526//
1527// TODO -- this does not exist in the raw data, but does in the processed data
1528// !!! how to handle this?? Binning routines need the error wave
1529//
1530Function/WAVE V_getDetectorDataErrW(fname,detStr)
1531        String fname,detStr
1532
1533        String path = "entry:instrument:detector_"+detStr+":data_error"
1534        WAVE w = V_getRealWaveFromHDF5(fname,path)
1535
1536        return w
1537End
1538
1539// TODO -- write this function to return a WAVE with the data
1540// either as a wave reference, or as an input parameter
1541// ALSO -- the "B" deadtime will be a single value (probably)
1542//  but the tube banks will be 1D arrays of values, one per tube
1543Function/WAVE V_getDetector_deadtime(fname,detStr)
1544        String fname,detStr
1545
1546        String path = "entry:instrument:detector_"+detStr+":dead_time"
1547        if(cmpstr(detStr,"B") == 0)
1548                return $""
1549        else   
1550                WAVE w = V_getRealWaveFromHDF5(fname,path)
1551                return w
1552        endif
1553End
1554
1555// for "B" only
1556Function V_getDetector_deadtime_B(fname,detStr)
1557        String fname,detStr
1558
1559        String path = "entry:instrument:detector_"+detStr+":dead_time"
1560        if(cmpstr(detStr,"B") == 0)
1561                return(V_getRealValueFromHDF5(fname,path))
1562        else   
1563                return(0)
1564        endif
1565End
1566
1567Function/S V_getDetDescription(fname,detStr)
1568        String fname,detStr
1569
1570        String path = "entry:instrument:detector_"+detStr+":description"
1571        Variable num=60
1572        return(V_getStringFromHDF5(fname,path,num))
1573End
1574
1575// return value in [cm]
1576Function V_getDet_NominalDistance(fname,detStr)
1577        String fname,detStr
1578
1579        String path = "entry:instrument:detector_"+detStr+":distance"
1580        return(V_getRealValueFromHDF5(fname,path))
1581End
1582
1583//this is a DERIVED distance, since the nominal sdd is for the carriage (=LR panels)
1584// return value in [cm]
1585Function V_getDet_ActualDistance(fname,detStr)
1586        String fname,detStr
1587
1588        Variable sdd
1589        sdd = V_getDet_NominalDistance(fname,detStr)            //[cm]
1590        sdd += V_getDet_TBSetback(fname,detStr)         // written [cm], returns 0 for L/R/B panels
1591               
1592        return(sdd)
1593End
1594
1595//// only defined for the "B" detector, and only to satisfy NXsas
1596//Function V_getDet_equatorial_angle(fname,detStr)
1597//      String fname,detStr
1598//
1599//      if(cmpstr(detStr,"B") == 0)
1600//              String path = "entry:instrument:detector_"+detStr+":equatorial_angle"
1601//              return(V_getRealValueFromHDF5(fname,path))
1602//      else
1603//              return(0)
1604//      endif
1605//End
1606
1607Function/S V_getDetEventFileName(fname,detStr)
1608        String fname,detStr
1609
1610        String path = "entry:instrument:detector_"+detStr+":event_file_name"
1611        Variable num=60
1612        return(V_getStringFromHDF5(fname,path,num))
1613End
1614
1615Function V_getDet_IntegratedCount(fname,detStr)
1616        String fname,detStr
1617
1618        String path = "entry:instrument:detector_"+detStr+":integrated_count"
1619        return(V_getRealValueFromHDF5(fname,path))
1620End
1621
1622// only return value for B and L/R detectors. everything else returns zero
1623Function V_getDet_LateralOffset(fname,detStr)
1624        String fname,detStr
1625
1626        if(cmpstr(detStr,"FT") == 0 || cmpstr(detStr,"FB") == 0)
1627                return(0)
1628        endif
1629        if(cmpstr(detStr,"MT") == 0 || cmpstr(detStr,"MB") == 0)
1630                return(0)
1631        endif   
1632       
1633        String path = "entry:instrument:detector_"+detStr+":lateral_offset"
1634        return(V_getRealValueFromHDF5(fname,path))
1635End
1636
1637// only return values for T/B. everything else returns zero
1638Function V_getDet_VerticalOffset(fname,detStr)
1639        String fname,detStr
1640
1641        if(cmpstr(detStr,"B") == 0)
1642                return(0)
1643        endif
1644        if(cmpstr(detStr,"FR") == 0 || cmpstr(detStr,"FL") == 0)
1645                return(0)
1646        endif
1647        if(cmpstr(detStr,"MR") == 0 || cmpstr(detStr,"ML") == 0)
1648                return(0)
1649        endif   
1650       
1651        String path = "entry:instrument:detector_"+detStr+":vertical_offset"
1652        return(V_getRealValueFromHDF5(fname,path))
1653End
1654
1655// TODO -DONE be sure this is defined correctly (with correct units-- this is now 41.0 cm)
1656// -- only returns for T/B detectors
1657Function V_getDet_TBSetback(fname,detStr)
1658        String fname,detStr
1659
1660        if(cmpstr(detStr,"B") == 0)
1661                return(0)
1662        endif
1663        if(cmpstr(detStr,"FR") == 0 || cmpstr(detStr,"FL") == 0)
1664                return(0)
1665        endif
1666        if(cmpstr(detStr,"MR") == 0 || cmpstr(detStr,"ML") == 0)
1667                return(0)
1668        endif   
1669       
1670        String path = "entry:instrument:detector_"+detStr+":setback"
1671        return(V_getRealValueFromHDF5(fname,path))
1672       
1673       
1674End
1675
1676// gap when panels are "touching"
1677// units are mm
1678// returns gap value for RIGHT and LEFT (they are the same)
1679// returns gap value for TOP and BOTTOM (they are the same)
1680// returns 0 for BACK, (no such field for this detector)
1681//
1682Function V_getDet_panel_gap(fname,detStr)
1683        String fname,detStr
1684
1685        if(cmpstr(detStr,"B") == 0)
1686                return(0)
1687        endif
1688//      if(cmpstr(detStr,"FB") == 0 || cmpstr(detStr,"FL") == 0)
1689//              return(0)
1690//      endif
1691//      if(cmpstr(detStr,"MB") == 0 || cmpstr(detStr,"ML") == 0)
1692//              return(0)
1693//      endif   
1694       
1695        String path = "entry:instrument:detector_"+detStr+":panel_gap"
1696        return(V_getRealValueFromHDF5(fname,path))
1697       
1698       
1699End
1700
1701Function/S V_getDetSettings(fname,detStr)
1702        String fname,detStr
1703
1704        String path = "entry:instrument:detector_"+detStr+":settings"
1705        Variable num=60
1706        return(V_getStringFromHDF5(fname,path,num))
1707End
1708
1709
1710Function V_getDet_x_pixel_size(fname,detStr)
1711        String fname,detStr
1712
1713        String path = "entry:instrument:detector_"+detStr+":x_pixel_size"
1714        return(V_getRealValueFromHDF5(fname,path))
1715End
1716
1717Function V_getDet_y_pixel_size(fname,detStr)
1718        String fname,detStr
1719
1720        String path = "entry:instrument:detector_"+detStr+":y_pixel_size"
1721        return(V_getRealValueFromHDF5(fname,path))
1722End
1723
1724/////////                       detector_FB (data folder) + ALL other PANEL DETECTORS
1725
1726Function V_getDet_numberOfTubes(fname,detStr)
1727        String fname,detStr
1728
1729        String path = "entry:instrument:detector_"+detStr+":number_of_tubes"
1730        if(cmpstr(detStr,"B") == 0)
1731                return(0)
1732        else
1733                return(V_getRealValueFromHDF5(fname,path))
1734        endif
1735End
1736
1737
1738// DONE -- write this function to return a WAVE with the data
1739// either as a wave reference, or as an input parameter
1740Function/WAVE V_getDetTube_spatialCalib(fname,detStr)
1741        String fname,detStr
1742
1743        String path = "entry:instrument:detector_"+detStr+":spatial_calibration"
1744        if(cmpstr(detStr,"B") == 0)
1745                return $("")    // return should be null
1746        else
1747                WAVE w = V_getRealWaveFromHDF5(fname,path)
1748                return w
1749        endif
1750End
1751
1752
1753Function/S V_getDet_tubeOrientation(fname,detStr)
1754        String fname,detStr
1755
1756        String path = "entry:instrument:detector_"+detStr+":tube_orientation"
1757        Variable num=60
1758        if(cmpstr(detStr,"B") == 0)
1759                return("")
1760        else
1761                return(V_getStringFromHDF5(fname,path,num))
1762        endif
1763End
1764
1765// TODO -- be clear on how this is defined. Units?
1766Function V_getDet_tubeWidth(fname,detStr)
1767        String fname,detStr
1768
1769        String path = "entry:instrument:detector_"+detStr+":tube_width"
1770        if(cmpstr(detStr,"B") == 0)
1771                return(0)
1772        else
1773                return(V_getRealValueFromHDF5(fname,path))
1774        endif
1775End
1776
1777//////////////////////
1778
1779// INSTRUMENT/LENSES
1780//  lenses (data folder)
1781
1782Function V_getLensCurvature(fname)
1783        String fname
1784
1785        String path = "entry:instrument:lenses:curvature"
1786        return(V_getRealValueFromHDF5(fname,path))
1787End
1788
1789Function/S V_getLensesFocusType(fname)
1790        String fname
1791
1792        String path = "entry:instrument:lenses:focus_type"
1793        Variable num=60
1794        return(V_getStringFromHDF5(fname,path,num))
1795End
1796
1797Function V_getLensDistance(fname)
1798        String fname
1799
1800        String path = "entry:instrument:lenses:lens_distance"
1801        return(V_getRealValueFromHDF5(fname,path))
1802End
1803
1804Function/S V_getLensGeometry(fname)
1805        String fname
1806
1807        String path = "entry:instrument:lenses:lens_geometry"
1808        Variable num=60
1809        return(V_getStringFromHDF5(fname,path,num))
1810End
1811
1812Function/S V_getLensMaterial(fname)
1813        String fname
1814
1815        String path = "entry:instrument:lenses:lens_material"
1816        Variable num=60
1817        return(V_getStringFromHDF5(fname,path,num))
1818End
1819
1820Function V_getNumber_of_Lenses(fname)
1821        String fname
1822
1823        String path = "entry:instrument:lenses:number_of_lenses"
1824        return(V_getRealValueFromHDF5(fname,path))
1825End
1826
1827Function V_getNumber_of_prisms(fname)
1828        String fname
1829
1830        String path = "entry:instrument:lenses:number_of_prisms"
1831        return(V_getRealValueFromHDF5(fname,path))
1832End
1833
1834Function V_getPrism_distance(fname)
1835        String fname
1836
1837        String path = "entry:instrument:lenses:prism_distance"
1838        return(V_getRealValueFromHDF5(fname,path))
1839End
1840
1841Function/S V_getPrismMaterial(fname)
1842        String fname
1843
1844        String path = "entry:instrument:lenses:prism_material"
1845        Variable num=60
1846        return(V_getStringFromHDF5(fname,path,num))
1847End
1848
1849// status of lens/prism = lens | prism | both | out
1850Function/S V_getLensPrismStatus(fname)
1851        String fname
1852
1853        String path = "entry:instrument:lenses:status"
1854        Variable num=60
1855        return(V_getStringFromHDF5(fname,path,num))
1856End
1857       
1858
1859
1860
1861///////  sample_aperture (1) (data folder)
1862// this is the INTERNAL sample aperture
1863//
1864Function/S V_getSampleAp_Description(fname)
1865        String fname
1866
1867        String path = "entry:instrument:sample_aperture:description"
1868        Variable num=60
1869        return(V_getStringFromHDF5(fname,path,num))
1870End
1871
1872Function V_getSampleAp_distance(fname)
1873        String fname
1874
1875        String path = "entry:instrument:sample_aperture:distance"
1876        return(V_getRealValueFromHDF5(fname,path))
1877End
1878
1879//      shape (data folder)
1880Function V_getSampleAp_height(fname)
1881        String fname
1882
1883        String path = "entry:instrument:sample_aperture:shape:height"
1884        return(V_getRealValueFromHDF5(fname,path))
1885End
1886
1887Function/S V_getSampleAp_shape(fname)
1888        String fname
1889
1890        String path = "entry:instrument:sample_aperture:shape:shape"
1891        Variable num=60
1892        return(V_getStringFromHDF5(fname,path,num))
1893End
1894
1895// this returns TEXT, due to GUI input, == to diameter if CIRCLE
1896Function/S V_getSampleAp_size(fname)
1897        String fname
1898
1899        String path = "entry:instrument:sample_aperture:shape:size"
1900        Variable num=60
1901        return(V_getStringFromHDF5(fname,path,num))
1902End
1903
1904Function V_getSampleAp_width(fname)
1905        String fname
1906
1907        String path = "entry:instrument:sample_aperture:shape:width"
1908        return(V_getRealValueFromHDF5(fname,path))
1909End
1910
1911
1912
1913///////  sample_aperture_2 (data folder)
1914// sample aperture (2) is the external aperture, which may or may not be present
1915
1916Function/S V_getSampleAp2_Description(fname)
1917        String fname
1918
1919        String path = "entry:instrument:sample_aperture_2:description"
1920        Variable num=60
1921        return(V_getStringFromHDF5(fname,path,num))
1922End
1923
1924Function V_getSampleAp2_distance(fname)
1925        String fname
1926
1927        String path = "entry:instrument:sample_aperture_2:distance"
1928        return(V_getRealValueFromHDF5(fname,path))
1929End
1930
1931//      shape (data folder)
1932// height and width are reported in [cm]
1933Function V_getSampleAp2_height(fname)
1934        String fname
1935
1936        String path = "entry:instrument:sample_aperture_2:shape:height"
1937        return(V_getRealValueFromHDF5(fname,path))
1938End
1939
1940Function/S V_getSampleAp2_shape(fname)
1941        String fname
1942
1943        String path = "entry:instrument:sample_aperture_2:shape:shape"
1944        Variable num=60
1945        return(V_getStringFromHDF5(fname,path,num))
1946End
1947
1948// this returns REAL, DIFFERENT than SampleAp1
1949Function V_getSampleAp2_size(fname)
1950        String fname
1951
1952        String path = "entry:instrument:sample_aperture_2:shape:size"
1953        return(V_getRealValueFromHDF5(fname,path))
1954End
1955
1956Function V_getSampleAp2_width(fname)
1957        String fname
1958
1959        String path = "entry:instrument:sample_aperture_2:shape:width"
1960        return(V_getRealValueFromHDF5(fname,path))
1961End
1962
1963       
1964//////  sample_table (data folder)
1965// location  = "CHAMBER" or HUBER
1966Function/S V_getSampleTableLocation(fname)
1967        String fname
1968
1969        String path = "entry:instrument:sample_table:location"
1970        Variable num=60
1971        return(V_getStringFromHDF5(fname,path,num))
1972End
1973
1974// TODO - verify the meaning
1975//      offset_distance (?? for center of sample table vs. sample position)
1976Function V_getSampleTableOffset(fname)
1977        String fname
1978
1979        String path = "entry:instrument:sample_table:offset_distance"
1980        return(V_getRealValueFromHDF5(fname,path))
1981End     
1982       
1983//  source (data folder)
1984//name "NCNR"
1985Function/S V_getSourceName(fname)
1986        String fname
1987
1988        String path = "entry:instrument:source:name"
1989        Variable num=60
1990        return(V_getStringFromHDF5(fname,path,num))
1991End
1992
1993//      power -- nominal only, not connected to any real number
1994Function V_getReactorPower(fname)
1995        String fname
1996
1997        String path = "entry:instrument:source:power"
1998        return(V_getRealValueFromHDF5(fname,path))
1999End     
2000
2001//probe (wave) "neutron"
2002Function/S V_getSourceProbe(fname)
2003        String fname
2004
2005        String path = "entry:instrument:source:probe"
2006        Variable num=60
2007        return(V_getStringFromHDF5(fname,path,num))
2008End
2009
2010//type (wave) "Reactor Neutron Source"
2011Function/S V_getSourceType(fname)
2012        String fname
2013
2014        String path = "entry:instrument:source:type"
2015        Variable num=60
2016        return(V_getStringFromHDF5(fname,path,num))
2017End
2018
2019       
2020///////  source_aperture (data folder)
2021
2022Function/S V_getSourceAp_Description(fname)
2023        String fname
2024
2025        String path = "entry:instrument:source_aperture:description"
2026        Variable num=60
2027        return(V_getStringFromHDF5(fname,path,num))
2028End
2029
2030Function V_getSourceAp_distance(fname)
2031        String fname
2032
2033        String path = "entry:instrument:source_aperture:distance"
2034        return(V_getRealValueFromHDF5(fname,path))
2035End
2036
2037//      shape (data folder)
2038Function V_getSourceAp_height(fname)
2039        String fname
2040
2041        String path = "entry:instrument:source_aperture:shape:height"
2042        return(V_getRealValueFromHDF5(fname,path))
2043End
2044
2045Function/S V_getSourceAp_shape(fname)
2046        String fname
2047
2048        String path = "entry:instrument:source_aperture:shape:shape"
2049        Variable num=60
2050        return(V_getStringFromHDF5(fname,path,num))
2051End
2052
2053// this returns TEXT, due to GUI input, == to diameter if CIRCLE
2054Function/S V_getSourceAp_size(fname)
2055        String fname
2056
2057        String path = "entry:instrument:source_aperture:shape:size"
2058        Variable num=60
2059        return(V_getStringFromHDF5(fname,path,num))
2060End
2061
2062Function V_getSourceAp_width(fname)
2063        String fname
2064
2065        String path = "entry:instrument:source_aperture:shape:width"
2066        return(V_getRealValueFromHDF5(fname,path))
2067End
2068
2069
2070//////// SAMPLE
2071//////// SAMPLE
2072//////// SAMPLE
2073
2074//Sample position in changer (returned as TEXT)
2075Function/S V_getSamplePosition(fname)
2076        String fname
2077       
2078        String path = "entry:sample:changer_position"   
2079        Variable num=60
2080        return(V_getStringFromHDF5(fname,path,num))
2081end
2082
2083// sample label
2084Function/S V_getSampleDescription(fname)
2085        String fname
2086
2087        String path = "entry:sample:description"
2088        Variable num=60
2089        return(V_getStringFromHDF5(fname,path,num))
2090End
2091
2092// for a z-stage??
2093Function V_getSampleElevation(fname)
2094        String fname
2095       
2096        String path = "entry:sample:elevation" 
2097        return(V_getRealValueFromHDF5(fname,path))
2098end
2099
2100//no meaning to this...
2101Function V_getSample_equatorial_ang(fname)
2102        String fname
2103       
2104        String path = "entry:sample:equatorial_angle"   
2105        return(V_getRealValueFromHDF5(fname,path))
2106end
2107
2108// group ID !!! very important for matching up files
2109Function V_getSample_GroupID(fname)
2110        String fname
2111       
2112        String path = "entry:sample:group_id"   
2113        return(V_getRealValueFromHDF5(fname,path))
2114end
2115
2116
2117//Sample Rotation Angle
2118Function V_getSampleRotationAngle(fname)
2119        String fname
2120       
2121        String path = "entry:sample:rotation_angle"     
2122        return(V_getRealValueFromHDF5(fname,path))
2123end
2124
2125//?? this is huber/chamber??
2126// TODO -- then where is the description of 10CB, etc...
2127Function/S V_getSampleHolderDescription(fname)
2128        String fname
2129
2130        String path = "entry:sample:sample_holder_description"
2131        Variable num=60
2132        return(V_getStringFromHDF5(fname,path,num))
2133End
2134
2135Function V_getSampleTemperature(fname)
2136        String fname
2137       
2138        String path = "entry:sample:temperature"       
2139        return(V_getRealValueFromHDF5(fname,path))
2140end
2141
2142Function V_getSampleTempSetPoint(fname)
2143        String fname
2144       
2145        String path = "entry:sample:temperature_setpoint"       
2146        return(V_getRealValueFromHDF5(fname,path))
2147end
2148
2149
2150//Sample Thickness
2151// TODO -- somehow, this is not set correctly in the acquisition, so NaN results
2152Function V_getSampleThickness(fname)
2153        String fname
2154       
2155        String path = "entry:sample:thickness" 
2156        return(V_getRealValueFromHDF5(fname,path))
2157end
2158
2159Function V_getSampleTranslation(fname)
2160        String fname
2161       
2162        String path = "entry:sample:translation"       
2163        return(V_getRealValueFromHDF5(fname,path))
2164end
2165
2166// sample transmission
2167Function V_getSampleTransmission(fname)
2168        String fname
2169       
2170        String path = "entry:sample:transmission"       
2171        return(V_getRealValueFromHDF5(fname,path))
2172end
2173
2174//transmission error (one sigma)
2175Function V_getSampleTransError(fname)
2176        String fname
2177       
2178        String path = "entry:sample:transmission_error"
2179        return(V_getRealValueFromHDF5(fname,path))
2180end
2181
2182
2183
2184//
2185// TODO -- this is all a big mess with the changes in the data file structure
2186//  in JUNE 2017, which completely wrecks what was decided in 2016.
2187// Now, I'm not sure at all what I'll get...or what the field will be called... or what they mean...
2188//
2189//
2190//// SAMPLE / DATA LOGS
2191// write this generic , call with the name of the environment log desired
2192//
2193//
2194// shear_field
2195// pressure
2196// magnetic_field
2197// electric_field
2198//
2199//////// (for example) electric_field (data folder)
2200
2201Function/S V_getLog_attachedTo(fname,logStr)
2202        String fname,logStr
2203
2204        String path = "entry:sample:"+logstr+":attached_to"
2205        Variable num=60
2206        return(V_getStringFromHDF5(fname,path,num))
2207End
2208
2209
2210Function/S V_getLog_measurement(fname,logStr)
2211        String fname,logStr
2212
2213        String path = "entry:sample:"+logstr+":measurement"
2214        Variable num=60
2215        return(V_getStringFromHDF5(fname,path,num))
2216End
2217
2218
2219Function/S V_getLog_Name(fname,logStr)
2220        String fname,logStr
2221
2222        String path = "entry:sample:"+logstr+":name"
2223        Variable num=60
2224        return(V_getStringFromHDF5(fname,path,num))
2225End
2226
2227
2228
2229// for temperature only, logStr = "temperature_env"
2230Function/S V_getTemp_ControlSensor(fname,logStr)
2231        String fname,logStr
2232
2233        String path = "entry:sample:"+logstr+":control_sensor"
2234        Variable num=60
2235        return(V_getStringFromHDF5(fname,path,num))
2236End
2237
2238// for temperature only, logStr = "temperature_env"
2239Function/S V_getTemp_MonitorSensor(fname,logStr)
2240        String fname,logStr
2241
2242        String path = "entry:sample:"+logstr+":monitor_sensor"
2243        Variable num=60
2244        return(V_getStringFromHDF5(fname,path,num))
2245End
2246
2247       
2248
2249//// TODO -- this may not exist if it is not a "controlling" sensor, but there still may be logged data present
2250//// TODO -- it may also have different names for each sensor (setpoint_1, setpoint_2, etc. which will be a big hassle)
2251//Function V_getLog_setPoint(fname,logStr)
2252//      String fname,logStr
2253//     
2254//      String path = "entry:sample:"+logstr+":setpoint_1"
2255//      return(V_getRealValueFromHDF5(fname,path))
2256//end
2257//
2258//Function/S V_getLog_startTime(fname,logStr)
2259//      String fname,logStr
2260//
2261//      String path = "entry:sample:"+logstr+":start"
2262//      Variable num=60
2263//      return(V_getStringFromHDF5(fname,path,num))
2264//End
2265//
2266//
2267//// TODO -- this may only exist for electric field and magnetic field...
2268//// or may be eliminated altogether
2269//Function V_getLog_nomValue(fname,logStr)
2270//      String fname,logStr
2271//     
2272//      String path = "entry:sample:"+logstr+":value"
2273//      return(V_getRealValueFromHDF5(fname,path))
2274//end
2275
2276
2277
2278///////////
2279// for temperature, the "attached_to", "measurement", and "name" fields
2280// are one level down farther than before, and down deeper than for other sensors
2281//
2282//
2283// read the value of V_getTemp_MonitorSensor/ControlSensor to get the name of the sensor level .
2284//
2285
2286Function/S V_getTempLog_attachedTo(fname,logStr)
2287        String fname,logStr
2288
2289        String path = "entry:sample:temperature_env:"+logstr+":attached_to"
2290        Variable num=60
2291        return(V_getStringFromHDF5(fname,path,num))
2292End
2293
2294Function V_getTempLog_highTrip(fname,logStr)
2295        String fname,logStr
2296       
2297        String path = "entry:sample:temperature_env:"+logstr+":high_trip_value"
2298        return(V_getRealValueFromHDF5(fname,path))
2299end
2300
2301Function V_getTempLog_holdTime(fname,logStr)
2302        String fname,logStr
2303       
2304        String path = "entry:sample:temperature_env:"+logstr+":hold_time"
2305        return(V_getRealValueFromHDF5(fname,path))
2306end
2307
2308Function V_getTempLog_lowTrip(fname,logStr)
2309        String fname,logStr
2310       
2311        String path = "entry:sample:temperature_env:"+logstr+":low_trip_value"
2312        return(V_getRealValueFromHDF5(fname,path))
2313end
2314
2315Function/S V_getTempLog_measurement(fname,logStr)
2316        String fname,logStr
2317
2318        String path = "entry:sample:temperature_env:"+logstr+":measurement"
2319        Variable num=60
2320        return(V_getStringFromHDF5(fname,path,num))
2321End
2322
2323
2324Function/S V_getTempLog_Model(fname,logStr)
2325        String fname,logStr
2326
2327        String path = "entry:sample:temperature_env:"+logstr+":model"
2328        Variable num=60
2329        return(V_getStringFromHDF5(fname,path,num))
2330End
2331
2332Function/S V_getTempLog_Name(fname,logStr)
2333        String fname,logStr
2334
2335        String path = "entry:sample:temperature_env:"+logstr+":name"
2336        Variable num=60
2337        return(V_getStringFromHDF5(fname,path,num))
2338End
2339
2340Function V_getTempLog_runControl(fname,logStr)
2341        String fname,logStr
2342       
2343        String path = "entry:sample:temperature_env:"+logstr+":run_control"
2344        return(V_getRealValueFromHDF5(fname,path))
2345end
2346
2347Function V_getTempLog_Setpoint(fname,logStr)
2348        String fname,logStr
2349       
2350        String path = "entry:sample:temperature_env:"+logstr+":setpoint"
2351        return(V_getRealValueFromHDF5(fname,path))
2352end
2353
2354Function/S V_getTempLog_ShortName(fname,logStr)
2355        String fname,logStr
2356
2357        String path = "entry:sample:temperature_env:"+logstr+":short_name"
2358        Variable num=60
2359        return(V_getStringFromHDF5(fname,path,num))
2360End
2361
2362Function V_getTempLog_Timeout(fname,logStr)
2363        String fname,logStr
2364       
2365        String path = "entry:sample:temperature_env:"+logstr+":timeout"
2366        return(V_getRealValueFromHDF5(fname,path))
2367end
2368
2369Function V_getTempLog_Tolerance(fname,logStr)
2370        String fname,logStr
2371       
2372        String path = "entry:sample:temperature_env:"+logstr+":tolerance"
2373        return(V_getRealValueFromHDF5(fname,path))
2374end
2375
2376Function V_getTempLog_ToleranceBand(fname,logStr)
2377        String fname,logStr
2378       
2379        String path = "entry:sample:temperature_env:"+logstr+":tolerance_band_time"
2380        return(V_getRealValueFromHDF5(fname,path))
2381end
2382
2383Function V_getTempLog_Value(fname,logStr)
2384        String fname,logStr
2385       
2386        String path = "entry:sample:temperature_env:"+logstr+":value"
2387        return(V_getRealValueFromHDF5(fname,path))
2388end
2389
2390
2391
2392
2393
2394
2395//
2396// temperature_env:temp_Internal_1:value_log
2397//
2398////            value_log (data folder)
2399//
2400// TODO:
2401// -- be sure that the calling function properly calls for temperture
2402// logs which are down an extra layer:
2403//      for example, logStr = "temperature_env:temp_Internal_1"
2404//
2405// read the value of V_getTemp_MonitorSensor to get the name of the sensor the next level down.
2406//
2407Function V_getLog_avgValue(fname,logStr)
2408        String fname,logStr
2409       
2410        String path = "entry:sample:"+logstr+":value_log:average_value"
2411        return(V_getRealValueFromHDF5(fname,path))
2412end
2413
2414Function V_getLog_avgValue_err(fname,logStr)
2415        String fname,logStr
2416       
2417        String path = "entry:sample:"+logstr+":value_log:average_value_error"
2418        return(V_getRealValueFromHDF5(fname,path))
2419end
2420
2421Function V_getLog_maximumValue(fname,logStr)
2422        String fname,logStr
2423       
2424        String path = "entry:sample:"+logstr+":value_log:maximum_value"
2425        return(V_getRealValueFromHDF5(fname,path))
2426end
2427
2428Function V_getLog_medianValue(fname,logStr)
2429        String fname,logStr
2430       
2431        String path = "entry:sample:"+logstr+":value_log:median_value"
2432        return(V_getRealValueFromHDF5(fname,path))
2433end
2434
2435Function V_getLog_minimumValue(fname,logStr)
2436        String fname,logStr
2437       
2438        String path = "entry:sample:"+logstr+":value_log:minimum_value"
2439        return(V_getRealValueFromHDF5(fname,path))
2440end
2441
2442// DONE -- this needs to be a WAVE reference
2443// DONE -- verify that the field is really read in as "time0"
2444Function V_getLog_timeWave(fname,logStr,outW)
2445        String fname,logStr
2446        Wave outW
2447       
2448        String path = "entry:sample:"+logstr+":value_log:time0"
2449        WAVE w = V_getRealWaveFromHDF5(fname,path)
2450
2451        outW = w
2452        return(0)
2453end
2454
2455// DONE -- this needs to be a WAVE reference
2456Function V_getLog_ValueWave(fname,logStr,outW)
2457        String fname,logStr
2458        Wave outW
2459       
2460        String path = "entry:sample:"+logstr+":value_log:value"
2461        WAVE w = V_getRealWaveFromHDF5(fname,path)
2462
2463        outW = w
2464        return(0)
2465end
2466
2467
2468
2469
2470
2471
2472
2473///////// REDUCTION
2474///////// REDUCTION
2475///////// REDUCTION
2476
2477
2478Function/WAVE V_getAbsolute_Scaling(fname)
2479        String fname
2480       
2481        String path = "entry:reduction:absolute_scaling"       
2482        WAVE w = V_getRealWaveFromHDF5(fname,path)
2483       
2484        return w
2485end
2486
2487Function/S V_getBackgroundFileName(fname)
2488        String fname
2489
2490        String path = "entry:reduction:background_file_name"   
2491        Variable num=60
2492        return(V_getStringFromHDF5(fname,path,num))
2493End
2494
2495// THIS IS A NON-NICE ENTERED FIELD
2496// -- this is the panel string where the box coordinates refer to (for the open beam and transmission)
2497Function/S V_getReduction_BoxPanel(fname)
2498        String fname
2499
2500        String path = "entry:reduction:box_panel"       
2501        Variable num=60
2502        return(V_getStringFromHDF5(fname,path,num))
2503End
2504
2505Function/WAVE V_getBoxCoordinates(fname)
2506        String fname
2507       
2508        String path = "entry:reduction:box_coordinates"
2509        WAVE w = V_getRealWaveFromHDF5(fname,path)
2510
2511        return w
2512end
2513
2514//box counts
2515Function V_getBoxCounts(fname)
2516        String fname
2517       
2518        String path = "entry:reduction:box_count"       
2519        return(V_getRealValueFromHDF5(fname,path))
2520end
2521
2522//box counts error
2523Function V_getBoxCountsError(fname)
2524        String fname
2525       
2526        String path = "entry:reduction:box_count_error"
2527        return(V_getRealValueFromHDF5(fname,path))
2528end
2529
2530Function/S V_getReductionComments(fname)
2531        String fname
2532
2533        String path = "entry:reduction:comments"       
2534        Variable num=60
2535        return(V_getStringFromHDF5(fname,path,num))
2536End
2537
2538
2539Function/S V_getEmptyBeamFileName(fname)
2540        String fname
2541
2542        String path = "entry:reduction:empty_beam_file_name"   
2543        Variable num=60
2544        return(V_getStringFromHDF5(fname,path,num))
2545End
2546
2547Function/S V_getEmptyFileName(fname)
2548        String fname
2549
2550        String path = "entry:reduction:empty_file_name"
2551        Variable num=60
2552        return(V_getStringFromHDF5(fname,path,num))
2553End
2554
2555// this is purpose is used for all files, and has different meaning
2556// if polarization is used. need the "intent" also to be able to fully decipher what a file
2557//  is really being used for. GUI controls this, not me.
2558Function/S V_getReduction_purpose(fname)
2559        String fname
2560
2561        String path = "entry:reduction:file_purpose"   
2562        Variable num=60
2563        return(V_getStringFromHDF5(fname,path,num))
2564End
2565
2566////group ID
2567//// DONE
2568//// x- is this duplicated?
2569//// x- yes, this is a duplicated field in the /entry/sample block (and is probably more appropriate there)
2570//// x- so pick a single location, rather than needing to duplicate.
2571//// x- REPLACE with a single function V_getSample_GroupID()
2572////
2573//Function V_getSample_group_ID(fname)
2574//      String fname
2575//
2576//// do not use the entry/reduction location
2577////    String path = "entry:reduction:group_id"
2578//      String path = "entry:sample:group_id"   
2579//
2580//      return(V_getRealValueFromHDF5(fname,path))
2581//end
2582
2583Function/S V_getReduction_intent(fname)
2584        String fname
2585
2586        String path = "entry:reduction:intent" 
2587        Variable num=60
2588        return(V_getStringFromHDF5(fname,path,num))
2589End
2590
2591Function/S V_getMaskFileName(fname)
2592        String fname
2593
2594        String path = "entry:reduction:mask_file_name" 
2595        Variable num=60
2596        return(V_getStringFromHDF5(fname,path,num))
2597End
2598
2599Function/S V_getLogFileName(fname)
2600        String fname
2601
2602        String path = "entry:reduction:sans_log_file_name"     
2603        Variable num=60
2604        return(V_getStringFromHDF5(fname,path,num))
2605End
2606
2607Function/S V_getSensitivityFileName(fname)
2608        String fname
2609
2610        String path = "entry:reduction:sensitivity_file_name"   
2611        Variable num=60
2612        return(V_getStringFromHDF5(fname,path,num))
2613End
2614
2615Function/S V_getTransmissionFileName(fname)
2616        String fname
2617
2618        String path = "entry:reduction:transmission_file_name" 
2619        Variable num=60
2620        return(V_getStringFromHDF5(fname,path,num))
2621End
2622
2623//whole detector trasmission
2624Function V_getSampleTransWholeDetector(fname)
2625        String fname
2626       
2627        String path = "entry:reduction:whole_trans"     
2628        return(V_getRealValueFromHDF5(fname,path))
2629end
2630
2631//whole detector trasmission error
2632Function V_getSampleTransWholeDetErr(fname)
2633        String fname
2634       
2635        String path = "entry:reduction:whole_trans_error"       
2636        return(V_getRealValueFromHDF5(fname,path))
2637end
2638
2639// this is a NON NICE entered field
2640// so I need to catch the error if it's not there
2641Function/WAVE V_getReductionProtocolWave(fname)
2642        String fname
2643       
2644        String path = "entry:reduction:protocol"       
2645        WAVE/T/Z tw = V_getTextWaveFromHDF5(fname,path)
2646       
2647        if(waveExists(tw))
2648                return tw
2649        else
2650                Make/O/T/N=0 nullTextWave
2651                return nullTextWave
2652        endif
2653       
2654end
2655
2656// this is a NON NICE entered field
2657// so if it's not there, it returns -999999
2658//
2659// this is a flag to mark the file as "flipped" so it prevents a 2nd flip
2660// if the flip has been done, the field is written with a value of 1 (= true)
2661//
2662Function V_getLeftRightFlipDone(fname)
2663        String fname
2664       
2665        String path = "entry:reduction:left_right_flip"
2666        return(V_getRealValueFromHDF5(fname,path))
2667end     
2668
2669
2670
2671// these have all been moved elsewhere                 
2672///////                 pol_sans (data folder)
2673//
2674//Function/S V_getPolSANS_cellName(fname)
2675//      String fname
2676//
2677//      String path = "entry:reduction:pol_sans:cell_name"     
2678//      Variable num=60
2679//      return(V_getStringFromHDF5(fname,path,num))
2680//End
2681//
2682//
2683//Function/WAVE V_getPolSANS_cellParams(fname)
2684//      String fname
2685//     
2686//      String path = "entry:reduction:pol_sans:cell_parameters"       
2687//      WAVE w = V_getRealWaveFromHDF5(fname,path)
2688//
2689//      return w
2690//end
2691//
2692//Function/S V_getPolSANS_PolSANSPurpose(fname)
2693//      String fname
2694//
2695//      String path = "entry:reduction:pol_sans:pol_sans_purpose"       
2696//      Variable num=60
2697//      return(V_getStringFromHDF5(fname,path,num))
2698//End
2699
2700                               
2701//////// TOP LEVEL DATA REPRESENTATION
2702//
2703// note that here the data is (supposed to be) a link, not the actual data
2704// Igor HDf implementation cannot follow links properly, as far as I know.
2705// so ignore them here, and focus on the image that may be possible to read
2706//
2707
2708//              data_B (data folder)
2709//                      data (wave) 1           //ignore this, it's a link
2710//                      variables (wave) 320
2711//                      thumbnail (data folder)
2712
2713////data (wave) "binary"
2714//// TODO -- this will need to be completely replaced with a function that can
2715//// read the binary image data. should be possible, but I don't know the details on either end...
2716//Function/S V_getDataImage(fname,detStr)
2717//      String fname,detStr
2718//
2719//      String path = "entry:data_"+detStr+":thumbnail:data"   
2720//      Variable num=60
2721//      return(V_getStringFromHDF5(fname,path,num))
2722//End
2723//
2724//Function/S V_getDataImageDescription(fname,detStr)
2725//      String fname,detStr
2726//
2727//      String path = "entry:data_"+detStr+":thumbnail:description"     
2728//      Variable num=60
2729//      return(V_getStringFromHDF5(fname,path,num))
2730//End
2731//                                                             
2732//Function/S V_getDataImageType(fname,detStr)
2733//      String fname,detStr
2734//
2735//      String path = "entry:data_"+detStr+":thumbnail:type"   
2736//      Variable num=60
2737//      return(V_getStringFromHDF5(fname,path,num))
2738//End
2739//
2740//
2741
2742
Note: See TracBrowser for help on using the repository browser.