Changeset aaa801e in sasview for src/sas/sascalc/dataloader/readers
- Timestamp:
- Sep 23, 2017 4:33:43 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:
- b796c72
- Parents:
- 1cdbcd8 (diff), d3b0c77 (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. - Location:
- src/sas/sascalc/dataloader/readers
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/readers/__init__.py
r574adc7 raaa801e 1 1 # Method to associate extensions to default readers 2 2 from .associations import read_associations 3 4 5 # Method to return the location of the XML settings file6 def get_data_path():7 """8 Return the location of the settings file for the data readers.9 """10 import os11 return os.path.dirname(__file__) -
src/sas/sascalc/dataloader/readers/abs_reader.py
rad92c5a 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__) … … 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) … … 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 -
src/sas/sascalc/dataloader/readers/anton_paar_saxs_reader.py
rfafe52a ra5bd87a 63 63 ## Reinitialize the class when loading a new data file to reset all class variables 64 64 self.reset_state() 65 buff = self. f_open.read()65 buff = self.readall() 66 66 self.raw_data = buff.splitlines() 67 67 self.read_data() -
src/sas/sascalc/dataloader/readers/ascii_reader.py
rf994e8b1 rf7d720f 45 45 """ 46 46 47 buff = self. f_open.read()47 buff = self.readall() 48 48 filepath = self.f_open.name 49 49 lines = buff.splitlines() … … 130 130 # Reset # of lines of data candidates 131 131 candidate_lines = 0 132 132 133 133 if not is_data: 134 134 self.set_all_to_none() -
src/sas/sascalc/dataloader/readers/associations.py
rce8c7bd r574adc7 40 40 """ 41 41 # For each FileType entry, get the associated reader and extension 42 for ext, reader in settings.ite ritems():42 for ext, reader in settings.items(): 43 43 if reader is not None and ext is not None: 44 44 # Associate the extension with a particular reader … … 47 47 # and remove the extra line below. 48 48 try: 49 exec "import %s" % reader50 exec "loader.associate_file_type('%s', %s)" % (ext.lower(),51 reader)52 exec "loader.associate_file_type('%s', %s)" % (ext.upper(),53 reader)49 exec("from . import %s" % reader) 50 exec("loader.associate_file_type('%s', %s)" 51 % (ext.lower(), reader)) 52 exec("loader.associate_file_type('%s', %s)" 53 % (ext.upper(), reader)) 54 54 except: 55 55 msg = "read_associations: skipping association" -
src/sas/sascalc/dataloader/readers/cansas_reader.py
rae69c690 re6e89c4 1 1 import logging 2 import numpy as np3 2 import os 4 3 import sys 5 4 import datetime 6 5 import inspect 7 # For saving individual sections of data 8 from sas.sascalc.dataloader.data_info import Data1D, Data2D, DataInfo, \ 9 plottable_1D, plottable_2D 10 from sas.sascalc.dataloader.data_info import Collimation, TransmissionSpectrum, \ 11 Detector, Process, Aperture 12 from sas.sascalc.dataloader.data_info import \ 13 combine_data_info_with_plottable as combine_data 14 import sas.sascalc.dataloader.readers.xml_reader as xml_reader 15 from sas.sascalc.dataloader.readers.xml_reader import XMLreader 16 from sas.sascalc.dataloader.readers.cansas_constants import CansasConstants, CurrentLevel 17 from sas.sascalc.dataloader.loader_exceptions import FileContentsException, \ 18 DefaultReaderException, DataReaderException 6 7 import numpy as np 19 8 20 9 # The following 2 imports *ARE* used. Do not remove either. … … 23 12 24 13 from lxml import etree 14 15 from sas.sascalc.data_util.nxsunit import Converter 16 17 # For saving individual sections of data 18 from ..data_info import Data1D, Data2D, DataInfo, plottable_1D, plottable_2D, \ 19 Collimation, TransmissionSpectrum, Detector, Process, Aperture, \ 20 combine_data_info_with_plottable as combine_data 21 from ..loader_exceptions import FileContentsException, DefaultReaderException, \ 22 DataReaderException 23 from . import xml_reader 24 from .xml_reader import XMLreader 25 from .cansas_constants import CansasConstants, CurrentLevel 25 26 26 27 logger = logging.getLogger(__name__) … … 34 35 "as much of the data as possible.\n\n" 35 36 HAS_CONVERTER = True 36 try:37 from sas.sascalc.data_util.nxsunit import Converter38 except ImportError:39 HAS_CONVERTER = False40 37 41 38 CONSTANTS = CansasConstants() … … 163 160 raise fc_exc 164 161 except Exception as e: # Convert all other exceptions to FileContentsExceptions 165 raise FileContentsException(e.message) 162 raise 163 raise FileContentsException(str(e)) 166 164 167 165 … … 632 630 else: 633 631 save_in = "current_datainfo" 634 exec "default_unit = self.{0}.{1}".format(save_in, unitname) 635 if local_unit and default_unit and local_unit.lower() != default_unit.lower() \ 636 and local_unit.lower() != "none": 637 if HAS_CONVERTER == True: 632 default_unit = getattrchain(self, '.'.join((save_in, unitname))) 633 if (local_unit and default_unit 634 and local_unit.lower() != default_unit.lower() 635 and local_unit.lower() != "none"): 636 if HAS_CONVERTER: 638 637 # Check local units - bad units raise KeyError 638 #print("loading", tagname, node_value, local_unit, default_unit) 639 639 data_conv_q = Converter(local_unit) 640 640 value_unit = default_unit … … 654 654 err_msg += "expecting [{0}]".format(default_unit) 655 655 value_unit = local_unit 656 except :656 except Exception: 657 657 err_msg = "CanSAS reader: unknown error converting " 658 658 err_msg += "\"{0}\" unit [{1}]" … … 717 717 doc, _ = self._to_xml_doc(datainfo) 718 718 # Write the file 719 file_ref = open(filename, 'w ')719 file_ref = open(filename, 'wb') 720 720 if self.encoding is None: 721 721 self.encoding = "UTF-8" … … 908 908 point = self.create_element("Idata") 909 909 node.append(point) 910 qx = ','.join( [str(datainfo.qx_data[i]) for i in xrange(len(datainfo.qx_data))])911 qy = ','.join( [str(datainfo.qy_data[i]) for i in xrange(len(datainfo.qy_data))])912 intensity = ','.join( [str(datainfo.data[i]) for i in xrange(len(datainfo.data))])910 qx = ','.join(str(v) for v in datainfo.qx_data) 911 qy = ','.join(str(v) for v in datainfo.qy_data) 912 intensity = ','.join(str(v) for v in datainfo.data) 913 913 914 914 self.write_node(point, "Qx", qx, … … 919 919 {'unit': datainfo._zunit}) 920 920 if datainfo.err_data is not None: 921 err = ','.join([str(datainfo.err_data[i]) for i in 922 xrange(len(datainfo.err_data))]) 921 err = ','.join(str(v) for v in datainfo.err_data) 923 922 self.write_node(point, "Idev", err, 924 923 {'unit': datainfo._zunit}) 925 924 if datainfo.dqy_data is not None: 926 dqy = ','.join([str(datainfo.dqy_data[i]) for i in 927 xrange(len(datainfo.dqy_data))]) 925 dqy = ','.join(str(v) for v in datainfo.dqy_data) 928 926 self.write_node(point, "Qydev", dqy, 929 927 {'unit': datainfo._yunit}) 930 928 if datainfo.dqx_data is not None: 931 dqx = ','.join([str(datainfo.dqx_data[i]) for i in 932 xrange(len(datainfo.dqx_data))]) 929 dqx = ','.join(str(v) for v in datainfo.dqx_data) 933 930 self.write_node(point, "Qxdev", dqx, 934 931 {'unit': datainfo._xunit}) 935 932 if datainfo.mask is not None: 936 mask = ','.join( 937 ["1" if datainfo.mask[i] else "0" 938 for i in xrange(len(datainfo.mask))]) 933 mask = ','.join("1" if v else "0" for v in datainfo.mask) 939 934 self.write_node(point, "Mask", mask) 940 935 … … 1280 1275 try: 1281 1276 value = float(entry.text) 1282 except :1277 except ValueError: 1283 1278 value = None 1284 1279 … … 1289 1284 if units is not None: 1290 1285 toks = variable.split('.') 1291 local_unit = None1292 exec "local_unit = storage.%s_unit" % toks[0]1286 # TODO: why split() when accessing unit, but not when setting value? 1287 local_unit = getattr(storage, toks[0]+"_unit") 1293 1288 if local_unit is not None and units.lower() != local_unit.lower(): 1294 1289 if HAS_CONVERTER == True: 1295 1290 try: 1296 1291 conv = Converter(units) 1297 exec "storage.%s = %g" % \ 1298 (variable, conv(value, units=local_unit)) 1299 except: 1292 setattrchain(storage, variable, conv(value, units=local_unit)) 1293 except Exception: 1300 1294 _, exc_value, _ = sys.exc_info() 1301 1295 err_mess = "CanSAS reader: could not convert" … … 1306 1300 logger.info(err_mess) 1307 1301 else: 1308 raise ValueError , err_mess1302 raise ValueError(err_mess) 1309 1303 else: 1310 1304 err_mess = "CanSAS reader: unrecognized %s unit [%s];"\ … … 1315 1309 logger.info(err_mess) 1316 1310 else: 1317 raise ValueError , err_mess1311 raise ValueError(err_mess) 1318 1312 else: 1319 exec "storage.%s = value" % variable1313 setattrchain(storage, variable, value) 1320 1314 else: 1321 exec "storage.%s = value" % variable1315 setattrchain(storage, variable, value) 1322 1316 1323 1317 # DO NOT REMOVE - used in saving and loading panel states. … … 1339 1333 entry = get_content(location, node) 1340 1334 if entry is not None and entry.text is not None: 1341 exec "storage.%s = entry.text.strip()" % variable1335 exec("storage.%s = entry.text.strip()" % variable) 1342 1336 1343 1337 # DO NOT REMOVE Called by outside packages: … … 1382 1376 return True 1383 1377 return False 1378 1379 def getattrchain(obj, chain, default=None): 1380 """Like getattr, but the attr may contain multiple parts separated by '.'""" 1381 for part in chain.split('.'): 1382 if hasattr(obj, part): 1383 obj = getattr(obj, part, None) 1384 else: 1385 return default 1386 return obj 1387 1388 def setattrchain(obj, chain, value): 1389 """Like setattr, but the attr may contain multiple parts separated by '.'""" 1390 parts = list(chain.split('.')) 1391 for part in parts[-1]: 1392 obj = getattr(obj, part, None) 1393 if obj is None: 1394 raise ValueError("missing parent object "+part) 1395 setattr(obj, value) -
src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py
rcd57c7d4 r7b50f14 9 9 import sys 10 10 11 from sas.sascalc.dataloader.data_info import plottable_1D, plottable_2D,\11 from ..data_info import plottable_1D, plottable_2D,\ 12 12 Data1D, Data2D, DataInfo, Process, Aperture, Collimation, \ 13 13 TransmissionSpectrum, Detector 14 from sas.sascalc.dataloader.data_info import combine_data_info_with_plottable 15 from sas.sascalc.dataloader.loader_exceptions import FileContentsException, DefaultReaderException 16 from sas.sascalc.dataloader.file_reader_base_class import FileReader 17 14 from ..data_info import combine_data_info_with_plottable 15 from ..loader_exceptions import FileContentsException, DefaultReaderException 16 from ..file_reader_base_class import FileReader, decode 17 18 def h5attr(node, key, default=None): 19 return decode(node.attrs.get(key, default)) 18 20 19 21 class Reader(FileReader): … … 130 132 # Get all information for the current key 131 133 value = data.get(key) 132 if value.attrs.get(u'canSAS_class') is not None: 133 class_name = value.attrs.get(u'canSAS_class') 134 else: 135 class_name = value.attrs.get(u'NX_class') 134 class_name = h5attr(value, u'canSAS_class') 135 if class_name is None: 136 class_name = h5attr(value, u'NX_class') 136 137 if class_name is not None: 137 138 class_prog = re.compile(class_name) … … 225 226 226 227 for data_point in data_set: 228 if data_point.dtype.char == 'S': 229 data_point = decode(bytes(data_point)) 227 230 # Top Level Meta Data 228 231 if key == u'definition': … … 231 234 self.current_datainfo.run.append(data_point) 232 235 try: 233 run_name = value.attrs['name']236 run_name = h5attr(value, 'name') 234 237 run_dict = {data_point: run_name} 235 238 self.current_datainfo.run_name = run_dict 236 except :239 except Exception: 237 240 pass 238 241 elif key == u'title': … … 576 579 :return: unit for the value passed to the method 577 580 """ 578 unit = value.attrs.get(u'units')581 unit = h5attr(value, u'units') 579 582 if unit is None: 580 unit = value.attrs.get(u'unit')583 unit = h5attr(value, u'unit') 581 584 # Convert the unit formats 582 585 if unit == "1/A": -
src/sas/sascalc/dataloader/readers/danse_reader.py
ra78a02f raf3e9f5 14 14 import math 15 15 import os 16 import logging 17 16 18 import numpy as np 17 import logging 18 from sas.sascalc.dataloader.data_info import plottable_2D, DataInfo, Detector19 from sas.sascalc.dataloader.manipulations import reader2D_converter20 from sas.sascalc.dataloader.file_reader_base_class import FileReader21 from sas.sascalc.dataloader.loader_exceptions import FileContentsException, DataReaderException19 20 from ..data_info import plottable_2D, DataInfo, Detector 21 from ..manipulations import reader2D_converter 22 from ..file_reader_base_class import FileReader 23 from ..loader_exceptions import FileContentsException, DataReaderException 22 24 23 25 logger = logging.getLogger(__name__) … … 78 80 data_start_line = 1 79 81 while read_on: 80 line = self. f_open.readline()82 line = self.nextline() 81 83 data_start_line += 1 82 84 if line.find("DATA:") >= 0: … … 112 114 raise FileContentsException(msg) 113 115 114 for line_num, data_str in enumerate(self. f_open.readlines()):116 for line_num, data_str in enumerate(self.nextlines()): 115 117 toks = data_str.split() 116 118 try: -
src/sas/sascalc/dataloader/readers/red2d_reader.py
r2f85af7 rc8321cfc 10 10 ###################################################################### 11 11 import os 12 import math 13 import time 14 12 15 import numpy as np 13 import math 14 from sas.sascalc.dataloader.data_info import plottable_2D, DataInfo, Detector 15 from sas.sascalc.dataloader.file_reader_base_class import FileReader 16 from sas.sascalc.dataloader.loader_exceptions import FileContentsException 17 18 # Look for unit converter 19 has_converter = True 20 try: 21 from sas.sascalc.data_util.nxsunit import Converter 22 except: 23 has_converter = False 16 17 from sas.sascalc.data_util.nxsunit import Converter 18 19 from ..data_info import plottable_2D, DataInfo, Detector 20 from ..file_reader_base_class import FileReader 21 from ..loader_exceptions import FileContentsException 24 22 25 23 … … 31 29 try: 32 30 return float(x_point) 33 except :31 except Exception: 34 32 return 0 35 33 … … 51 49 :param data: data2D 52 50 """ 53 import time54 51 # Write the file 55 52 try: … … 72 69 def get_file_contents(self): 73 70 # Read file 74 buf = self. f_open.read()71 buf = self.readall() 75 72 self.f_open.close() 76 73 # Instantiate data object … … 119 116 try: 120 117 wavelength = float(line_toks[1]) 121 # Units 122 if has_converter == True and \ 123 self.current_datainfo.source.wavelength_unit != 'A': 118 # Wavelength is stored in angstroms; convert if necessary 119 if self.current_datainfo.source.wavelength_unit != 'A': 124 120 conv = Converter('A') 125 121 wavelength = conv(wavelength, 126 122 units=self.current_datainfo.source.wavelength_unit) 127 except: 128 #Not required 129 pass 130 # Distance in mm 123 except Exception: 124 pass # Not required 131 125 try: 132 126 distance = float(line_toks[3]) 133 # Units134 if has_converter == True andself.current_datainfo.detector[0].distance_unit != 'm':127 # Distance is stored in meters; convert if necessary 128 if self.current_datainfo.detector[0].distance_unit != 'm': 135 129 conv = Converter('m') 136 130 distance = conv(distance, 137 131 units=self.current_datainfo.detector[0].distance_unit) 138 except: 139 #Not required 140 pass 141 142 # Distance in meters 132 except Exception: 133 pass # Not required 134 143 135 try: 144 136 transmission = float(line_toks[4]) 145 except: 146 #Not required 147 pass 137 except Exception: 138 pass # Not required 148 139 149 140 if line.count("LAMBDA") > 0: … … 170 161 171 162 ## Read and get data. 172 if data_started == True:163 if data_started: 173 164 line_toks = line.split() 174 165 if len(line_toks) == 0: … … 178 169 col_num = len(line_toks) 179 170 break 171 180 172 # Make numpy array to remove header lines using index 181 173 lines_array = np.array(lines) … … 203 195 # Change it(string) into float 204 196 #data_list = map(float,data_list) 205 data_list1 = map(check_point, data_list)197 data_list1 = list(map(check_point, data_list)) 206 198 207 199 # numpy array form … … 211 203 try: 212 204 data_point = data_array.reshape(row_num, col_num).transpose() 213 except :205 except Exception: 214 206 msg = "red2d_reader can't read this file: Incorrect number of data points provided." 215 207 raise FileContentsException(msg) … … 325 317 326 318 # Units of axes 327 self.current_dataset.xaxis( "\\rm{Q_{x}}", 'A^{-1}')328 self.current_dataset.yaxis( "\\rm{Q_{y}}", 'A^{-1}')329 self.current_dataset.zaxis( "\\rm{Intensity}", "cm^{-1}")319 self.current_dataset.xaxis(r"\rm{Q_{x}}", 'A^{-1}') 320 self.current_dataset.yaxis(r"\rm{Q_{y}}", 'A^{-1}') 321 self.current_dataset.zaxis(r"\rm{Intensity}", "cm^{-1}") 330 322 331 323 # Store loading process information -
src/sas/sascalc/dataloader/readers/sesans_reader.py
rbe43448 r849094a 6 6 Jurrian Bakker 7 7 """ 8 import os 9 8 10 import numpy as np 9 import os 10 from sas.sascalc.dataloader.file_reader_base_class import FileReader11 from sas.sascalc.dataloader.data_info import plottable_1D, DataInfo12 from sas.sascalc.dataloader.loader_exceptions import FileContentsException, DataReaderException11 12 from ..file_reader_base_class import FileReader 13 from ..data_info import plottable_1D, DataInfo 14 from ..loader_exceptions import FileContentsException, DataReaderException 13 15 14 16 # Check whether we have a converter available … … 42 44 self.output = [] 43 45 44 line = self. f_open.readline()46 line = self.nextline() 45 47 params = {} 46 48 while not line.startswith("BEGIN_DATA"): … … 48 50 if len(terms) >= 2: 49 51 params[terms[0]] = " ".join(terms[1:]) 50 line = self. f_open.readline()52 line = self.nextline() 51 53 self.params = params 52 54 … … 68 70 "handled by other software.") 69 71 70 headers = self. f_open.readline().split()72 headers = self.nextline().split() 71 73 72 74 self._insist_header(headers, "SpinEchoLength") -
src/sas/sascalc/dataloader/readers/tiff_reader.py
r959eb01 r574adc7 2 2 #This software was developed by the University of Tennessee as part of the 3 3 #Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 4 #project funded by the US National Science Foundation. 4 #project funded by the US National Science Foundation. 5 5 #See the license text in license.txt 6 6 #copyright 2008, University of Tennessee … … 31 31 ## Extension 32 32 ext = ['.tif', '.tiff'] 33 33 34 34 def read(self, filename=None): 35 35 """ 36 36 Open and read the data in a file 37 37 38 38 :param file: path of the file 39 39 """ … … 44 44 except: 45 45 msg = "tiff_reader: could not load file. Missing Image module." 46 raise RuntimeError , msg47 46 raise RuntimeError(msg) 47 48 48 # Instantiate data object 49 49 output = Data2D() 50 50 output.filename = os.path.basename(filename) 51 51 52 52 # Read in the image 53 53 try: 54 54 im = Image.open(filename) 55 55 except: 56 raise RuntimeError , "cannot open %s"%(filename)56 raise RuntimeError("cannot open %s"%(filename)) 57 57 data = im.getdata() 58 58 … … 61 61 output.err_data = np.zeros([im.size[0], im.size[1]]) 62 62 output.mask = np.ones([im.size[0], im.size[1]], dtype=bool) 63 63 64 64 # Initialize 65 65 x_vals = [] … … 69 69 for i_x in range(im.size[0]): 70 70 x_vals.append(i_x) 71 71 72 72 itot = 0 73 73 for i_y in range(im.size[1]): … … 80 80 logger.error("tiff_reader: had to skip a non-float point") 81 81 continue 82 82 83 83 # Get bin number 84 84 if math.fmod(itot, im.size[0]) == 0: … … 87 87 else: 88 88 i_x += 1 89 89 90 90 output.data[im.size[1] - 1 - i_y][i_x] = value 91 91 92 92 itot += 1 93 93 94 94 output.xbins = im.size[0] 95 95 output.ybins = im.size[1] … … 102 102 output.ymin = 0 103 103 output.ymax = im.size[0] - 1 104 104 105 105 # Store loading process information 106 106 output.meta_data['loader'] = self.type_name -
src/sas/sascalc/dataloader/readers/xml_reader.py
rcd57c7d4 r7b50f14 16 16 17 17 import logging 18 18 19 from lxml import etree 19 20 from lxml.builder import E 20 from sas.sascalc.dataloader.file_reader_base_class import FileReader 21 22 from ..file_reader_base_class import FileReader, decode 21 23 22 24 logger = logging.getLogger(__name__) … … 151 153 Converts an etree element into a string 152 154 """ 153 return etree.tostring(elem, pretty_print=pretty_print, \154 encoding=encoding)155 return decode(etree.tostring(elem, pretty_print=pretty_print, 156 encoding=encoding)) 155 157 156 158 def break_processing_instructions(self, string, dic):
Note: See TracChangeset
for help on using the changeset viewer.