path_2 = askdirectory() # Get Second Day Image path_3 = askdirectory() # Get Third Day Image root.destroy() path = filename.rsplit('/', 1)[0] print path # Get SKY REGION MASK sky_region_mask = ImageProcess.getSkyRegion(path) # Get Sun Orbit among three-day image stream using SUN REGION MASK sun_orbit = [] sun_orbit = ImageProcess.getSunOrbit(path_1, path_2, path_3, sky_region_mask) # Get Centroid of all the Detected Sun in sun_orbit. centroid_list = [] centroid_list = ImageProcess.getCentroidList(sun_orbit) # Fit the centroid list sample to a quadratic equation(general parabola). theta, coeffs = ImageProcess.generalParabola(centroid_list) # Detect sun of test image img_centroid_radius = ImageProcess.sunDetect(filename, sky_region_mask) # percentage = 0.0 if img_centroid_radius is not None and ImageProcess.sunDetectUsingOrbit(img_centroid_radius, theta, coeffs): # Sun Detected! percentage = ImageProcess.calculateCloudCoverage(filename, sky_region_mask, img_centroid_radius) else: percentage = ImageProcess.calculateCloudCoverage(filename, sky_region_mask)
images_d1_filter = images_d1.filter(lambda x: x[0] in l1) images_d21_filter = images_d2.filter(lambda x: x[0] in l2_1) images_d23_filter = images_d2.filter(lambda x: x[0] in l2_3) images_d3_filter = images_d3.filter(lambda x: x[0] in l3) # For each filtered file, apply Sun Detect Function images_d1_sunDetect = images_d1_filter.map(lambda x: ImageProcess.sunDetect(x[1], sky_region_mask.value)) images_d21_sunDetect = images_d21_filter.map(lambda x: ImageProcess.sunDetect(x[1], sky_region_mask.value)) images_d23_sunDetect = images_d23_filter.map(lambda x: ImageProcess.sunDetect(x[1], sky_region_mask.value)) images_d3_sunDetect = images_d3_filter.map(lambda x: ImageProcess.sunDetect(x[1], sky_region_mask.value)) # Sun Intersection Detect. (Note: coalesce to only ONE group to do this.) images_d12_intersect = images_d1_sunDetect.coalesce(1).zip(images_d21_sunDetect.coalesce(1)).filter(lambda x: x[0] is not None and x[1] is not None and ImageProcess.intersectionDetect(x[0], x[1])).collect() images_d23_intersect = images_d3_sunDetect.coalesce(1).zip(images_d23_sunDetect.coalesce(1)).filter(lambda x: x[0] is not None and x[1] is not None and ImageProcess.intersectionDetect(x[0], x[1])).collect() print (images_d12_intersect) print (images_d23_intersect) # Get intersection sun centroid list centroid_list = ImageProcess.getCentroidList(images_d12_intersect + images_d23_intersect) print (centroid_list) # Generate Sun Track try: theta, coeffs = ImageProcess.generalParabola(centroid_list) print ("theta = ", theta) print ("coeffs = ", coeffs) except: print ("Not enough sample to generate sun track")