Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

wein versus planck model

877 views
Kernel: Python 3 (Ubuntu Linux)

Why do stars have different colors?

An introduction to blackbody radiation

η Carinae

S. Singleton, adapted from

Content:

  • blackbody radiation, Raleigh-Jeans law, Planck law

  • relationships between temperature, energy, emissivity, and observed color

  • relationship between temperature and emissivity

  • stellar emission spectra

Skills:

  • applying functions to arrays

  • numerical integration

  • interactive plots

  • (optional) symbolic manipulation

Background Information

Python Environment

import matplotlib.pyplot as plt import numpy as np import random import pandas as pd %matplotlib inline

Are all stars “red hot”?

Astronomers are interested in knowing the temperature of a star because it provides clues about the star's composition, and the state of matter within. To learn what elements are present in stars, it is necessary to know more about how stellar temperature is measured. In this notebook, we will explore the question What is the relationship between the color of a star and its temperature?

How are stars classified?

In the early part of this century, the director of the Harvard College Observatory, E. C Pickering and his collaborators, Williamina P. S. Flemming, Antonia C. Maury, and Annie J. Cannon, began a large study of nearly a quarter of a million stars. The result of their survey was a stellar classification system https://en.wikipedia.org/wiki/Stellar_classification. Under this scheme, stars are classified into seven lettered categories that describe the surface temperature of a star: O, B, A, F, G, K, M. Class O stars are hottest, while class M stars are coolest. The Sun is a class G star, with a surface temperature of about 5,800 Kelvin. The table below summarizes the stellar classes and a temperature range that defines each.

Surface Temperature (K) Class
30,000 O
11,000-30,000 B
7,500-11,000 A
6,000-7,500 F
5,000-6,000 G
3,500-5,000 K
3,500 M

As a first step in understanding what the color of stars tells us, we will focus upon objects that emit or give off radiation, such as stars and heated solids, and also those that do not emit visible light. We will consider the color and temperature of these objects and answer the question, Are all red objects "red hot"?

Models for Black Body Radiation

A classical model suggesting a blackbody radiator can have any energy.

Bλ=2ckTλ4\begin{equation} B_\lambda = \frac{2ckT}{\lambda^4} \end{equation}

A quantized model suggesting a blackbody radiator comprises oscillators of discrete energies.

ρ(λ,T)  dλ=8πhcλ5(ehc/λkT1)  dλ\begin{equation} \rho(\lambda, T)\;d\lambda = \frac{8 \pi h c}{\lambda^5 \left (e^{hc/\lambda kT} -1 \right ) } \;d\lambda \end{equation}

Plotting these model functions gives these curves:

CTQ 1 Using SI units for each term in the Planck equation, determine the units for ρ\rho. (Answer: J/m2s)

CTQ 2 There are two curves labeled 5000K, representing two different models. Match the curves with their model functions. Why do the curves have dramatically different shapes? (Hint: examine the terms in each model function).

CTQ 3 Using best practices (concise, calls attention to key features of plot), write a caption for the figure above.

Partially Worked Example: Emission of a blackbody radiator

Use the Planck relationship to model the emission spectrum of a blackbody radiator as a function of λ.

# define common constants from scipy.constants import Planck, speed_of_light, Boltzmann h = Planck # Js c = speed_of_light # m/s kb = Boltzmann # J/molec K # use "lamda" to avoid conflict with python reserved word "lambda" def rho(wavelength, T): """Calculate the emission from wavelength and temperature. Arguments:: lamda: wavelength cm T: temperature K""" return 8 * np.pi * h * c / ( wavelength**5 * (np.exp(h*c/(wavelength*kb*T)) - 1))

Exercise 1 Use the model function rho() to plot the predicted emission spectra for a K-type star and a G-type star from the UV to IR wavelength region (say, 100 to 3000 nm).

wavelength =np.linspace(1*10**-7, 3*10**-6,1000) wavelength
array([1.00000000e-07, 1.02902903e-07, 1.05805806e-07, 1.08708709e-07, 1.11611612e-07, 1.14514515e-07, 1.17417417e-07, 1.20320320e-07, 1.23223223e-07, 1.26126126e-07, 1.29029029e-07, 1.31931932e-07, 1.34834835e-07, 1.37737738e-07, 1.40640641e-07, 1.43543544e-07, 1.46446446e-07, 1.49349349e-07, 1.52252252e-07, 1.55155155e-07, 1.58058058e-07, 1.60960961e-07, 1.63863864e-07, 1.66766767e-07, 1.69669670e-07, 1.72572573e-07, 1.75475475e-07, 1.78378378e-07, 1.81281281e-07, 1.84184184e-07, 1.87087087e-07, 1.89989990e-07, 1.92892893e-07, 1.95795796e-07, 1.98698699e-07, 2.01601602e-07, 2.04504505e-07, 2.07407407e-07, 2.10310310e-07, 2.13213213e-07, 2.16116116e-07, 2.19019019e-07, 2.21921922e-07, 2.24824825e-07, 2.27727728e-07, 2.30630631e-07, 2.33533534e-07, 2.36436436e-07, 2.39339339e-07, 2.42242242e-07, 2.45145145e-07, 2.48048048e-07, 2.50950951e-07, 2.53853854e-07, 2.56756757e-07, 2.59659660e-07, 2.62562563e-07, 2.65465465e-07, 2.68368368e-07, 2.71271271e-07, 2.74174174e-07, 2.77077077e-07, 2.79979980e-07, 2.82882883e-07, 2.85785786e-07, 2.88688689e-07, 2.91591592e-07, 2.94494494e-07, 2.97397397e-07, 3.00300300e-07, 3.03203203e-07, 3.06106106e-07, 3.09009009e-07, 3.11911912e-07, 3.14814815e-07, 3.17717718e-07, 3.20620621e-07, 3.23523524e-07, 3.26426426e-07, 3.29329329e-07, 3.32232232e-07, 3.35135135e-07, 3.38038038e-07, 3.40940941e-07, 3.43843844e-07, 3.46746747e-07, 3.49649650e-07, 3.52552553e-07, 3.55455455e-07, 3.58358358e-07, 3.61261261e-07, 3.64164164e-07, 3.67067067e-07, 3.69969970e-07, 3.72872873e-07, 3.75775776e-07, 3.78678679e-07, 3.81581582e-07, 3.84484484e-07, 3.87387387e-07, 3.90290290e-07, 3.93193193e-07, 3.96096096e-07, 3.98998999e-07, 4.01901902e-07, 4.04804805e-07, 4.07707708e-07, 4.10610611e-07, 4.13513514e-07, 4.16416416e-07, 4.19319319e-07, 4.22222222e-07, 4.25125125e-07, 4.28028028e-07, 4.30930931e-07, 4.33833834e-07, 4.36736737e-07, 4.39639640e-07, 4.42542543e-07, 4.45445445e-07, 4.48348348e-07, 4.51251251e-07, 4.54154154e-07, 4.57057057e-07, 4.59959960e-07, 4.62862863e-07, 4.65765766e-07, 4.68668669e-07, 4.71571572e-07, 4.74474474e-07, 4.77377377e-07, 4.80280280e-07, 4.83183183e-07, 4.86086086e-07, 4.88988989e-07, 4.91891892e-07, 4.94794795e-07, 4.97697698e-07, 5.00600601e-07, 5.03503504e-07, 5.06406406e-07, 5.09309309e-07, 5.12212212e-07, 5.15115115e-07, 5.18018018e-07, 5.20920921e-07, 5.23823824e-07, 5.26726727e-07, 5.29629630e-07, 5.32532533e-07, 5.35435435e-07, 5.38338338e-07, 5.41241241e-07, 5.44144144e-07, 5.47047047e-07, 5.49949950e-07, 5.52852853e-07, 5.55755756e-07, 5.58658659e-07, 5.61561562e-07, 5.64464464e-07, 5.67367367e-07, 5.70270270e-07, 5.73173173e-07, 5.76076076e-07, 5.78978979e-07, 5.81881882e-07, 5.84784785e-07, 5.87687688e-07, 5.90590591e-07, 5.93493493e-07, 5.96396396e-07, 5.99299299e-07, 6.02202202e-07, 6.05105105e-07, 6.08008008e-07, 6.10910911e-07, 6.13813814e-07, 6.16716717e-07, 6.19619620e-07, 6.22522523e-07, 6.25425425e-07, 6.28328328e-07, 6.31231231e-07, 6.34134134e-07, 6.37037037e-07, 6.39939940e-07, 6.42842843e-07, 6.45745746e-07, 6.48648649e-07, 6.51551552e-07, 6.54454454e-07, 6.57357357e-07, 6.60260260e-07, 6.63163163e-07, 6.66066066e-07, 6.68968969e-07, 6.71871872e-07, 6.74774775e-07, 6.77677678e-07, 6.80580581e-07, 6.83483483e-07, 6.86386386e-07, 6.89289289e-07, 6.92192192e-07, 6.95095095e-07, 6.97997998e-07, 7.00900901e-07, 7.03803804e-07, 7.06706707e-07, 7.09609610e-07, 7.12512513e-07, 7.15415415e-07, 7.18318318e-07, 7.21221221e-07, 7.24124124e-07, 7.27027027e-07, 7.29929930e-07, 7.32832833e-07, 7.35735736e-07, 7.38638639e-07, 7.41541542e-07, 7.44444444e-07, 7.47347347e-07, 7.50250250e-07, 7.53153153e-07, 7.56056056e-07, 7.58958959e-07, 7.61861862e-07, 7.64764765e-07, 7.67667668e-07, 7.70570571e-07, 7.73473473e-07, 7.76376376e-07, 7.79279279e-07, 7.82182182e-07, 7.85085085e-07, 7.87987988e-07, 7.90890891e-07, 7.93793794e-07, 7.96696697e-07, 7.99599600e-07, 8.02502503e-07, 8.05405405e-07, 8.08308308e-07, 8.11211211e-07, 8.14114114e-07, 8.17017017e-07, 8.19919920e-07, 8.22822823e-07, 8.25725726e-07, 8.28628629e-07, 8.31531532e-07, 8.34434434e-07, 8.37337337e-07, 8.40240240e-07, 8.43143143e-07, 8.46046046e-07, 8.48948949e-07, 8.51851852e-07, 8.54754755e-07, 8.57657658e-07, 8.60560561e-07, 8.63463463e-07, 8.66366366e-07, 8.69269269e-07, 8.72172172e-07, 8.75075075e-07, 8.77977978e-07, 8.80880881e-07, 8.83783784e-07, 8.86686687e-07, 8.89589590e-07, 8.92492492e-07, 8.95395395e-07, 8.98298298e-07, 9.01201201e-07, 9.04104104e-07, 9.07007007e-07, 9.09909910e-07, 9.12812813e-07, 9.15715716e-07, 9.18618619e-07, 9.21521522e-07, 9.24424424e-07, 9.27327327e-07, 9.30230230e-07, 9.33133133e-07, 9.36036036e-07, 9.38938939e-07, 9.41841842e-07, 9.44744745e-07, 9.47647648e-07, 9.50550551e-07, 9.53453453e-07, 9.56356356e-07, 9.59259259e-07, 9.62162162e-07, 9.65065065e-07, 9.67967968e-07, 9.70870871e-07, 9.73773774e-07, 9.76676677e-07, 9.79579580e-07, 9.82482482e-07, 9.85385385e-07, 9.88288288e-07, 9.91191191e-07, 9.94094094e-07, 9.96996997e-07, 9.99899900e-07, 1.00280280e-06, 1.00570571e-06, 1.00860861e-06, 1.01151151e-06, 1.01441441e-06, 1.01731732e-06, 1.02022022e-06, 1.02312312e-06, 1.02602603e-06, 1.02892893e-06, 1.03183183e-06, 1.03473473e-06, 1.03763764e-06, 1.04054054e-06, 1.04344344e-06, 1.04634635e-06, 1.04924925e-06, 1.05215215e-06, 1.05505506e-06, 1.05795796e-06, 1.06086086e-06, 1.06376376e-06, 1.06666667e-06, 1.06956957e-06, 1.07247247e-06, 1.07537538e-06, 1.07827828e-06, 1.08118118e-06, 1.08408408e-06, 1.08698699e-06, 1.08988989e-06, 1.09279279e-06, 1.09569570e-06, 1.09859860e-06, 1.10150150e-06, 1.10440440e-06, 1.10730731e-06, 1.11021021e-06, 1.11311311e-06, 1.11601602e-06, 1.11891892e-06, 1.12182182e-06, 1.12472472e-06, 1.12762763e-06, 1.13053053e-06, 1.13343343e-06, 1.13633634e-06, 1.13923924e-06, 1.14214214e-06, 1.14504505e-06, 1.14794795e-06, 1.15085085e-06, 1.15375375e-06, 1.15665666e-06, 1.15955956e-06, 1.16246246e-06, 1.16536537e-06, 1.16826827e-06, 1.17117117e-06, 1.17407407e-06, 1.17697698e-06, 1.17987988e-06, 1.18278278e-06, 1.18568569e-06, 1.18858859e-06, 1.19149149e-06, 1.19439439e-06, 1.19729730e-06, 1.20020020e-06, 1.20310310e-06, 1.20600601e-06, 1.20890891e-06, 1.21181181e-06, 1.21471471e-06, 1.21761762e-06, 1.22052052e-06, 1.22342342e-06, 1.22632633e-06, 1.22922923e-06, 1.23213213e-06, 1.23503504e-06, 1.23793794e-06, 1.24084084e-06, 1.24374374e-06, 1.24664665e-06, 1.24954955e-06, 1.25245245e-06, 1.25535536e-06, 1.25825826e-06, 1.26116116e-06, 1.26406406e-06, 1.26696697e-06, 1.26986987e-06, 1.27277277e-06, 1.27567568e-06, 1.27857858e-06, 1.28148148e-06, 1.28438438e-06, 1.28728729e-06, 1.29019019e-06, 1.29309309e-06, 1.29599600e-06, 1.29889890e-06, 1.30180180e-06, 1.30470470e-06, 1.30760761e-06, 1.31051051e-06, 1.31341341e-06, 1.31631632e-06, 1.31921922e-06, 1.32212212e-06, 1.32502503e-06, 1.32792793e-06, 1.33083083e-06, 1.33373373e-06, 1.33663664e-06, 1.33953954e-06, 1.34244244e-06, 1.34534535e-06, 1.34824825e-06, 1.35115115e-06, 1.35405405e-06, 1.35695696e-06, 1.35985986e-06, 1.36276276e-06, 1.36566567e-06, 1.36856857e-06, 1.37147147e-06, 1.37437437e-06, 1.37727728e-06, 1.38018018e-06, 1.38308308e-06, 1.38598599e-06, 1.38888889e-06, 1.39179179e-06, 1.39469469e-06, 1.39759760e-06, 1.40050050e-06, 1.40340340e-06, 1.40630631e-06, 1.40920921e-06, 1.41211211e-06, 1.41501502e-06, 1.41791792e-06, 1.42082082e-06, 1.42372372e-06, 1.42662663e-06, 1.42952953e-06, 1.43243243e-06, 1.43533534e-06, 1.43823824e-06, 1.44114114e-06, 1.44404404e-06, 1.44694695e-06, 1.44984985e-06, 1.45275275e-06, 1.45565566e-06, 1.45855856e-06, 1.46146146e-06, 1.46436436e-06, 1.46726727e-06, 1.47017017e-06, 1.47307307e-06, 1.47597598e-06, 1.47887888e-06, 1.48178178e-06, 1.48468468e-06, 1.48758759e-06, 1.49049049e-06, 1.49339339e-06, 1.49629630e-06, 1.49919920e-06, 1.50210210e-06, 1.50500501e-06, 1.50790791e-06, 1.51081081e-06, 1.51371371e-06, 1.51661662e-06, 1.51951952e-06, 1.52242242e-06, 1.52532533e-06, 1.52822823e-06, 1.53113113e-06, 1.53403403e-06, 1.53693694e-06, 1.53983984e-06, 1.54274274e-06, 1.54564565e-06, 1.54854855e-06, 1.55145145e-06, 1.55435435e-06, 1.55725726e-06, 1.56016016e-06, 1.56306306e-06, 1.56596597e-06, 1.56886887e-06, 1.57177177e-06, 1.57467467e-06, 1.57757758e-06, 1.58048048e-06, 1.58338338e-06, 1.58628629e-06, 1.58918919e-06, 1.59209209e-06, 1.59499499e-06, 1.59789790e-06, 1.60080080e-06, 1.60370370e-06, 1.60660661e-06, 1.60950951e-06, 1.61241241e-06, 1.61531532e-06, 1.61821822e-06, 1.62112112e-06, 1.62402402e-06, 1.62692693e-06, 1.62982983e-06, 1.63273273e-06, 1.63563564e-06, 1.63853854e-06, 1.64144144e-06, 1.64434434e-06, 1.64724725e-06, 1.65015015e-06, 1.65305305e-06, 1.65595596e-06, 1.65885886e-06, 1.66176176e-06, 1.66466466e-06, 1.66756757e-06, 1.67047047e-06, 1.67337337e-06, 1.67627628e-06, 1.67917918e-06, 1.68208208e-06, 1.68498498e-06, 1.68788789e-06, 1.69079079e-06, 1.69369369e-06, 1.69659660e-06, 1.69949950e-06, 1.70240240e-06, 1.70530531e-06, 1.70820821e-06, 1.71111111e-06, 1.71401401e-06, 1.71691692e-06, 1.71981982e-06, 1.72272272e-06, 1.72562563e-06, 1.72852853e-06, 1.73143143e-06, 1.73433433e-06, 1.73723724e-06, 1.74014014e-06, 1.74304304e-06, 1.74594595e-06, 1.74884885e-06, 1.75175175e-06, 1.75465465e-06, 1.75755756e-06, 1.76046046e-06, 1.76336336e-06, 1.76626627e-06, 1.76916917e-06, 1.77207207e-06, 1.77497497e-06, 1.77787788e-06, 1.78078078e-06, 1.78368368e-06, 1.78658659e-06, 1.78948949e-06, 1.79239239e-06, 1.79529530e-06, 1.79819820e-06, 1.80110110e-06, 1.80400400e-06, 1.80690691e-06, 1.80980981e-06, 1.81271271e-06, 1.81561562e-06, 1.81851852e-06, 1.82142142e-06, 1.82432432e-06, 1.82722723e-06, 1.83013013e-06, 1.83303303e-06, 1.83593594e-06, 1.83883884e-06, 1.84174174e-06, 1.84464464e-06, 1.84754755e-06, 1.85045045e-06, 1.85335335e-06, 1.85625626e-06, 1.85915916e-06, 1.86206206e-06, 1.86496496e-06, 1.86786787e-06, 1.87077077e-06, 1.87367367e-06, 1.87657658e-06, 1.87947948e-06, 1.88238238e-06, 1.88528529e-06, 1.88818819e-06, 1.89109109e-06, 1.89399399e-06, 1.89689690e-06, 1.89979980e-06, 1.90270270e-06, 1.90560561e-06, 1.90850851e-06, 1.91141141e-06, 1.91431431e-06, 1.91721722e-06, 1.92012012e-06, 1.92302302e-06, 1.92592593e-06, 1.92882883e-06, 1.93173173e-06, 1.93463463e-06, 1.93753754e-06, 1.94044044e-06, 1.94334334e-06, 1.94624625e-06, 1.94914915e-06, 1.95205205e-06, 1.95495495e-06, 1.95785786e-06, 1.96076076e-06, 1.96366366e-06, 1.96656657e-06, 1.96946947e-06, 1.97237237e-06, 1.97527528e-06, 1.97817818e-06, 1.98108108e-06, 1.98398398e-06, 1.98688689e-06, 1.98978979e-06, 1.99269269e-06, 1.99559560e-06, 1.99849850e-06, 2.00140140e-06, 2.00430430e-06, 2.00720721e-06, 2.01011011e-06, 2.01301301e-06, 2.01591592e-06, 2.01881882e-06, 2.02172172e-06, 2.02462462e-06, 2.02752753e-06, 2.03043043e-06, 2.03333333e-06, 2.03623624e-06, 2.03913914e-06, 2.04204204e-06, 2.04494494e-06, 2.04784785e-06, 2.05075075e-06, 2.05365365e-06, 2.05655656e-06, 2.05945946e-06, 2.06236236e-06, 2.06526527e-06, 2.06816817e-06, 2.07107107e-06, 2.07397397e-06, 2.07687688e-06, 2.07977978e-06, 2.08268268e-06, 2.08558559e-06, 2.08848849e-06, 2.09139139e-06, 2.09429429e-06, 2.09719720e-06, 2.10010010e-06, 2.10300300e-06, 2.10590591e-06, 2.10880881e-06, 2.11171171e-06, 2.11461461e-06, 2.11751752e-06, 2.12042042e-06, 2.12332332e-06, 2.12622623e-06, 2.12912913e-06, 2.13203203e-06, 2.13493493e-06, 2.13783784e-06, 2.14074074e-06, 2.14364364e-06, 2.14654655e-06, 2.14944945e-06, 2.15235235e-06, 2.15525526e-06, 2.15815816e-06, 2.16106106e-06, 2.16396396e-06, 2.16686687e-06, 2.16976977e-06, 2.17267267e-06, 2.17557558e-06, 2.17847848e-06, 2.18138138e-06, 2.18428428e-06, 2.18718719e-06, 2.19009009e-06, 2.19299299e-06, 2.19589590e-06, 2.19879880e-06, 2.20170170e-06, 2.20460460e-06, 2.20750751e-06, 2.21041041e-06, 2.21331331e-06, 2.21621622e-06, 2.21911912e-06, 2.22202202e-06, 2.22492492e-06, 2.22782783e-06, 2.23073073e-06, 2.23363363e-06, 2.23653654e-06, 2.23943944e-06, 2.24234234e-06, 2.24524525e-06, 2.24814815e-06, 2.25105105e-06, 2.25395395e-06, 2.25685686e-06, 2.25975976e-06, 2.26266266e-06, 2.26556557e-06, 2.26846847e-06, 2.27137137e-06, 2.27427427e-06, 2.27717718e-06, 2.28008008e-06, 2.28298298e-06, 2.28588589e-06, 2.28878879e-06, 2.29169169e-06, 2.29459459e-06, 2.29749750e-06, 2.30040040e-06, 2.30330330e-06, 2.30620621e-06, 2.30910911e-06, 2.31201201e-06, 2.31491491e-06, 2.31781782e-06, 2.32072072e-06, 2.32362362e-06, 2.32652653e-06, 2.32942943e-06, 2.33233233e-06, 2.33523524e-06, 2.33813814e-06, 2.34104104e-06, 2.34394394e-06, 2.34684685e-06, 2.34974975e-06, 2.35265265e-06, 2.35555556e-06, 2.35845846e-06, 2.36136136e-06, 2.36426426e-06, 2.36716717e-06, 2.37007007e-06, 2.37297297e-06, 2.37587588e-06, 2.37877878e-06, 2.38168168e-06, 2.38458458e-06, 2.38748749e-06, 2.39039039e-06, 2.39329329e-06, 2.39619620e-06, 2.39909910e-06, 2.40200200e-06, 2.40490490e-06, 2.40780781e-06, 2.41071071e-06, 2.41361361e-06, 2.41651652e-06, 2.41941942e-06, 2.42232232e-06, 2.42522523e-06, 2.42812813e-06, 2.43103103e-06, 2.43393393e-06, 2.43683684e-06, 2.43973974e-06, 2.44264264e-06, 2.44554555e-06, 2.44844845e-06, 2.45135135e-06, 2.45425425e-06, 2.45715716e-06, 2.46006006e-06, 2.46296296e-06, 2.46586587e-06, 2.46876877e-06, 2.47167167e-06, 2.47457457e-06, 2.47747748e-06, 2.48038038e-06, 2.48328328e-06, 2.48618619e-06, 2.48908909e-06, 2.49199199e-06, 2.49489489e-06, 2.49779780e-06, 2.50070070e-06, 2.50360360e-06, 2.50650651e-06, 2.50940941e-06, 2.51231231e-06, 2.51521522e-06, 2.51811812e-06, 2.52102102e-06, 2.52392392e-06, 2.52682683e-06, 2.52972973e-06, 2.53263263e-06, 2.53553554e-06, 2.53843844e-06, 2.54134134e-06, 2.54424424e-06, 2.54714715e-06, 2.55005005e-06, 2.55295295e-06, 2.55585586e-06, 2.55875876e-06, 2.56166166e-06, 2.56456456e-06, 2.56746747e-06, 2.57037037e-06, 2.57327327e-06, 2.57617618e-06, 2.57907908e-06, 2.58198198e-06, 2.58488488e-06, 2.58778779e-06, 2.59069069e-06, 2.59359359e-06, 2.59649650e-06, 2.59939940e-06, 2.60230230e-06, 2.60520521e-06, 2.60810811e-06, 2.61101101e-06, 2.61391391e-06, 2.61681682e-06, 2.61971972e-06, 2.62262262e-06, 2.62552553e-06, 2.62842843e-06, 2.63133133e-06, 2.63423423e-06, 2.63713714e-06, 2.64004004e-06, 2.64294294e-06, 2.64584585e-06, 2.64874875e-06, 2.65165165e-06, 2.65455455e-06, 2.65745746e-06, 2.66036036e-06, 2.66326326e-06, 2.66616617e-06, 2.66906907e-06, 2.67197197e-06, 2.67487487e-06, 2.67777778e-06, 2.68068068e-06, 2.68358358e-06, 2.68648649e-06, 2.68938939e-06, 2.69229229e-06, 2.69519520e-06, 2.69809810e-06, 2.70100100e-06, 2.70390390e-06, 2.70680681e-06, 2.70970971e-06, 2.71261261e-06, 2.71551552e-06, 2.71841842e-06, 2.72132132e-06, 2.72422422e-06, 2.72712713e-06, 2.73003003e-06, 2.73293293e-06, 2.73583584e-06, 2.73873874e-06, 2.74164164e-06, 2.74454454e-06, 2.74744745e-06, 2.75035035e-06, 2.75325325e-06, 2.75615616e-06, 2.75905906e-06, 2.76196196e-06, 2.76486486e-06, 2.76776777e-06, 2.77067067e-06, 2.77357357e-06, 2.77647648e-06, 2.77937938e-06, 2.78228228e-06, 2.78518519e-06, 2.78808809e-06, 2.79099099e-06, 2.79389389e-06, 2.79679680e-06, 2.79969970e-06, 2.80260260e-06, 2.80550551e-06, 2.80840841e-06, 2.81131131e-06, 2.81421421e-06, 2.81711712e-06, 2.82002002e-06, 2.82292292e-06, 2.82582583e-06, 2.82872873e-06, 2.83163163e-06, 2.83453453e-06, 2.83743744e-06, 2.84034034e-06, 2.84324324e-06, 2.84614615e-06, 2.84904905e-06, 2.85195195e-06, 2.85485485e-06, 2.85775776e-06, 2.86066066e-06, 2.86356356e-06, 2.86646647e-06, 2.86936937e-06, 2.87227227e-06, 2.87517518e-06, 2.87807808e-06, 2.88098098e-06, 2.88388388e-06, 2.88678679e-06, 2.88968969e-06, 2.89259259e-06, 2.89549550e-06, 2.89839840e-06, 2.90130130e-06, 2.90420420e-06, 2.90710711e-06, 2.91001001e-06, 2.91291291e-06, 2.91581582e-06, 2.91871872e-06, 2.92162162e-06, 2.92452452e-06, 2.92742743e-06, 2.93033033e-06, 2.93323323e-06, 2.93613614e-06, 2.93903904e-06, 2.94194194e-06, 2.94484484e-06, 2.94774775e-06, 2.95065065e-06, 2.95355355e-06, 2.95645646e-06, 2.95935936e-06, 2.96226226e-06, 2.96516517e-06, 2.96806807e-06, 2.97097097e-06, 2.97387387e-06, 2.97677678e-06, 2.97967968e-06, 2.98258258e-06, 2.98548549e-06, 2.98838839e-06, 2.99129129e-06, 2.99419419e-06, 2.99709710e-06, 3.00000000e-06])
TK = 4000 # temperature of a K-type star TG = 5500 # temperature of a G-type star TF = 7000 # temperature of a F-type star IntensityK = rho(wavelength,TK) IntensityG = rho(wavelength,TG) IntensityF = rho(wavelength,TF) plt.figure() plt.plot(wavelength,IntensityK,'g-') plt.plot(wavelength, IntensityG,'k-') plt.plot(wavelength, IntensityF, 'r-')
[<matplotlib.lines.Line2D at 0x7f47f0023438>]
Image in a Jupyter notebook

CTQ 4 Referring to the plot and the model function, identify at least three characteristics blackbody radiation.

Emission as a function of ν\nu

Alternatively, the blackbody emission can be modeled using frequency ν\nu. [Optional algebra problem: Try using the relationship c=λνc = \lambda \nu to derive the Planck relationship in terms of frequency instead of wavelength.]

ρ(ν,T)=8πhν3c31ehν/kt1\begin{equation} \rho(\nu, T) = \frac{8\pi h \nu^3}{c^3} \frac{1}{e^{h\nu/kt}-1} \end{equation}

Exercise 2 Using Planck's equation for blackbody radiation, write a function called rhonu that returns the emission given ν\nu and TT. Use this function to plot emission spectra for stars at 4000K and 5000K (including axes). Record your observations. Here is a skeleton to get you started.

def rhonu(nu, T): """Calculates the radiance from frequency and temperature. Arguments nu: frequency Hz T: temperature K """ return (8 * np.pi * h * nu**3 / c**3) * (1 / (np.exp(h*nu/(kb*T)) - 1)) nu1 = c/200e-9 nu2 = c/900e-8 # frequency x = np.linspace(nu1,nu2,1000) y=rhonu(x,4000) plt.figure() plt.plot(x,rhonu(x,4000),'g') plt.plot(x,rhonu(x,5000),'r') plt.plot(x,rhonu(x,7000),'k') # Intensity versus frequency #rhonu(nu,4000)
[<matplotlib.lines.Line2D at 0x7f47effc5a20>]
Image in a Jupyter notebook
wavelength =np.linspace(100e-9, 2000e-9, 1000) plt.figure() plt.plot(wavelength,rho(wavelength, 4000),'g') # The function for intensity versus wavelength for a K-type star plt.plot(wavelength,rho(wavelength, 5000),'r') # The function for intensity versus wavelenght for a G-type star plt.plot(wavelength,rho(wavelength,7000),'k') # The function for intensity versus wavelength for a F-type star
[<matplotlib.lines.Line2D at 0x7f47eff350f0>]
Image in a Jupyter notebook
from scipy.constants import Planck, speed_of_light, Boltzmann h = Planck #Js c = speed_of_light #m.s kb = Boltzmann # J/molec K def rhonu(nu, T): """ Return emission intensity as function of frequency and temperature. Arguments:: nu = frequency Hz T = temperature K """ return 2*h*nu**2/c**2 * 1/(np.exp(h*nu/(kb*T)-1))
nus = np.linspace(1e10, 1e15, 100) for T in [4000, 5000, 7000]: plt.plot(nus,rhonu(nus, T), label='%s K'%T) plt.xlabel('Frequency/Hz') plt.ylabel('Intensity') plt.legend()
<matplotlib.legend.Legend at 0x7f47efea54e0>
Image in a Jupyter notebook

