- Timestamp:
- Sep 22, 2017 7:23: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:
- 7b50f14
- Parents:
- f7d720f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/readers/abs_reader.py
r574adc7 r46cf4c9 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__) … … 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) … … 110 105 try: 111 106 value = float(line_toks[5]) 112 if self.has_converter and \ 113 self.current_datainfo.sample.thickness_unit != 'cm': 107 if self.current_datainfo.sample.thickness_unit != 'cm': 114 108 conv = Converter('cm') 115 109 self.current_datainfo.sample.thickness = conv(value, … … 134 128 135 129 # Bin size 136 if self.has_converter anddetector.pixel_size_unit != 'mm':130 if detector.pixel_size_unit != 'mm': 137 131 conv = Converter('mm') 138 132 detector.pixel_size.x = conv(5.08, … … 146 140 # Store beam center in distance units 147 141 # Det 640 x 640 mm 148 if self.has_converter anddetector.beam_center_unit != 'mm':142 if detector.beam_center_unit != 'mm': 149 143 conv = Converter('mm') 150 144 detector.beam_center.x = conv(center_x * 5.08, 151 145 units=detector.beam_center_unit) 152 146 detector.beam_center.y = conv(center_y * 5.08, 153 units=detector.beam_center_unit)147 units=detector.beam_center_unit) 154 148 else: 155 149 detector.beam_center.x = center_x * 5.08
Note: See TracChangeset
for help on using the changeset viewer.