def __init__(self, dataSource, \ outputFileName, \ nx=200, ny=201, nz=202, \ transform = None, \ gridWriter = None, appConfig = None): ''' Constructor :param dataSource: source of scan data :param outputFileName: filename for output :param nx: number of points in x direction for griidder :param ny: number of points in y direction for griidder :param nz: number of points in z direction for griidder :param transform: Transform to be applied to the axes before gridding ''' self.appConfig = None if not (appConfig is None): self.appConfig = appConfig else: raise RSMap3DException("no AppConfig object received.") self.dataSource = dataSource self.outputFileName = outputFileName self.nx = nx self.ny = ny self.nz = nz self.haltMap = False self.progressUpdater = None self.gridWriter = gridWriter if transform is None: self.transform = UnityTransform3D() else: self.transform = transform
def __init__(self, dataSource, outputFileName, transform=None, gridWriter=None, appConfig=None, dataCoord=X_COORD_OPTIONS[0], xCoordMin=None, xCoordMax=None, xCoordStep=None, plotResults=False, yScaling=Y_SCALING_OPTIONS[0], writeXyeFile=True): self.dataSource = dataSource self.outputFileName = outputFileName self.gridWriter = gridWriter self.appConfig = None self.progressUpdater = None if transform is None: self.transform = UnityTransform3D() else: self.transform = transform if not (appConfig is None): self.appConfig = appConfig else: raise RSMap3DException("No AppConfig object received") self.dataCoord = dataCoord self.yScaling = yScaling self.plotResults = plotResults self.writeXyeFile = writeXyeFile self.xCoordMin = xCoordMin self.xCoordMax = xCoordMax self.XCoordStep = xCoordStep
def getDataSource(self): logger.debug(METHOD_ENTER_STR) if self.getOutputType() == self.SIMPLE_GRID_MAP_STR: self.transform = UnityTransform3D() elif self.getOutputType() == self.POLE_MAP_STR: self.transform = \ PoleMapTransform3D(projectionDirection=\ self.getProjectionDirection()) else: self.transform = None self.dataSource = \ Sector33SpecDataSource(str(self.getProjectDir()), \ str(self.getProjectName()), \ str(self.getProjectExtension()), \ str(self.getInstConfigName()), \ str(self.getDetConfigName()), \ transform = self.transform, \ scanList = self.getScanList(), \ roi = self.getDetectorROI(), \ pixelsToAverage = \ self.getPixelsToAverage(), \ badPixelFile = \ self.getBadPixelFileName(), \ flatFieldFile = \ self.getFlatFieldFileName(), \ appConfig = self.appConfig ) self.dataSource.setProgressUpdater(self.updateProgress) self.dataSource.setCurrentDetector(self.currentDetector) self.dataSource.loadSource(mapHKL=self.getMapAsHKL()) logger.debug(METHOD_EXIT_STR) return self.dataSource
def testS1HighEnergyDiffractionDS(self): projectDir = os.path.join(configDir, "../1-idscan") projectName = "fastpar_startup_oct16_FF1" projectExtension = ".par" instConfig = os.path.join(projectDir, "1-ID-E_AeroTable.xml") detConfig = os.path.join(projectDir, "1-ID-GE.xml") transform = UnityTransform3D() pixelsToAverage = [1, 1] scanList = [ 3, ] detRoi = [1, 2048, 1, 2048] imageDirName = "" #fake since not used here. appConfig = RSMap3DConfigParser() ds = S1HighEnergyDiffractionDS(str(projectDir), str(projectName), str(projectExtension), str(instConfig), str(detConfig), imageDirName, transform=transform, scanList=scanList, pixelsToAverage=pixelsToAverage, badPixelFile=None, flatFieldFile=None, appConfig=appConfig) ds.setCurrentDetector('ge3') ds.loadSource() availableScans = ds.getAvailableScans() self.assertEquals(availableScans, [ 3, ])
def __init__(self, transform=None, scanList=None, roi=None, pixelsToAverage=[1, 1], badPixelFile=None, flatFieldFile=None, **kwargs): ''' Constructor ''' super(AbstractXrayutilitiesDataSource, self).__init__(**kwargs) self.sampleCircleDirections = None self.detectorCircleDirections = None self.primaryBeamDirection = None self.incidentWavelength = float('nan') self.incidentEnergy = None self.sampleInplaneReferenceDirection = None self.sampleSurfaceNormalDirection = None self.detectorCenterChannel = None self.distanceToDetector = float('nan') self.detectorPixelWidth = None self.detectorChannelPerDegree = None self.numPixelsToAverage = pixelsToAverage self.detectorROI = roi self.detectorAngles = None self.sampleAngles = None self.detectorAngleNames = None self.sampleAngleNames = None self.detectorPixelDirection1 = None self.detectorPixelDirection2 = None self.imageToBeUsed = {} self.availableScans = [] self.ubMatrix = {} self.badPixels = [] self.rangeBounds = None self.cancelLoad = False self.monitorName = None self.monitorScaleFactor = 1.0 self.projectionDirection = None self.filterName = None self.filterScaleFactor = 1.0 if transform is None: self.transform = UnityTransform3D() else: self.transform = transform self.badPixelFile = badPixelFile self.flatFieldFile = flatFieldFile self.flatFieldData = None self.progressUpdater = None
def loadScanFile(self): ''' Set up to load the scan file ''' self.blockTabsForLoad.emit() if self.fileFormWidget.getOutputType( ) == self.fileFormWidget.SIMPLE_GRID_MAP_STR: self.transform = UnityTransform3D() elif self.fileFormWidget.getOutputType( ) == self.fileFormWidget.POLE_MAP_STR: self.transform = \ PoleMapTransform3D(projectionDirection=\ self.fileFormWidget.getProjectionDirection()) else: self.transform = None try: self.dataSource = \ self.fileFormWidget.getDataSource() except LoadCanceledException as e: self.blockTabsForLoad.emit() self.setScanLoadOK.emit() #self.fileForm.setLoadOK() return except ScanDataMissingException as e: self.fileError.emit(str(e)) return except DetectorConfigException as e: self.fileError.emit(str(e)) return except InstConfigException as e: self.fileError.emit(str(e)) return except Transform3DException as e: self.fileError.emit(str(e)) return except ScanDataMissingException as e: self.fileError.emit(str(e)) return except RSMap3DException as e: self.fileError.emit(str(e)) return except Exception as e: self.fileError.emit(str(e) + "\n" + str(traceback.format_exc())) return self.loadDataSourceToScanForm.emit() self.setScanLoadOK.emit()
def getDataSource(self): if self.getOutputType() == self.SIMPLE_GRID_MAP_STR: self.transform = UnityTransform3D() elif self.getOutputType() == self.POLE_MAP_STR: self.transform = \ PoleMapTransform3D(projectionDirection=\ self.fileForm.getProjectionDirection()) else: self.transform = None self.dataSource = \ Sector34NexusEscanSource(str(self.getProjectDir()), \ str(self.getProjectName()), \ str(self.getProjectExtension()), \ str(self.getDetConfigName()), \ appConfig = self.appConfig) self.dataSource.setProgressUpdater(self.updateProgress) self.dataSource.loadSource() return self.dataSource
def getDataSource(self): logger.debug(METHOD_ENTER_STR) if self.getOutputType() == self.SIMPLE_GRID_MAP_STR: self.transform = UnityTransform3D() elif self.getOutputType() == self.POLE_MAP_STR: self.transform = \ PoleMapTransform3D(projectionDirection=\ self.getProjectionDirection()) else: self.transform = None self.dataSource = \ S1HighEnergyDiffractionDS(str(self.getProjectDir()), \ str(self.getProjectName()), \ str(self.getProjectExtension()), \ str(self.getInstConfigName()), \ str(self.getDetConfigName()), \ str(self.getImageDirName()), \ transform = self.transform, \ scanList = self.getScanList(), \ roi = self.getDetectorROI(), \ pixelsToAverage = \ [1,1], \ badPixelFile = None, \ flatFieldFile = None, \ detectorDistanceOverride = \ self.getDetectorDistanceOverride(), \ incidentEnergyOverride = self.getIncidentEnergyOverride(), \ offsetAngle = self.getOffsetAngle(), \ appConfig = self.appConfig ) self.dataSource.setProgressUpdater(self.updateProgress) self.dataSource.setCurrentDetector(self.currentDetector) self.dataSource.loadSource(mapHKL=self.getMapAsHKL()) logger.debug(METHOD_EXIT_STR) return self.dataSource
def getDataSource(self): if self.getOutputType() == self.SIMPLE_GRID_MAP_STR: self.transform = UnityTransform3D() elif self.getOutputType() == self.POLE_MAP_STR: self.transform = \ PoleMapTransform3D(projectionDirection=\ self.fileForm.getProjectionDirection()) else: self.transform = None pathToReplaceStr = str(self.pathToReplaceTxt.text()) replacePathWithStr = str(self.replacePathWithTxt.text()) if (pathToReplaceStr == ""): pathToReplace = None else: pathToReplace = pathToReplaceStr if (replacePathWithStr == ""): replacePathWith = None else: replacePathWith = replacePathWithStr self.dataSource = \ XPCSSpecDataSource(str(self.getProjectDir()), \ str(self.getProjectName()), \ str(self.getProjectExtension()), \ str(self.getInstConfigName()), \ str(self.getDetConfigName()), \ # str(self.getImmFileName()), \ scanList = self.getScanList(), \ transform = self.transform, \ appConfig = self.appConfig, pathToReplace = pathToReplace, replacePathWith = replacePathWith ) self.dataSource.setProgressUpdater(self.updateProgress) self.dataSource.setCurrentDetector(self.currentDetector) self.dataSource.loadSource(mapHKL=self.getMapAsHKL()) return self.dataSource
ds.setRangeBounds(ds.getOverallRanges()) imageToBeUsed = ds.getImageToBeUsed() print("imageToBeUsed %s" % imageToBeUsed) # wavelen = ENERGY_WAVELENGTH_CONVERT_FACTOR/ds.getIncidentEnergy()[scans[0]] imageSize = np.prod(ds.getDetectorDimensions()) print scanRange[0] for imageInScan in range(1, len(imageToBeUsed[scanRange[0]])+1): print ("Scan Line %d" % imageInScan) outputFileName = os.path.join(projectDir, specName + \ ('_N%d.vti' % imageInScan)) gridWriter = VTIGridWriter() tmpImageUsed = imageToBeUsed[scanRange[0]] savImageUsed = imageToBeUsed[scanRange[0]] tmpImageUsed[imageInScan] = False ds.imageToBeUsed[scanRange[0]] = [not i for i in tmpImageUsed] gridMapper = QGridMapper(ds, outputFileName, outputType=BINARY_OUTPUT, transform=UnityTransform3D(), gridWriter=gridWriter, appConfig=appConfig, nx=nx, ny=ny, nz=nz) gridMapper.setProgressUpdater(updateMapperProgress) gridMapper.doMap() ds.imageToBeUsed[scanRange[0]] = savImageUsed