Skip to content
Snippets Groups Projects
Commit 095b558f authored by Yhony Mamani Arce's avatar Yhony Mamani Arce
Browse files

Trabajo

parent c83ed64e
No related branches found
No related tags found
No related merge requests found
.ipynb_checkpoints/
ENTREGA.html 0 → 100644
source diff could not be displayed: it is too large. Options to address this: view the blob.
%% Cell type:markdown id: tags:
## Yhony Mamani Arce
# Diagrama de Hertzsprung-Russell (H-R)
%% Cell type:markdown id: tags:
El diagram H-R se observa que las estrellas no se distribuyen al azar sino que se agrupan en el espacio según su magnitud luminosa y su temperatura. Las estrellas, además, evolucionan y cambian su luminosidad y temperatura a lo largo de su vida. De acuerdo con la etapa evolutiva en la que se encuentren, ocupan una zona en el diagrama H-R. A partir de él se puede inferir la luminosidad, la magnitud, el tipo espectral o color, la composición química y la etapa de evolución de una estrella.
<img src="">
%% Cell type:markdown id: tags:
## Ejercicios 1: Diagrama H-R
%% Cell type:markdown id: tags:
Importamos las librerias a usar
%% Cell type:code id: tags:
``` python
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.animation as animation
```
%% Cell type:markdown id: tags:
**Paso 1:** Importamos los datos y asignamos los ejes del plano cartesiano
%% Cell type:code id: tags:
``` python
data0 = pd.read_csv("data/supergiants.txt", header=0, delim_whitespace=True)
x0 = data0.iloc[:,1]
y0 = data0.iloc[:,0]
a0 = data0.iloc[:,2]
```
%% Cell type:markdown id: tags:
Graficamos para cada carpeta que contiene los datos
%% Cell type:code id: tags:
``` python
fig, ax0 = plt.subplots()
for i in range(len(a0)):
ax0.scatter(x0[i],y0[i], s=a0[i])
ax0.invert_xaxis()
plt.xlabel('Temperatura (ºK)')
plt.ylabel('Luminosidad')
plt.title('Diagrama de Hertzsprung-Russell')
plt.show
```
%% Output
<function matplotlib.pyplot.show(close=None, block=None)>
%% Cell type:markdown id: tags:
Hacemos lo mismo para los siguientes datos
%% Cell type:code id: tags:
``` python
data1 = pd.read_csv("data/ms.csv", header=0)
x1 = data1.iloc[:,1]
y1 = data1.iloc[:,0]
a1 = data1.iloc[:,2]
```
%% Cell type:code id: tags:
``` python
fig, ax1 = plt.subplots()
for i in range(len(a1)):
ax1.scatter(x1[i],y1[i], s=a1[i])
ax1.invert_xaxis()
plt.xlabel('Temperatura (ºK)')
plt.ylabel('Luminosidad')
plt.title('Diagrama de Hertzsprung-Russell')
plt.show
```
%% Output
<function matplotlib.pyplot.show(close=None, block=None)>
%% Cell type:code id: tags:
``` python
data2 = pd.read_csv("data/giants.txt", header=0, delim_whitespace=True)
x2 = data2.iloc[:,1]
y2 = data2.iloc[:,0]
a2 = data2.iloc[:,2]
```
%% Cell type:code id: tags:
``` python
fig, ax2 = plt.subplots()
for i in range(len(a2)):
ax2.scatter(x2[i],y2[i], s=a2[i])
ax2.invert_xaxis()
plt.xlabel('Temperatura (ºK)')
plt.ylabel('Luminosidad')
plt.title('Diagrama de Hertzsprung-Russell')
plt.show
```
%% Output
<function matplotlib.pyplot.show(close=None, block=None)>
%% Cell type:code id: tags:
``` python
data3 = pd.read_csv("data/dwarfs.csv", header=0)
x3 = data3.iloc[:,1]
y3 = data3.iloc[:,0]
a3 = data3.iloc[:,2]
```
%% Cell type:code id: tags:
``` python
fig, ax3 = plt.subplots()
for i in range(len(a3)):
ax3.scatter(x3[i],y3[i], s=a3[i])
ax3.invert_xaxis()
plt.xlabel('Temperatura (ºK)')
plt.ylabel('Luminosidad')
plt.title('Diagrama de Hertzsprung-Russell')
plt.show
```
%% Output
<function matplotlib.pyplot.show(close=None, block=None)>
%% Cell type:markdown id: tags:
**Paso 2:** Unimos todos los datos
%% Cell type:code id: tags:
``` python
x = pd.concat([x0,x1,x2,x3])
y = pd.concat([y0,y1,y2,y3])
a = pd.concat([a0,a1,a2,a3])
```
%% Cell type:markdown id: tags:
**Paso 3:** Gracifamos todos los datos en uno solo
%% Cell type:code id: tags:
``` python
fig, ax = plt.subplots()
for j in range(90):
ax.scatter(x[j],y[j], s=a[j])
ax.invert_xaxis() # Invertimos el eje
plt.xlabel('Temperatura (ºK)')
plt.ylabel('Luminosidad')
plt.title('Diagrama de Hertzsprung-Russell')
plt.show
```
%% Output
<function matplotlib.pyplot.show(close=None, block=None)>
%% Cell type:markdown id: tags:
## Ejercicios 2: Animacion
%% Cell type:code id: tags:
``` python
!jupyter nbconvert --to html ENTREGA.ipynb
```
%% Output
[NbConvertApp] Converting notebook ENTREGA.ipynb to html
[NbConvertApp] Writing 632662 bytes to ENTREGA.html
%% Cell type:code id: tags:
``` python
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment