|
@@ -0,0 +1,555 @@
|
|
|
+import numpy as np
|
|
|
+import time,sys
|
|
|
+import requests
|
|
|
+import json
|
|
|
+import matplotlib
|
|
|
+import matplotlib as mpl
|
|
|
+mpl.use('Agg')
|
|
|
+
|
|
|
+import matplotlib.pyplot as plt
|
|
|
+import datetime
|
|
|
+import os
|
|
|
+import urllib
|
|
|
+import urllib.request
|
|
|
+import urllib.parse
|
|
|
+import base64
|
|
|
+#import cv2
|
|
|
+from PIL import Image
|
|
|
+import time
|
|
|
+def c21():
|
|
|
+ head = {
|
|
|
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36',
|
|
|
+ }
|
|
|
+
|
|
|
+ url = ("http://52.195.10.119/MQTT/c21a.php")
|
|
|
+ res = requests.post(url, headers=head)
|
|
|
+ a =json.loads(res.text)
|
|
|
+ time1a = int(a['time1a'])
|
|
|
+ time2a = int(a['time2a'])
|
|
|
+ time3a = int(a['time3a'])
|
|
|
+ time4a = int(a['time4a'])
|
|
|
+ time5a = int(a['time5a'])
|
|
|
+ time6a = int(a['time6a'])
|
|
|
+ time7a = int(a['time7a'])
|
|
|
+ time8a = int(a['time8a'])
|
|
|
+ time9a = int(a['time9a'])
|
|
|
+ print(time1a)
|
|
|
+ if (time1a == 0):
|
|
|
+ print('wow')
|
|
|
+ elif (time1a == 1):
|
|
|
+ print('1')
|
|
|
+ img21_1()
|
|
|
+ print('2')
|
|
|
+ throw21()
|
|
|
+ print('3')
|
|
|
+ if (time2a == 0):
|
|
|
+ print('wow')
|
|
|
+ elif (time2a == 1):
|
|
|
+ print('1')
|
|
|
+ img21_2()
|
|
|
+ print('2')
|
|
|
+ throw21()
|
|
|
+ print('3')
|
|
|
+ if (time3a == 0):
|
|
|
+ print('wow')
|
|
|
+ elif (time3a == 1):
|
|
|
+ print('1')
|
|
|
+ img21_3()
|
|
|
+ print('2')
|
|
|
+ throw21()
|
|
|
+ print('3')
|
|
|
+ if (time4a == 0):
|
|
|
+ print('wow')
|
|
|
+ elif (time4a == 1):
|
|
|
+ print('1')
|
|
|
+ img21_4()
|
|
|
+ print('2')
|
|
|
+ throw21()
|
|
|
+ print('3')
|
|
|
+ if (time5a == 0):
|
|
|
+ print('wow')
|
|
|
+ elif (time5a == 1):
|
|
|
+ print('1')
|
|
|
+ img21_5()
|
|
|
+ print('2')
|
|
|
+ throw21()
|
|
|
+ print('3')
|
|
|
+ if (time6a == 0):
|
|
|
+ print('wow')
|
|
|
+ elif (time6a == 1):
|
|
|
+ print('1')
|
|
|
+ img21_6()
|
|
|
+ print('2')
|
|
|
+ throw21()
|
|
|
+ print('3')
|
|
|
+ if (time7a == 0):
|
|
|
+ print('wow')
|
|
|
+ elif (time7a == 1):
|
|
|
+ print('1')
|
|
|
+ img21_7()
|
|
|
+ print('2')
|
|
|
+ throw21()
|
|
|
+ print('3')
|
|
|
+ if (time8a == 0):
|
|
|
+ print('wow')
|
|
|
+ elif (time8a == 1):
|
|
|
+ print('1')
|
|
|
+ img21_8()
|
|
|
+ print('2')
|
|
|
+ throw21()
|
|
|
+ print('3')
|
|
|
+ if (time9a == 0):
|
|
|
+ print('wow')
|
|
|
+ elif (time9a == 1):
|
|
|
+ print('1')
|
|
|
+ img21_9()
|
|
|
+ print('2')
|
|
|
+ throw21()
|
|
|
+ print('3')
|
|
|
+def img21_1():
|
|
|
+ ndvis = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvi1/%Y-%m-%d_%H.%M.tif') #ndvi is time.tif
|
|
|
+ ndvia = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia1/%Y-%m-%d_%H.%M.png') #ndvi is time.png
|
|
|
+ ndviajpg = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia/c.png') #ndvi is c.png
|
|
|
+ irt = datetime.datetime.now().strftime('/var/www/html/cust/21/ir1/%Y-%m-%d_%H.%M.tif') # irtif is time.tif
|
|
|
+ nt = datetime.datetime.now().strftime('/var/www/html/cust/21/n1/%Y-%m-%d_%H.%M.tif') # ntif is time.tif
|
|
|
+ irj = datetime.datetime.now().strftime('/var/www/html/cust/21/irj1/%Y-%m-%d_%H.%M.jpg') # irjpg is time.jpg
|
|
|
+ nj = datetime.datetime.now().strftime('/var/www/html/cust/21/nj1/%Y-%m-%d_%H.%M.jpg') # njpg is time.jpg
|
|
|
+ date = datetime.datetime.now().strftime('\n%Y-%m-%d_%H.%Mn')
|
|
|
+
|
|
|
+ rgb_img0 = Image.open('/var/www/html/cust/21/c/a1.tif')
|
|
|
+ ir_img0 = Image.open('/var/www/html/cust/21/c/b1.tif')
|
|
|
+
|
|
|
+ rgb_img0.save(nt)
|
|
|
+ ir_img0.save(irt)
|
|
|
+
|
|
|
+ rgb_img0.save(nj,quality=95)
|
|
|
+ ir_img0.save(irj,quality=95)
|
|
|
+
|
|
|
+ r,_,_ = rgb_img0.split()
|
|
|
+ r = np.asarray(r, dtype=float)
|
|
|
+
|
|
|
+
|
|
|
+ ir,_,_ = ir_img0.split()
|
|
|
+ ir = np.asarray(ir, dtype=float)
|
|
|
+
|
|
|
+
|
|
|
+ ndvi = np.zeros(r.size) # The NDVI image will be the same size as the input image
|
|
|
+
|
|
|
+
|
|
|
+ np.seterr(divide='ignore', invalid='ignore')
|
|
|
+ ndvi = np.true_divide(np.subtract(ir, r), np.add(ir, r))
|
|
|
+
|
|
|
+
|
|
|
+ # Display the results
|
|
|
+ plt.plot(ndvi)
|
|
|
+ plt.imshow(ndvi, cmap=plt.cm.get_cmap('Spectral'))
|
|
|
+ plt.colorbar()
|
|
|
+ #plt.show()
|
|
|
+ plt.savefig(ndvis)
|
|
|
+ plt.savefig(ndvia)
|
|
|
+ plt.savefig(ndviajpg)
|
|
|
+ plt.close('all')
|
|
|
+ f = open('/var/www/html/cust/c21_1.txt','a')
|
|
|
+ f.write(date)
|
|
|
+ f.close()
|
|
|
+ #plt.close(na)
|
|
|
+def img21_2():
|
|
|
+ ndvis = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvi2/%Y-%m-%d_%H.%M.tif') #ndvi is time.tif
|
|
|
+ ndvia = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia2/%Y-%m-%d_%H.%M.png') #ndvi is time.png
|
|
|
+ ndviajpg = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia/c.png') #ndvi is c.png
|
|
|
+ irt = datetime.datetime.now().strftime('/var/www/html/cust/21/ir2/%Y-%m-%d_%H.%M.tif') # irtif is time.tif
|
|
|
+ nt = datetime.datetime.now().strftime('/var/www/html/cust/21/n2/%Y-%m-%d_%H.%M.tif') # ntif is time.tif
|
|
|
+ irj = datetime.datetime.now().strftime('/var/www/html/cust/21/irj2/%Y-%m-%d_%H.%M.jpg') # irjpg is time.jpg
|
|
|
+ nj = datetime.datetime.now().strftime('/var/www/html/cust/21/nj2/%Y-%m-%d_%H.%M.jpg') # njpg is time.jpg
|
|
|
+ date = datetime.datetime.now().strftime('\n%Y-%m-%d_%H.%Mn')
|
|
|
+
|
|
|
+ rgb_img0 = Image.open('/var/www/html/cust/21/c/a2.tif')
|
|
|
+ ir_img0 = Image.open('/var/www/html/cust/21/c/b2.tif')
|
|
|
+
|
|
|
+ rgb_img0.save(nt)
|
|
|
+ ir_img0.save(irt)
|
|
|
+
|
|
|
+ rgb_img0.save(nj,quality=95)
|
|
|
+ ir_img0.save(irj,quality=95)
|
|
|
+
|
|
|
+ r,_,_ = rgb_img0.split()
|
|
|
+ r = np.asarray(r, dtype=float)
|
|
|
+
|
|
|
+
|
|
|
+ ir,_,_ = ir_img0.split()
|
|
|
+ ir = np.asarray(ir, dtype=float)
|
|
|
+
|
|
|
+
|
|
|
+ ndvi = np.zeros(r.size) # The NDVI image will be the same size as the input image
|
|
|
+
|
|
|
+
|
|
|
+ np.seterr(divide='ignore', invalid='ignore')
|
|
|
+ ndvi = np.true_divide(np.subtract(ir, r), np.add(ir, r))
|
|
|
+
|
|
|
+
|
|
|
+ # Display the results
|
|
|
+ plt.plot(ndvi)
|
|
|
+ plt.imshow(ndvi, cmap=plt.cm.get_cmap('Spectral'))
|
|
|
+ plt.colorbar()
|
|
|
+ #plt.show()
|
|
|
+ plt.savefig(ndvis)
|
|
|
+ plt.savefig(ndvia)
|
|
|
+ plt.savefig(ndviajpg)
|
|
|
+ plt.close('all')
|
|
|
+ f = open('/var/www/html/cust/c21_2.txt','a')
|
|
|
+ f.write(date)
|
|
|
+ f.close()
|
|
|
+def img21_3():
|
|
|
+ ndvis = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvi3/%Y-%m-%d_%H.%M.tif') #ndvi is time.tif
|
|
|
+ ndvia = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia3/%Y-%m-%d_%H.%M.png') #ndvi is time.png
|
|
|
+ ndviajpg = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia/c.png') #ndvi is c.png
|
|
|
+ irt = datetime.datetime.now().strftime('/var/www/html/cust/21/ir3/%Y-%m-%d_%H.%M.tif') # irtif is time.tif
|
|
|
+ nt = datetime.datetime.now().strftime('/var/www/html/cust/21/n3/%Y-%m-%d_%H.%M.tif') # ntif is time.tif
|
|
|
+ irj = datetime.datetime.now().strftime('/var/www/html/cust/21/irj3/%Y-%m-%d_%H.%M.jpg') # irjpg is time.jpg
|
|
|
+ nj = datetime.datetime.now().strftime('/var/www/html/cust/21/nj3/%Y-%m-%d_%H.%M.jpg') # njpg is time.jpg
|
|
|
+ date = datetime.datetime.now().strftime('\n%Y-%m-%d_%H.%Mn')
|
|
|
+
|
|
|
+ rgb_img0 = Image.open('/var/www/html/cust/21/c/a3.tif')
|
|
|
+ ir_img0 = Image.open('/var/www/html/cust/21/c/b3.tif')
|
|
|
+
|
|
|
+ rgb_img0.save(nt)
|
|
|
+ ir_img0.save(irt)
|
|
|
+
|
|
|
+ rgb_img0.save(nj,quality=95)
|
|
|
+ ir_img0.save(irj,quality=95)
|
|
|
+
|
|
|
+ r,_,_ = rgb_img0.split()
|
|
|
+ r = np.asarray(r, dtype=float)
|
|
|
+
|
|
|
+
|
|
|
+ ir,_,_ = ir_img0.split()
|
|
|
+ ir = np.asarray(ir, dtype=float)
|
|
|
+
|
|
|
+
|
|
|
+ ndvi = np.zeros(r.size) # The NDVI image will be the same size as the input image
|
|
|
+
|
|
|
+
|
|
|
+ np.seterr(divide='ignore', invalid='ignore')
|
|
|
+ ndvi = np.true_divide(np.subtract(ir, r), np.add(ir, r))
|
|
|
+
|
|
|
+
|
|
|
+ # Display the results
|
|
|
+ plt.plot(ndvi)
|
|
|
+ plt.imshow(ndvi, cmap=plt.cm.get_cmap('Spectral'))
|
|
|
+ plt.colorbar()
|
|
|
+ #plt.show()
|
|
|
+ plt.savefig(ndvis)
|
|
|
+ plt.savefig(ndvia)
|
|
|
+ plt.savefig(ndviajpg)
|
|
|
+ plt.close('all')
|
|
|
+ f = open('/var/www/html/cust/c21_3.txt','a')
|
|
|
+ f.write(date)
|
|
|
+ f.close()
|
|
|
+def img21_4():
|
|
|
+ ndvis = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvi4/%Y-%m-%d_%H.%M.tif') #ndvi is time.tif
|
|
|
+ ndvia = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia4/%Y-%m-%d_%H.%M.png') #ndvi is time.png
|
|
|
+ ndviajpg = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia/c.png') #ndvi is c.png
|
|
|
+ irt = datetime.datetime.now().strftime('/var/www/html/cust/21/ir4/%Y-%m-%d_%H.%M.tif') # irtif is time.tif
|
|
|
+ nt = datetime.datetime.now().strftime('/var/www/html/cust/21/n4/%Y-%m-%d_%H.%M.tif') # ntif is time.tif
|
|
|
+ irj = datetime.datetime.now().strftime('/var/www/html/cust/21/irj4/%Y-%m-%d_%H.%M.jpg') # irjpg is time.jpg
|
|
|
+ nj = datetime.datetime.now().strftime('/var/www/html/cust/21/nj4/%Y-%m-%d_%H.%M.jpg') # njpg is time.jpg
|
|
|
+ date = datetime.datetime.now().strftime('\n%Y-%m-%d_%H.%Mn')
|
|
|
+
|
|
|
+ rgb_img0 = Image.open('/var/www/html/cust/21/c/a4.tif')
|
|
|
+ ir_img0 = Image.open('/var/www/html/cust/21/c/b4.tif')
|
|
|
+
|
|
|
+ rgb_img0.save(nt)
|
|
|
+ ir_img0.save(irt)
|
|
|
+
|
|
|
+ rgb_img0.save(nj,quality=95)
|
|
|
+ ir_img0.save(irj,quality=95)
|
|
|
+
|
|
|
+ r,_,_ = rgb_img0.split()
|
|
|
+ r = np.asarray(r, dtype=float)
|
|
|
+
|
|
|
+
|
|
|
+ ir,_,_ = ir_img0.split()
|
|
|
+ ir = np.asarray(ir, dtype=float)
|
|
|
+
|
|
|
+
|
|
|
+ ndvi = np.zeros(r.size) # The NDVI image will be the same size as the input image
|
|
|
+
|
|
|
+
|
|
|
+ np.seterr(divide='ignore', invalid='ignore')
|
|
|
+ ndvi = np.true_divide(np.subtract(ir, r), np.add(ir, r))
|
|
|
+
|
|
|
+
|
|
|
+ # Display the results
|
|
|
+ plt.plot(ndvi)
|
|
|
+ plt.imshow(ndvi, cmap=plt.cm.get_cmap('Spectral'))
|
|
|
+ plt.colorbar()
|
|
|
+ #plt.show()
|
|
|
+ plt.savefig(ndvis)
|
|
|
+ plt.savefig(ndvia)
|
|
|
+ plt.savefig(ndviajpg)
|
|
|
+ plt.close('all')
|
|
|
+ f = open('/var/www/html/cust/c21_4.txt','a')
|
|
|
+ f.write(date)
|
|
|
+ f.close()
|
|
|
+def img21_5():
|
|
|
+ ndvis = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvi5/%Y-%m-%d_%H.%M.tif') #ndvi is time.tif
|
|
|
+ ndvia = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia5/%Y-%m-%d_%H.%M.png') #ndvi is time.png
|
|
|
+ ndviajpg = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia/c.png') #ndvi is c.png
|
|
|
+ irt = datetime.datetime.now().strftime('/var/www/html/cust/21/ir5/%Y-%m-%d_%H.%M.tif') # irtif is time.tif
|
|
|
+ nt = datetime.datetime.now().strftime('/var/www/html/cust/21/n5/%Y-%m-%d_%H.%M.tif') # ntif is time.tif
|
|
|
+ irj = datetime.datetime.now().strftime('/var/www/html/cust/21/irj5/%Y-%m-%d_%H.%M.jpg') # irjpg is time.jpg
|
|
|
+ nj = datetime.datetime.now().strftime('/var/www/html/cust/21/nj5/%Y-%m-%d_%H.%M.jpg') # njpg is time.jpg
|
|
|
+ date = datetime.datetime.now().strftime('\n%Y-%m-%d_%H.%Mn')
|
|
|
+
|
|
|
+ rgb_img0 = Image.open('/var/www/html/cust/21/c/a5.tif')
|
|
|
+ ir_img0 = Image.open('/var/www/html/cust/21/c/b5.tif')
|
|
|
+
|
|
|
+ rgb_img0.save(nt)
|
|
|
+ ir_img0.save(irt)
|
|
|
+
|
|
|
+ rgb_img0.save(nj,quality=95)
|
|
|
+ ir_img0.save(irj,quality=95)
|
|
|
+
|
|
|
+ r,_,_ = rgb_img0.split()
|
|
|
+ r = np.asarray(r, dtype=float)
|
|
|
+
|
|
|
+
|
|
|
+ ir,_,_ = ir_img0.split()
|
|
|
+ ir = np.asarray(ir, dtype=float)
|
|
|
+
|
|
|
+
|
|
|
+ ndvi = np.zeros(r.size) # The NDVI image will be the same size as the input image
|
|
|
+
|
|
|
+
|
|
|
+ np.seterr(divide='ignore', invalid='ignore')
|
|
|
+ ndvi = np.true_divide(np.subtract(ir, r), np.add(ir, r))
|
|
|
+
|
|
|
+
|
|
|
+ # Display the results
|
|
|
+ plt.plot(ndvi)
|
|
|
+ plt.imshow(ndvi, cmap=plt.cm.get_cmap('Spectral'))
|
|
|
+ plt.colorbar()
|
|
|
+ #plt.show()
|
|
|
+ plt.savefig(ndvis)
|
|
|
+ plt.savefig(ndvia)
|
|
|
+ plt.savefig(ndviajpg)
|
|
|
+ plt.close('all')
|
|
|
+ f = open('/var/www/html/cust/c21_5.txt','a')
|
|
|
+ f.write(date)
|
|
|
+ f.close()
|
|
|
+def img21_6():
|
|
|
+ ndvis = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvi6/%Y-%m-%d_%H.%M.tif') #ndvi is time.tif
|
|
|
+ ndvia = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia6/%Y-%m-%d_%H.%M.png') #ndvi is time.png
|
|
|
+ ndviajpg = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia/c.png') #ndvi is c.png
|
|
|
+ irt = datetime.datetime.now().strftime('/var/www/html/cust/21/ir6/%Y-%m-%d_%H.%M.tif') # irtif is time.tif
|
|
|
+ nt = datetime.datetime.now().strftime('/var/www/html/cust/21/n6/%Y-%m-%d_%H.%M.tif') # ntif is time.tif
|
|
|
+ irj = datetime.datetime.now().strftime('/var/www/html/cust/21/irj6/%Y-%m-%d_%H.%M.jpg') # irjpg is time.jpg
|
|
|
+ nj = datetime.datetime.now().strftime('/var/www/html/cust/21/nj6/%Y-%m-%d_%H.%M.jpg') # njpg is time.jpg
|
|
|
+ date = datetime.datetime.now().strftime('\n%Y-%m-%d_%H.%Mn')
|
|
|
+
|
|
|
+ rgb_img0 = Image.open('/var/www/html/cust/21/c/a6.tif')
|
|
|
+ ir_img0 = Image.open('/var/www/html/cust/21/c/b6.tif')
|
|
|
+
|
|
|
+ rgb_img0.save(nt)
|
|
|
+ ir_img0.save(irt)
|
|
|
+
|
|
|
+ rgb_img0.save(nj,quality=95)
|
|
|
+ ir_img0.save(irj,quality=95)
|
|
|
+
|
|
|
+ r,_,_ = rgb_img0.split()
|
|
|
+ r = np.asarray(r, dtype=float)
|
|
|
+
|
|
|
+
|
|
|
+ ir,_,_ = ir_img0.split()
|
|
|
+ ir = np.asarray(ir, dtype=float)
|
|
|
+
|
|
|
+
|
|
|
+ ndvi = np.zeros(r.size) # The NDVI image will be the same size as the input image
|
|
|
+
|
|
|
+
|
|
|
+ np.seterr(divide='ignore', invalid='ignore')
|
|
|
+ ndvi = np.true_divide(np.subtract(ir, r), np.add(ir, r))
|
|
|
+
|
|
|
+
|
|
|
+ # Display the results
|
|
|
+ plt.plot(ndvi)
|
|
|
+ plt.imshow(ndvi, cmap=plt.cm.get_cmap('Spectral'))
|
|
|
+ plt.colorbar()
|
|
|
+ #plt.show()
|
|
|
+ plt.savefig(ndvis)
|
|
|
+ plt.savefig(ndvia)
|
|
|
+ plt.savefig(ndviajpg)
|
|
|
+ plt.close('all')
|
|
|
+ f = open('/var/www/html/cust/c21_6.txt','a')
|
|
|
+ f.write(date)
|
|
|
+ f.close()
|
|
|
+def img21_7():
|
|
|
+ ndvis = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvi7/%Y-%m-%d_%H.%M.tif') #ndvi is time.tif
|
|
|
+ ndvia = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia7/%Y-%m-%d_%H.%M.png') #ndvi is time.png
|
|
|
+ ndviajpg = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia/c.png') #ndvi is c.png
|
|
|
+ irt = datetime.datetime.now().strftime('/var/www/html/cust/21/ir7/%Y-%m-%d_%H.%M.tif') # irtif is time.tif
|
|
|
+ nt = datetime.datetime.now().strftime('/var/www/html/cust/21/n7/%Y-%m-%d_%H.%M.tif') # ntif is time.tif
|
|
|
+ irj = datetime.datetime.now().strftime('/var/www/html/cust/21/irj7/%Y-%m-%d_%H.%M.jpg') # irjpg is time.jpg
|
|
|
+ nj = datetime.datetime.now().strftime('/var/www/html/cust/21/nj7/%Y-%m-%d_%H.%M.jpg') # njpg is time.jpg
|
|
|
+ date = datetime.datetime.now().strftime('\n%Y-%m-%d_%H.%Mn')
|
|
|
+
|
|
|
+ rgb_img0 = Image.open('/var/www/html/cust/21/c/a7.tif')
|
|
|
+ ir_img0 = Image.open('/var/www/html/cust/21/c/b7.tif')
|
|
|
+
|
|
|
+ rgb_img0.save(nt)
|
|
|
+ ir_img0.save(irt)
|
|
|
+
|
|
|
+ rgb_img0.save(nj,quality=95)
|
|
|
+ ir_img0.save(irj,quality=95)
|
|
|
+
|
|
|
+ r,_,_ = rgb_img0.split()
|
|
|
+ r = np.asarray(r, dtype=float)
|
|
|
+
|
|
|
+
|
|
|
+ ir,_,_ = ir_img0.split()
|
|
|
+ ir = np.asarray(ir, dtype=float)
|
|
|
+
|
|
|
+
|
|
|
+ ndvi = np.zeros(r.size) # The NDVI image will be the same size as the input image
|
|
|
+
|
|
|
+
|
|
|
+ np.seterr(divide='ignore', invalid='ignore')
|
|
|
+ ndvi = np.true_divide(np.subtract(ir, r), np.add(ir, r))
|
|
|
+
|
|
|
+
|
|
|
+ # Display the results
|
|
|
+ plt.plot(ndvi)
|
|
|
+ plt.imshow(ndvi, cmap=plt.cm.get_cmap('Spectral'))
|
|
|
+ plt.colorbar()
|
|
|
+ #plt.show()
|
|
|
+ plt.savefig(ndvis)
|
|
|
+ plt.savefig(ndvia)
|
|
|
+ plt.savefig(ndviajpg)
|
|
|
+ plt.close('all')
|
|
|
+ f = open('/var/www/html/cust/c21_7.txt','a')
|
|
|
+ f.write(date)
|
|
|
+ f.close()
|
|
|
+def img21_8():
|
|
|
+ ndvis = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvi8/%Y-%m-%d_%H.%M.tif') #ndvi is time.tif
|
|
|
+ ndvia = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia8/%Y-%m-%d_%H.%M.png') #ndvi is time.png
|
|
|
+ ndviajpg = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia/c.png') #ndvi is c.png
|
|
|
+ irt = datetime.datetime.now().strftime('/var/www/html/cust/21/ir8/%Y-%m-%d_%H.%M.tif') # irtif is time.tif
|
|
|
+ nt = datetime.datetime.now().strftime('/var/www/html/cust/21/n8/%Y-%m-%d_%H.%M.tif') # ntif is time.tif
|
|
|
+ irj = datetime.datetime.now().strftime('/var/www/html/cust/21/irj8/%Y-%m-%d_%H.%M.jpg') # irjpg is time.jpg
|
|
|
+ nj = datetime.datetime.now().strftime('/var/www/html/cust/21/nj8/%Y-%m-%d_%H.%M.jpg') # njpg is time.jpg
|
|
|
+ date = datetime.datetime.now().strftime('\n%Y-%m-%d_%H.%Mn')
|
|
|
+
|
|
|
+ rgb_img0 = Image.open('/var/www/html/cust/21/c/a8.tif')
|
|
|
+ ir_img0 = Image.open('/var/www/html/cust/21/c/b8.tif')
|
|
|
+
|
|
|
+ rgb_img0.save(nt)
|
|
|
+ ir_img0.save(irt)
|
|
|
+
|
|
|
+ rgb_img0.save(nj,quality=95)
|
|
|
+ ir_img0.save(irj,quality=95)
|
|
|
+
|
|
|
+ r,_,_ = rgb_img0.split()
|
|
|
+ r = np.asarray(r, dtype=float)
|
|
|
+
|
|
|
+
|
|
|
+ ir,_,_ = ir_img0.split()
|
|
|
+ ir = np.asarray(ir, dtype=float)
|
|
|
+
|
|
|
+
|
|
|
+ ndvi = np.zeros(r.size) # The NDVI image will be the same size as the input image
|
|
|
+
|
|
|
+
|
|
|
+ np.seterr(divide='ignore', invalid='ignore')
|
|
|
+ ndvi = np.true_divide(np.subtract(ir, r), np.add(ir, r))
|
|
|
+
|
|
|
+
|
|
|
+ # Display the results
|
|
|
+ plt.plot(ndvi)
|
|
|
+ plt.imshow(ndvi, cmap=plt.cm.get_cmap('Spectral'))
|
|
|
+ plt.colorbar()
|
|
|
+ #plt.show()
|
|
|
+ plt.savefig(ndvis)
|
|
|
+ plt.savefig(ndvia)
|
|
|
+ plt.savefig(ndviajpg)
|
|
|
+ plt.close('all')
|
|
|
+ f = open('/var/www/html/cust/c21_8.txt','a')
|
|
|
+ f.write(date)
|
|
|
+ f.close()
|
|
|
+def img21_9():
|
|
|
+ ndvis = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvi/%Y-%m-%d_%H.%M.tif') #ndvi is time.tif
|
|
|
+ ndvia = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia/%Y-%m-%d_%H.%M.png') #ndvi is time.png
|
|
|
+ ndviajpg = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia/c.png') #ndvi is c.png
|
|
|
+ irt = datetime.datetime.now().strftime('/var/www/html/cust/21/ir/%Y-%m-%d_%H.%M.tif') # irtif is time.tif
|
|
|
+ nt = datetime.datetime.now().strftime('/var/www/html/cust/21/n/%Y-%m-%d_%H.%M.tif') # ntif is time.tif
|
|
|
+ irj = datetime.datetime.now().strftime('/var/www/html/cust/21/irj/%Y-%m-%d_%H.%M.jpg') # irjpg is time.jpg
|
|
|
+ nj = datetime.datetime.now().strftime('/var/www/html/cust/21/nj/%Y-%m-%d_%H.%M.jpg') # njpg is time.jpg
|
|
|
+ date = datetime.datetime.now().strftime('\n%Y-%m-%d_%H.%Mn')
|
|
|
+
|
|
|
+ rgb_img0 = Image.open('/var/www/html/cust/21/c/a.tif')
|
|
|
+ ir_img0 = Image.open('/var/www/html/cust/21/c/b.tif')
|
|
|
+
|
|
|
+ rgb_img0.save(nt)
|
|
|
+ ir_img0.save(irt)
|
|
|
+
|
|
|
+ rgb_img0.save(nj,quality=95)
|
|
|
+ ir_img0.save(irj,quality=95)
|
|
|
+
|
|
|
+ r,_,_ = rgb_img0.split()
|
|
|
+ r = np.asarray(r, dtype=float)
|
|
|
+
|
|
|
+
|
|
|
+ ir,_,_ = ir_img0.split()
|
|
|
+ ir = np.asarray(ir, dtype=float)
|
|
|
+
|
|
|
+
|
|
|
+ ndvi = np.zeros(r.size) # The NDVI image will be the same size as the input image
|
|
|
+
|
|
|
+
|
|
|
+ np.seterr(divide='ignore', invalid='ignore')
|
|
|
+ ndvi = np.true_divide(np.subtract(ir, r), np.add(ir, r))
|
|
|
+
|
|
|
+
|
|
|
+ # Display the results
|
|
|
+ plt.plot(ndvi)
|
|
|
+ plt.imshow(ndvi, cmap=plt.cm.get_cmap('Spectral'))
|
|
|
+ plt.colorbar()
|
|
|
+ #plt.show()
|
|
|
+ plt.savefig(ndvis)
|
|
|
+ plt.savefig(ndvia)
|
|
|
+ plt.savefig(ndviajpg)
|
|
|
+ plt.close('all')
|
|
|
+ f = open('/var/www/html/cust/c21.txt','a')
|
|
|
+ f.write(date)
|
|
|
+ f.close()
|
|
|
+def throw21():
|
|
|
+ dress = '/var/www/html/cust/21/c/'
|
|
|
+ for root, dirs, files in os.walk(dress):
|
|
|
+ print('files: {}'.format(len(files)))
|
|
|
+ if len(files)>=1:
|
|
|
+ files.sort()
|
|
|
+ for f in files:
|
|
|
+ with open(os.path.join(root, f), "rb") as imageFile:
|
|
|
+ str = base64.b64encode(imageFile.read())
|
|
|
+ url = 'http://60.250.156.234/cust/t21.php'
|
|
|
+ values = {'data1':str, 'name':f}
|
|
|
+ data1 = urllib.parse.urlencode(values)
|
|
|
+ data1 = data1.encode('utf-8')
|
|
|
+ req = urllib.request.Request(url, data1)
|
|
|
+ req.add_header('User-Agent','Magic Browser')
|
|
|
+ resp = urllib.request.urlopen(req)
|
|
|
+ respdata1 = resp.read()
|
|
|
+ print(os.path.join(root, f))
|
|
|
+ #print(respdata1)
|
|
|
+ os.remove(os.path.join(root, f))
|
|
|
+ print("ok")
|
|
|
+ url = 'http://52.195.10.119/MQTT/BBtoNDVI.php'
|
|
|
+ data = {'nrs': 'KDARES21'}
|
|
|
+ data = urllib.parse.urlencode(data)
|
|
|
+ data = data.encode('utf-8')
|
|
|
+ req = urllib.request.Request(url, data)
|
|
|
+ req.add_header('User-Agent', 'Magic Browser')
|
|
|
+ resp = urllib.request.urlopen(req)
|
|
|
+ respData = resp.read()
|
|
|
+ print("ok")
|
|
|
+while True:
|
|
|
+ c21()
|