AliceTt commited on
Commit
319e1da
·
1 Parent(s): 25d0ed1

added formatting

Browse files
Files changed (3) hide show
  1. .gitignore +3 -1
  2. app.py +195 -42
  3. func_utils.py +3 -8
.gitignore CHANGED
@@ -1,3 +1,5 @@
1
  .env
2
  __pycache__/
3
- .venv/
 
 
 
1
  .env
2
  __pycache__/
3
+ .venv/
4
+ .data/climate_data_moderate/*
5
+ .data/climate_data_pessimist/*
app.py CHANGED
@@ -7,7 +7,6 @@ import pandas as pd
7
 
8
  import os
9
  from func_utils import *
10
- from summary_test import generate_irradiance_trend, get_mocked_summary
11
 
12
 
13
  def go_to_page_1():
@@ -21,13 +20,70 @@ with gr.Blocks() as demo:
21
  gr.HTML(
22
  """
23
  <style>
24
- /* Custom style for a specific row */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  .box {
26
- background-color: #90909b;
 
 
 
 
 
 
 
27
  border-radius: 10px;
28
  display: flex;
29
  align-content: center;
30
  padding: 20px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  }
32
  .culture_box {
33
  background-color: #52525b;
@@ -43,100 +99,197 @@ with gr.Blocks() as demo:
43
  .padding.svelte-phx28p{
44
  padding: 0px;
45
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  </style>
47
  """
48
  )
49
  demo.title = "Démo GAIA - Les bénéfices de l'ombrage"
50
- gr.HTML("<h1 style='text-align: center;'>Les bénéfices de l'ombrage</h1>")
51
  gr.HTML(
52
- "<p style=''>Découvrez le potentiel de l'ombrage sur votre exploitation !</p>"
 
 
 
53
  )
54
 
55
  with gr.Blocks() as infos:
56
 
57
  infos.title = "Informations sur votre exploitation"
58
- gr.HTML("<h2>Renseignez les informations relatives à votre projet</h2>")
 
 
59
  with gr.Row(equal_height=True):
60
- with gr.Column(variant="panel", scale=1):
61
- with gr.Row(equal_height=True, elem_classes="box"):
62
- with gr.Tab(label="Adresse", scale=1):
 
 
63
  address = gr.Textbox(
64
  label="Addresse",
65
- info="Adresse de votre projet",
 
66
  )
67
  with gr.Tab(label="Coordonnées GPS", scale=1):
68
  lat = gr.Number(
69
- label="Latitude",
70
- info="Latitude de votre projet",
71
  )
72
  lon = gr.Number(
73
- label="Longitude",
74
- info="Longitude de votre projet",
75
  )
76
  place_btn = gr.Button(
77
- value="Valider la localisation", size="sm"
 
 
78
  )
79
  place_cancel_btn = gr.Button(
80
- value="Réinitialiser la localisation", size="sm"
 
 
 
81
  )
82
 
83
- with gr.Row(elem_classes="box"):
84
  culture = gr.Dropdown(
85
- label="Culture", scale=1, elem_classes="culture_box", choices=["Blé", "Colza", "Orge"]
 
 
 
86
  )
87
 
88
  with gr.Column(variant="panel", scale=3):
89
  map = gr.HTML()
90
 
91
- simulation_btn = gr.Button(value="Lancer la simulation", size="lg")
 
 
92
 
93
- go_to_page_2_btn = gr.Button("Aller aux résultats", visible=False)
 
 
94
 
95
  page_2 = gr.Column(visible=False)
96
  with page_2:
97
  with gr.Blocks() as results:
98
- results.title = "Résultats"
99
- gr.HTML("<h2>Résultats de la simulation</h2>")
100
- with gr.Row(equal_height=True, elem_classes="box"):
101
- with gr.Tab(label="Analyse générale", scale=1):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  with gr.Row(elem_classes="box"):
103
  with gr.Column():
104
  gr.HTML(
105
- "<h2>Synthèse des Prévisions Météorologiques selon le Scénario Pessimiste</h2>"
106
  )
107
  current_situation_summary = gr.Markdown(
108
  elem_classes="summary"
109
  )
110
  with gr.Row(elem_classes="box"):
111
  with gr.Column():
112
- gr.HTML("<h2>Déficit hydrique</h2>")
 
 
113
  gr.Plot()
114
  with gr.Column():
115
- gr.HTML("<h2>Rendements</h2>")
116
  gr.Plot()
117
- with gr.Column(elem_classes="box"):
118
- with gr.Row():
119
- gr.HTML("<h2>Bilan climatique</h2>")
120
- with gr.Row():
121
- plot_1 = gr.Plot()
122
- plot_2 = gr.Plot()
123
- with gr.Row():
124
- plot_3 = gr.Plot()
125
- with gr.Tab(label="Analyse avec AgriPv", scale=1):
126
  with gr.Row(elem_classes="box"):
127
  with gr.Column():
128
- gr.HTML("<h2>Synthèse des bénéfices avec ombrage</h2>")
 
 
129
  agripv_summary = gr.Markdown(elem_classes="summary")
130
  with gr.Row(elem_classes="box"):
131
  with gr.Column():
132
- gr.HTML("<h2>Déficit hydrique</h2>")
 
 
133
  gr.Plot()
134
  with gr.Column():
135
- gr.HTML("<h2>Rendements</h2>")
136
  gr.Plot()
137
- go_to_page_1_btn = gr.Button(
138
- value="Revenir aux informations du projet", size="lg"
139
- )
140
 
141
  demo.load(on_init, [lat, lon, address], [lat, lon, map])
142
  place_btn.click(on_init, [lat, lon, address], [lat, lon, map])
 
7
 
8
  import os
9
  from func_utils import *
 
10
 
11
 
12
  def go_to_page_1():
 
20
  gr.HTML(
21
  """
22
  <style>
23
+ .gradio-container {
24
+ background-color: #FFFFFF;
25
+ color: #000000;
26
+ },
27
+ .font-color{
28
+ color: #000000;
29
+ }
30
+ .white-background {
31
+ background-color: #FFFFFF !important;
32
+ }
33
+ .card {
34
+ background-color: #FFFFFF !important;
35
+ border: solid 1px;
36
+ border-radius: 10px;
37
+ border-color: #000000;
38
+ display: flex;
39
+ align-content: center;
40
+ padding: 20px;
41
+ }
42
  .box {
43
+ background-color: #FFFFFF !important;
44
+ # border-radius: 10px;
45
+ display: flex;
46
+ align-content: center;
47
+ padding: 20px;
48
+ }
49
+ .result-page {
50
+ background-color: #FFFFFF !important;
51
  border-radius: 10px;
52
  display: flex;
53
  align-content: center;
54
  padding: 20px;
55
+ border: solid 1px;
56
+ border-color: #000000;
57
+ }
58
+ .selected.svelte-1tcem6n.svelte-1tcem6n {
59
+ color: #28C896;
60
+ border-bottom-color: #28C896;
61
+ }
62
+ .selected.svelte-1tcem6n.svelte-1tcem6n:after {
63
+ background-color: #28C896;
64
+ }
65
+ button.svelte-1tcem6n.svelte-1tcem6n {
66
+ color: #000000 !important;
67
+ border-radius: 20px;
68
+ }
69
+ p {
70
+ color: #000000 !important;
71
+ }
72
+ .tab {
73
+ color: #28C896;
74
+ }
75
+ .adress-card {
76
+ background-color: #FFFFFF !important;
77
+ color: #000000;
78
+ }
79
+ span.svelte-1gfkn6j {
80
+ color: #000000 !important;
81
+ }
82
+ span.has-info.svelte-1gfkn6j {
83
+ color: #000000 !important;
84
+ }
85
+ textarea.svelte-173056l.svelte-173056l {
86
+ background-color: #FFFFFF !important;
87
  }
88
  .culture_box {
89
  background-color: #52525b;
 
99
  .padding.svelte-phx28p{
100
  padding: 0px;
101
  }
102
+ .ok-button {
103
+ background-color: #28C896;
104
+ width: 200px !important;
105
+ border-radius: 20px;
106
+ }
107
+ .back-button {
108
+ background-color: #FFFFFF;
109
+ width: 200px !important;
110
+ border-radius: 20px;
111
+ }
112
+ .secondary.svelte-1ixn6qd {
113
+ background: linear-gradient(#28C896, #96E600);
114
+ color: #FFFFFF;
115
+ border-radius: 40px;
116
+ width: 200px !important;
117
+ }
118
+ input[type=number].svelte-7ha85a.svelte-7ha85a {
119
+ background-color: #FFFFFF;
120
+ color: #000000 !important;
121
+ }
122
+ .culture-box {
123
+ background-color: #FFFFFF;
124
+ color: #000000 !important;
125
+ }
126
+ .block.svelte-11xb1hd{
127
+ background-color: #FFFFFF !important;
128
+ color: #000000 !important;
129
+ }
130
+ .culture_box {
131
+ background-color: #FFFFFF !important;
132
+ color: #000000 !important;
133
+ }
134
+ .wrap.svelte-1hfxrpf.svelte-1hfxrpf {
135
+ background-color: #FFFFFF !important;
136
+ color: #000000 !important;
137
+ }
138
+ input.svelte-1hfxrpf.svelte-1hfxrpf {
139
+ background-color: #FFFFFF !important;
140
+ color: #000000 !important;
141
+ }
142
+ .svelte-1hfxrpf{
143
+ background-color: #FFFFFF !important;
144
+ color: #000000 !important;
145
+ }
146
+ button.svelte-1tcem6n.svelte-1tcem6n:hover:not(:disabled):not(.selected) {
147
+ background-color: linear-gradient(#28C896, #96E600);
148
+ }
149
+ .primary.svelte-1ixn6qd{
150
+ background: #FFFFFF;
151
+ color: #000000;
152
+ border-radius: 40px;
153
+ width: 200px !important;
154
+ border: solid 1px;
155
+ border-color: #000000;
156
+ }
157
+ .primary.svelte-1ixn6qd:hover,.primary[disabled].svelte-1ixn6qd {
158
+ background: #28C896;
159
+ }
160
+ .primary.svelte-1ixn6qd:hover {
161
+ border-color: #000000;
162
+ border-shadow: #000000;
163
+ }
164
  </style>
165
  """
166
  )
167
  demo.title = "Démo GAIA - Les bénéfices de l'ombrage"
 
168
  gr.HTML(
169
+ "<h1 style='text-align: center; color: #000000; font-size:xx-large'>Les bénéfices de l'ombrage</h1>"
170
+ )
171
+ gr.HTML(
172
+ "<p style='color: #000000; font-size:x-large; font-weight: 700'>Découvrez le potentiel de l'ombrage sur votre exploitation !</p>"
173
  )
174
 
175
  with gr.Blocks() as infos:
176
 
177
  infos.title = "Informations sur votre exploitation"
178
+ gr.HTML(
179
+ "<h2 style='color: #000000'>Renseignez les informations relatives à votre projet</h2>"
180
+ )
181
  with gr.Row(equal_height=True):
182
+ with gr.Column(
183
+ variant="panel", scale=1, elem_classes=["white-background"]
184
+ ):
185
+ with gr.Row(equal_height=True, elem_classes=["card"]):
186
+ with gr.Tab(label="Adresse", scale=1, elem_classes="tab"):
187
  address = gr.Textbox(
188
  label="Addresse",
189
+ placeholder="Entrez une adresse",
190
+ elem_classes=["adress-card"],
191
  )
192
  with gr.Tab(label="Coordonnées GPS", scale=1):
193
  lat = gr.Number(
194
+ label="Latitude", elem_classes=["white-background"]
 
195
  )
196
  lon = gr.Number(
197
+ label="Longitude", elem_classes=["white-background"]
 
198
  )
199
  place_btn = gr.Button(
200
+ value="Valider la localisation",
201
+ size="md",
202
+ elem_classes=["ok-button"],
203
  )
204
  place_cancel_btn = gr.Button(
205
+ value="Réinitialiser la localisation",
206
+ size="md",
207
+ elem_classes=["back-button"],
208
+ variant="primary"
209
  )
210
 
211
+ with gr.Row(elem_classes=["card"]):
212
  culture = gr.Dropdown(
213
+ label="Culture",
214
+ scale=1,
215
+ elem_classes="culture_box",
216
+ choices=["Blé", "Colza", "Orge"],
217
  )
218
 
219
  with gr.Column(variant="panel", scale=3):
220
  map = gr.HTML()
221
 
222
+ simulation_btn = gr.Button(
223
+ value="Lancer la simulation", size="md", elem_classes=["ok-button"]
224
+ )
225
 
226
+ go_to_page_2_btn = gr.Button(
227
+ "Aller aux résultats", visible=False, elem_classes=["ok-button"], variant="primary"
228
+ )
229
 
230
  page_2 = gr.Column(visible=False)
231
  with page_2:
232
  with gr.Blocks() as results:
233
+ gr.HTML(
234
+ "<h2 style='padding: 30px; color: #000000'>Résultats de la simulation : les conséquences du changement climatique pour l'exploitation jusqu'en 2099</h2>"
235
+ )
236
+ go_to_page_1_btn = gr.Button(
237
+ value="Retour",
238
+ size="md",
239
+ elem_classes=["back-button"],
240
+ variant="primary"
241
+ )
242
+ with gr.Row(equal_height=True, elem_classes="result-page"):
243
+ with gr.Tab(label="Prévisions climatiques", scale=1):
244
+ with gr.Column(elem_classes="box"):
245
+ with gr.Row():
246
+ gr.HTML(
247
+ "<h2 style='color: #000000'>Prévisions climatiques</h2>"
248
+ )
249
+ with gr.Row():
250
+ plot_1 = gr.Plot()
251
+ with gr.Row():
252
+ plot_2 = gr.Plot()
253
+ with gr.Row():
254
+ plot_3 = gr.Plot()
255
+ with gr.Tab(
256
+ label="Prévisions pour l'exploitation sans ombrage", scale=1
257
+ ):
258
  with gr.Row(elem_classes="box"):
259
  with gr.Column():
260
  gr.HTML(
261
+ "<h2 style='color: #000000'>Prévisions spécifiques à l'exploitation, sans solution d'ombrage</h2>"
262
  )
263
  current_situation_summary = gr.Markdown(
264
  elem_classes="summary"
265
  )
266
  with gr.Row(elem_classes="box"):
267
  with gr.Column():
268
+ gr.HTML(
269
+ "<h2 style='color: #000000'>Déficit hydrique</h2>"
270
+ )
271
  gr.Plot()
272
  with gr.Column():
273
+ gr.HTML("<h2 style='color: #000000'>Rendements</h2>")
274
  gr.Plot()
275
+ with gr.Tab(
276
+ label="Prévisions pour l'exploitation avec ombrage", scale=1
277
+ ):
 
 
 
 
 
 
278
  with gr.Row(elem_classes="box"):
279
  with gr.Column():
280
+ gr.HTML(
281
+ "<h2 style='color: #000000'>Synthèse des bénéfices pour l'exploitation suite à la mise en place d'une solution d'ombrage</h2>"
282
+ )
283
  agripv_summary = gr.Markdown(elem_classes="summary")
284
  with gr.Row(elem_classes="box"):
285
  with gr.Column():
286
+ gr.HTML(
287
+ "<h2 style='color: #000000'>Déficit hydrique</h2>"
288
+ )
289
  gr.Plot()
290
  with gr.Column():
291
+ gr.HTML("<h2 style='color: #000000'>Rendements</h2>")
292
  gr.Plot()
 
 
 
293
 
294
  demo.load(on_init, [lat, lon, address], [lat, lon, map])
295
  place_btn.click(on_init, [lat, lon, address], [lat, lon, map])
func_utils.py CHANGED
@@ -2,12 +2,7 @@ import folium
2
  import requests
3
  import gradio as gr
4
 
5
- from summary_test import (
6
- generate_irradiance_trend,
7
- get_mocked_summary,
8
- get_not_shaded_summary,
9
- get_shaded_summary,
10
- )
11
  from visualize.visualize import get_plots
12
 
13
 
@@ -73,8 +68,8 @@ def go_to_page_2():
73
 
74
 
75
  def launch_simulation(lat, lon, address, culture):
76
- current_situation_summary = get_not_shaded_summary()
77
- agripv_summary = get_shaded_summary()
78
  page1, page_2 = go_to_page_2()
79
  plot_1, plot_2, plot_3 = get_plots()
80
  return (
 
2
  import requests
3
  import gradio as gr
4
 
5
+
 
 
 
 
 
6
  from visualize.visualize import get_plots
7
 
8
 
 
68
 
69
 
70
  def launch_simulation(lat, lon, address, culture):
71
+ current_situation_summary = "truc"
72
+ agripv_summary = "bidule"
73
  page1, page_2 = go_to_page_2()
74
  plot_1, plot_2, plot_3 = get_plots()
75
  return (