Changeset 5a81885 in sasview for src/sas/sascalc/dataloader/readers/abs_reader.py
- Timestamp:
- Sep 26, 2017 5:18:30 PM (7 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- b916afa
- Parents:
- 0a3c740 (diff), 69a6897 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/readers/abs_reader.py
rffb6474 r1efbc190 11 11 12 12 import logging 13 13 14 import numpy as np 14 from sas.sascalc.dataloader.file_reader_base_class import FileReader 15 from sas.sascalc.data loader.data_info import DataInfo, plottable_1D, Data1D,\16 Detector17 from sas.sascalc.dataloader.loader_exceptions import FileContentsException,\18 15 16 from sas.sascalc.data_util.nxsunit import Converter 17 from ..file_reader_base_class import FileReader 18 from ..data_info import DataInfo, plottable_1D, Data1D, Detector 19 from ..loader_exceptions import FileContentsException, DefaultReaderException 19 20 20 21 logger = logging.getLogger(__name__) … … 31 32 # List of allowed extensions 32 33 ext = ['.abs'] 33 34 34 35 def get_file_contents(self): 35 """ 36 """ 36 37 Get the contents of the file 37 38 38 39 :raise RuntimeError: when the file can't be opened 39 40 :raise ValueError: when the length of the data vectors are inconsistent 40 41 """ 41 buff = self. f_open.read()42 buff = self.readall() 42 43 filepath = self.f_open.name 43 44 lines = buff.splitlines() 44 self.has_converter = True45 try:46 from sas.sascalc.data_util.nxsunit import Converter47 except:48 self.has_converter = False49 45 self.output = [] 50 46 self.current_datainfo = DataInfo() … … 75 71 try: 76 72 value = float(line_toks[1]) 77 if self.has_converter and \ 78 self.current_datainfo.source.wavelength_unit != 'A': 73 if self.current_datainfo.source.wavelength_unit != 'A': 79 74 conv = Converter('A') 80 75 self.current_datainfo.source.wavelength = conv(value, … … 89 84 try: 90 85 value = float(line_toks[3]) 91 if self.has_converter anddetector.distance_unit != 'm':86 if detector.distance_unit != 'm': 92 87 conv = Converter('m') 93 88 detector.distance = conv(value, … … 95 90 else: 96 91 detector.distance = value 97 except :92 except Exception: 98 93 msg = "ABSReader cannot read SDD from %s" % filepath 99 94 self.current_datainfo.errors.append(msg) … … 109 104 # Sample thickness in mm 110 105 try: 111 value = float(line_toks[5][:-1]) 112 if self.has_converter and \ 113 self.current_datainfo.sample.thickness_unit != 'cm': 106 # ABS writer adds 'C' with no space to the end of the 107 # thickness column. Remove it if it is there before 108 # converting the thickness. 109 if line_toks[5][-1] not in '012345679.': 110 value = float(line_toks[5][:-1]) 111 else: 112 value = float(line_toks[5]) 113 if self.current_datainfo.sample.thickness_unit != 'cm': 114 114 conv = Converter('cm') 115 115 self.current_datainfo.sample.thickness = conv(value, … … 134 134 135 135 # Bin size 136 if self.has_converter anddetector.pixel_size_unit != 'mm':136 if detector.pixel_size_unit != 'mm': 137 137 conv = Converter('mm') 138 138 detector.pixel_size.x = conv(5.08, … … 146 146 # Store beam center in distance units 147 147 # Det 640 x 640 mm 148 if self.has_converter anddetector.beam_center_unit != 'mm':148 if detector.beam_center_unit != 'mm': 149 149 conv = Converter('mm') 150 150 detector.beam_center.x = conv(center_x * 5.08, 151 151 units=detector.beam_center_unit) 152 152 detector.beam_center.y = conv(center_y * 5.08, 153 units=detector.beam_center_unit)153 units=detector.beam_center_unit) 154 154 else: 155 155 detector.beam_center.x = center_x * 5.08
Note: See TracChangeset
for help on using the changeset viewer.