def potassium_check(k): date1 = date(2019, 7, 16) #actual start date of the crop date2 = date.today() #current date day_count = abs(date2 - date1).days list = [] df = pd.read_csv("potassium_data.csv", header=None) k = int(k) r, c = df.shape #level from 1 to 6 where 1 stands for dry and going on to state 6 fully moist array_level = [[0] * c] * r list = [[]] * r list = df.values.tolist() X_min = np.amin(array_level, axis=0) X_max = np.amax(array_level, axis=0) X_mean = np.mean(array_level, axis=0) X_mid = [] for i in range(0, 134): X_mid.append((X_max[i] + X_min[i]) / 2) check_level = 2 #2 means ok as reuired ###check for the level if (X_mean[day_count] >= 2.3 and X_mean[day_count] <= 2.8): if (k >= 1.6 and k <= 2.2): check_level = 1 #1 means low elif (k < 1.6): check_level = 0 #0 very low elif (X_mean[day_count] >= 2.9): if (k >= 3.4): check_level = 2 elif (k <= 2.3 and k >= 2.8): check_level = 1 elif (k <= 1.6 and k >= 2.2): check_level = 0 elif (X_mean[day_count] >= 1.6 and X_mean[day_count] <= 2.2): if (k < 1.6): check_level = 1 else: check_level = 2 print("done") sms.notification(check_level, "potassium") return X_mean[day_count]
def phosphorous_check(p): date1 = date(yyyy, mm, dd) #actual start date of the crop date2 = date.today() #current date day_count = abs(date2 - date1).days list = [] df = pd.read_csv("phosphorous_data.csv", header=None) p = int(p) r, c = df.shape #level from 1 to 6 where 1 stands for dry and going on to state 6 fully moist array_level = [[0] * c] * r list = [[]] * r list = df.values.tolist() X_min = np.amin(array_level, axis=0) X_max = np.amax(array_level, axis=0) X_mean = np.mean(array_level, axis=0) X_mid = [] for i in range(0, 134): X_mid.append((X_max[i] + X_min[i]) / 2) check_level = 2 #2 means ok as reuired ###check for the level if (X_mean[day_count] >= 2.9 and X_mean[day_count] <= 3.3): if (p >= 2.45 and p <= 2.8): check_level = 1 #1 means low elif (p < 2.45): check_level = 0 #0 very low elif (X_mean[day_count] >= 3.4): if (p >= 3.4): check_level = 2 elif (p <= 2.45 and p >= 2.8): check_level = 0 elif (p <= 3.3 and p >= 2.9): check_level = 1 elif (X_mean[day_count] >= 2.45 and X_mean[day_count] <= 2.8): if (p < 2.45): check_level = 1 else: check_level = 2 sms.notification(check_level, "phosphorous") return X_mean[day_count]
def nitrogen_check(n): date1 = date(yyyy, mm, dd) #actual start date of the crop date2 = date.today() #current date day_count = abs(date2 - date1).days list = [] df = pd.read_csv("nitrogen_data.csv", header=None) n = int(n) r, c = df.shape #level from 1 to 6 where 1 stands for dry and going on to state 6 fully moist array_level = [[0] * c] * r list = [[]] * r list = df.values.tolist() X_min = np.amin(array_level, axis=0) X_max = np.amax(array_level, axis=0) X_mean = np.mean(array_level, axis=0) X_mid = [] for i in range(0, 134): #assumed level range X_mid.append((X_max[i] + X_min[i]) / 2) check_level = 2 #2 means ok as reuired ###check for the level if (X_mean[day_count] >= 3.8 and X_mean[day_count] <= 4.1): if (n >= 3.5 and n <= 3.8): check_level = 1 #1 means low elif (n < 3.5): check_level = 0 #0 very low elif (X_mean[day_count] >= 4.2): if (n >= 4.2): check_level = 2 elif (n >= 3.5 and n < 3.8): check_level = 0 elif (n >= 3.8 and n <= 4.1): check_level = 1 elif (X_mean[day_count] >= 3.5 and X_mean[day_count] < 3.8): if (n < 3.45): check_level = 1 else: check_level = 2 sms.notification(check_level, "nitrogen") return X_mean[day_count]
print(float(upto_sm)) if (float(wl) <= upto_wl and float(sm) >= upto_sm) : if(rain == 0): print("##########################################") print("\nIrrigation is required") print("------------------------------------------") print("Water pump has been turned ON") try: motor.motor_control(upto_wl,upto_sm) except KeyboardInterrupt: print("Keyboard Interrupt!!!") exit(0) sms.notification(2,"Water pump has been turned ON") print("------------------------------------------") print("Water _level has been maintained") print("------------------------------------------") print("Next iteration will be after 6hrs") print("##########################################") else: print("------------------------------------------") print("Rain is expected so do not irrigate ") print("------------------------------------------") print("Next iteration will be after 6hrs") print("------------------------------------------") else : print("------------------------------------------")