def _process(self, ds, xoffset=0, yoffset=0):###dsxaxis, dsyaxis): ## assert(dsyaxis is None) # STUB ## assert(dsxaxis is None) # STUB integrator = Integrate2D() dsy, dsx = integrator.value(ds) dsyaxis = DatasetFactory.createRange(dsy.shape[0]) dsxaxis = DatasetFactory.createRange(dsx.shape[0]) gaussian = Gaussian(dsyaxis.min(), dsyaxis.max(), dsyaxis.max()-dsyaxis.min(), (dsyaxis.max()-dsyaxis.min())*(dsy.max()-dsy.min()) ) gaussian.getParameter(2).setLowerLimit(0) if self.maxwidth is not None: gaussian.getParameter(1).setUpperLimit(self.maxwidth) ansy = Fitter.fit(dsyaxis, dsy, GeneticAlg(0.001), [ gaussian, Offset( dsy.min(),dsy.max() ) ] ) # ansy = DataSetFunctionFitter().fit( dsyaxis, dsy, GeneticAlg(.001), [ gaussian, Offset( dsy.min(),dsy.max() ) ] ) # ansy = ansy.functionOutput gaussian = Gaussian(dsxaxis.min(), dsxaxis.max(), dsxaxis.max()-dsxaxis.min(), (dsxaxis.max()-dsxaxis.min())*(dsx.max()-dsx.min()) ) gaussian.getParameter(2).setLowerLimit(0) if self.maxwidth is not None: gaussian.getParameter(1).setUpperLimit(self.maxwidth) try: ansx = fitplot( dsxaxis, dsx, GeneticAlg(.001), [ gaussian, Offset( dsx.min(),dsx.max() ) ] ) except java.lang.Exception: # Probably cannot find Plot_Manager on the finder ansx = Fitter.fit(dsxaxis, dsx, GeneticAlg(0.001), [ gaussian, Offset( dsx.min(),dsx.max() ) ] ) #dsyaxis = dsyaxis.subSampleMean(dsy.dimensions[0]/2) #dsy = dsy.subSampleMean(dsy.dimensions[0]/2) #dsxaxis = dsxaxis.subSampleMean(dsx.dimensions[0]/2) #dsx = dsx.subSampleMean(dsx.dimensions[0]/2) peaky = ansy.getParameters()[0].getValue() fwhmy = ansy.getParameters()[1].getValue() areay = ansy.getParameters()[2].getValue() offsety = ansy.getParameters()[3].getValue() / dsx.shape[0] peakx = ansx.getParameters()[0].getValue() fwhmx = ansx.getParameters()[1].getValue() areax = ansx.getParameters()[2].getValue() offsetx = ansx.getParameters()[3].getValue() / dsy.shape[0] background = (offsetx+offsety)/2. fwhmarea = fwhmy*fwhmx*pi/4 topy = areay / fwhmy topx = areax / fwhmx if xoffset==None: xoffset=0 if yoffset==None: yoffset=0 return background, peakx+xoffset, peaky+yoffset, topx, topy, fwhmx, fwhmy, fwhmarea
def arange(start, stop=None, step=1, dtype=None): '''Create a 1D dataset of given type where values range from specified start up to but not including stop in given steps Arguments: start -- optional starting value, defaults to 0 stop -- exclusive stop value step -- difference between neighbouring values, defaults to 1 dtype -- defaults to None which means the type is inferred from given start, stop, step values ''' if stop is None: stop = start start = 0 dtype = _translatenativetype(dtype) if dtype is None: if type(start) is _types.ComplexType or type(stop) is _types.ComplexType or type(step) is _types.ComplexType: dtype = complex128 elif type(start) is _types.FloatType or type(stop) is _types.FloatType or type(step) is _types.FloatType: dtype = float64 elif type(start) is _types.IntType or type(stop) is _types.IntType or type(step) is _types.IntType: dtype = int32 else: raise ValueError, "Unknown or invalid type of input value" if dtype == bool: return None return _df.createRange(start, stop, step, dtype.value)
def testSimpleCreation(self): # file = NexusUtils.createNexusFile(self.abspath) # g = file.getGroup("/ScanFileHolder:NXentry/datasets:NXdata", True) # lazy = NexusUtils.createLazyWriteableDataset("heading1", Dataset.FLOAT64, [10, 100000], None, None) # file.createData(g, lazy) # dataIn = DatasetFactory.createRange(lazy.getSize(), Dataset.FLOAT64) # dataIn.shape = lazy.getShape() # lazy.setSlice(None, dataIn, SliceND.createSlice(lazy, None, None)) # file.close() # os.remove(self.abspath) # This cannot work as the saved file is _NOT_ a valid SRS format # sfh.save(AsciiScanFileHolderSaver(self.abspath+"_srs")); # dataIn = DatasetFactory.createRange(1000000, Dataset.FLOAT64) dataIn.shape = [10, 100000] sfh = ScanFileHolder() sfh.addDataSet("heading1", dataIn) # sfh.load(SRSLoader(self.abspath+"_srs"));#@UndefinedVariable # os.remove(self.abspath) sfh.save(SimpleNexusSaver(self.abspath)) file = NexusUtils.openNexusFileReadOnly(self.abspath) g = file.getGroup("/ScanFileHolder:NXentry/datasets:NXdata", False) dataOut = file.getData(g, "heading1").getDataset().getSlice() file.close() if dataIn != dataOut: self.fail("dataIn != dataOut")
def testSimpleCreation(self): abspath = os.path.abspath(TestFileFolder + "/1.nxs") parentPath = os.path.split(abspath)[0] if not os.path.exists(parentPath): os.makedirs(parentPath) file = NexusUtils.createNexusFile(abspath) g = file.getGroup("/ScanFileHolder:NXentry/datasets:NXdata", True) lazy = NexusUtils.createLazyWriteableDataset("heading1", Dataset.FLOAT64, [10, 100000], None, None) file.createData(g, lazy) dataIn = DatasetFactory.createRange(lazy.getSize(), Dataset.FLOAT64) dataIn.shape = lazy.getShape() lazy.setSlice(None, dataIn, SliceND.createSlice(lazy, None, None)) file.close() file = NexusUtils.openNexusFileReadOnly(abspath) g = file.getGroup("/ScanFileHolder:NXentry/datasets:NXdata", False) dataOut = file.getData(g, "heading1").getDataset().getSlice() file.close() self.assertEqual(dataIn, dataOut)
from gda.analysis import RCPPlotter from uk.ac.diamond.scisoft.analysis.plotserver import GuiBean from uk.ac.diamond.scisoft.analysis.plotserver import GuiParameters from org.eclipse.dawnsci.analysis.dataset.roi import RectangularROI, RectangularROIList from org.eclipse.january.dataset import DatasetFactory pp = RCPPlotter() pp.plot("Area Detector", DatasetFactory.createFromObject(range(100))) #This is used to plot on the PlotView #d = DataSet.arange(10000) #d.shape = [100,100] d = DatasetFactory.createRange(10000) d.shape = [100, 100] # or, d = DataSet.arange(10000).reshape((100,100)) in GDA v8.12 pp.imagePlot("Area Detector", d) #This is used to plot on the ImageExploreView pp.plotImageToGrid("Image Explorer", DatasetFactory.ones([20, 30])) pp.plotImageToGrid("Image Explorer", "/home/xr56/temp/p100kImage26455.tif") #RCPPlotter().plotImageToGrid("Image Explorer","/home/xr56/temp/pilatus100K/p686905.tif") RCPPlotter().scanForImages("Image Explorer", "/dls/i06/data/2010/cm1895-1/demoImages") #ROI #Get ROI info