sifaaral commited on
Commit
d48bea6
·
verified ·
1 Parent(s): ac9ed7d

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +118 -0
  2. requirements.txt +10 -0
app.py ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import plotly.graph_objects as go
3
+
4
+ # Function to create spheres
5
+ def spheres(diameter, color, distance):
6
+ return go.Scatter3d(
7
+ x=[distance],
8
+ y=[0],
9
+ z=[0],
10
+ mode='markers',
11
+ marker=dict(size=diameter, color=color, opacity=0.8),
12
+ name='Planet'
13
+ )
14
+
15
+ # Function to create orbits
16
+ def orbits(distance, color='#ffffff', width=1):
17
+ return go.Scatter3d(
18
+ x=[distance],
19
+ y=[0],
20
+ z=[0],
21
+ mode='lines',
22
+ line=dict(color=color, width=width),
23
+ name='Orbit'
24
+ )
25
+
26
+ # Function to create annotations
27
+ def annot(x, y, text, xancr='center'):
28
+ return dict(
29
+ x=x,
30
+ y=y,
31
+ text=text,
32
+ showarrow=True,
33
+ arrowhead=2,
34
+ ax=0,
35
+ ay=-40,
36
+ xanchor=xancr
37
+ )
38
+
39
+ # Diameter and distance data
40
+ diameter_km = [200000, 4878, 12104, 12756, 6787, 142796, 120660, 51118, 48600]
41
+ diameter = [((i / 12756) * 2) for i in diameter_km]
42
+ distance_from_sun = [0, 57.9, 108.2, 149.6, 227.9, 778.6, 1433.5, 2872.5, 4495.1]
43
+
44
+ # Create spheres for the Sun and planets
45
+ trace0 = spheres(diameter[0], '#ffff00', distance_from_sun[0]) # Sun
46
+ trace1 = spheres(diameter[1], '#87877d', distance_from_sun[1]) # Mercury
47
+ trace2 = spheres(diameter[2], '#d23100', distance_from_sun[2]) # Venus
48
+ trace3 = spheres(diameter[3], '#325bff', distance_from_sun[3]) # Earth
49
+ trace4 = spheres(diameter[4], '#b20000', distance_from_sun[4]) # Mars
50
+ trace5 = spheres(diameter[5], '#ebebd2', distance_from_sun[5]) # Jupiter
51
+ trace6 = spheres(diameter[6], '#ebcd82', distance_from_sun[6]) # Saturn
52
+ trace7 = spheres(diameter[7], '#37ffda', distance_from_sun[7]) # Uranus
53
+ trace8 = spheres(diameter[8], '#2500ab', distance_from_sun[8]) # Neptune
54
+
55
+ # Set up orbit traces
56
+ trace11 = orbits(distance_from_sun[1]) # Mercury
57
+ trace12 = orbits(distance_from_sun[2]) # Venus
58
+ trace13 = orbits(distance_from_sun[3]) # Earth
59
+ trace14 = orbits(distance_from_sun[4]) # Mars
60
+ trace15 = orbits(distance_from_sun[5]) # Jupiter
61
+ trace16 = orbits(distance_from_sun[6]) # Saturn
62
+ trace17 = orbits(distance_from_sun[7]) # Uranus
63
+ trace18 = orbits(distance_from_sun[8]) # Neptune
64
+
65
+ # Additional rings for Saturn
66
+ rings = [orbits(23 + i, '#827962', 3) for i in range(6)]
67
+
68
+ # Layout configuration
69
+ layout = go.Layout(
70
+ title='Solar System',
71
+ showlegend=False,
72
+ margin=dict(l=0, r=0, t=0, b=0),
73
+ scene=dict(
74
+ xaxis=dict(
75
+ title='Distance from the Sun',
76
+ titlefont_color='black',
77
+ range=[-7000, 7000],
78
+ backgroundcolor='black',
79
+ color='black',
80
+ gridcolor='black'
81
+ ),
82
+ yaxis=dict(
83
+ title='Distance from the Sun',
84
+ titlefont_color='black',
85
+ range=[-7000, 7000],
86
+ backgroundcolor='black',
87
+ color='black',
88
+ gridcolor='black'
89
+ ),
90
+ zaxis=dict(
91
+ title='',
92
+ range=[-7000, 7000],
93
+ backgroundcolor='black',
94
+ color='white',
95
+ gridcolor='black'
96
+ ),
97
+ annotations=[
98
+ annot(distance_from_sun[0], 40, 'Sun', xancr='left'),
99
+ annot(distance_from_sun[1], 5, 'Mercury'),
100
+ annot(distance_from_sun[2], 9, 'Venus'),
101
+ annot(distance_from_sun[3], 9, 'Earth'),
102
+ annot(distance_from_sun[4], 7, 'Mars'),
103
+ annot(distance_from_sun[5], 30, 'Jupiter'),
104
+ annot(distance_from_sun[6], 28, 'Saturn'),
105
+ annot(distance_from_sun[7], 20, 'Uranus'),
106
+ annot(distance_from_sun[8], 20, 'Neptune'),
107
+ ]
108
+ )
109
+ )
110
+
111
+ # Create the figure
112
+ fig = go.Figure(data=[trace0, trace1, trace2, trace3, trace4, trace5, trace6, trace7, trace8,
113
+ trace11, trace12, trace13, trace14, trace15, trace16, trace17, trace18] + rings,
114
+ layout=layout)
115
+
116
+ # Streamlit app layout
117
+ st.title('Solar System Visualization')
118
+ st.plotly_chart(fig, use_container_width=True)
requirements.txt ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ streamlit
2
+ tensorflow
3
+ opencv-python
4
+ scikit-learn
5
+ torch
6
+ torchvision
7
+ matplotlib
8
+ transformers
9
+ sentencepiece
10
+ plotly