def detectorbase_start(self): from iotbx.detectors.adsc import ADSCImage self.detectorbase = ADSCImage(self._image_file) self.detectorbase.open_file = self.open_file self.detectorbase.readHeader()
def ADSC_module_from_file_url(url): #backward compatibility with Python 2.5 try: from urlparse import parse_qs except Exception: from cgi import parse_qs from urlparse import urlparse parsed = urlparse(url) assert parsed.scheme == "file" file = parsed.path.split("?")[0] if file == parsed.path: return ADSCImage(file) qs = parse_qs(parsed.path.split("?")[1]) sliceindex = int(qs["slice"][0]) object = ADSCImage(file) object.readHeader() return ADSC_module_from_object_and_slicenumber(object, sliceindex)
if self.object.linearintdata.__dict__.get("bin2by2") == True: new_data_array.bin2by2 = True del self.object #once the data are copied, no need to keep the original return new_data_array def read(self): if self.already_read_data: return self.bin_safe_set_data(self.slice_callback()) self.already_read_data = True if __name__ == '__main__': import sys sliceidx = 4 full_path_to_file = sys.argv[1] a = ADSCImage(full_path_to_file) a.read() print(a) print(a.parameters) print(a.rawdata, len(a.rawdata), a.size1 * a.size2) for dataitem in [ 'bin', 'filename', 'header', 'headerlines', 'linearintdata', 'parameters', 'vendortype' ]: print(dataitem, end=' ') exec("print a.%s" % dataitem) print(ADSC_module_from_object_and_slicenumber(a, sliceidx)) P = ADSC_module_from_file_url(url="file://%s?slice=%d" % (full_path_to_file, sliceidx)) print("file://%s?slice=%d" % (full_path_to_file, sliceidx))
def detectorbase_start(self): self.detectorbase = ADSCImage(self._image_file) self.detectorbase.open_file = self.open_file self.detectorbase.readHeader()