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

Last change on this file since 1246 was 1242, checked in by srkline, 3 years ago

updating the IgorVersion? pragma to v7.0 for all files to be consistent.

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