コード例 #1
0
def analyseData(dd):
    #ss = dd.sum(0)
    #dnp.plot.image(ss)
    ##ss is the flat field
    print "Calculating median for the dataset ..."
    med = dnp.median(dd, 0)
    print "Median calculated"
    if plotData: dnp.plot.image(med)
    
    Sleep.sleep(2000)
    #flatFieldCorrectedSum = ss/med
    #dnp.plot.image(flatFieldCorrectedSum)
    
    xVals = []
    yVals = []
    ##
    print "Calculating centroid ..."
    centroids = []
    for i in range(18):
        #dnp.plot.image(dd[i, :, :] / med)
        im = dd[i, :, :] / med
        im = javaImage.medianFilter(im, [3, 3])
        im = dnp.array(im)
        threshold = 0.85
        if plotData: dnp.plot.image(im)
        if plotData: Sleep.sleep(1000)
        if plotData: dnp.plot.image(im < threshold)
        if plotData: Sleep.sleep(1000)
        cent = dnp.centroid(im < threshold)
        yVals.append(cent[0])
        xVals.append(cent[1])
        centroids.append(cent)
    print "y:" + `yVals`
    print('')
    print "x:" + `xVals`
    #help(dnp.fit.ellipsefit)
    
    if plotData: dnp.plot.line(dnp.array(xVals), dnp.array(yVals))
    ellipseFitValues = dnp.fit.ellipsefit(xVals, yVals)
    print "major: " + `ellipseFitValues[0]`
    print "minor semi-axis: " + `ellipseFitValues[1]`
    print "major axis angle: " + `ellipseFitValues[2]`
    print "centre co-ord 1: " + `ellipseFitValues[3]`
    print "centre co-ord 2: " + `ellipseFitValues[4]`
    print "centroids:" + `centroids`
    xOffset = getXOffset(ellipseFitValues[1], ellipseFitValues[0])
    zOffset = getZOffset(ellipseFitValues[2])
    return xOffset, zOffset, centroids, ellipseFitValues
コード例 #2
0
def analyseData(dd):
    #ss = dd.sum(0)
    #dnp.plot.image(ss)
    ##ss is the flat field
    print "Calculating median for the dataset ..."
    med = dnp.median(dd, 0)
    print "Median calculated"
    if plotData: dnp.plot.image(med)

    sleep(2)
    #flatFieldCorrectedSum = ss/med
    #dnp.plot.image(flatFieldCorrectedSum)

    xVals = []
    yVals = []
    ##
    print "Calculating centroid ..."
    centroids = []
    for i in range(18):
        #dnp.plot.image(dd[i, :, :] / med)
        im = dd[i, :, :] / med
        im = javaImage.medianFilter(im, [3, 3])
        im = dnp.array(im)
        threshold = 0.85
        if plotData: dnp.plot.image(im)
        if plotData: sleep(1)
        if plotData: dnp.plot.image(im < threshold)
        if plotData: sleep(1)
        cent = dnp.centroid(im < threshold)
        yVals.append(cent[0])
        xVals.append(cent[1])
        centroids.append(cent)
    print "y:" + ` yVals `
    print('')
    print "x:" + ` xVals `
    #help(dnp.fit.ellipsefit)

    if plotData: dnp.plot.line(dnp.array(xVals), dnp.array(yVals))
    ellipseFitValues = dnp.fit.ellipsefit(xVals, yVals)
    print "major: " + ` ellipseFitValues[0] `
    print "minor semi-axis: " + ` ellipseFitValues[1] `
    print "major axis angle: " + ` ellipseFitValues[2] `
    print "centre co-ord 1: " + ` ellipseFitValues[3] `
    print "centre co-ord 2: " + ` ellipseFitValues[4] `
    print "centroids:" + ` centroids `
    xOffset = getXOffset(ellipseFitValues[1], ellipseFitValues[0])
    zOffset = getZOffset(ellipseFitValues[2])
    return xOffset, zOffset, centroids, ellipseFitValues
コード例 #3
0
 def testQuantile(self):
     print 'Quantile testing'
     a = np.array([6., 47., 49., 15., 42., 41., 7., 39., 43., 40., 36., 21.])
     ans = [19.5, 39.5, 42.25]
     self.assertEquals(np.median(a), ans[1])
     iqr = np.iqr(a)
     self.assertEquals(iqr, ans[2] - ans[0])
     qs = np.quantile(a, [0.25, 0.5, 0.75])
     self.checkitems(ans, np.array(qs))
     a.shape = (3,4)
     qs = np.quantile(a, [0.25, 0.5, 0.75], axis=1)
     self.checkitems([12.75, 31., 32.25], qs[0])
     self.checkitems([31., 40., 38.], qs[1])
     self.checkitems([47.5, 41.25, 40.75], qs[2])
     iqr = np.iqr(a, axis=1)
     print type(iqr)
     self.assertEquals(-12.75 + 47.5, iqr[0])
     self.assertEquals(-31. + 41.25, iqr[1])
     self.assertEquals(-32.25 + 40.75, iqr[2])
コード例 #4
0
 def testQuantile(self):
     print 'Quantile testing'
     a = np.array([6., 47., 49., 15., 42., 41., 7., 39., 43., 40., 36., 21.])
     ans = [19.5, 39.5, 42.25]
     self.assertEquals(np.median(a), ans[1])
     iqr = np.iqr(a)
     self.assertEquals(iqr, ans[2] - ans[0])
     qs = np.quantile(a, [0.25, 0.5, 0.75])
     self.checkitems(ans, np.array(qs))
     a.shape = (3,4)
     qs = np.quantile(a, [0.25, 0.5, 0.75], axis=1)
     self.checkitems([12.75, 31., 32.25], qs[0])
     self.checkitems([31., 40., 38.], qs[1])
     self.checkitems([47.5, 41.25, 40.75], qs[2])
     iqr = np.iqr(a, axis=1)
     print type(iqr)
     self.assertEquals(-12.75 + 47.5, iqr[0])
     self.assertEquals(-31. + 41.25, iqr[1])
     self.assertEquals(-32.25 + 40.75, iqr[2])