-
Notifications
You must be signed in to change notification settings - Fork 0
/
04_📊_Synthetic Evolution.py
186 lines (140 loc) · 6.85 KB
/
04_📊_Synthetic Evolution.py
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
# -*- coding: utf-8 -*-
"""
Created on Thu Mar 30 21:34:23 2023
@author: Anderson Almeida
"""
import pandas as pd
from synthetic import *
import streamlit as st
import plotly.express as px
import plotly.graph_objects as go
import numpy as np
import time
from oc_tools_padova_edr3 import *
#load grif isocrones
iso = np.load('full_isoc_Gaia_eDR3_CMD34.npy')
Mlim = 21
st.set_page_config(page_title="Synthetic Oc Evolution",layout='wide', page_icon='✨')
coluna = st.sidebar
placeholder02 = st.empty()
st.text(
"This code is still under development, don't consider its results")
coluna.subheader("Fundamental Parameters")
#number of stars
nstars = coluna.number_input("Initial Members:", value=1000, step=1)
#slider dist
dist_min = 0.1
dist_max = 5.0
dist_standard = 1.0
dist = coluna.slider("Distance (kpc)",
min_value=dist_min,
max_value=dist_max,
value=dist_standard,
step=0.1,
format="%.1f")
#slider Av
av_min = 0.0
av_max = 3.0
av_standard = 1.0
Av = coluna.slider("Av (mag)",
min_value=av_min,
max_value=av_max,
value=av_standard,
step=0.1,
format="%.1f")
#slider meta
meta_min = 0.0152
meta_max = 3.0
meta_standard = 0.1
FeH = coluna.slider("FeH",
min_value=meta_min,
max_value=meta_max,
value=meta_standard,
step=0.1,
format="%.1f")
#slider binaries
bin_frac_min = 0.0
bin_frac_max = 1.0
bin_frac_standard = 0.5
bin_frac = coluna.slider("Binary Fraction",
min_value=bin_frac_min,
max_value=bin_frac_max,
value=bin_frac_standard,
step=0.1,
format="%.1f")
age_range = np.arange(6.6, 10.13, 0.009)
if st.button(" ▶️ Play"):
progress_bar = st.empty()
for i, age in enumerate(age_range):
(mod_cluster_obs, mod_cluster, cor_obs, absMag_obs, fit_iso, total_mass) = synthetic(age,
dist,
Av,
FeH,
bin_frac,
nstars,
Mlim)
# Atualiza a barra de progresso
progress_bar.progress((i+1) / len(age_range))
#update parameters
crop = mod_cluster_obs['Mass'] < 8.0
diff_stars = mod_cluster_obs['Mass'].size - (mod_cluster_obs[crop]).size
nstars = nstars - diff_stars
mod_cluster_obs = mod_cluster_obs[crop]
cor_obs = cor_obs[crop]
absMag_obs = absMag_obs[crop]
###############################################################################################
# CMD com massa
cmd_scatter = pd.DataFrame({'G_BPmag - G_RPmag': cor_obs, 'Gmag': absMag_obs,
'Mass': mod_cluster_obs['Mass']})
cmd_iso = pd.DataFrame({'G_BPmag - G_RPmag': fit_iso['G_BPmag']-fit_iso['G_RPmag'],
'Gmag': fit_iso['Gmag']})
fig1 = px.scatter(cmd_scatter, x = 'G_BPmag - G_RPmag', y = 'Gmag',
opacity=0.6, color= 'Mass', color_continuous_scale = 'jet_r', size=mod_cluster_obs['Mass'])
fig2 = px.line(cmd_iso, x = 'G_BPmag - G_RPmag', y = 'Gmag')
fig01 = go.Figure(data = fig1.data + fig2.data).update_layout(coloraxis=fig1.layout.coloraxis)
fig01.update_layout(xaxis_title= 'G_BP - G_RP (mag)',
yaxis_title="G (mag)",
coloraxis_colorbar=dict(title="M☉"),
yaxis_range=[22,2],
xaxis_range=[-1,6])
###############################################################################################
# CMD com binarias
ind_single = mod_cluster_obs['bin_flag'] == 0
ind_bin = mod_cluster_obs['bin_flag'] == 1
scatter_single = pd.DataFrame({'G_BPmag - G_RPmag': cor_obs[ind_single], 'Gmag': absMag_obs[ind_single]})
scatter_bin = pd.DataFrame({'G_BPmag - G_RPmag': cor_obs[ind_bin], 'Gmag': absMag_obs[ind_bin]})
cmd_iso = pd.DataFrame({'G_BPmag - G_RPmag': fit_iso['G_BPmag']-fit_iso['G_RPmag'],
'Gmag': fit_iso['Gmag']})
fig1 = px.scatter(scatter_single, x = 'G_BPmag - G_RPmag', y = 'Gmag',
opacity=0.9)
fig2 = px.scatter(scatter_bin, x = 'G_BPmag - G_RPmag', y = 'Gmag',
opacity=0.6 , color_discrete_sequence=['orange'])
fig3 = px.line(cmd_iso, x = 'G_BPmag - G_RPmag', y = 'Gmag')
fig02 = go.Figure(data = fig1.data + fig2.data + fig3.data).update_layout(coloraxis=fig1.layout.coloraxis)
fig02.update_layout(xaxis_title= 'G_BP - G_RP (mag)',
yaxis_title="G (mag)",
yaxis_range=[22,2],
xaxis_range=[-1,6])
###############################################################################################
# RA x DEC
# the mass is arranged according to the mass of the primary
ind = np.argsort(mod_cluster_obs['Mass'])
ra_dec = pd.DataFrame({'RA': mod_cluster_obs['RA_ICRS'][ind],
'DEC': mod_cluster_obs['DEC_ICRS'][ind], 'Mass': mod_cluster_obs['Mass'][ind]})
fig_ra_dec = px.scatter(ra_dec, x = 'RA', y = 'DEC', color= 'Mass',
color_continuous_scale = 'jet_r', size=mod_cluster_obs['Mass'])
fig_ra_dec.update_layout(coloraxis_colorbar=dict(title="M☉"),
yaxis_range=[-65.0,-64.7],
xaxis_range=[232.3,232.6])
with placeholder02.container():
st.metric(label='log(age)', value= np.around(age, decimals=2))
st.metric(label="Members", value=nstars)
container1 = st.container()
col1, col2, col3 = st.columns(3)
with container1:
with col1:
st.plotly_chart(fig01, use_container_width=True)
with col2:
st.plotly_chart(fig02, use_container_width=True)
with col3:
st.plotly_chart(fig_ra_dec, use_container_width=True)