Modeling the emission of stars of different classes

Temperatures and colors of M, K, and G stars

Exercise 3 Use your function to plot the blackbody emission curves at temperatures corresponding to F, G, and K stars. Speculate as to the color of these stars, and explain your reasoning.

Hints: Note that the x- and y-axis units will be different from plots in Fig 1 and the Worked Example. (Typical emission intensities are on the order of 10510^5 for temperatures around 5000 K.)

#wl = np.linspace(1e-8, 25e-7, 1000) nus = np.linspace(0, 2e15, 100) #Hz for t in [7000, 5000, 4000]: y = rhonu(nus,t) plt.plot(nus, rhonu(nus, t), label=(f'{t}K')) mx = np.argmax(y) print(mx,nus[mx],y[mx]) # This operation will print all the lambda maximum frequency values and all the maximum y values for each varied temperature curve. plt.scatter(nus[mx], y[mx], c='k') plt.ticklabel_format(style='sci', axis='x', scilimits=(0,0)) plt.ticklabel_format(style='sci', axis='y', scilimits=(0,0)) plt.xlabel(r'frequency / $s^{-1}$') plt.ylabel('Intensity') plt.legend()
14 282828282828282.9 4.611574428565192e-22 10 202020202020202.03 2.352844096206731e-22 8 161616161616161.62 1.5058202215723077e-22
<matplotlib.legend.Legend at 0x7f47efe219b0>
Image in a Jupyter notebook

