dt = (t1 - t0) / n # maps [0, n) -> colors # generate a linear interpolation of temperatures # then map the temperatures to colors using black body # color predictions colors = np.zeros(n, dtype=(np.float32, 3)) for i in range(n): temperature = t0 + i * dt x, y, z = galaxy_specrend.spectrum_to_xyz(galaxy_specrend.bb_spectrum, temperature) r, g, b = galaxy_specrend.xyz_to_rgb(galaxy_specrend.SMPTEsystem, x, y, z) r = min((max(r, 0), 1)) g = min((max(g, 0), 1)) b = min((max(b, 0), 1)) colors[i] = galaxy_specrend.norm_rgb(r, g, b) # load the PNG that we use to blend the star with # to provide a circular look to each star. def load_galaxy_star_image(): fname = io.load_data_file('galaxy/star-particle.png') raw_image = io.read_png(fname) return raw_image class Canvas(app.Canvas): def __init__(self): # setup initial width, height app.Canvas.__init__(self, keys='interactive', size=(800, 600))
dt = (t1 - t0) / n # maps [0, n) -> colors # generate a linear interpolation of temperatures # then map the temperatures to colors using black body # color predictions colors = np.zeros(n, dtype=(np.float32, 3)) for i in range(n): temperature = t0 + i * dt x, y, z = galaxy_specrend.spectrum_to_xyz(galaxy_specrend.bb_spectrum, temperature) r, g, b = galaxy_specrend.xyz_to_rgb(galaxy_specrend.SMPTEsystem, x, y, z) r = min((max(r, 0), 1)) g = min((max(g, 0), 1)) b = min((max(b, 0), 1)) colors[i] = galaxy_specrend.norm_rgb(r, g, b) # load the PNG that we use to blend the star with # to provide a circular look to each star. def load_galaxy_star_image(): fname = io.load_data_file('galaxy/star-particle.png') raw_image = io.read_png(fname) return raw_image class Canvas(app.Canvas): def __init__(self): # setup initial width, height