from make_modis_temp import make_modis_temp from tempfile import tempdir import firebase_admin from firebase_admin import credentials from firebase_admin import db from find_s1_image2 import find_img_value import pandas as pdf from sklearn.metrics import classification_report, confusion_matrix, accuracy_score import statsmodels.api as sm import seaborn as sns sns.set() import traceback from sklearn.ensemble import RandomForestRegressor from sklearn.model_selection import train_test_split import csv import time import json from find_modis_ndvi import find_modis_ndvi import numpy as np from sklearn.cluster import KMeans from find_study_area_values import find_study_area_values from find_study_area_values4 import find_study_area_values4 from make_area_estimate_image import make_area_estimate_image from make_egypt_estimate_image import make_egypt_estimate_image from sentinelhub import WebFeatureService, BBox, CRS, DataSource, MimeType, CRS, BBox, WmsRequest,DataCollection import traceback from get_mask import get_mask from PIL import Image import numpy as np from google.cloud import storage from find_study_area_values import find_study_area_values from find_study_area_values3 import find_study_area_values3 from make_area_estimate_image import make_area_estimate_image from make_egypt_estimate_image import make_egypt_estimate_image from make_area_estimation_image import make_area_estimation_image cred = credentials.Certificate('servicekey.json') x = 0.0003 y = 0.0003 fromdate = '20220701' todate = '20220715' s1_images = ['IW-VH-DB'] s2_images = [] # s1_images = ["B02", "B03", "B04", "B05"] #s2_images = ["RVI-NEW"] try: firebase_admin.initialize_app(cred, {'databaseURL': 'https://farmbase-b2f7e-31c0c.firebaseio.com/'}) except: print('fire running') #get all non_gt farms sentinelSettings = db.reference('SentinelSettings').get() clientID = sentinelSettings["ClientID"] clientSecret = sentinelSettings["ClientSecret"] wmsID = sentinelSettings["WMSID"] rviID = sentinelSettings["RVIID"] demID = sentinelSettings["DEMID"] modisID = sentinelSettings["MODISID"] uid = 'wEJQVaxiZZaaId2aJe6lRJ8Zd0S2' field_obj= db.reference('PaidMonitoredFields').child('PMF').child(uid).get() from_date = '2022-11-20T00:00:00' to_date = '2022-11-25T23:59:59' def get_field_bounds(field_obj): fieldmaxlat = field_obj["FieldMaxLat"] fieldminlat = field_obj["FieldMinLat"] fieldmaxlong = field_obj["FieldMaxLong"] fieldminlong = field_obj["FieldMinLong"] bounds = [fieldminlong,fieldminlat,fieldmaxlong,fieldmaxlat] return bounds make_modis_temp(DataCollection.MODIS, "NDVI", get_field_bounds(field_obj), from_date, to_date, clientID, clientSecret, modisID) #make_modis_temp(satellite, imageType,bounds, from_date, to_date,CLIENT_ID,CLIENT_SECRET,INSTANCE_ID, max_dim)