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

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

First pass at all of the get() and write() accessors for the Nexus VSANS file. The definition is still incomplete and untested, so these procedures will require complete verification, and some editing.

get and write are separated into their own files, so be sure to make the change in the pair if needed

File size: 47.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
24Function proto_V_get_FP2(str,str2)
25        String str,str2
26        return(0)
27end
28//Function/S proto_V_get_STR(str)
29//      String str
30//      return("")
31//end
32
33Function Test_V_get_FP(str,fname)
34        String str,fname
35       
36        Variable ii,num
37        String list,item
38       
39       
40        list=FunctionList(str,";","NPARAMS:1,VALTYPE:1") //,VALTYPE:1 gives real return values, not strings
41//      Print list
42        num = ItemsInlist(list)
43       
44       
45        for(ii=0;ii<num;ii+=1)
46                item = StringFromList(ii, list , ";")
47                FUNCREF proto_V_get_FP f = $item
48                Print item ," = ", f(fname)
49        endfor
50       
51        return(0)
52end
53
54Function Test_V_get_FP2(str,fname,detStr)
55        String str,fname,detStr
56       
57        Variable ii,num
58        String list,item
59       
60       
61        list=FunctionList(str,";","NPARAMS:2,VALTYPE:1") //,VALTYPE:1 gives real return values, not strings
62//      Print list
63        num = ItemsInlist(list)
64       
65       
66        for(ii=0;ii<num;ii+=1)
67                item = StringFromList(ii, list , ";")
68                FUNCREF proto_V_get_FP2 f = $item
69                Print item ," = ", f(fname,detStr)
70        endfor
71       
72        return(0)
73end
74
75Function Test_V_get_STR(str,fname)
76        String str,fname
77       
78        Variable ii,num
79        String list,item,strToEx
80       
81       
82        list=FunctionList(str,";","NPARAMS:1,VALTYPE:4")
83//      Print list
84        num = ItemsInlist(list)
85       
86       
87        for(ii=0;ii<num;ii+=1)
88                item = StringFromList(ii, list , ";")
89        //      FUNCREF proto_V_get_STR f = $item
90                printf "%s = ",item
91                sprintf strToEx,"Print %s(\"%s\")",item,fname
92                Execute strToEx
93//              print strToEx
94//              Print item ," = ", f(fname)
95        endfor
96       
97        return(0)
98end
99
100Function Test_V_get_STR2(str,fname,detStr)
101        String str,fname,detStr
102       
103        Variable ii,num
104        String list,item,strToEx
105       
106       
107        list=FunctionList(str,";","NPARAMS:2,VALTYPE:4")
108//      Print list
109        num = ItemsInlist(list)
110       
111       
112        for(ii=0;ii<num;ii+=1)
113                item = StringFromList(ii, list , ";")
114        //      FUNCREF proto_V_get_STR f = $item
115                printf "%s = ",item
116                sprintf strToEx,"Print %s(\"%s\",\"%s\")",item,fname,detStr
117                Execute strToEx
118//              print strToEx
119//              Print item ," = ", f(fname)
120        endfor
121       
122        return(0)
123end
124///////////////////////////////////////
125
126
127//////////////////////////////////////////////
128
129
130///////////////////////
131//
132// *These are the specific bits of information to retrieve (or write) to the data file
133// *These functions use the path to the file as input, and each has the specific
134//   path to the variable srting, or wave hard-coded into the access function
135// *They call the generic worker functions to get the values, either from the local copy if present,
136//   or the full file is loaded.
137//
138// *Since the path is the important bit, these are written as get/write pairs to make it easier to
139//   keep up with any changes in path
140//
141//
142// TODO -- verify the paths, and add more as needed
143// TODO -- for all of the String functions -- "num" does nothing right now -
144//         -- if it ever does, or needs to, a lot of locations will need to be corrected
145//
146
147
148//////// TOP LEVEL
149//////// TOP LEVEL
150//////// TOP LEVEL
151
152// nexus version used for definitions
153Function/S V_getNeXus_version(fname)
154        String fname
155       
156        String path = "entry:NeXus_version"     
157        Variable num=60
158        return(V_getStringFromHDF5(fname,path,num))
159End
160
161// TODO -- not mine, added somewhere by Nexus writer?
162// data collection time (! this is the true counting time??)
163Function V_getCollectionTime(fname)
164        String fname
165       
166        String path = "entry:collection_time"   
167        return(V_getRealValueFromHDF5(fname,path))
168End
169
170// data directory where data files are stored (for user access, not archive)
171Function/S V_getData_directory(fname)
172        String fname
173       
174        String path = "entry:data_directory"   
175        Variable num=60
176        return(V_getStringFromHDF5(fname,path,num))
177End
178
179// Base class of Nexus definition (=NXsas)
180Function/S V_getNexusDefinition(fname)
181        String fname
182       
183        String path = "entry:definition"       
184        Variable num=60
185        return(V_getStringFromHDF5(fname,path,num))
186End
187
188// TODO -- not mine, added somewhere by Nexus writer?
189// data collection duration (may include pauses, other "dead" time)
190Function V_getDataDuration(fname)
191        String fname
192       
193        String path = "entry:duration" 
194        return(V_getRealValueFromHDF5(fname,path))
195End
196
197// TODO -- not mine, added somewhere by Nexus writer?
198// data collection end time
199Function/S V_getDataEndTime(fname)
200        String fname
201       
202        String path = "entry:end_time" 
203        Variable num=60
204        return(V_getStringFromHDF5(fname,path,num))
205End
206
207// experiment description
208Function/S V_getExperiment_description(fname)
209        String fname
210       
211        String path = "entry:experiment_description"   
212        Variable num=60
213        return(V_getStringFromHDF5(fname,path,num))
214End
215
216// experiment identifier? used only by NICE?
217Function/S V_getExperiment_identifier(fname)
218        String fname
219       
220        String path = "entry:experiment_identifier"     
221        Variable num=60
222        return(V_getStringFromHDF5(fname,path,num))
223End
224
225// name of facility = NCNR
226Function/S V_getFacility(fname)
227        String fname
228       
229        String path = "entry:facility" 
230        Variable num=60
231        return(V_getStringFromHDF5(fname,path,num))
232End
233               
234// file write time (what is this??
235// TODO - figure out if this is supposed to be an integer or text (ISO)
236Function V_getFileWriteTime(fname)
237        String fname
238       
239        String path = "entry:file_time"
240        return(V_getRealValueFromHDF5(fname,path))
241End
242               
243//
244Function/S V_getHDF_version(fname)
245        String fname
246       
247        String path = "entry:hdf_version"       
248        Variable num=60
249        return(V_getStringFromHDF5(fname,path,num))
250End
251
252// TODO -- not mine, added somewhere by Nexus writer?
253Function/S V_getProgram_name(fname)
254        String fname
255       
256        String path = "entry:program_name"     
257        Variable num=60
258        return(V_getStringFromHDF5(fname,path,num))
259End
260
261// TODO -- not mine, added somewhere by Nexus writer?
262// data collection start time
263Function/S V_getDataStartTime(fname)
264        String fname
265       
266        String path = "entry:start_time"       
267        Variable num=60
268        return(V_getStringFromHDF5(fname,path,num))
269End
270               
271// title of experiment
272Function/S V_getTitle(fname)
273        String fname
274       
275        String path = "entry:title"     
276        Variable num=60
277        return(V_getStringFromHDF5(fname,path,num))
278end
279       
280       
281               
282////////// USER
283////////// USER
284////////// USER
285
286// list of user names
287// TODO -- currently not written out to data file??
288Function/S V_getUserNames(fname)
289        String fname
290       
291        String path = "entry:user:name"
292        Variable num=60
293        return(V_getStringFromHDF5(fname,path,num))
294end
295
296
297//////// CONTROL
298//////// CONTROL
299//////// CONTROL
300
301// TODO -- for the control section, document each of the fields
302
303Function V_getCount_end(fname)
304        String fname
305       
306        String path = "entry:control:count_end"
307        return(V_getRealValueFromHDF5(fname,path))
308end
309
310
311Function V_getCount_start(fname)
312        String fname
313       
314        String path = "entry:control:count_start"       
315        return(V_getRealValueFromHDF5(fname,path))
316end
317
318
319Function V_getCount_time(fname)
320        String fname
321       
322        String path = "entry:control:count_time"       
323        return(V_getRealValueFromHDF5(fname,path))
324end
325
326
327Function V_getCount_time_preset(fname)
328        String fname
329       
330        String path = "entry:control:count_time_preset"
331        return(V_getRealValueFromHDF5(fname,path))
332end
333
334
335Function V_getDetector_counts(fname)
336        String fname
337       
338        String path = "entry:control:detector_counts"   
339        return(V_getRealValueFromHDF5(fname,path))
340end
341
342
343Function V_getDetector_preset(fname)
344        String fname
345       
346        String path = "entry:control:detector_preset"   
347        return(V_getRealValueFromHDF5(fname,path))
348end
349
350
351Function V_getIntegral(fname)
352        String fname
353       
354        String path = "entry:control:integral" 
355        return(V_getRealValueFromHDF5(fname,path))
356end
357
358// control mode for data acquisition, "timer"
359Function/S V_getControlMode(fname)
360        String fname
361       
362        String path = "entry:control:mode"     
363        Variable num=60
364        return(V_getStringFromHDF5(fname,path,num))
365End
366
367//monitor count
368Function V_getMonitorCount(fname)
369        String fname
370       
371        String path = "entry:control:monitor_counts"   
372        return(V_getRealValueFromHDF5(fname,path))
373end
374
375Function V_getMonitor_preset(fname)
376        String fname
377       
378        String path = "entry:control:monitor_preset"   
379        return(V_getRealValueFromHDF5(fname,path))
380end
381
382Function V_getPreset(fname)
383        String fname
384       
385        String path = "entry:control:preset"   
386        return(V_getRealValueFromHDF5(fname,path))
387end
388
389
390
391
392
393//////// INSTRUMENT
394//////// INSTRUMENT
395//////// INSTRUMENT
396
397Function/S V_getLocalContact(fname)
398        String fname
399
400        String path = "entry:instrument:local_contact"
401        Variable num=60
402        return(V_getStringFromHDF5(fname,path,num))
403End
404
405Function/S V_getInstrumentName(fname)
406        String fname
407
408        String path = "entry:instrument:name"
409        Variable num=60
410        return(V_getStringFromHDF5(fname,path,num))
411End
412
413Function/S V_getInstrumentType(fname)
414        String fname
415
416        String path = "entry:instrument:type"
417        Variable num=60
418        return(V_getStringFromHDF5(fname,path,num))
419End
420
421////// INSTRUMENT/ATTENUATOR
422// TODO
423// attenuator number -- for VSANS I think I want this to be some "binary" representation
424// of 4 plates in/out - so this may be an integer-> binary, or a text string (4 char)
425Function V_getAtten_number(fname)
426        String fname
427       
428        String path = "entry:instrument:attenuator:atten_number"       
429        return(V_getRealValueFromHDF5(fname,path))
430end
431
432
433// transmission value for the attenuator in the beam
434// use this, but if something wrong, the tables are present
435Function V_getAttenuator_transmission(fname)
436        String fname
437       
438        String path = "entry:instrument:attenuator:attenuator_transmission"     
439        return(V_getRealValueFromHDF5(fname,path))
440end
441
442
443// distance from the attenuator to the sample (units??)
444Function V_getAttenDistance(fname)
445        String fname
446       
447        String path = "entry:instrument:attenuator:distance"   
448        return(V_getRealValueFromHDF5(fname,path))
449end
450
451
452// attenuator index, to use in the lookup table of transmission values
453Function V_getAttenIndex(fname)
454        String fname
455       
456        String path = "entry:instrument:attenuator:index"       
457        return(V_getRealValueFromHDF5(fname,path))
458end
459
460
461// table of the attenuation factor
462Function V_getAttenIndex_table(fname,outW)
463        String fname
464        Wave outW
465       
466        String path = "entry:instrument:attenuator:index_table"
467        WAVE w = V_getRealWaveFromHDF5(fname,path)
468
469        outW = w
470        return(0)
471end
472
473
474// status "in or out"
475Function/S V_getAttenStatus(fname)
476        String fname
477
478        String path = "entry:instrument:attenuator:status"
479        Variable num=60
480        return(V_getStringFromHDF5(fname,path,num))
481End
482
483// thickness of the attenuator (PMMA) - units??
484Function V_getAttenThickness(fname)
485        String fname
486       
487        String path = "entry:instrument:attenuator:thickness"   
488        return(V_getRealValueFromHDF5(fname,path))
489end
490
491
492// type of material for the atteunator
493Function/S V_getAttenType(fname)
494        String fname
495
496        String path = "entry:instrument:attenuator:type"
497        Variable num=60
498        return(V_getStringFromHDF5(fname,path,num))
499End
500
501
502////// INSTRUMENT/BEAM
503// instrument/beam/chopper (data folder)
504Function V_getChopperAngular_opening(fname)
505        String fname
506       
507        String path = "entry:instrument:beam:chopper:angular_opening"   
508        return(V_getRealValueFromHDF5(fname,path))
509end
510
511Function V_getChopDistance_from_sample(fname)
512        String fname
513       
514        String path = "entry:instrument:beam:chopper:distance_from_sample"     
515        return(V_getRealValueFromHDF5(fname,path))
516end
517
518Function V_getChopDistance_from_source(fname)
519        String fname
520       
521        String path = "entry:instrument:beam:chopper:distance_from_source"     
522        return(V_getRealValueFromHDF5(fname,path))
523end
524
525Function V_getChopperDuty_cycle(fname)
526        String fname
527       
528        String path = "entry:instrument:beam:chopper:duty_cycle"       
529        return(V_getRealValueFromHDF5(fname,path))
530end
531
532Function V_getChopperRotation_speed(fname)
533        String fname
534       
535        String path = "entry:instrument:beam:chopper:rotation_speed"   
536        return(V_getRealValueFromHDF5(fname,path))
537end
538
539Function V_getChopperSlits(fname)
540        String fname
541       
542        String path = "entry:instrument:beam:chopper:slits"     
543        return(V_getRealValueFromHDF5(fname,path))
544end
545
546Function/S V_getChopperstatus(fname)
547        String fname
548
549        String path = "entry:instrument:beam:chopper:status"
550        Variable num=60
551        return(V_getStringFromHDF5(fname,path,num))
552End
553
554Function/S V_getChoppertype(fname)
555        String fname
556
557        String path = "entry:instrument:beam:chopper:type"
558        Variable num=60
559        return(V_getStringFromHDF5(fname,path,num))
560End
561
562
563// instrument/beam/flipper (data folder)
564Function V_getFlipperDriving_current(fname)
565        String fname
566       
567        String path = "entry:instrument:beam:flipper:driving_current"   
568        return(V_getRealValueFromHDF5(fname,path))
569end
570
571Function V_getFlipperFrequency(fname)
572        String fname
573       
574        String path = "entry:instrument:beam:flipper:frequency"
575        return(V_getRealValueFromHDF5(fname,path))
576end
577
578Function/S V_getFlipperstatus(fname)
579        String fname
580
581        String path = "entry:instrument:beam:flipper:status"
582        Variable num=60
583        return(V_getStringFromHDF5(fname,path,num))
584End
585
586Function V_getFlipperTransmitted_power(fname)
587        String fname
588       
589        String path = "entry:instrument:beam:flipper:transmitted_power"
590        return(V_getRealValueFromHDF5(fname,path))
591end
592
593Function/S V_getFlipperWaveform(fname)
594        String fname
595
596        String path = "entry:instrument:beam:flipper:waveform"
597        Variable num=60
598        return(V_getStringFromHDF5(fname,path,num))
599End
600
601// instrument/beam/monochromator (data folder)
602Function/S V_getMonochromatorType(fname)
603        String fname
604
605        String path = "entry:instrument:beam:monochromator:type"
606        Variable num=60
607        return(V_getStringFromHDF5(fname,path,num))
608End
609
610Function V_getWavelength(fname)
611        String fname
612       
613        String path = "entry:instrument:beam:monochromator:wavelength" 
614        return(V_getRealValueFromHDF5(fname,path))
615end
616
617Function V_getWavelength_spread(fname)
618        String fname
619       
620        String path = "entry:instrument:beam:monochromator:wavelength_spread"   
621        return(V_getRealValueFromHDF5(fname,path))
622end
623
624// instrument/beam/monochromator/crystal (data folder)
625Function V_getCrystalEnergy(fname)
626        String fname
627       
628        String path = "entry:instrument:beam:monochromator:crystal:energy"     
629        return(V_getRealValueFromHDF5(fname,path))
630end
631
632Function V_getCrystalHorizontal_aperture(fname)
633        String fname
634       
635        String path = "entry:instrument:beam:monochromator:crystal:horizontal_aperture"
636        return(V_getRealValueFromHDF5(fname,path))
637end
638
639Function V_getCrystalHoriz_curvature(fname)
640        String fname
641       
642        String path = "entry:instrument:beam:monochromator:crystal:horizontal_curvature"       
643        return(V_getRealValueFromHDF5(fname,path))
644end
645
646Function V_getCrystalLattice_parameter(fname)
647        String fname
648       
649        String path = "entry:instrument:beam:monochromator:crystal:lattice_parameter"   
650        return(V_getRealValueFromHDF5(fname,path))
651end
652
653Function V_getCrystalnx_distance(fname)
654        String fname
655       
656        String path = "entry:instrument:beam:monochromator:crystal:nx_distance"
657        return(V_getRealValueFromHDF5(fname,path))
658end
659
660Function V_getCrystalReflection(fname)
661        String fname
662       
663        String path = "entry:instrument:beam:monochromator:crystal:reflection" 
664        return(V_getRealValueFromHDF5(fname,path))
665end
666
667Function V_getCrystalRotation(fname)
668        String fname
669       
670        String path = "entry:instrument:beam:monochromator:crystal:rotation"   
671        return(V_getRealValueFromHDF5(fname,path))
672end
673
674Function/S V_getCrystalStatus(fname)
675        String fname
676
677        String path = "entry:instrument:beam:monochromator:crystal:status"
678        Variable num=60
679        return(V_getStringFromHDF5(fname,path,num))
680End
681
682Function V_getCrystalVertical_aperture(fname)
683        String fname
684       
685        String path = "entry:instrument:beam:monochromator:crystal:vertical_aperture"   
686        return(V_getRealValueFromHDF5(fname,path))
687end
688
689Function V_getCrystalVertical_curvature(fname)
690        String fname
691       
692        String path = "entry:instrument:beam:monochromator:crystal:vertical_curvature" 
693        return(V_getRealValueFromHDF5(fname,path))
694end
695
696Function V_getCrystalWavelength(fname)
697        String fname
698       
699        String path = "entry:instrument:beam:monochromator:crystal:wavelength" 
700        return(V_getRealValueFromHDF5(fname,path))
701end
702
703Function V_getCrystalWavelength_spread(fname)
704        String fname
705       
706        String path = "entry:instrument:beam:monochromator:crystal:wavelength_spread"   
707        return(V_getRealValueFromHDF5(fname,path))
708end
709
710Function V_getCrystalWavevector(fname)
711        String fname
712       
713        String path = "entry:instrument:beam:monochromator:crystal:wavevector" 
714        return(V_getRealValueFromHDF5(fname,path))
715end
716
717// instrument/beam/monochromator/velocity_selector (data folder)
718Function V_getVSnx_distance(fname)
719        String fname
720       
721        String path = "entry:instrument:beam:monochromator:velocity_selector:nx_distance"       
722        return(V_getRealValueFromHDF5(fname,path))
723end
724
725Function V_getVSRotation_speed(fname)
726        String fname
727       
728        String path = "entry:instrument:beam:monochromator:velocity_selector:rotation_speed"   
729        return(V_getRealValueFromHDF5(fname,path))
730end
731
732Function/S V_getVelSelStatus(fname)
733        String fname
734
735        String path = "entry:instrument:beam:monochromator:velocity_selector:status"
736        Variable num=60
737        return(V_getStringFromHDF5(fname,path,num))
738End
739
740Function V_getVSTable(fname,outW)
741        String fname
742        Wave outW
743       
744        String path = "entry:instrument:beam:monochromator:velocity_selector:table"     
745        WAVE w = V_getRealWaveFromHDF5(fname,path)
746
747        outW = w
748        return(0)
749end
750
751Function V_getVSTable_parameters(fname)
752        String fname
753       
754        String path = "entry:instrument:beam:monochromator:velocity_selector:table_parameters" 
755        return(V_getRealValueFromHDF5(fname,path))
756end
757
758Function V_getVS_tilt(fname)
759        String fname
760       
761        String path = "entry:instrument:beam:monochromator:velocity_selector:vs_tilt"   
762        return(V_getRealValueFromHDF5(fname,path))
763end
764
765Function V_getVSWavelength(fname)
766        String fname
767       
768        String path = "entry:instrument:beam:monochromator:velocity_selector:wavelength"       
769        return(V_getRealValueFromHDF5(fname,path))
770end
771
772Function V_getVSWavelength_spread(fname)
773        String fname
774       
775        String path = "entry:instrument:beam:monochromator:velocity_selector:wavelength_spread"
776        return(V_getRealValueFromHDF5(fname,path))
777end
778
779// instrument/beam/monochromator/white_beam (data folder)
780Function/S V_getWhiteBeamStatus(fname)
781        String fname
782
783        String path = "entry:instrument:beam:monochromator:white_beam:status"
784        Variable num=60
785        return(V_getStringFromHDF5(fname,path,num))
786End
787
788Function V_getWhiteBeamWavelength(fname)
789        String fname
790       
791        String path = "entry:instrument:beam:monochromator:white_beam:wavelength"       
792        return(V_getRealValueFromHDF5(fname,path))
793end
794
795Function V_getWhiteBeamWavelength_spread(fname)
796        String fname
797       
798        String path = "entry:instrument:beam:monochromator:white_beam:wavelength_spread"       
799        return(V_getRealValueFromHDF5(fname,path))
800end
801
802// instrument/beam/polarizer (data folder)
803Function/S V_getPolarizerComposition(fname)
804        String fname
805
806        String path = "entry:instrument:beam:polarizer:composition"
807        Variable num=60
808        return(V_getStringFromHDF5(fname,path,num))
809End
810
811Function V_getPolarizerEfficiency(fname)
812        String fname
813       
814        String path = "entry:instrument:beam:polarizer:efficiency"     
815        return(V_getRealValueFromHDF5(fname,path))
816end
817
818Function/S V_getPolarizerStatus(fname)
819        String fname
820
821        String path = "entry:instrument:beam:polarizer:status"
822        Variable num=60
823        return(V_getStringFromHDF5(fname,path,num))
824End
825
826Function/S V_getPolarizerType(fname)
827        String fname
828
829        String path = "entry:instrument:beam:polarizer:type"
830        Variable num=60
831        return(V_getStringFromHDF5(fname,path,num))
832End
833
834// instrument/beam/polarizer_analyzer (data folder)
835Function V_getPolAnaCell_index(fname)
836        String fname
837
838        String path = "entry:instrument:beam:polarizer_analyzer:cell_index"
839        return(V_getRealValueFromHDF5(fname,path))
840End
841
842Function/S V_getPolAnaCell_name(fname)
843        String fname
844
845        String path = "entry:instrument:beam:polarizer_analyzer:cell_name"
846        Variable num=60
847        return(V_getStringFromHDF5(fname,path,num))
848End
849
850Function V_getPolAnaCell_parameters(fname,outW)
851        String fname
852        Wave outW
853
854        String path = "entry:instrument:beam:polarizer_analyzer:cell_parameters"
855        WAVE w = V_getRealWaveFromHDF5(fname,path)
856
857        outW = w
858        return(0)
859End
860
861Function V_getPolAnaGuideFieldCur_1(fname)
862        String fname
863
864        String path = "entry:instrument:beam:polarizer_analyzer:guide_field_current_1"
865        return(V_getRealValueFromHDF5(fname,path))
866End
867
868Function V_getPolAnaGuideFieldCur_2(fname)
869        String fname
870
871        String path = "entry:instrument:beam:polarizer_analyzer:guide_field_current_2"
872        return(V_getRealValueFromHDF5(fname,path))
873End
874
875Function V_getPolAnaSolenoid_current(fname)
876        String fname
877
878        String path = "entry:instrument:beam:polarizer_analyzer:solenoid_current"
879        return(V_getRealValueFromHDF5(fname,path))
880End
881
882Function/S V_getPolAnaStatus(fname)
883        String fname
884
885        String path = "entry:instrument:beam:polarizer_analyzer:status"
886        Variable num=60
887        return(V_getStringFromHDF5(fname,path,num))
888End
889
890                                       
891/////// INSTRUMENT/BEAM MONITORS
892
893//beam_monitor_low (data folder)
894Function V_getBeamMonLowData(fname)
895        String fname
896
897        String path = "entry:instrument:beam_monitor_low:data"
898        return(V_getRealValueFromHDF5(fname,path))
899End
900
901Function V_getBeamMonLowEfficiency(fname)
902        String fname
903
904        String path = "entry:instrument:beam_monitor_low:efficiency"
905        return(V_getRealValueFromHDF5(fname,path))
906End
907
908Function V_getBeamMonLownx_distance(fname)
909        String fname
910
911        String path = "entry:instrument:beam_monitor_low:nx_distance"
912        return(V_getRealValueFromHDF5(fname,path))
913End
914
915Function V_getBeamMonLowSaved_count(fname)
916        String fname
917
918        String path = "entry:instrument:beam_monitor_low:saved_count"
919        return(V_getRealValueFromHDF5(fname,path))
920End
921
922Function/S V_getBeamMonLowType(fname)
923        String fname
924
925        String path = "entry:instrument:beam_monitor_low:type"
926        Variable num=60
927        return(V_getStringFromHDF5(fname,path,num))
928End
929
930//beam_monitor_norm (data folder)
931Function V_getBeamMonNormData(fname)
932        String fname
933
934        String path = "entry:instrument:beam_monitor_norm:data"
935        return(V_getRealValueFromHDF5(fname,path))
936End
937
938Function V_getBeamMonNormEfficiency(fname)
939        String fname
940
941        String path = "entry:instrument:beam_monitor_norm:efficiency"
942        return(V_getRealValueFromHDF5(fname,path))
943End
944
945Function V_getBeamMonNormnx_distance(fname)
946        String fname
947
948        String path = "entry:instrument:beam_monitor_norm:nx_distance"
949        return(V_getRealValueFromHDF5(fname,path))
950End
951
952Function V_getBeamMonNormSaved_count(fname)
953        String fname
954
955        String path = "entry:instrument:beam_monitor_norm:saved_count"
956        return(V_getRealValueFromHDF5(fname,path))
957End
958
959Function/S V_getBeamMonNormType(fname)
960        String fname
961
962        String path = "entry:instrument:beam_monitor_norm:type"
963        Variable num=60
964        return(V_getStringFromHDF5(fname,path,num))
965End
966
967//beam_stop (data folder)
968Function/S V_getBeamStopDescription(fname)
969        String fname
970
971        String path = "entry:instrument:beam_stop:description"
972        Variable num=60
973        return(V_getStringFromHDF5(fname,path,num))
974End
975
976Function V_getBeamStopDist_to_det(fname)
977        String fname
978
979        String path = "entry:instrument:beam_stop:distance_to_detector"
980        return(V_getRealValueFromHDF5(fname,path))
981End
982
983Function V_getBeamStop_x0(fname)
984        String fname
985
986        String path = "entry:instrument:beam_stop:x0"
987        return(V_getRealValueFromHDF5(fname,path))
988End
989
990Function V_getBeamStop_y0(fname)
991        String fname
992
993        String path = "entry:instrument:beam_stop:y0"
994        return(V_getRealValueFromHDF5(fname,path))
995End
996
997//// INSTRUMENT/COLLIMATOR
998//collimator (data folder)
999Function V_getNumberOfGuides(fname)
1000        String fname
1001
1002        String path = "entry:instrument:collimator:number_guides"
1003        return(V_getRealValueFromHDF5(fname,path))
1004End
1005
1006//                              geometry (data folder)
1007//                                      shape (data folder)
1008Function/S V_getGuideShape(fname)
1009        String fname
1010
1011        String path = "entry:instrument:collimator:geometry:shape:shape"
1012        Variable num=60
1013        return(V_getStringFromHDF5(fname,path,num))
1014End
1015
1016Function V_getGuideSize(fname)
1017        String fname
1018
1019        String path = "entry:instrument:collimator:geometry:shape:size"
1020        return(V_getRealValueFromHDF5(fname,path))
1021End
1022
1023//                      converging_pinholes (data folder)
1024Function/S V_getConvPinholeStatus(fname)
1025        String fname
1026
1027        String path = "entry:instrument:converging_pinholes:status"
1028        Variable num=60
1029        return(V_getStringFromHDF5(fname,path,num))
1030End
1031
1032//                      converging_slits (data folder)
1033Function/S V_getConvSlitStatus(fname)
1034        String fname
1035
1036        String path = "entry:instrument:converging_slits:status"
1037        Variable num=60
1038        return(V_getStringFromHDF5(fname,path,num))
1039End
1040
1041
1042////// INSTRUMENT/DETECTORS
1043//                      detector_B (data folder)
1044//
1045// only defined for the "B" detector, and may not be necessary?
1046// TODO -- write to return an ARRAY
1047Function V_getDet_CALX(fname,detStr,outW)
1048        String fname,detStr
1049        Wave outW
1050
1051        if(cmpstr(detStr,"B") == 0)
1052                String path = "entry:instrument:detector_"+detStr+":CALX"
1053                WAVE w = V_getRealWaveFromHDF5(fname,path)
1054
1055                outW = w
1056                return(0)
1057        else
1058                return(0)
1059        endif
1060End
1061
1062// only defined for the "B" detector, and may not be necessary?
1063// TODO -- write to return an ARRAY
1064Function V_getDet_CALY(fname,detStr,outW)
1065        String fname,detStr
1066        Wave outW
1067
1068        if(cmpstr(detStr,"B") == 0)
1069                String path = "entry:instrument:detector_"+detStr+":CALY"
1070                WAVE w = V_getRealWaveFromHDF5(fname,path)
1071       
1072                outW = w
1073                return(0)
1074        else
1075                return(0)
1076        endif
1077End
1078
1079// TODO -- write and X and Y version of this. Pixels are not square
1080// so the FHWM will be different in each direction. May need to return
1081// "dummy" value for "B" detector if pixels there are square
1082Function V_getDet_PixelFWHM(fname,detStr)
1083        String fname,detStr
1084
1085        String path = "entry:instrument:detector_"+detStr+":PixelFWHM"
1086
1087// TODO -- different behavior for "B"
1088        if(cmpstr(detStr,"B") == 0)
1089                return(V_getRealValueFromHDF5(fname,path))
1090        else
1091                return(V_getRealValueFromHDF5(fname,path))
1092        endif
1093End
1094
1095Function V_getDet_PixelNumX(fname,detStr)
1096        String fname,detStr
1097
1098        String path = "entry:instrument:detector_"+detStr+":PixelNumX"
1099        return(V_getRealValueFromHDF5(fname,path))
1100End
1101
1102Function V_getDet_PixelNumY(fname,detStr)
1103        String fname,detStr
1104
1105        String path = "entry:instrument:detector_"+detStr+":PixelNumY"
1106        return(V_getRealValueFromHDF5(fname,path))
1107End
1108
1109// only defined for the "B" detector, and only to satisfy NXsas
1110Function V_getDet_azimuthalAngle(fname,detStr)
1111        String fname,detStr
1112
1113        if(cmpstr(detStr,"B") == 0)
1114                String path = "entry:instrument:detector_"+detStr+":azimuthal_angle"
1115                return(V_getRealValueFromHDF5(fname,path))
1116        else
1117                return(0)
1118        endif
1119End
1120
1121Function V_getDet_beam_center_x(fname,detStr)
1122        String fname,detStr
1123
1124        String path = "entry:instrument:detector_"+detStr+":beam_center_x"
1125        return(V_getRealValueFromHDF5(fname,path))
1126End
1127
1128Function V_getDet_beam_center_y(fname,detStr)
1129        String fname,detStr
1130
1131        String path = "entry:instrument:detector_"+detStr+":beam_center_y"
1132        return(V_getRealValueFromHDF5(fname,path))
1133End
1134
1135// TODO -- write this function to return a WAVE with the data
1136// either as a wave reference, or as an input parameter
1137Function V_getDetectorData(fname,detStr,outW)
1138        String fname,detStr
1139        Wave outW
1140
1141        String path = "entry:instrument:detector_"+detStr+":data"
1142        WAVE w = V_getRealWaveFromHDF5(fname,path)
1143
1144        outW = w
1145        return(0)
1146End
1147
1148
1149// TODO -- write this function to return a WAVE with the data
1150// either as a wave reference, or as an input parameter
1151// ALSO -- the "B" deadtime will be a single value (probably)
1152//  but the tube banks will be 1D arrays of values, one per tube
1153Function V_getDetector_deadtime(fname,detStr,outW)
1154        String fname,detStr
1155        Wave outW
1156
1157        String path = "entry:instrument:detector_"+detStr+":dead_time"
1158        WAVE w = V_getRealWaveFromHDF5(fname,path)
1159
1160        outW = w
1161        return(0)
1162End
1163
1164
1165Function/S V_getDetDescription(fname,detStr)
1166        String fname,detStr
1167
1168        String path = "entry:instrument:detector_"+detStr+":description"
1169        Variable num=60
1170        return(V_getStringFromHDF5(fname,path,num))
1171End
1172
1173Function V_getDet_distance(fname,detStr)
1174        String fname,detStr
1175
1176        String path = "entry:instrument:detector_"+detStr+":distance"
1177        return(V_getRealValueFromHDF5(fname,path))
1178End
1179
1180// only defined for the "B" detector, and only to satisfy NXsas
1181Function V_getDet_equatorial_angle(fname,detStr)
1182        String fname,detStr
1183
1184        if(cmpstr(detStr,"B") == 0)
1185                String path = "entry:instrument:detector_"+detStr+":equatorial_angle"
1186                return(V_getRealValueFromHDF5(fname,path))
1187        else
1188                return(0)
1189        endif
1190End
1191
1192Function/S V_getDetEventFileName(fname,detStr)
1193        String fname,detStr
1194
1195        String path = "entry:instrument:detector_"+detStr+":event_file_name"
1196        Variable num=60
1197        return(V_getStringFromHDF5(fname,path,num))
1198End
1199
1200Function V_getDet_IntegratedCount(fname,detStr)
1201        String fname,detStr
1202
1203        String path = "entry:instrument:detector_"+detStr+":integrated_count"
1204        return(V_getRealValueFromHDF5(fname,path))
1205End
1206
1207Function V_getDet_LateralOffset(fname,detStr)
1208        String fname,detStr
1209
1210        String path = "entry:instrument:detector_"+detStr+":lateral_offset"
1211        return(V_getRealValueFromHDF5(fname,path))
1212End
1213
1214// only defined for the "B" detector, and only to satisfy NXsas
1215Function V_getDet_polar_angle(fname,detStr)
1216        String fname,detStr
1217
1218        if(cmpstr(detStr,"B") == 0)
1219                String path = "entry:instrument:detector_"+detStr+":polar_angle"
1220                return(V_getRealValueFromHDF5(fname,path))
1221        else
1222                return(0)
1223        endif
1224End
1225
1226// only defined for the "B" detector, and only to satisfy NXsas
1227Function V_getDet_rotational_angle(fname,detStr)
1228        String fname,detStr
1229
1230        if(cmpstr(detStr,"B") == 0)
1231                String path = "entry:instrument:detector_"+detStr+":rotational_angle"
1232                return(V_getRealValueFromHDF5(fname,path))
1233        else
1234                return(0)
1235        endif
1236End
1237
1238Function/S V_getDetSettings(fname,detStr)
1239        String fname,detStr
1240
1241        String path = "entry:instrument:detector_"+detStr+":settings"
1242        Variable num=60
1243        return(V_getStringFromHDF5(fname,path,num))
1244End
1245
1246// really has no meaning at all
1247Function V_getDet_size(fname,detStr)
1248        String fname,detStr
1249
1250        String path = "entry:instrument:detector_"+detStr+":size"
1251        return(V_getRealValueFromHDF5(fname,path))
1252End
1253
1254Function/S V_getDetType(fname,detStr)
1255        String fname,detStr
1256
1257        String path = "entry:instrument:detector_"+detStr+":type"
1258        Variable num=60
1259        return(V_getStringFromHDF5(fname,path,num))
1260End
1261
1262Function V_getDet_x_pixel_size(fname,detStr)
1263        String fname,detStr
1264
1265        String path = "entry:instrument:detector_"+detStr+":x_pixel_size"
1266        return(V_getRealValueFromHDF5(fname,path))
1267End
1268
1269Function V_getDet_y_pixel_size(fname,detStr)
1270        String fname,detStr
1271
1272        String path = "entry:instrument:detector_"+detStr+":y_pixel_size"
1273        return(V_getRealValueFromHDF5(fname,path))
1274End
1275
1276/////////                       detector_FB (data folder) + ALL other PANEL DETECTORS
1277
1278Function V_getDet_numberOfTubes(fname,detStr)
1279        String fname,detStr
1280
1281        String path = "entry:instrument:detector_"+detStr+":number_of_tubes"
1282        if(cmpstr(detStr,"B") == 0)
1283                return(0)
1284        else
1285                return(V_getRealValueFromHDF5(fname,path))
1286        endif
1287End
1288
1289// TODO -- be clear on how this is defined. Separation as defined from what point? Units?
1290Function V_getDetPanelSeparation(fname,detStr)
1291        String fname,detStr
1292
1293        String path = "entry:instrument:detector_"+detStr+":separation"
1294        if(cmpstr(detStr,"B") == 0)
1295                return(0)
1296        else
1297                return(V_getRealValueFromHDF5(fname,path))
1298        endif
1299End
1300
1301// TODO -- write this function to return a WAVE with the data
1302// either as a wave reference, or as an input parameter
1303Function V_getDetTube_spatialCalib(fname,detStr,outW)
1304        String fname,detStr
1305        Wave outW
1306
1307        String path = "entry:instrument:detector_"+detStr+":spatial_calibration"
1308        if(cmpstr(detStr,"B") == 0)
1309                return(0)
1310        else
1311                WAVE w = V_getRealWaveFromHDF5(fname,path)
1312       
1313                outW = w
1314                return(0)
1315        endif
1316End
1317
1318// TODO -- be clear on how this is defined.
1319Function V_getDet_tubeIndex(fname,detStr)
1320        String fname,detStr
1321
1322        String path = "entry:instrument:detector_"+detStr+":tube_index"
1323        if(cmpstr(detStr,"B") == 0)
1324                return(0)
1325        else
1326                return(V_getRealValueFromHDF5(fname,path))
1327        endif
1328End
1329
1330Function/S V_getDet_tubeOrientation(fname,detStr)
1331        String fname,detStr
1332
1333        String path = "entry:instrument:detector_"+detStr+":tube_orientation"
1334        Variable num=60
1335        if(cmpstr(detStr,"B") == 0)
1336                return("")
1337        else
1338                return(V_getStringFromHDF5(fname,path,num))
1339        endif
1340End
1341
1342// TODO -- be clear on how this is defined. Units?
1343Function V_getDet_tubeWidth(fname,detStr)
1344        String fname,detStr
1345
1346        String path = "entry:instrument:detector_"+detStr+":tube_width"
1347        if(cmpstr(detStr,"B") == 0)
1348                return(0)
1349        else
1350                return(V_getRealValueFromHDF5(fname,path))
1351        endif
1352End
1353
1354//////////////////////
1355
1356// INSTRUMENT/LENSES    /APERTURES
1357//  lenses (data folder)
1358
1359Function V_getLensCurvature(fname)
1360        String fname
1361
1362        String path = "entry:instrument:lenses:curvature"
1363        return(V_getRealValueFromHDF5(fname,path))
1364End
1365
1366Function/S V_getLensesFocusType(fname)
1367        String fname
1368
1369        String path = "entry:instrument:lenses:focus_type"
1370        Variable num=60
1371        return(V_getStringFromHDF5(fname,path,num))
1372End
1373
1374Function V_getLensDistance(fname)
1375        String fname
1376
1377        String path = "entry:instrument:lenses:lens_distance"
1378        return(V_getRealValueFromHDF5(fname,path))
1379End
1380
1381Function/S V_getLensGeometry(fname)
1382        String fname
1383
1384        String path = "entry:instrument:lenses:lens_geometry"
1385        Variable num=60
1386        return(V_getStringFromHDF5(fname,path,num))
1387End
1388
1389Function/S V_getLensMaterial(fname)
1390        String fname
1391
1392        String path = "entry:instrument:lenses:lens_material"
1393        Variable num=60
1394        return(V_getStringFromHDF5(fname,path,num))
1395End
1396
1397Function V_getNumber_of_Lenses(fname)
1398        String fname
1399
1400        String path = "entry:instrument:lenses:number_of_lenses"
1401        return(V_getRealValueFromHDF5(fname,path))
1402End
1403
1404Function V_getNumber_of_prisms(fname)
1405        String fname
1406
1407        String path = "entry:instrument:lenses:number_of_prisms"
1408        return(V_getRealValueFromHDF5(fname,path))
1409End
1410
1411Function V_getPrism_distance(fname)
1412        String fname
1413
1414        String path = "entry:instrument:lenses:prism_distance"
1415        return(V_getRealValueFromHDF5(fname,path))
1416End
1417
1418Function/S V_getPrismMaterial(fname)
1419        String fname
1420
1421        String path = "entry:instrument:lenses:prism_material"
1422        Variable num=60
1423        return(V_getStringFromHDF5(fname,path,num))
1424End
1425
1426// status of lens/prism = lens | prism | both | out
1427Function/S V_getLensPrismStatus(fname)
1428        String fname
1429
1430        String path = "entry:instrument:lenses:status"
1431        Variable num=60
1432        return(V_getStringFromHDF5(fname,path,num))
1433End
1434       
1435
1436///////  sample_aperture (data folder)
1437
1438Function/S V_getSampleAp_Description(fname)
1439        String fname
1440
1441        String path = "entry:instrument:sample_aperture:description"
1442        Variable num=60
1443        return(V_getStringFromHDF5(fname,path,num))
1444End
1445
1446Function V_getSampleAp_distance(fname)
1447        String fname
1448
1449        String path = "entry:instrument:sample_aperture:distance"
1450        return(V_getRealValueFromHDF5(fname,path))
1451End
1452//      shape (data folder)
1453
1454Function/S V_getSampleAp_shape(fname)
1455        String fname
1456
1457        String path = "entry:instrument:sample_aperture:shape:shape"
1458        Variable num=60
1459        return(V_getStringFromHDF5(fname,path,num))
1460End
1461
1462// TODO -- this needs to return a WAVE, since the shape may be circle, or rectangle
1463// and will need to return more than a single dimension
1464// TODO -- be careful of the UNITS
1465Function V_getSampleAp_size(fname,outW)
1466        String fname
1467        Wave outW
1468
1469        String path = "entry:instrument:sample_aperture:shape:size"
1470        WAVE w = V_getRealWaveFromHDF5(fname,path)
1471
1472        outW = w
1473        return(0)
1474End             
1475               
1476//////  sample_table (data folder)
1477// location  = "CHAMBER" or HUBER
1478Function/S V_getSampleTableLocation(fname)
1479        String fname
1480
1481        String path = "entry:instrument:sample_table:location"
1482        Variable num=60
1483        return(V_getStringFromHDF5(fname,path,num))
1484End
1485
1486// TODO - verify the meaning
1487//      offset_distance (?? for center of sample table vs. sample position)
1488Function V_getSampleTableOffset(fname)
1489        String fname
1490
1491        String path = "entry:instrument:sample_table:offset_distance"
1492        return(V_getRealValueFromHDF5(fname,path))
1493End     
1494       
1495//  source (data folder)
1496//name "NCNR"
1497Function/S V_getSourceName(fname)
1498        String fname
1499
1500        String path = "entry:instrument:source:name"
1501        Variable num=60
1502        return(V_getStringFromHDF5(fname,path,num))
1503End
1504
1505//      power -- nominal only, not connected to any real number
1506Function V_getReactorPower(fname)
1507        String fname
1508
1509        String path = "entry:instrument:source:power"
1510        return(V_getRealValueFromHDF5(fname,path))
1511End     
1512
1513//probe (wave) "neutron"
1514Function/S V_getSourceProbe(fname)
1515        String fname
1516
1517        String path = "entry:instrument:source:probe"
1518        Variable num=60
1519        return(V_getStringFromHDF5(fname,path,num))
1520End
1521
1522//type (wave) "Reactor Neutron Source"
1523Function/S V_getSourceType(fname)
1524        String fname
1525
1526        String path = "entry:instrument:source:type"
1527        Variable num=60
1528        return(V_getStringFromHDF5(fname,path,num))
1529End
1530
1531       
1532///////  source_aperture (data folder)
1533
1534Function/S V_getSourceAp_Description(fname)
1535        String fname
1536
1537        String path = "entry:instrument:source_aperture:description"
1538        Variable num=60
1539        return(V_getStringFromHDF5(fname,path,num))
1540End
1541
1542Function V_getSourceAp_distance(fname)
1543        String fname
1544
1545        String path = "entry:instrument:source_aperture:distance"
1546        return(V_getRealValueFromHDF5(fname,path))
1547End
1548//      shape (data folder)
1549
1550Function/S V_getSourceAp_shape(fname)
1551        String fname
1552
1553        String path = "entry:instrument:source_aperture:shape:shape"
1554        Variable num=60
1555        return(V_getStringFromHDF5(fname,path,num))
1556End
1557
1558// TODO -- this needs to return a WAVE, since the shape may be circle, or rectangle
1559// and will need to return more than a single dimension
1560// TODO -- be careful of the UNITS
1561Function V_getSourceAp_size(fname,outW)
1562        String fname
1563        Wave outW
1564
1565        String path = "entry:instrument:source_aperture:shape:size"
1566        WAVE w = V_getRealWaveFromHDF5(fname,path)
1567
1568        outW = w
1569        return(0)
1570End             
1571
1572
1573
1574
1575//////// SAMPLE
1576//////// SAMPLE
1577//////// SAMPLE
1578
1579//Sample position in changer
1580// TODO -- in the NexusWriter, this ends up as a STRING -- which is wrong. it needs to be FP
1581Function V_getSamplePosition(fname)
1582        String fname
1583       
1584        String path = "entry:sample:changer_position"   
1585        return(V_getRealValueFromHDF5(fname,path))
1586end
1587
1588// sample label
1589// TODO: value of num is currently not used
1590Function/S V_getSampleDescription(fname)
1591        String fname
1592
1593        String path = "entry:sample:description"
1594        Variable num=60
1595        return(V_getStringFromHDF5(fname,path,num))
1596End
1597
1598//no meaning to this...
1599Function V_getSample_equatorial_ang(fname)
1600        String fname
1601       
1602        String path = "entry:sample:equatorial_angle"   
1603        return(V_getRealValueFromHDF5(fname,path))
1604end
1605
1606// group ID !!! very important for matching up files
1607Function V_getSample_GroupID(fname)
1608        String fname
1609       
1610        String path = "entry:sample:group_id"   
1611        return(V_getRealValueFromHDF5(fname,path))
1612end
1613
1614
1615Function V_getSample_rotationAngle(fname)
1616        String fname
1617       
1618        String path = "entry:sample:rotation_angle"     
1619        return(V_getRealValueFromHDF5(fname,path))
1620end
1621
1622
1623//Sample Rotation Angle
1624Function V_getSampleRotationAngle(fname)
1625        String fname
1626       
1627        String path = "entry:sample:rotation_angle"     
1628        return(V_getRealValueFromHDF5(fname,path))
1629end
1630
1631//?? this is huber/chamber??
1632// TODO -- then where is the description of 10CB, etc...
1633Function/S V_getSampleHolderDescription(fname)
1634        String fname
1635
1636        String path = "entry:sample:sample_holder_description"
1637        Variable num=60
1638        return(V_getStringFromHDF5(fname,path,num))
1639End
1640
1641//Sample Thickness
1642// TODO -- somehow, this is not set correctly in the acquisition, so NaN results
1643Function V_getSampleThickness(fname)
1644        String fname
1645       
1646        String path = "entry:sample:thickness" 
1647        return(V_getRealValueFromHDF5(fname,path))
1648end
1649
1650// sample transmission
1651Function V_getSampleTransmission(fname)
1652        String fname
1653       
1654        String path = "entry:sample:transmission"       
1655//      String path = "QKK0037737:data:Transmission"   
1656        return(V_getRealValueFromHDF5(fname,path))
1657end
1658
1659//transmission error (one sigma)
1660Function V_getSampleTransError(fname)
1661        String fname
1662       
1663        String path = "entry:sample:transmission_error"
1664        return(V_getRealValueFromHDF5(fname,path))
1665end
1666
1667
1668
1669
1670
1671// sample label
1672//
1673// TODO
1674// limit to 60 characters?? do I need to do this with HDF5?
1675//
1676// do I need to pad to 60 characters?
1677//
1678Function V_WriteSamLabelToHeader(fname,str)
1679        String fname,str
1680       
1681//      if(strlen(str) > 60)
1682//              str = str[0,59]
1683//      endif   
1684       
1685        Make/O/T/N=1 tmpTW
1686        String groupName = "/sample"    //      /entry is automatically prepended -- so just explicitly state the group
1687        String varName = "description"
1688        tmpTW[0] = str //
1689
1690        variable err
1691        err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)
1692        if(err)
1693                Print "HDF write err = ",err
1694        endif
1695       
1696        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1697        err = V_KillNamedDataFolder(fname)
1698        if(err)
1699                Print "DataFolder kill err = ",err
1700        endif
1701               
1702        return(err)
1703End
1704
1705// sample transmission
1706Function V_WriteTransmissionToHeader(fname,trans)
1707        String fname
1708        Variable trans
1709       
1710        Make/O/D/N=1 wTmpWrite
1711        String groupName = "/sample"    //      skip "entry" - /entry/sample becomes groupName /entry/entry/sample
1712        String varName = "transmission"
1713//      Make/O/R/N=1 wTmpWrite
1714//      String groupName = "/data"      //      skip "entry" - /entry/sample becomes groupName /entry/entry/sample
1715//      String varName = "Transmission"
1716        wTmpWrite[0] = trans //
1717
1718        variable err
1719        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)
1720        if(err)
1721                Print "HDF write err = ",err
1722        endif
1723        // now be sure to kill the data folder to force a re-read of the data next time this file is read in
1724        err = V_KillNamedDataFolder(fname)
1725        if(err)
1726                Print "DataFolder kill err = ",err
1727        endif
1728        return(err)
1729End
1730
1731
1732//// SAMPLE / DATA LOGS
1733// write this generic , call with the name of the environment log desired
1734//
1735// temperature_1
1736// temperature_2
1737// shear_field
1738// pressure
1739// magnetic_field
1740// electric_field
1741//
1742//////// (for example) electric_field (data folder)
1743
1744Function/S V_getLog_attachedTo(fname,logStr)
1745        String fname,logStr
1746
1747        String path = "entry:sample:"+logstr+":attached_to"
1748        Variable num=60
1749        return(V_getStringFromHDF5(fname,path,num))
1750End
1751
1752
1753Function/S V_getLog_measurement(fname,logStr)
1754        String fname,logStr
1755
1756        String path = "entry:sample:"+logstr+":measurement"
1757        Variable num=60
1758        return(V_getStringFromHDF5(fname,path,num))
1759End
1760
1761
1762Function/S V_getLog_Name(fname,logStr)
1763        String fname,logStr
1764
1765        String path = "entry:sample:"+logstr+":name"
1766        Variable num=60
1767        return(V_getStringFromHDF5(fname,path,num))
1768End
1769
1770
1771// TODO --
1772Function V_getLog_nomValue(fname,logStr)
1773        String fname,logStr
1774       
1775        String path = "entry:sample:"+logstr+":value"
1776        return(V_getRealValueFromHDF5(fname,path))
1777end
1778
1779////            value_log (data folder)
1780Function/S V_getLog_startTime(fname,logStr)
1781        String fname,logStr
1782
1783        String path = "entry:sample:"+logstr+":value_log:start"
1784        Variable num=60
1785        return(V_getStringFromHDF5(fname,path,num))
1786End
1787
1788// TODO --
1789Function V_getLog_avgValue(fname,logStr)
1790        String fname,logStr
1791       
1792        String path = "entry:sample:"+logstr+":value_log:average_value"
1793        return(V_getRealValueFromHDF5(fname,path))
1794end
1795
1796// TODO -- this needs to be a WAVE reference
1797Function V_getLog_time(fname,logStr,outW)
1798        String fname,logStr
1799        Wave outW
1800       
1801        String path = "entry:sample:"+logstr+":value_log:nx_time"
1802        WAVE w = V_getRealWaveFromHDF5(fname,path)
1803
1804        outW = w
1805        return(0)
1806end
1807
1808
1809// TODO -- this needs to be a WAVE reference
1810Function V_getLog_Value(fname,logStr,outW)
1811        String fname,logStr
1812        Wave outW
1813       
1814        String path = "entry:sample:"+logstr+":value_log:value"
1815        WAVE w = V_getRealWaveFromHDF5(fname,path)
1816
1817        outW = w
1818        return(0)
1819end
1820
1821
1822
1823
1824
1825
1826
1827///////// REDUCTION
1828///////// REDUCTION
1829///////// REDUCTION
1830
1831
1832// TODO -- needs to be a WAVE
1833Function V_getAbsolute_Scaling(fname,outW)
1834        String fname
1835        Wave outW
1836       
1837        String path = "entry:reduction:absolute_scaling"       
1838        WAVE w = V_getRealWaveFromHDF5(fname,path)
1839
1840        outW = w
1841        return(0)
1842end
1843
1844// TODO -- needs to be a WAVE
1845Function V_getBoxCoordinates(fname,outW)
1846        String fname
1847        Wave outW
1848       
1849        String path = "entry:reduction:box_coordinates"
1850        WAVE w = V_getRealWaveFromHDF5(fname,path)
1851
1852        outW = w
1853        return(0)
1854end
1855
1856//box counts
1857Function V_getBoxCounts(fname)
1858        String fname
1859       
1860        String path = "entry:reduction:box_count"       
1861        return(V_getRealValueFromHDF5(fname,path))
1862end
1863
1864//box counts error
1865Function V_getBoxCountsError(fname)
1866        String fname
1867       
1868        String path = "entry:reduction:box_count_error"
1869        return(V_getRealValueFromHDF5(fname,path))
1870end
1871
1872Function/S V_getReductionComments(fname)
1873        String fname
1874
1875        String path = "entry:reduction:comments"       
1876        Variable num=60
1877        return(V_getStringFromHDF5(fname,path,num))
1878End
1879
1880
1881Function/S V_getReductionIntent(fname)
1882        String fname
1883
1884        String path = "entry:reduction:intent" 
1885        Variable num=60
1886        return(V_getStringFromHDF5(fname,path,num))
1887End
1888
1889
1890Function/S V_getLogFileName(fname)
1891        String fname
1892
1893        String path = "entry:reduction:sans_log_file_name"     
1894        Variable num=60
1895        return(V_getStringFromHDF5(fname,path,num))
1896End
1897
1898
1899Function/S V_getSensitivityFileName(fname)
1900        String fname
1901
1902        String path = "entry:reduction:sensitivity_file_name"   
1903        Variable num=60
1904        return(V_getStringFromHDF5(fname,path,num))
1905End
1906
1907
1908//whole detector trasmission
1909Function V_getSampleTransWholeDetector(fname)
1910        String fname
1911       
1912        String path = "entry:reduction:whole_trans"     
1913        return(V_getRealValueFromHDF5(fname,path))
1914end
1915
1916//whole detector trasmission error
1917Function V_getSampleTransWholeDetErr(fname)
1918        String fname
1919       
1920        String path = "entry:reduction:whole_trans_error"       
1921        return(V_getRealValueFromHDF5(fname,path))
1922end
1923
1924                       
1925/////                   pol_sans (data folder)
1926
1927Function/S V_getPolSANS_cellName(fname)
1928        String fname
1929
1930        String path = "entry:reduction:pol_sans:cell_name"     
1931        Variable num=60
1932        return(V_getStringFromHDF5(fname,path,num))
1933End
1934
1935
1936// TODO -- needs to be a WAVE
1937Function V_getPolSANS_cellParams(fname,outW)
1938        String fname
1939        Wave outW
1940       
1941        String path = "entry:reduction:pol_sans:cell_parameters"       
1942        WAVE w = V_getRealWaveFromHDF5(fname,path)
1943
1944        outW = w
1945        return(0)
1946end
1947
1948Function/S V_getPolSANS_PolSANSPurpose(fname)
1949        String fname
1950
1951        String path = "entry:reduction:pol_sans:pol_sans_purpose"       
1952        Variable num=60
1953        return(V_getStringFromHDF5(fname,path,num))
1954End
1955
1956                               
1957//////// TOP LEVEL DATA REPRESENTATION
1958//
1959// note that here the data is (supposed to be) a link, not the actual data
1960// Igor HDf implementation cannot follow links properly, as far as I know.
1961// so ignore them here, and focus on the image that may be possible to read
1962//
1963
1964//              data_B (data folder)
1965//                      data (wave) 1           //ignore this, it's a link
1966//                      variables (wave) 320
1967//                      thumbnail (data folder)
1968
1969//data (wave) "binary"
1970// TODO -- this will need to be completely replaced with a function that can
1971// read the binary image data. should be possible, but I don't know the details on either end...
1972Function/S V_getDataImage(fname,detStr)
1973        String fname,detStr
1974
1975        String path = "entry:data_"+detStr+":thumbnail:data"   
1976        Variable num=60
1977        return(V_getStringFromHDF5(fname,path,num))
1978End
1979
1980Function/S V_getDataImageDescription(fname,detStr)
1981        String fname,detStr
1982
1983        String path = "entry:data_"+detStr+":thumbnail:description"     
1984        Variable num=60
1985        return(V_getStringFromHDF5(fname,path,num))
1986End
1987                                                               
1988Function/S V_getDataImageType(fname,detStr)
1989        String fname,detStr
1990
1991        String path = "entry:data_"+detStr+":thumbnail:type"   
1992        Variable num=60
1993        return(V_getStringFromHDF5(fname,path,num))
1994End
1995
1996
1997
1998
1999
2000
2001
2002//////////////////////////////
2003//////////////////////////////
2004//////////////////////////////
2005
2006Function V_KillNamedDataFolder(fname)
2007        String fname
2008       
2009        Variable err=0
2010       
2011        String folderStr = V_GetFileNameFromPathNoSemi(fname)
2012        folderStr = V_RemoveDotExtension(folderStr)
2013       
2014        KillDataFolder/Z $("root:"+folderStr)
2015        err = V_flag
2016       
2017        return(err)
2018end
2019
2020//given a filename of a SANS data filename of the form
2021// name.anything
2022//returns the name as a string without the ".fbdfasga" extension
2023//
2024// returns the input string if a"." can't be found (maybe it wasn't there"
2025Function/S V_RemoveDotExtension(item)
2026        String item
2027        String invalid = item   //
2028        Variable num=-1
2029       
2030        //find the "dot"
2031        String runStr=""
2032        Variable pos = strsearch(item,".",0)
2033        if(pos == -1)
2034                //"dot" not found
2035                return (invalid)
2036        else
2037                //found, get all of the characters preceeding it
2038                runStr = item[0,pos-1]
2039                return (runStr)
2040        Endif
2041End
2042
2043//returns a string containing filename (WITHOUT the ;vers)
2044//the input string is a full path to the file (Mac-style, still works on Win in IGOR)
2045//with the folders separated by colons
2046//
2047// called by MaskUtils.ipf, ProtocolAsPanel.ipf, WriteQIS.ipf
2048//
2049Function/S V_GetFileNameFromPathNoSemi(fullPath)
2050        String fullPath
2051       
2052        Variable offset1,offset2
2053        String filename=""
2054        //String PartialPath
2055        offset1 = 0
2056        do
2057                offset2 = StrSearch(fullPath, ":", offset1)
2058                if (offset2 == -1)                              // no more colons ?
2059                        fileName = FullPath[offset1,strlen(FullPath) ]
2060                        //PartialPath = FullPath[0, offset1-1]
2061                        break
2062                endif
2063                offset1 = offset2+1
2064        while (1)
2065       
2066        //remove version number from name, if it's there - format should be: filename;N
2067        filename =  StringFromList(0,filename,";")              //returns null if error
2068       
2069        Return filename
2070End
Note: See TracBrowser for help on using the repository browser.