Update app.py
Browse files
app.py
CHANGED
@@ -14,14 +14,14 @@ from glob import glob
|
|
14 |
import wget
|
15 |
|
16 |
##
|
17 |
-
def timer(start_time=None):
|
18 |
if not start_time:
|
19 |
start_time = datetime.now()
|
20 |
return start_time
|
21 |
elif start_time:
|
22 |
thour, temp_sec = divmod((datetime.now() - start_time).total_seconds(), 3600)
|
23 |
tmin, tsec = divmod(temp_sec, 60)
|
24 |
-
print('\n Time taken: %i hours %i minutes and %s seconds.' % (thour, tmin, round(tsec, 2)))
|
25 |
|
26 |
##
|
27 |
def predict(lat, lon):
|
@@ -45,24 +45,25 @@ def predict(lat, lon):
|
|
45 |
return "Choose an area of ivory coast","","","",""
|
46 |
|
47 |
else:
|
48 |
-
|
49 |
df = pd.read_csv("data/frame.csv")
|
50 |
name = find_good_tile(df,point2)
|
51 |
-
timer(
|
52 |
if name ==404:
|
53 |
reponse = "Sentinel-2 does not have data on this location to date"
|
54 |
return reponse,"","","",""
|
55 |
else:
|
56 |
-
|
57 |
path = "https://data354-public-assets.s3.eu-west-3.amazonaws.com/cisentineldata/"
|
58 |
url = path+name
|
59 |
wget.download(url)
|
60 |
-
timer(
|
61 |
|
62 |
-
|
63 |
unzip()
|
64 |
-
timer(
|
65 |
|
|
|
66 |
name,cld_prob,days_ago = select_best_cloud_coverage_tile()
|
67 |
bandes_path_10,bandes_path_20,bandes_path_60,tile_path,path_cld_20,path_cld_60 =paths(name)
|
68 |
# create image dataset
|
@@ -90,6 +91,7 @@ def predict(lat, lon):
|
|
90 |
|
91 |
# NDVI
|
92 |
ndvi_index = ndvi(cord,name)
|
|
|
93 |
|
94 |
# deleted download files
|
95 |
delete_tiles()
|
|
|
14 |
import wget
|
15 |
|
16 |
##
|
17 |
+
def timer(start_time=None, message):
|
18 |
if not start_time:
|
19 |
start_time = datetime.now()
|
20 |
return start_time
|
21 |
elif start_time:
|
22 |
thour, temp_sec = divmod((datetime.now() - start_time).total_seconds(), 3600)
|
23 |
tmin, tsec = divmod(temp_sec, 60)
|
24 |
+
print('\n'+message+' Time taken: %i hours %i minutes and %s seconds.' % (thour, tmin, round(tsec, 2)))
|
25 |
|
26 |
##
|
27 |
def predict(lat, lon):
|
|
|
45 |
return "Choose an area of ivory coast","","","",""
|
46 |
|
47 |
else:
|
48 |
+
start_time_research = timer(None,'research tile')
|
49 |
df = pd.read_csv("data/frame.csv")
|
50 |
name = find_good_tile(df,point2)
|
51 |
+
timer(start_time_research,'research tile')
|
52 |
if name ==404:
|
53 |
reponse = "Sentinel-2 does not have data on this location to date"
|
54 |
return reponse,"","","",""
|
55 |
else:
|
56 |
+
start_time_download = timer(None,'download tile')
|
57 |
path = "https://data354-public-assets.s3.eu-west-3.amazonaws.com/cisentineldata/"
|
58 |
url = path+name
|
59 |
wget.download(url)
|
60 |
+
timer(start_time_download,'download tile')
|
61 |
|
62 |
+
start_time_unzip = timer(None,'unzip data')
|
63 |
unzip()
|
64 |
+
timer(start_time_unzip,'unzip data')
|
65 |
|
66 |
+
start_time_processing = timer(None,'processing data')
|
67 |
name,cld_prob,days_ago = select_best_cloud_coverage_tile()
|
68 |
bandes_path_10,bandes_path_20,bandes_path_60,tile_path,path_cld_20,path_cld_60 =paths(name)
|
69 |
# create image dataset
|
|
|
91 |
|
92 |
# NDVI
|
93 |
ndvi_index = ndvi(cord,name)
|
94 |
+
timer(start_time_processing,'processing data')
|
95 |
|
96 |
# deleted download files
|
97 |
delete_tiles()
|