def main():
    outpath = r"/Users/phoetrymaster/Documents/School/Geography/Thesis/GIS In Action/Images/example_fit_process_1.pdf"
    wheat = r"/Users/phoetrymaster/Documents/School/Geography/Thesis/Data/MODIS_KANSAS_2007-2012/reprojected/Refs/2012clip1test2/clip1/wwheat_NDVI_mean.ref"
    corn = r"/Users/phoetrymaster/Documents/School/Geography/Thesis/Data/MODIS_KANSAS_2007-2012/reprojected/Refs/2012clip1test2/clip1/corn_NDVI_mean.ref"
    soy = r"/Users/phoetrymaster/Documents/School/Geography/Thesis/Data/MODIS_KANSAS_2007-2012/reprojected/Refs/2012clip1test2/clip1/soy_NDVI_mean.ref"

    pixel = r"/Users/phoetrymaster/Documents/School/Geography/Thesis/Scripting/Testing/corn_example_point.ref"

    wheatmean = create_rule_image_multiprocessed_bypx.read_reference_file(wheat)[1]
    cornmean = create_rule_image_multiprocessed_bypx.read_reference_file(corn)[1]
    soymean = create_rule_image_multiprocessed_bypx.read_reference_file(soy)[1]

    refs = [('wheat', wheatmean), ('corn', cornmean), ('soy', soymean)]
    print refs

    pixelvalues = create_rule_image_multiprocessed_bypx.read_reference_file(pixel)[1]

    toplot = [(wheatmean, 'b', 'Wheat Signature'), (cornmean, 'y', "Corn Signature"), (soymean, 'g', 'Soy Signature'), (pixelvalues, 'r', 'Unknown Pixel')]

    figure = plt.figure()
    axes = figure.add_subplot(1, 1, 1)

    pdf = PdfPages(outpath)

    for item, color, label in toplot:
        print item
        x, y = create_rule_image_multiprocessed_bypx.get_sort_dates_values(item)

        newy = []
        for value in y:
            newy.append(value / 10000.0)

        axes.plot(x, newy, '{0}-'.format(color), label=label)

    handles, labels = axes.get_legend_handles_labels()

    axes.set_xlabel("Day of Year")
    axes.set_ylabel("NDVI")
    axes.legend(handles, labels, fontsize='small')
    pdf.savefig()
    plt.close(figure)
    pdf.close()

    for crop, ref in refs:
        interp = create_rule_image_multiprocessed_bypx.interpolate_ref(ref)
        result = create_rule_image_multiprocessed_bypx.find_fit(pixelvalues, interp, 0, 0, 'SLSQP', bnds=((0.6, 1.4), (0.6, 1.4), (-10, 10)))
        print(crop + ":")
        print(result)
Esempio n. 2
0
clip5imgs = ["/Users/phoetrymaster/Documents/School/Geography/Thesis/Data/MODIS_KANSAS_2007-2012/reprojected/clips/KansasNDVI_2012_clip5.tif", "/Users/phoetrymaster/Documents/School/Geography/Thesis/Data/MODIS_KANSAS_2007-2012/reprojected/clips/KansasEVI_2012_clip5.tif"]
clip6imgs = ["/Users/phoetrymaster/Documents/School/Geography/Thesis/Data/MODIS_KANSAS_2007-2012/reprojected/clips/KansasNDVI_2012_clip6.tif", "/Users/phoetrymaster/Documents/School/Geography/Thesis/Data/MODIS_KANSAS_2007-2012/reprojected/clips/KansasEVI_2012_clip6.tif"]

imagelist = [clip1imgs, clip2imgs, clip3imgs, clip4imgs, clip5imgs, clip6imgs]

searchstrings = ["soy", "corn", "wwheat", "sorghum", "wwheatsoydbl"]
fitmethods = ["SLSQP"]#, "TNC"]


for method in fitmethods:
    for images in imagelist:
        for img in images:
            name = os.path.splitext(os.path.basename(img))[0]
            if "NDVI" in name:
                type = "NDVI"
            else:
                type = "EVI"

            for reffile, outfolder in zip(reffiles, outfolders):

                refs = {}
                for f in reffile:
                    if type in f:
                        for string in searchstrings:
                            if string + "_" + type in f:
                                error, refs[string] = read_reference_file(f)
                if not error:
                    print refs
                    phenological_classificaion(img, outfolder, name + "_" + method, refs, "ENVI", 17, 16, -500, 0, method, toprint=False)
                else:
                    print "ERROR +++++++++++++++++++++++++++++++++++++++++++++++++++ ERROR"
Esempio n. 3
0
__author__ = 'phoetrymaster'


import create_rule_image_multiprocessed_bypx as d

print d.read_reference_file("/Users/phoetrymaster/Desktop/corn_mean.ref")
Esempio n. 4
0
for locs, imgs, out in clips:
    for img in imgs:
        print "Processing {0}...".format(img)
        if "NDVI" in img:
            postfix = "_NDVI"
        else:
            postfix = "_EVI"
        get_reference_curves(img, locs, 17, 16, outdir=out, filepostfix=postfix)

means = find_files(outroot, "mean.ref")
searchstrings = (["soy", "wwheat", "sorghum", "corn", "wwheatsoydbl"], ["_EVI", "_NDVI"])

for string in searchstrings[0]:
    for vi in searchstrings[1]:
        cropmeans = []
        for mean in means:
            if string + vi in mean:
                cropmeans.append(mean)
        cropname = string + vi
        refvals = []
        for cropmean in cropmeans:
            error, vals = read_reference_file(cropmean)
            if not error:
                refvals.append(vals)
        listedvals = []
        for ref in refvals:
            x, y = get_sort_dates_values(ref)
            listedvals.append(y)
        print cropname
        write_mean_ref_to_txt(cropname, listedvals, 17, 16, outroot, comment="Generated by clipref.py version 0.1")