youl commited on
Commit
e6c27ee
·
1 Parent(s): 2faec43

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -6,12 +6,21 @@ from indices import indices
6
  import xgboost as xgb
7
  import pickle
8
  import json
 
9
  from shapely.geometry import MultiPolygon,shape
10
  from shapely.geometry import Point
11
  from shapely.geometry.polygon import Polygon
12
  from glob import glob
13
  import wget
14
 
 
 
 
 
 
 
 
 
15
 
16
  def predict(lat, lon):
17
  cord = [lon,lat]
@@ -34,15 +43,19 @@ def predict(lat, lon):
34
  return "Choose an area of ivory coast","","","",""
35
 
36
  else:
 
37
  df = pd.read_csv("data/frame.csv")
38
  name = find_good_tile(df,point2)
 
39
  if name ==404:
40
  reponse = "Sentinel-2 does not have data on this location to date"
41
  return reponse,"","","",""
42
  else:
 
43
  path = "https://data354-public-assets.s3.eu-west-3.amazonaws.com/cisentineldata/"
44
  url = path+name
45
  wget.download(url)
 
46
  unzip()
47
  name,cld_prob,days_ago = select_best_cloud_coverage_tile()
48
  bandes_path_10,bandes_path_20,bandes_path_60,tile_path,path_cld_20,path_cld_60 =paths(name)
 
6
  import xgboost as xgb
7
  import pickle
8
  import json
9
+ from datetime import datetime
10
  from shapely.geometry import MultiPolygon,shape
11
  from shapely.geometry import Point
12
  from shapely.geometry.polygon import Polygon
13
  from glob import glob
14
  import wget
15
 
16
+ def timer(start_time=None):
17
+ if not start_time:
18
+ start_time = datetime.now()
19
+ return start_time
20
+ elif start_time:
21
+ thour, temp_sec = divmod((datetime.now() - start_time).total_seconds(), 3600)
22
+ tmin, tsec = divmod(temp_sec, 60)
23
+ print('\n Time taken: %i hours %i minutes and %s seconds.' % (thour, tmin, round(tsec, 2)))
24
 
25
  def predict(lat, lon):
26
  cord = [lon,lat]
 
43
  return "Choose an area of ivory coast","","","",""
44
 
45
  else:
46
+ start_time = timer(None)
47
  df = pd.read_csv("data/frame.csv")
48
  name = find_good_tile(df,point2)
49
+ timer(start_time)
50
  if name ==404:
51
  reponse = "Sentinel-2 does not have data on this location to date"
52
  return reponse,"","","",""
53
  else:
54
+ start_time = timer(None)
55
  path = "https://data354-public-assets.s3.eu-west-3.amazonaws.com/cisentineldata/"
56
  url = path+name
57
  wget.download(url)
58
+ timer(start_time)
59
  unzip()
60
  name,cld_prob,days_ago = select_best_cloud_coverage_tile()
61
  bandes_path_10,bandes_path_20,bandes_path_60,tile_path,path_cld_20,path_cld_60 =paths(name)