Mushfi commited on
Commit
02c80dc
·
1 Parent(s): 1da1cb9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -38
app.py CHANGED
@@ -1,50 +1,34 @@
1
  import gradio as gr
2
  #import tensorflow as tf
3
  import os
4
- #import numpy as np
5
- #import pandas as pd
6
 
7
- def k():
8
- return gr.update(value=None)
9
-
10
- def predict_input_image(file):
11
- #df = pd.DataFrame(file)
12
- return '0.1854984', '8.68441'
13
 
14
  with gr.Blocks(title="Forecasting Geomagnetic Storms", css="") as demo:
15
  with gr.Row():
16
  textmd = gr.Markdown('''
17
- # Forecasting Geomagnetic Storms
 
 
 
18
  ''')
19
- with gr.Row():
20
- with gr.Column(scale=1, min_width=600):
21
- textmd1 = gr.Markdown('''
22
- ## Inputs
23
- Solar wind data should be composed of solar-wind readings from the satellites, in the form of a csv file with the following columns:
24
- bx_gse, by_gse, bz_gse, theta_gse, phi_gse, bx_gsm, by_gsm, bz_gsm, theta_gsm, phi_gsm, bt, density, speed, temperature, source
25
- ''')
26
- file1 = gr.File(label="Solar Wind Data (7 days)")
27
- textmd2 = gr.Markdown('''
28
- The satellite positions data should be composed of the daily positions of the DSCOVR and ACE Spacecrafts in Geocentric Solar Ecliptic (GSE) Coordinates for projections in the XY, XZ, and YZ planes. The csv file should have the following columns:
29
- gse_x, gse_y, gse_z
30
- ''')
31
- file2 = gr.File(label="Satellite Positions Data (7 days)")
32
- number = gr.inputs.Number(label="Latest Subspot Number")
33
 
34
- with gr.Row():
35
- clear_btn = gr.Button("Clear")
36
- submit_btn = gr.Button("Submit", elem_id="warning", variant='primary')
37
- #label = gr.outputs.Label(num_top_classes=4)
38
- #label = gr.HTML(value="<div style='height:300px; border-width: 1px; border-color: #000000; border-radius: 5px;'></div>")
39
- with gr.Column(scale=1, min_width=300):
40
- textmd = gr.Markdown('''
41
- ## Outputs
42
- Predicted value of the Disturbance Storm-Time Index (Dst) at time t hour and t+1 hour
43
- ''')
44
- label1 = gr.outputs.Textbox(label="Dst value (t)")
45
- label2 = gr.outputs.Textbox(label="Dst value (t+1)")
46
-
47
- clear_btn.click(k, inputs=[], outputs=file1)
48
- submit_btn.click(predict_input_image, inputs=file1, outputs=[label1, label2])
49
 
50
  demo.launch(debug='False', share=False)
 
1
  import gradio as gr
2
  #import tensorflow as tf
3
  import os
4
+ import numpy as np
5
+ import pandas as pd
6
 
7
+ df = pd.read_csv('/content/graph.csv')
8
+ start_datetime = pd.to_datetime('2011-01-01 00:00:00')
9
+ df['datetime'] = start_datetime + pd.to_timedelta(df['timestep'], unit='h')
 
 
 
10
 
11
  with gr.Blocks(title="Forecasting Geomagnetic Storms", css="") as demo:
12
  with gr.Row():
13
  textmd = gr.Markdown('''
14
+ # Forecasting Geomagnetic Storms
15
+ DST (Disturbance Storm Time) index is a measure of the strength of geomagnetic storms
16
+ `predicted_t0` is the predicted DST value at the current hour
17
+ `predicted_t1` is the predicted DST value at the next hour
18
  ''')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
+ with gr.Row():
21
+ line = gr.LinePlot(
22
+ df,
23
+ x="datetime",
24
+ y="DST",
25
+ color="name",
26
+ color_legend_position="bottom",
27
+ title="Graph of Predicted DST values and Ground Truth",
28
+ tooltip=["datetime", "DST", "name"],
29
+ height=600,
30
+ width=1000,
31
+ interactive=True,
32
+ )
 
 
33
 
34
  demo.launch(debug='False', share=False)