Feature #948

Feature #287: IntensityData campaign

Implement new IntensityData object with improved usability

Added by pospelov about 5 years ago. Updated over 4 years ago.

Status:ArchivedStart date:02 Feb 2015
Priority:NormalDue date:
Assignee:pospelov% Done:

0%

Category:-
Target version:Sprint 29

Description

Consider creation of new IntensityData object to replace current typedefs in PythonAPI

typedef OutputData<double> IntensityData;

  • New IntensityData has to have a convenient set of constructors to create either 1D or 2D objects
  • with histogramming functionality (Fill(Phi_f, alpha_f, weight))
  • with convenient access to axes bin information
  • with slicing possibility (2D->1D)
  • with integrated masking
  • with integrated weights (for fitting)
  • with rebinning functionality

What will be the relation of this class with the Detector class?

figure_1.png (140 KB) pospelov, 23 Sep 2015 14:46

figure_2.png (279 KB) pospelov, 23 Sep 2015 14:47

History

#1 Updated by pospelov about 5 years ago

  • Description updated (diff)
  • Parent task set to #287

#2 Updated by pospelov almost 5 years ago

  • Status changed from Sprint to Backlog
  • Target version deleted (Sprint 26)

#3 Updated by herck almost 5 years ago

  • Target version set to Sprint 27

#4 Updated by herck almost 5 years ago

  • Status changed from Backlog to Sprint

#5 Updated by herck almost 5 years ago

  • Status changed from Sprint to Backlog

#6 Updated by herck almost 5 years ago

  • Target version deleted (Sprint 27)

#7 Updated by pospelov almost 5 years ago

  • Status changed from Backlog to Sprint
  • Target version set to Sprint 28

#8 Updated by herck over 4 years ago

  • Status changed from Sprint to Backlog

#9 Updated by herck over 4 years ago

  • Target version deleted (Sprint 28)

#10 Updated by pospelov over 4 years ago

  • Status changed from Backlog to Sprint
  • Target version set to Sprint 29

#11 Updated by pospelov over 4 years ago

  • Assignee set to pospelov

#12 Updated by pospelov over 4 years ago

Two new classes are available: Histogram1D and Histogram2D. See code examples
Suggestions on API are welcome.

def test_histograms_from_intensity():
    """ 
    Making 2D histograms from intensity data, making profiles
    """ 
    data = ba.IntensityDataIOFactory.readIntensityData("/home/pospelov/development/git/gisas/support/001_ElisabethJosten/data/004_230_P144_cut1.int.gz")

    h2 = ba.Histogram2D(data)

    plt.figure(1)

    # standard color map for 2D histogram
    plt.subplot(2, 2, 1)
    plt.imshow(h2.getArray(), norm=matplotlib.colors.LogNorm(), extent=[h2.getXmin(), h2.getXmax(), h2.getYmin(), h2.getYmax()])

    # making crop
    plt.subplot(2, 2, 2)
    crop = h2.crop(0.026, 0.008, 0.030, 0.013)
    plt.imshow(crop.getArray(), norm=matplotlib.colors.LogNorm(), extent=[crop.getXmin(), crop.getXmax(), crop.getYmin(), crop.getYmax()])

    # Projection along Y. Making 3 slices at 3 different x-values
    plt.subplot(2, 2, 3)
    proj = h2.projectionY(0.015)
    plt.semilogy(proj.getBinCenters(), proj.getBinValues()) # proj.getBinValues() is equivalent proj.getArray()
    proj = h2.projectionY(0.016)
    plt.semilogy(proj.getBinCenters(), proj.getBinValues())
    proj = h2.projectionY(0.017)
    plt.semilogy(proj.getBinCenters(), proj.getBinValues())

    # Projection along Y. comparing slice at certain x-value with averaged slice (averaged between [xlow, xup])
    plt.subplot(2, 2, 4)
    proj = h2.projectionY(0.016)
    plt.semilogy(proj.getBinCenters(), proj.getBinValues())
    proj = h2.projectionY(0.015, 0.017)
    plt.semilogy(proj.getBinCenters(), proj.getArray(ba.IHistogram.AVERAGE))

def test_a_la_ROOT():
    """ 
    ROOT like histogramming, with access to accumulated value, bin average, ben errors and bin number of entries
    """ 
    plt.figure(2)

    h2 = ba.Histogram2D(100, -10.0, 10.0, 100, 0.0, 20.0)

    for i in range(0, 100000):
        x = -10.0+20.0*random.random()
        y = 20.0*random.random()
        h2.fill(x, y, sinc(x, y))

    # bin content (accumulated value in the bin)
    plt.subplot(2, 2, 1)
    im = plt.imshow(h2.getArray(), extent=[h2.getXmin(), h2.getXmax(), h2.getYmin(), h2.getYmax()])
    plt.colorbar(im)

    # bin average
    plt.subplot(2, 2, 2)
    im = plt.imshow(h2.getArray(ba.IHistogram.AVERAGE), extent=[h2.getXmin(), h2.getXmax(), h2.getYmin(), h2.getYmax()])
    plt.colorbar(im)

    # bin error (RMS calculated over entries)
    plt.subplot(2, 2, 3)
    im = plt.imshow(h2.getArray(ba.IHistogram.ERROR), extent=[h2.getXmin(), h2.getXmax(), h2.getYmin(), h2.getYmax()])
    plt.colorbar(im)

    # number of entries in the bin
    plt.subplot(2, 2, 4)
    im = plt.imshow(h2.getArray(ba.IHistogram.NENTRIES), extent=[h2.getXmin(), h2.getXmax(), h2.getYmin(), h2.getYmax()])
    plt.colorbar(im)

#13 Updated by pospelov over 4 years ago

  • Status changed from Resolved to Archived

Also available in: Atom PDF