-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathdream_constellation_map.py
More file actions
216 lines (195 loc) · 7.26 KB
/
dream_constellation_map.py
File metadata and controls
216 lines (195 loc) · 7.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
import plotly.graph_objects as go
import numpy as np
import pandas as pd
from sklearn.manifold import MDS
from sklearn.preprocessing import StandardScaler
import networkx as nx
from datetime import datetime
import colorsys
import random
class DreamConstellationMap:
def __init__(self):
# Sample dream data (you can replace this with your own data)
self.dreams = [
{
"theme": "Flying",
"emotions": ["freedom", "joy", "excitement"],
"symbols": ["wings", "clouds", "birds"],
"intensity": 8,
"date": "2024-10-15",
"color_tone": "bright",
"dreamscape": "sky"
},
{
"theme": "Ocean Depths",
"emotions": ["mystery", "peace", "wonder"],
"symbols": ["fish", "coral", "waves"],
"intensity": 7,
"date": "2024-10-16",
"color_tone": "deep",
"dreamscape": "underwater"
},
{
"theme": "Ancient Temple",
"emotions": ["awe", "curiosity", "reverence"],
"symbols": ["statues", "inscriptions", "torch"],
"intensity": 9,
"date": "2024-10-17",
"color_tone": "warm",
"dreamscape": "indoor"
}
]
def _create_star_coordinates(self, n_stars, spread=1):
"""Generate star coordinates in a spiral galaxy pattern"""
theta = np.random.uniform(0, 2*np.pi, n_stars)
radius = np.random.normal(loc=0.5, scale=0.2, size=n_stars) * spread
x = radius * np.cos(theta)
y = radius * np.sin(theta)
z = np.random.normal(0, 0.1, n_stars)
return x, y, z
def _generate_star_colors(self, n_stars):
"""Generate realistic star colors based on temperature"""
# Simulate star temperatures (2000K to 12000K)
temperatures = np.random.uniform(2000, 12000, n_stars)
colors = []
for temp in temperatures:
# Approximate star color based on temperature
if temp < 3500:
# Red stars
hue = 0.0
elif temp < 5000:
# Orange/Yellow stars
hue = 0.08
elif temp < 6000:
# Yellow stars
hue = 0.16
elif temp < 7500:
# White stars
hue = 0.6
else:
# Blue stars
hue = 0.7
# Convert HSV to RGB
rgb = colorsys.hsv_to_rgb(hue, 0.3, 1.0)
colors.append(f'rgb({int(rgb[0]*255)},{int(rgb[1]*255)},{int(rgb[2]*255)})')
return colors
def _create_nebula_effect(self, n_points=1000):
"""Create a colorful nebula effect in the background"""
x = np.random.normal(0, 1, n_points)
y = np.random.normal(0, 1, n_points)
z = np.random.normal(0, 0.1, n_points)
# Create different colored nebula regions
colors = []
for _ in range(n_points):
hue = random.choice([0.7, 0.1, 0.9]) # Blue, Red, Purple
sat = random.uniform(0.5, 1.0)
val = random.uniform(0.1, 0.3)
rgb = colorsys.hsv_to_rgb(hue, sat, val)
colors.append(f'rgba({int(rgb[0]*255)},{int(rgb[1]*255)},{int(rgb[2]*255)},0.1)')
return x, y, z, colors
def create_constellation_map(self):
"""Create the main constellation map visualization"""
# Create figure
fig = go.Figure()
# Add nebula background
neb_x, neb_y, neb_z, neb_colors = self._create_nebula_effect(2000)
fig.add_trace(go.Scatter3d(
x=neb_x, y=neb_y, z=neb_z,
mode='markers',
marker=dict(
size=2,
color=neb_colors,
opacity=0.1
),
hoverinfo='none',
showlegend=False
))
# Create star field
n_stars = 500
star_x, star_y, star_z = self._create_star_coordinates(n_stars)
star_colors = self._generate_star_colors(n_stars)
# Add background stars
fig.add_trace(go.Scatter3d(
x=star_x, y=star_y, z=star_z,
mode='markers',
marker=dict(
size=2,
color=star_colors,
opacity=0.8
),
hoverinfo='none',
showlegend=False
))
# Create dream theme nodes
themes = [dream['theme'] for dream in self.dreams]
theme_x, theme_y, theme_z = self._create_star_coordinates(len(themes), spread=0.5)
# Add dream theme "constellations"
fig.add_trace(go.Scatter3d(
x=theme_x, y=theme_y, z=theme_z,
mode='markers+text',
marker=dict(
size=10,
color=['#FFD700', '#7EB0D5', '#B793F5'],
symbol='star',
opacity=0.8
),
text=themes,
textposition='top center',
hovertemplate=(
"<b>Theme:</b> %{text}<br>" +
"<b>Emotions:</b> %{customdata[0]}<br>" +
"<b>Symbols:</b> %{customdata[1]}<br>" +
"<b>Intensity:</b> %{customdata[2]}"
),
customdata=[
[
', '.join(dream['emotions']),
', '.join(dream['symbols']),
dream['intensity']
] for dream in self.dreams
],
name='Dream Themes'
))
# Connect related themes with constellation lines
for i in range(len(themes)-1):
fig.add_trace(go.Scatter3d(
x=[theme_x[i], theme_x[i+1]],
y=[theme_y[i], theme_y[i+1]],
z=[theme_z[i], theme_z[i+1]],
mode='lines',
line=dict(
color='rgba(255, 255, 255, 0.3)',
width=2
),
hoverinfo='none',
showlegend=False
))
# Update layout for cosmic theme
fig.update_layout(
template='plotly_dark',
scene=dict(
xaxis=dict(showgrid=False, showticklabels=False, visible=False),
yaxis=dict(showgrid=False, showticklabels=False, visible=False),
zaxis=dict(showgrid=False, showticklabels=False, visible=False),
bgcolor='rgba(0,0,0,0.95)',
camera=dict(
up=dict(x=0, y=0, z=1),
center=dict(x=0, y=0, z=0),
eye=dict(x=1.5, y=1.5, z=1.5)
),
),
title=dict(
text='🌌 Dream Constellation Map',
font=dict(size=24, color='#E3E3E3'),
y=0.95
),
showlegend=False,
margin=dict(l=0, r=0, t=50, b=0)
)
return fig
if __name__ == "__main__":
# Create visualization
constellation_map = DreamConstellationMap()
fig = constellation_map.create_constellation_map()
# Show the interactive visualization
fig.show()