Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ejercicios-clase-03-datos
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yineth Melissa Pérez Ayala
ejercicios-clase-03-datos
Commits
1d6c359f
Commit
1d6c359f
authored
4 years ago
by
Yineth Melissa Pérez Ayala
Browse files
Options
Downloads
Patches
Plain Diff
Update ejercicio2-1.ipynb
parent
fb22b6fe
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ejercicio2-1.ipynb
+125
-1
125 additions, 1 deletion
ejercicio2-1.ipynb
with
125 additions
and
1 deletion
ejercicio2-1.ipynb
+
125
−
1
View file @
1d6c359f
prueba
#Tarea de la clase 3. Melissa Pérez
#En este primer punto se pretende reproducir el diagrama de Hertzprung-Russell que describe la evolución estelar.
import matplotlib.pyplot as plt
#Se importa la librería matplotlib la cuál se usará para hacer la gráfica.
# Install a pip package in the current Jupyter kernel
import sys
!{sys.executable} -m pip install numpy
Requirement already satisfied: numpy in /home/perezy/.local/lib/python3.7/site-packages (1.20.1)
import sys
!{sys.executable} -m pip install pandas
import sys
!{sys.executable} -m pip install pandas
Requirement already satisfied: pandas in /home/perezy/.local/lib/python3.7/site-packages (1.2.2)
Requirement already satisfied: python-dateutil>=2.7.3 in /usr/local/lib/python3.7/dist-packages (from pandas) (2.8.1)
Requirement already satisfied: numpy>=1.16.5 in /home/perezy/.local/lib/python3.7/site-packages (from pandas) (1.20.1)
Requirement already satisfied: pytz>=2017.3 in /usr/local/lib/python3.7/dist-packages (from pandas) (2020.1)
Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2.7.3->pandas) (1.12.0)
import pandas
data = pandas.read_csv("data_dwarfs.csv")
#Se instalan las librerías pandas y numpy con el fin de leer los datos
print(data)
lum temp radius
0 0.000109 5050.644696 7.096930
1 0.000128 5967.543450 4.583996
2 0.000230 6674.161524 4.151078
3 0.000269 7216.762974 3.491754
4 0.000472 7795.184395 3.472736
5 0.000613 8402.695283 3.077338
lum = list(data["lum"])
temp = list(data["temp"])
radius = list(data["radius"])
colores = []
for i in range(len(temp)):
colores.append(2**13)
lum = list(data["lum"])
temp = list(data["temp"])
radius = list(data["radius"])
colores = []
for i in range(len(temp)):
colores.append(2**13)
data = pandas.read_csv("data_ms.csv")
lum = lum + list(data["lum"])
temp = temp + list(data["temp"])
radius = radius + list(data["radius"])
colores = colores + list(data["temp"])
data = pandas.read_csv("data_ms.csv")
lum = lum + list(data["lum"])
temp = temp + list(data["temp"])
radius = radius + list(data["radius"])
colores = colores + list(data["temp"])
data = pandas.read_csv("data_supergiants.txt", sep=" ")
print(data)
lum = lum + list(data["lum"])
temp = temp + list(data["temp"])
radius = radius + list(data["radius"])
colores = colores + list(data["temp"])
data = pandas.read_csv("data_supergiants.txt", sep=" ")
print(data)
lum = lum + list(data["lum"])
temp = temp + list(data["temp"])
radius = radius + list(data["radius"])
colores = colores + list(data["temp"])
lum temp radius
0 359749.335156 3801.042587 278.055832
1 416869.383470 4398.962354 190.278395
2 1000000.000000 5465.163392 140.809113
3 920449.571753 7837.395137 46.187556
4 779830.110523 10200.701561 19.604244
data = pandas.read_csv("data_giants.txt", sep=" ")
print(data)
lum = lum + list(data["lum"])
temp = temp + list(data["temp"])
radius = radius + list(data["radius"])
colores = colores + list(data["temp"])
data = pandas.read_csv("data_giants.txt", sep=" ")
print(data)
lum = lum + list(data["lum"])
temp = temp + list(data["temp"])
radius = radius + list(data["radius"])
colores = colores + list(data["temp"])
lum temp radius
0 304.228573 3654.601099 145.483474
1 58.884366 3808.609875 66.642938
2 9.246982 3991.751692 27.603430
3 58.505945 4164.818180 50.832968
4 32.033176 4425.773883 33.290931
#Se traen los datos y se van agregando a tres listas lum, temp y radius.
#También se crea la lista colores con la que se establece el color de las enanas blancas.
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
fig.figsize=(12,10)
ax.scatter(temp, lum, s=radius, c=colores, cmap = 'coolwarm_r',alpha=1)
ax.set_xlabel("Temperatura ($K$)", fontsize=15)
ax.set_ylabel("Luminosidad ($L_s$)", fontsize=15)
ax.set_xlim(15000, 3000)
ax.set_ylim(0.00001, 10000000)
plt.xscale("log", base=2)
plt.yscale("log")
ax.set_title('HRD')
plt.xticks([12000,9000,6000,3000],[12000,9000,6000,3000])
plt.yticks([10**-5,10**-2,10**1,10**4,10**7])
ax.grid(True)
fig.tight_layout()
plt.text(8000, 10**-3, 'Enanas blancas')
plt.text(12000, 1, 'Sequencia principal')
plt.text(11000, 10**5, 'Gigantes azules')
plt.text(4500, 1, 'Gigantes rojas')
plt.text(5000, 12000, 'Super gigantes')
plt.show()
#Se crea el gráfico definiendo cada uno de sus elementos para que sea lo más similar posible.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment