Skip to content

Instantly share code, notes, and snippets.

@beta-decay
Created May 18, 2018 19:48
Show Gist options
  • Save beta-decay/0861c02f5a01eee00db6d0197a042be0 to your computer and use it in GitHub Desktop.
Save beta-decay/0861c02f5a01eee00db6d0197a042be0 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
import csv, math
import numpy as np
mag = []
bprp = []
with open('files/combined2.csv', 'r') as f:
table = csv.reader(f)
firstLine = True
for row in table:
if firstLine:
firstLine = False
continue
try:
parallax = float(row[9])
apparent_magnitude = float(row[50])
absolute_magnitude = apparent_magnitude + 5 - 5 * (1 + math.log10(1/parallax))
colour = float(row[55])-float(row[60])
mag.append(absolute_magnitude)
bprp.append(colour)
except:
pass
print("Number of stars: ", len(mag))
plt.hist2d(bprp, mag, bins=3500, norm=LogNorm(), cmap="plasma")
plt.ylabel(r"Mean Absolute Magnitude (mag)")
plt.xlabel("Mean BP Mag - Mean RP Mag (mag)")
#plt.xscale("log")
plt.colorbar()
plt.ylim(28, 0)
plt.xlim(-2,6)
#plt.gca().invert_yaxis()
plt.savefig("hertzprung_russell_alldata_colour_hist3.png")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment