8700fab4d82154271f3bcce8ca9967581c6c9185,plantcv/plantcv/hyperspectral/analyze_index.py,,analyze_index,#,15

Before Change



    // Auto calculate max_bin if set
    if type(max_bin) is str and (max_bin.upper() == "AUTO"):
        maxval = round(observed_max, 8)  // Auto bins will detect maxval to use for calculating labels/bins
    if type(min_bin) is str and (min_bin.upper() == "AUTO"):
        b = round(observed_min, 8) // If bin_min is auto then overwrite starting value

    // Print a warning if observed min/max outside user defined range
    if observed_max > maxval or observed_min < b:
        print("WARNING!!! The observed range of pixel values in your masked index provided is [" + str(observed_min) +
              ", " + str(observed_max) + "] but the user defined range of bins for pixel frequencies is [" + str(b) +
              ", " + str(maxval) + "]. Adjust min_bin and max_bin in order to avoid cutting off data being collected.")

    // Calculate histogram
    hist_val = [float(l[0]) for l in cv2.calcHist([masked_array.astype(np.float32)], [0], None, [bins], [b, maxval])]
    bin_width = (maxval - b) / float(bins)
    bin_labels = [float(b)]
    plotting_labels = [float(b)]
    for i in range(bins - 1):
        b += bin_width
        bin_labels.append(b)
        plotting_labels.append(round(b, 2))

    // Make hist percentage for plotting
    pixels = cv2.countNonZero(mask)
    hist_percent = [(p / float(pixels)) * 100 for p in hist_val]

    params.debug = debug

    if histplot is True:
        dataset = pd.DataFrame({"Index Reflectance": bin_labels,
                                "Proportion of pixels (%)": hist_percent})
        fig_hist = (ggplot(data=dataset,
                           mapping=aes(x="Index Reflectance",
                                       y="Proportion of pixels (%)"))
                    + geom_line(color="red")
                    + scale_x_continuous(breaks=bin_labels, labels=plotting_labels))
        analysis_image = fig_hist
        if params.debug == "print":
            fig_hist.save(os.path.join(params.debug_outdir, str(params.device) +
                                                            index_array.array_type + "hist.png"))

After Change



    // Auto calculate max_bin if set
    if type(max_bin) is str and (max_bin.upper() == "AUTO"):
        maxval = float(round(observed_max, 8))  // Auto bins will detect maxval to use for calculating labels/bins
    if type(min_bin) is str and (min_bin.upper() == "AUTO"):
        b = float(round(observed_min, 8))  // If bin_min is auto then overwrite starting value


    // Print a warning if observed min/max outside user defined range
    if observed_max > maxval or observed_min < b:
        print("WARNING!!! The observed range of pixel values in your masked index provided is [" + str(observed_min) +
              ", " + str(observed_max) + "] but the user defined range of bins for pixel frequencies is [" + str(b) +
              ", " + str(maxval) + "]. Adjust min_bin and max_bin in order to avoid cutting off data being collected.")


    // Calculate histogram
    hist_val = [float(l[0]) for l in cv2.calcHist([masked_array.astype(np.float32)], [0], None, [bins], [b, maxval])]
    bin_width = (maxval - b) / float(bins)
    bin_labels = [float(b)]
    plotting_labels = [float(b)]
    for i in range(bins - 1):
        b += bin_width
        bin_labels.append(b)
        plotting_labels.append(round(b, 2))

    // Make hist percentage for plotting
    pixels = cv2.countNonZero(mask)
    hist_percent = [(p / float(pixels)) * 100 for p in hist_val]

    params.debug = debug

    if histplot is True:
        dataset = pd.DataFrame({"Index Reflectance": bin_labels,
                                "Proportion of pixels (%)": hist_percent})
        fig_hist = (ggplot(data=dataset,
                           mapping=aes(x="Index Reflectance",
                                       y="Proportion of pixels (%)"))
                    + geom_line(color="red")
                    + scale_x_continuous(breaks=bin_labels, labels=plotting_labels))
        analysis_image = fig_hist
        if params.debug == "print":
            fig_hist.save(os.path.join(params.debug_outdir, str(params.device) +
                                                            index_array.array_type + "hist.png"))
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 2

Instances


Project Name: danforthcenter/plantcv
Commit Name: 8700fab4d82154271f3bcce8ca9967581c6c9185
Time: 2020-03-05
Author: haleyschuhl@gmail.com
File Name: plantcv/plantcv/hyperspectral/analyze_index.py
Class Name:
Method Name: analyze_index


Project Name: librosa/librosa
Commit Name: 63bd15c73405d208b5b4b7a4776f7524585743ab
Time: 2013-09-25
Author: brm2132@columbia.edu
File Name: librosa/beat.py
Class Name:
Method Name: onset_estimate_bpm