Exemplo n.º 1
0
def photonStatistics(stack):
    """ """

    number_of_images = stack.shape[0]
    photons = numpy.sum(stack, axis=(1, 2))
    avg_photons = numpy.mean(photons)
    rms_photons = numpy.std(photons)

    print("*************************")
    print("avg = %6.5e" % (avg_photons))
    print("std = %6.5e" % (rms_photons))
    print("*************************")

    # Plot histogram.
    plt.figure()
    max_photon_number = int(numpy.max(photons))
    min_photon_number = int(numpy.min(photons))
    if max_photon_number == min_photon_number:
        max_photon_number += 1

    binwidth = max_photon_number - min_photon_number
    number_of_bins = min(20, number_of_images)
    binwidth = int(binwidth / number_of_bins)

    plt.hist(photons,
             bins=range(min_photon_number, max_photon_number, binwidth),
             facecolor='red',
             alpha=0.75)
    plt.xlim([min_photon_number, max_photon_number])
    plt.xlabel("Photons")
    plt.ylabel("Histogram")
    plt.title("Photon number histogram")
Exemplo n.º 2
0
def photonStatistics(stack):
    """ """

    number_of_images = stack.shape[0]
    photons = numpy.sum(stack, axis=(1, 2))
    avg_photons = numpy.mean(photons)
    rms_photons = numpy.std(photons)

    meanPerPattern = numpy.mean(stack, axis=(1, 2))
    # average over the mean nphotons of each pattern in the stack
    avg_mean = numpy.mean(meanPerPattern)

    maxPerPattern = numpy.max(stack, axis=(1, 2))
    # average over the max nphotons of each pattern in the stack
    avg_max = numpy.mean(maxPerPattern)

    minPerPattern = numpy.min(stack, axis=(1, 2))
    # average over the min nphotons of each pattern in the stack
    avg_min = numpy.mean(minPerPattern)

    print("*************************")
    print("Photon number statistics per pattern")
    print("avg = %6.5e" % (avg_photons))
    print("std = %6.5e" % (rms_photons))
    print("Photon number statistics per pixel")
    print("avg_mean_pixel = %6.5e" % (avg_mean))
    print("avg_max_pixel = %6.5e" % (avg_max))
    print("avg_min_pixel = %6.5e" % (avg_min))
    print("*************************")

    # Plot histogram.
    plt.figure()
    max_photon_number = int(numpy.max(photons))
    min_photon_number = int(numpy.min(photons))
    if max_photon_number == min_photon_number:
        max_photon_number += 1

    binwidth = max_photon_number - min_photon_number
    number_of_bins = min(20, number_of_images)
    binwidth = int(binwidth / number_of_bins)

    plt.hist(photons,
             bins=range(min_photon_number, max_photon_number, binwidth),
             facecolor='red',
             alpha=0.75)
    plt.xlim([min_photon_number, max_photon_number])
    plt.xlabel("Photons")
    plt.ylabel("Histogram")
    plt.title("Photon number histogram")