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

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

Corrected attenuator table for VSANS to include the range 4.52->19. Patching of the attenuation factor is disabled since the factor is always calculated rather than read from the file.

Added a few help links in preparation for the full help file integration

Added a "super" white beam distribution definition and a single model function for testing of this new mode. Still need the normalization and mean wavelength for the distribution + a way to identify it in the file metadata.

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