Comparing the temperatures of stars

CTQ 6 Below are emission spectra for an F-type and a G-type star. Assign each spectrum to its star type, and compare and contrast the emission spectra (be specific about the information that can be elucidated).

http://classic.sdss.org/dr5/algorithms/spectemplates/index.html

fn = 'data/ukg5iii.csv' G = pd.read_csv(fn, skiprows=3, names=["wavelength", "intensity"]) # convert Angstroms to meters wavelength = G.wavelength / 1e10 # normalize intensity em_star = G.intensity / np.max(G.intensity) plt.plot(wavelength, em_star, 'k', lw=0.5) plt.ticklabel_format(style='sci', axis='x', scilimits=(0,0)) plt.xlabel("Wavelength / m"); plt.ylabel("Intensity") plt.title("Experimental Analysis of Intensity Plotted against Wavelength /m") # This is the experimental analysis of the plot of Intensity versus wavelength from the imported data
--------------------------------------------------------------------------- FileNotFoundError Traceback (most recent call last) <ipython-input-11-0faa1736b3cf> in <module>() 1 fn = 'data/ukg5iii.csv' ----> 2 G = pd.read_csv(fn, skiprows=3, names=["wavelength", "intensity"]) 3 4 # convert Angstroms to meters 5 wavelength = G.wavelength / 1e10 /usr/local/lib/python3.6/dist-packages/pandas/io/parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, skipfooter, doublequote, delim_whitespace, low_memory, memory_map, float_precision) 676 skip_blank_lines=skip_blank_lines) 677 --> 678 return _read(filepath_or_buffer, kwds) 679 680 parser_f.__name__ = name /usr/local/lib/python3.6/dist-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds) 438 439 # Create the parser. --> 440 parser = TextFileReader(filepath_or_buffer, **kwds) 441 442 if chunksize or iterator: /usr/local/lib/python3.6/dist-packages/pandas/io/parsers.py in __init__(self, f, engine, **kwds) 785 self.options['has_index_names'] = kwds['has_index_names'] 786 --> 787 self._make_engine(self.engine) 788 789 def close(self): /usr/local/lib/python3.6/dist-packages/pandas/io/parsers.py in _make_engine(self, engine) 1012 def _make_engine(self, engine='c'): 1013 if engine == 'c': -> 1014 self._engine = CParserWrapper(self.f, **self.options) 1015 else: 1016 if engine == 'python': /usr/local/lib/python3.6/dist-packages/pandas/io/parsers.py in __init__(self, src, **kwds) 1706 kwds['usecols'] = self.usecols 1707 -> 1708 self._reader = parsers.TextReader(src, **kwds) 1709 1710 passed_names = self.names is None pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.__cinit__() pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._setup_parser_source() FileNotFoundError: File b'data/ukg5iii.csv' does not exist
plt.plot(wavelength, em_star) T = 5300 # temperature of a K-type star em_calc = rho(wavelength, T) em_norm = em_calc/np.max(em_calc) plt.plot(wavelength, em_norm) plt.xlabel("wavelength /m") plt.ylabel("Intensity") plt.title("Calculated Results for Intensity Plotted against Wavelength /m") # I made a normalization curves, while varying the temperature to see if I could get my calculated curve as close as possible to the experimental analysis curve. Then I overlayed my generated curve on the experimental analysis curve.

