Le catalogue Hipparcos.
import csv
import numpy as np
import matplotlib.pyplot as plt
# V/137D Hipparchos
# W = Wolf-Rayet
# L T Y = froides
# R N C S = carbonnées
SpType, Fe_H, B_V, VMag = 0, 1, 2, 3
tout = []
with open('hip99999.tsv', newline='') as csvfile:
spamreader = csv.reader(csvfile, delimiter=';')
for ligne in spamreader:
tout.append(ligne)
maxi = len(tout) - 1
Remarque : emploi du trait de soulignement à la place du signe moins.
spectre = []
b_v = []
vmag = []
for i in range(maxi):
ligne = tout[i]
if (len(ligne[0].strip()) > 0) and (len(ligne[1].strip()) > 0) and len(ligne[2].strip()) > 0 and len(ligne[3].strip()) > 0:
spectre.append(ligne[0].strip())
b_v.append(float(ligne[2]))
vmag.append(float(ligne[3]))
W
.L, T et Y
.R, N, C et S
.Remarque : le code Python a été ici optimisé pour la facilité de lecture. Le fait de réaliser trois boucles au lieu d'une n'est pas idéal sur le plan de la consommation des ressources.
bvwolf, vmagwolf = [], []
bvfroides, vmagfroides = [], []
bvcarbon, vmagcarbon =[], []
for i in range(len(spectre)):
if "W" in spectre[i]:
bvwolf.append(b_v[i])
vmagwolf.append(vmag[i])
for i in range(len(spectre)):
if "L" in spectre[i] or "T" in spectre[i] or "Y" in spectre[i]:
bvfroides.append(b_v[i])
vmagfroides.append(vmag[i])
for i in range(len(spectre)):
if "R" in spectre[i] or "N" in spectre[i] or "C" in spectre[i] or "S" in spectre[i]:
bvcarbon.append(b_v[i])
vmagcarbon.append(vmag[i])
Afin de mettre en évidence la position de chaque type d'étoile sur le diagramme, on en tracera trois.
En fait on utilise le même code Python dont on active ou désactive certaines lignes avec le signe #
.
L'ensembles des 99999 étoiles extraites du catalogue est positionné sur le diagramme par des points gris.
fig = plt.figure(1, figsize=(10,12)) # dimensions du cadre
plt.plot(b_v, vmag, linestyle='none', marker = 'o', c = '#adadad', markersize = 2, label="Catalogue entier")
# plt.plot(bvfroides, vmagfroides, linestyle='none', marker = 'o', markersize = 4, label="L,T,Y = froides")
# plt.plot(bvcarbon, vmagcarbon, linestyle='none', marker = '+', c = '#653030', markersize = 4, label="R,N,C,S= carbonées")
plt.plot(bvwolf, vmagwolf, linestyle='none', marker = 'x', c = 'red', markersize = 3, label="Wolf-Rayet")
axes = plt.gca()
axes.set_xlabel("Couleur : B-V")
axes.set_ylabel("Magnitudes")
axes.invert_yaxis()
plt.legend(loc='right')
fig = plt.figure(1, figsize=(10,12)) # dimensions du cadre
plt.plot(b_v, vmag, linestyle='none', marker = 'o', c = '#adadad', markersize = 2, label="Catalogue entier")
plt.plot(bvfroides, vmagfroides, linestyle='none', marker = 'o', markersize = 4, label="L,T,Y = froides")
# plt.plot(bvcarbon, vmagcarbon, linestyle='none', marker = '+', c = '#653030', markersize = 4, label="R,N,C,S= carbonées")
# plt.plot(bvwolf, vmagwolf, linestyle='none', marker = 'x', c = 'red', markersize = 3, label="Wolf-Rayet")
axes = plt.gca()
axes.set_xlabel("Couleur : B-V")
axes.set_ylabel("Magnitudes")
axes.invert_yaxis()
plt.legend(loc='right')
fig = plt.figure(1, figsize=(10,12)) # dimensions du cadre
plt.plot(b_v, vmag, linestyle='none', marker = 'o', c = '#adadad', markersize = 2, label="Catalogue entier")
# plt.plot(bvfroides, vmagfroides, linestyle='none', marker = 'o', markersize = 4, label="L,T,Y = froides")
plt.plot(bvcarbon, vmagcarbon, linestyle='none', marker = '+', c = '#653030', markersize = 4, label="R,N,C,S= carbonées")
# plt.plot(bvwolf, vmagwolf, linestyle='none', marker = 'x', c = 'red', markersize = 3, label="Wolf-Rayet")
axes = plt.gca()
axes.set_xlabel("Couleur : B-V")
axes.set_ylabel("Magnitudes")
axes.invert_yaxis()
plt.legend(loc='right')
fig = plt.figure(1, figsize=(10,12)) # dimensions du cadre
plt.plot(b_v, vmag, linestyle='none', marker = 'o', c = '#adadad', markersize = 2, label="Catalogue entier")
plt.plot(bvfroides, vmagfroides, linestyle='none', marker = 'o', markersize = 4, label="L,T,Y = froides")
plt.plot(bvcarbon, vmagcarbon, linestyle='none', marker = '+', c = '#653030', markersize = 4, label="R,N,C,S= carbonées")
plt.plot(bvwolf, vmagwolf, linestyle='none', marker = 'x', c = 'red', markersize = 3, label="Wolf-Rayet")
axes = plt.gca()
axes.set_xlabel("Couleur : B-V")
axes.set_ylabel("Magnitudes")
axes.invert_yaxis()
plt.legend(loc='right')
Extensions possibles :