Skip to content

Commit

Permalink
Fixed issue #3, issue #4 and updated README.md (#2)
Browse files Browse the repository at this point in the history
* Updated app.py

Removed - SyntaxError: Non-ASCII character '\xa3' in file but no encoding declared

* Updated README.md

Updated installation instructions

* Added unit flexibility

Resolves Issue#3 by providing a dropdown selection of unit (m and km) according to the .csv file you have uploaded.
  • Loading branch information
rak183 authored and aryadas98 committed Mar 18, 2019
1 parent 6aa5954 commit ddde7f1
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 26 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ cd orbitdeterminator-webapp
Install OrbitDeterminator
```
pip install git+https://github.com/aerospaceresearch/orbitdeterminator
installation guide for orbitdeterminator-https://github.com/aerospaceresearch/orbitdeterminator/blob/master/README.md
if you are using ubuntu, install python3-tk using: sudo apt-get install python3-tk
if you are still getting an error explicitly mention python3 instead of python wherever required during installation
if your system doesn't have python3 then first install python3
```
Install other requirements
```
Expand Down
86 changes: 60 additions & 26 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

import dash
import dash_core_components as dcc
import dash_html_components as html
Expand Down Expand Up @@ -41,8 +43,23 @@ def serve_static(resource):

html.Div('''
Orbit Determinator: A python package to predict satellite orbits.''',id='subtitle'),
html.Div(['''
Choose appropriate unit of length according to the unit used in your .csv file-'''], style={'fontSize': 18,'marginBottom':7},id='unit-selection'),

dcc.Dropdown(
id='my-dropdown',
options=[
{'label': 'Kilometre(km)', 'value': '(km)'},
{'label': 'Metre(m)', 'value': '(m)'},

],
value='(km)'
),

html.Div(id='output-container'),

html.Div('''Upload a csv file below'''),

html.Div(['''Upload a csv file below:'''], style={'fontSize': 20,'marginBottom': 10, 'marginTop': 30}),

html.Div(id='upload-box',
children=dcc.Upload(id='file-upload',
Expand All @@ -55,6 +72,21 @@ def serve_static(resource):
html.Div(id='output-div',children=[dt.DataTable(rows=[{}])])
])



@app.callback(
dash.dependencies.Output('output-container', 'children'),
[dash.dependencies.Input('my-dropdown', 'value')])


def update_output(value):

return '- You have selected "{}" as unit of length.'.format(value)





def parse_file(file_content):
try:
file_content = file_content.split(',')[1]
Expand Down Expand Up @@ -109,16 +141,17 @@ def ground_track(kep,time0):

@app.callback(Output('output-div','children'),
[Input('file-upload','contents'),
Input('file-upload','filename')])
Input('file-upload','filename'),
Input('my-dropdown', 'value')])

def display_file(file_content, file_name):
def display_file(file_content, file_name, dropdown_value):

if file_content is None:
return html.Div(['Choose a file to process it.'])

data = parse_file(file_content)
if (data.shape[0] > 0):
data_dict = [{'No.':'{:03d}'.format(i+1), 't (s)':data[i][0], 'x (km)':data[i][1], 'y (km)':data[i][2], 'z (km)':data[i][3]} for i in range(data.shape[0])]
data_dict = [{'No.':'{:03d}'.format(i+1), 't (s)':data[i][0], 'x '+'{}'.format(dropdown_value):data[i][1], 'y '+'{}'.format(dropdown_value):data[i][2], 'z '+'{}'.format(dropdown_value):data[i][3]} for i in range(data.shape[0])]
kep, res = e_fit.determine_kep(data[:,1:])

# Visuals
Expand Down Expand Up @@ -285,16 +318,16 @@ def display_file(file_content, file_name):
xyz_fig.append_trace(earth_top,2,2)
xyz_fig.append_trace(earth_bottom,2,2)

xyz_fig['layout']['xaxis1'].update(title='x (km)')
xyz_fig['layout']['yaxis1'].update(title='z (km)', scaleanchor='x')
xyz_fig['layout']['xaxis2'].update(title='y (km)', scaleanchor='x')
xyz_fig['layout']['yaxis2'].update(title='z (km)', scaleanchor='x2')
xyz_fig['layout']['xaxis3'].update(title='x (km)', scaleanchor='x')
xyz_fig['layout']['yaxis3'].update(title='y (km)', scaleanchor='x3')
xyz_fig['layout']['xaxis1'].update(title='x '+'{}'.format(dropdown_value))
xyz_fig['layout']['yaxis1'].update(title='z '+'{}'.format(dropdown_value), scaleanchor='x')
xyz_fig['layout']['xaxis2'].update(title='y '+'{}'.format(dropdown_value), scaleanchor='x')
xyz_fig['layout']['yaxis2'].update(title='z '+'{}'.format(dropdown_value), scaleanchor='x2')
xyz_fig['layout']['xaxis3'].update(title='x '+'{}'.format(dropdown_value), scaleanchor='x')
xyz_fig['layout']['yaxis3'].update(title='y '+'{}'.format(dropdown_value), scaleanchor='x3')

xyz_fig['layout']['scene1']['xaxis'].update(showticklabels=True, showspikes=False, title='x (km)')
xyz_fig['layout']['scene1']['yaxis'].update(showticklabels=True, showspikes=False, title='y (km)')
xyz_fig['layout']['scene1']['zaxis'].update(showticklabels=True, showspikes=False, title='z (km)')
xyz_fig['layout']['scene1']['xaxis'].update(showticklabels=True, showspikes=False, title='x '+'{}'.format(dropdown_value))
xyz_fig['layout']['scene1']['yaxis'].update(showticklabels=True, showspikes=False, title='y '+'{}'.format(dropdown_value))
xyz_fig['layout']['scene1']['zaxis'].update(showticklabels=True, showspikes=False, title='z '+'{}'.format(dropdown_value))

xyz_fig['layout'].update(width=1050, height=700, margin={'t':50})
xyz_fig['layout']['legend'].update(orientation='h')
Expand Down Expand Up @@ -437,10 +470,10 @@ def display_file(file_content, file_name):
t_fig.append_trace(rt_cur,4,1)

t_fig['layout']['xaxis1'].update(title='t (s)')
t_fig['layout']['yaxis1'].update(title='x (km)')
t_fig['layout']['yaxis2'].update(title='y (km)', scaleanchor='y')
t_fig['layout']['yaxis3'].update(title='z (km)', scaleanchor='y')
t_fig['layout']['yaxis4'].update(title='|r| (km)', scaleanchor='y', scaleratio=100)
t_fig['layout']['yaxis1'].update(title='x '+'{}'.format(dropdown_value))
t_fig['layout']['yaxis2'].update(title='y '+'{}'.format(dropdown_value), scaleanchor='y')
t_fig['layout']['yaxis3'].update(title='z '+'{}'.format(dropdown_value), scaleanchor='y')
t_fig['layout']['yaxis4'].update(title='|r| '+'{}'.format(dropdown_value), scaleanchor='y', scaleratio=100)

t_fig['layout'].update(width=1050, height=700, margin={'t':50})
t_fig['layout']['legend'].update(orientation='h')
Expand All @@ -455,9 +488,9 @@ def display_file(file_content, file_name):
res_fig.append_trace(res_z,1,3)

res_fig['layout']['yaxis1'].update(title='Frequency')
res_fig['layout']['xaxis1'].update(title='Δx (km)')
res_fig['layout']['xaxis2'].update(title='Δy (km)')
res_fig['layout']['xaxis3'].update(title='Δz (km)')
res_fig['layout']['xaxis1'].update(title='Δx '+'{}'.format(dropdown_value))
res_fig['layout']['xaxis2'].update(title='Δy '+'{}'.format(dropdown_value))
res_fig['layout']['xaxis3'].update(title='Δz '+'{}'.format(dropdown_value))

res_fig['layout'].update(margin={'t':50}, showlegend=False)

Expand Down Expand Up @@ -497,7 +530,7 @@ def display_file(file_content, file_name):
html.Summary('''Computed Keplerian Elements'''),
dt.DataTable(rows=[
{'Element':'Semi-major Axis',
'Value' :str(kep[0][0])+' km'},
'Value' :str(kep[0][0])+'{}'.format(dropdown_value)},
{'Element':'Eccentricity',
'Value' :str(kep[1][0])},
{'Element':'Inclination',
Expand All @@ -511,6 +544,7 @@ def display_file(file_content, file_name):
],editable=False)
], open=True),


html.Details([
html.Summary('''XYZ Plots'''),
dcc.Graph(id='xyz-plot', figure=xyz_fig)
Expand All @@ -530,15 +564,15 @@ def display_file(file_content, file_name):
html.Summary('''Residuals'''),
dcc.Graph(id='res-plot', figure=res_fig),
dt.DataTable(rows=[
{' ':'Maximum','Δx (km)':np.max(res[:,0]),'Δy (km)':np.max(res[:,1]),'Δz (km)':np.max(res[:,2])},
{' ':'Minimum','Δx (km)':np.min(res[:,0]),'Δy (km)':np.min(res[:,1]),'Δz (km)':np.min(res[:,2])},
{' ':'Average','Δx (km)':np.average(res[:,0]),'Δy (km)':np.average(res[:,1]),'Δz (km)':np.average(res[:,2])},
{' ':'Standard Deviation','Δx (km)':np.std(res[:,0]),'Δy (km)':np.std(res[:,1]),'Δz (km)':np.std(res[:,2])}
{' ':'Maximum','Δx '+'{}'.format(dropdown_value):np.max(res[:,0]),'Δy '+'{}'.format(dropdown_value):np.max(res[:,1]),'Δz '+'{}'.format(dropdown_value):np.max(res[:,2])},
{' ':'Minimum','Δx '+'{}'.format(dropdown_value):np.min(res[:,0]),'Δy '+'{}'.format(dropdown_value):np.min(res[:,1]),'Δz '+'{}'.format(dropdown_value):np.min(res[:,2])},
{' ':'Average','Δx '+'{}'.format(dropdown_value):np.average(res[:,0]),'Δy '+'{}'.format(dropdown_value):np.average(res[:,1]),'Δz '+'{}'.format(dropdown_value):np.average(res[:,2])},
{' ':'Standard Deviation','Δx '+'{}'.format(dropdown_value):np.std(res[:,0]),'Δy '+'{}'.format(dropdown_value):np.std(res[:,1]),'Δz '+'{}'.format(dropdown_value):np.std(res[:,2])}
], editable=False)
], open=True),
]
else:
return html.Div('''There was an error processing this file.''')
return html.Div(children=[html.Div('''There was an error processing this file.Try uploading another file in required format.''')])

if __name__ == '__main__':
app.run_server(debug=True)

0 comments on commit ddde7f1

Please sign in to comment.