Using Curve_fit()

from scipy.optimize import curve_fit def model(wavelength, T): em_calc = rho(wavelength, T) # calculated emission print(em_calc) em_norm = em_calc/np.max(em_calc) # normalize calculated emission return em_norm T = 4000 # initial estimation for temperature of a K-type star popt, pcov = curve_fit(model, wavelength, T) # for curve_fit, model comes first, then the x and y data of which we are comparing the model to. popt
plt.plot(wavelength, em_star) plt.plot(wavelength, model(wavelength, *popt)) plt.ticklabel_format(style='sci', axis='x', scilimits=(0,0)) plt.ylabel("Normalizaed Intensity") plt.xlabel("Wavelength/m")

Comparing Planck model to the Wien model

def wien(T): "lambda_max for Wein law; T is temperature in K." l_max = 2.89e-3 / T return l_max temps = np.arange(1000,10001,1000) planck_list =[] wien_list = [] for temp in temps: y = rho(wavelength, temp) max_y = np.argmax(g) wavelength = wavelength[max_y] planck_list.append(wavelength) planck_list.append(wavelength[np.argmax(rho(wavelength,temp))]) wein_list.append(wien(temp)) print("Wien)\t\t\tPlanck") for w,p in zip(wien_list, planck_list): print("f{w:.3e} \t\t {p:.3e}")
plt.plot(wien_list, planck_list, 'o') plt.xlabel("Wien max") plt.ylabel("Planck max")
np.polyfit(wien_list,planck_list, 1)

Estimating the temperature of a star

This is the emission spectrum of a moderate temperature main sequence star.

import pandas as pd G = pd.read_csv('data/ukg5iii.csv', skiprows=3, names=['wavelength','intensity']) plt.plot(G.wavelength, G.intensity, 'k', lw=0.5) plt.ylabel('Intensity') plt.xlabel(r'Wavelength / $\AA$')

CTQ 7 Using one of the model functions rho() or rhonu(), how could the temperature of this star be estimated?

Exercise 4 Estimate the temperature of the star shown above.