code for creating HR-Diagram?

Ask questions, find resources, browse the virtual shelves.
Post Reply
User avatar
rstevenson
Quis custodiet ipsos custodes?
Posts: 2704
Joined: Fri Mar 28, 2008 1:24 pm
Location: Halifax, NS, Canada

code for creating HR-Diagram?

Post by rstevenson » Tue Feb 19, 2013 8:03 pm

Hi,

For a school assignment I'd like to create a Hertzsprung-Russell Diagram of a set of data of nearby stars plus stars in Orion. I've made a first stab at it using Excel, but there are problems. ...

The data I have is a table of stars giving me their spectral type and Mv. (I also have names/designations, but they're not for the graph.) Mv (absolute magnitude) is a number so it works just fine in Excel. But the spectral type is a complex alphanumeric and Excel is not dealing with it correctly. Here's a small sample of the data so you can see what I'm up against...

Code: Select all

BD+44°2051A      M1 V     10.40
Kapteyn’s Star   M1 VIp   10.89
CD–25°10553B     M1.5     13.80
a Ori            M2 Ib    -5.14
Even if Excel understands the alphanumeric nature of the spectral type column, I'd end up with a horizontal scale which is dependant on the relatively small amount of data I have, rather than being comparable to standard HR-Ds which are derived from data on many tens of thousands of stars.

I thought of a way to get the spectral type scale consistent, by inputting a fake data series which uses all possible spectral types, and giving that series false Mv data to make sure it's off the chart. But even that won't work, since the standard spectral type scale is not linear, and my false data would be.

So at this point I'm stuck. I've tried searching online for the numerical methods used to build an HR-Diagram, but if it's out there it's lost in the millions of Googlehits. So naturally I turn to the pool of experts here at APOD. Can anyone here lead me to instructions and algorithms for creating a suitably formatted HR-Diagram? If possible I'd like to do this in Excel, but if that's not possible I can try working with other graphing packages. (I use Mac OS X by preference, but I can use Windows if the alternative is death by a thousand cuts.)

Rob

User avatar
owlice
Guardian of the Codes
Posts: 8406
Joined: Wed Aug 04, 2004 4:18 pm
Location: Washington, DC

Re: code for creating HR-Diagram?

Post by owlice » Tue Feb 19, 2013 8:27 pm

A closed mouth gathers no foot.

User avatar
rstevenson
Quis custodiet ipsos custodes?
Posts: 2704
Joined: Fri Mar 28, 2008 1:24 pm
Location: Halifax, NS, Canada

Re: code for creating HR-Diagram?

Post by rstevenson » Tue Feb 19, 2013 8:56 pm

That certainly looks useful. It charts B-V against Mv, so is using numbers in both columns of data, and I think the B-V index is linear. But the links to more info should yield some insight.

Thanks,

Rob

User avatar
Chris Peterson
Abominable Snowman
Posts: 18103
Joined: Wed Jan 31, 2007 11:13 pm
Location: Guffey, Colorado, USA
Contact:

Re: code for creating HR-Diagram?

Post by Chris Peterson » Wed Feb 20, 2013 1:05 am

rstevenson wrote:For a school assignment I'd like to create a Hertzsprung-Russell Diagram of a set of data of nearby stars plus stars in Orion. I've made a first stab at it using Excel, but there are problems. ...

The data I have is a table of stars giving me their spectral type and Mv. (I also have names/designations, but they're not for the graph.) Mv (absolute magnitude) is a number so it works just fine in Excel. But the spectral type is a complex alphanumeric and Excel is not dealing with it correctly.
The problem is that the spectral type is really just a notation on an H-R diagram. What is really being plotted is the absolute magnitude (or luminosity) against a more rigorously measured value- temperature, or B-V. It would be best if you could get a version of your catalog that has one of those. If not, about all you can do is manually replace the spectral type with the corresponding temperature or color, and then generate your scatter plot.
Chris

*****************************************
Chris L Peterson
Cloudbait Observatory
https://www.cloudbait.com

User avatar
rstevenson
Quis custodiet ipsos custodes?
Posts: 2704
Joined: Fri Mar 28, 2008 1:24 pm
Location: Halifax, NS, Canada

Re: code for creating HR-Diagram?

Post by rstevenson » Wed Feb 20, 2013 3:24 am

Chris Peterson wrote:The problem is that the spectral type is really just a notation on an H-R diagram. What is really being plotted is the absolute magnitude (or luminosity) against a more rigorously measured value- temperature, or B-V. It would be best if you could get a version of your catalog that has one of those. If not, about all you can do is manually replace the spectral type with the corresponding temperature or color, and then generate your scatter plot.
Thanks Chris. I was relunctantly coming to that conclusion.

Further studying the problem today I realized that a spectral-type axis is more likely generated after the fact. I did manage to get a plot from my data which is similar to an HR-Diagram, but with the horizontal axis not properly scaled it's pretty much useless. We were provided with graph paper with hand lettered axes which we could use, and so I shall. But the instructions said that we could instead use a spreadsheet program, which is what set me off down this path.

Ah well, I now know a lot more about HR-Diagrams than I would have otherwise learned. That's a good thing.

Rob

User avatar
Ann
4725 Å
Posts: 13369
Joined: Sat May 29, 2010 5:33 am

Re: code for creating HR-Diagram?

Post by Ann » Wed Feb 20, 2013 7:17 am

Rob, I note that you have described a Ori, Betelgeuse, as belonging to spectral class M2 Ib. Not everyone agrees. Jim Kaler classifies Betelgeuse as belonging to spectral class M1.5 Ia (see this page), and he writes this, among other things, about Betelgeuse:
Betelgeuse is one of the larger stars that can be seen, indeed one of the larger stars to be found anywhere.
...
Direct parallax measures from space, using the most modern results, give 495 light years, whereas the parallax using the star's natural radio emission gives 640 light years. At a compromise distance of 570 light years, and allowing for a lot of infrared radiation and for absorption of light by circumstellar dust, the luminosity comes in at 85,000 times that of the Sun, considerably more than comes out of Antares.
Read the rest of Jim Kaler's text about Betelgeuse here.

My software generally agrees with you and classifies Betelgeuse as M2Ib, but it cites Bright Star catalog which classifies Betelgeuse as M1-2 Ia-Iab.

Ann
Color Commentator

User avatar
Ann
4725 Å
Posts: 13369
Joined: Sat May 29, 2010 5:33 am

Re: code for creating HR-Diagram?

Post by Ann » Wed Feb 20, 2013 7:33 am

One more thing, Rob. Some years ago I bought Sky Catalogue 2000.0, which lists more than 50,000 stars. I went through that catalog and underlined (with a blue pen) all stars that belonged to spectral classes A0, B and O or and all stars not belonging to these spectral classes, but which were nevertheless listed as having a "blue" (negative) B-V index. I then checked all these stars against the Hipparcos catalog, which was compiled after the Hipparcos satellite measured the B and V luminosity and parallax (and therefore distance) of all these stars with greater precision than any astronomical instrument has done before or since.

This was one conclusion I made, after I had finished my comparison of all these "blue" stars. The colors that had been ascribed to these stars were sometimes off (all the F-type stars that had been ascribed a negative B-V index - and there were several of them - turned out to have solidly positive B-V indexes after all). More importantly, the luminosities of the stars, which had been estimated from their spectral classes, were often wildly off. To my chagrin, I found a trend, namely that the intrinsic luminosity of blue stars had often been overestimated. The evolved stars of spectral classes K and M were often brighter than Sky Catalogue 2000.0 had predicted. But none of this could be really foreseen. Some blue stars really were extremely bright, and some red giants were fainter than expected. (I did check some red stars later.)

This is my conclusion. A spectral classification doesn't tell us everything about a star. A star can be underluminous for its spectral class, and it can also be overluminous. You shouldn't assume that you can "draw a star out of a hat" and tell a class of kids how bright this star is just by looking at its spectral class. Maybe in the future spectral classifications will be refined, and astronomers will know exactly what little signs to look for to say exactly how bright a star is from its spectral classification alone, but astronomy is not there yet.

Ann
Color Commentator

User avatar
Ann
4725 Å
Posts: 13369
Joined: Sat May 29, 2010 5:33 am

Re: code for creating HR-Diagram?

Post by Ann » Wed Feb 20, 2013 8:55 am

I haven't finished talking about spectral classes and absolute luminosities. Consider A-type stars Vega, Sirius, Alioth and Fomalhaut.

Vega is classified as A0V (the "V" means luminosity class V, but it also means a main sequence, hydrogen-fusing star). Vega's (well-measured) absolute V luminosity is 47 times solar. Its Johnson B-V index is -0.001. The distance to Vega is 25 light-years. Jim Kaler estimates is mass as 2.3 solar.

Sirius is classified as A1V, although the classification of A0V is also seen. Its absolute V luminosity is 22 times solar, about half that of Vega. Its Johnson B-V index is +0.009. The distance to Sirius is 8.6 light-years. Jim Kaler estimates its mass as 2.12 solar.

Alioth, the brightest-looking star in the Big Dipper, is classified as A0p ("p"for peculiar). Jim Kaler, however, lists it as an unevolved star of type A0, one that is still fusing hydrogen in its core. Its V luminosity is 105 times solar, double that of Vega. Its Johnson B-V index is -0.022. The distance to Alioth is 83 light-years. Jim Kaler estimates its mass to "close to triple that of the Sun". Kaler adds:
Large and luminous for its class, Alioth is probably ageing, and is nearing the end of its main sequence hydrogen-fusing lifetime. Of greater significance, Alioth is the brightest of the "peculiar A (Ap) stars," magnetic stars in which a variety of chemical elements are either depleted or enhanced
Fomalhaut, finally, is classified as A3V, so it is smaller, cooler and less massive than the other three A-type stars. Fascinatingly, Jim Kaler lists it as belonging to spectral class A8V! I think Kaler is definitely wrong here. Anyway, Fomalhaut's V luminosity is almost 17 times solar, so it is not much fainter than Sirius at 22 times solar. Its Johnson B-V index is +0.145. Kaler estimates its mass as 2.0 solar, not much less than that of Sirius. The distance to Fomalhaut is 25 light-years.

Let's mention one more A-type star, Altair, one of the Summer Triangle stars (the other two are Vega and Deneb). My software classifies it as A7IV-V, suggesting that it is on the verge of using up the hydrogen in its core. The classification of IV-V also suggests that the star may have expanded somewhat and become brighter than it was before.

Jim Kaler classifies it as A8V, the same as Fomalhaut!

The V luminosity of Altair is 11 times solar, considerably fainter than that of Fomalhaut and about half the luminosity of Sirius. On the other hand, it is also considerably cooler than Sirius. Its Johnson B-V index is +0.221. The distance to Altair is 17 light-years. Jim Kaler estimates its mass as between 1.7 and 1.8 solar, significantly less than Sirius.

Let's now compare these A-type stars and say something about their absolute luminosities. Alioth appears overluminous, while Sirius seems to be slightly underluminous. A word of caution is needed here, however. The bright and obvious stars in the sky, the ones that have proper names, are rarely underluminous when compared with a large sample of stars of the same spectral class.

As for Fomalhaut, it seems perhaps slightly cool for its mass.

To return to Alioth, we might perhaps compare it with IQ Aurigae, another star classified as A0p. IQ Aur is probably more or less as bright as Alioth. Hipparcos says that its V luminosity is 94.2 ± 8.8 light-years at a distance of 413 ± 19 light-years. But IQ Aur is really strikingly blue, with a Johnson B-V index of -0.167. Bright Star Catalog says that IQ Aur is one of the hottest Ap stars known, about 17,000 Kelvin, comparable to a star of spectral class B4.

Anyway, if you tried to draw a straight line between spectral class and luminosity of these four, five or six A-type stars, you would certainly fail.

Ann
Last edited by Ann on Wed Feb 20, 2013 7:07 pm, edited 1 time in total.
Color Commentator

User avatar
rstevenson
Quis custodiet ipsos custodes?
Posts: 2704
Joined: Fri Mar 28, 2008 1:24 pm
Location: Halifax, NS, Canada

Re: code for creating HR-Diagram?

Post by rstevenson » Wed Feb 20, 2013 2:49 pm

Thanks Ann. My understanding of these things is expanding by leaps and bounds. :D

As for "A spectral classification doesn't tell us everything about a star" I can only agree. But this is just a lab exercise and I must work with what I've been given.

I'm going to make one more stab at getting a reasonable facsimile of an HR-D out of Excel. I'm going to see if I can make the horizontal axis - Spectral Type - logarithmic. It shouldn't be, I know, but at the moment, because of the data I've been given (65 nearby stars plus 30 stars in Orion) my axis is spread out in the M part and squished up at the OBA end, exactly opposite to what it should be. I'll also need to do some manual sorting of some of the data points where I can see that Excel's alphanumeric sorting hasn't quite worked. And then, when all of that doesn't help, I'll use the provided paper graph and get on with the next assignment. :lol2:

Rob

User avatar
rstevenson
Quis custodiet ipsos custodes?
Posts: 2704
Joined: Fri Mar 28, 2008 1:24 pm
Location: Halifax, NS, Canada

Re: code for creating HR-Diagram?

Post by rstevenson » Wed Feb 20, 2013 2:54 pm

Being stubborn once I get going at something, I've decided to take it one step further. It's only 95 stars, and they're well known ones since they're either nearby or in a well-studied area like Orion, so I should be able to find a table of data which I can cross-correlate to get either temperature or BV index (or both) of all of them. Then I can create my Excel chart, manually add the Mv as a second horizontal axis, and amaze and delight my Prof (or his marker, more likely.)

My idea of fun.

Rob

User avatar
Chris Peterson
Abominable Snowman
Posts: 18103
Joined: Wed Jan 31, 2007 11:13 pm
Location: Guffey, Colorado, USA
Contact:

Re: code for creating HR-Diagram?

Post by Chris Peterson » Wed Feb 20, 2013 3:22 pm

Ann wrote:Rob, I note that you have described a Ori, Betelgeuse, as belonging to spectral class M2 Ib. Not everyone agrees.
In fact, spectral classification and color are crude measurements, and applied to any individual star are largely useless... and not much used. Any individual star under close study will be classified spectroscopically. The old-fashioned ideas of color and spectral class are really only useful for statistical purposes- such as producing H-R diagrams. They are used as filters for selecting stars for study, but by themselves simply don't tell us much about those stars.
Chris

*****************************************
Chris L Peterson
Cloudbait Observatory
https://www.cloudbait.com

User avatar
rstevenson
Quis custodiet ipsos custodes?
Posts: 2704
Joined: Fri Mar 28, 2008 1:24 pm
Location: Halifax, NS, Canada

Re: code for creating HR-Diagram?

Post by rstevenson » Fri Mar 01, 2013 3:19 pm

If I may ask for a little more help...

I've made some progress. Having realized I'd get a poor chart using the spectral type, I decided to cross-correlate my stars to other databases to find the B-V index for each of them, then use that to create a better HR-Diagram. I've managed to find the B-V index for 69 of the 95 stars I need. For several others I found lots of data for the star but it didn't include a B-V index, perhaps because no one has worked that out for that particular star.

But the majority of my missing data is in a group of 30 stars identified in the lab exercise as "Stars in Orion". Of those, I've managed to find a B-V index for only 11 out of 30. The problem, I think, is that in my given data they're identified only with their designation within Orion, like θ1 Ori C, or π5 Ori, and the databases I'm trying to find them in don't recognize those names. I thought I'd found the key when I started to search Hipparcos itself, since the interface gives me the option of using Simbad in the background to translate the name into an unambiguous identifier. But I can only get that to work by entering something like "Orionis", rather than the greek-letter and number name of a specific star, and Hipparcos just gives me a huge pile of data that seems not to relate to what I need.

So, I need suggestions. Maybe there are alternative interfaces to Hipparcos or other databases that will accept the names I have? So far I've found almost all my data in the Internet Stellar Database. But it has only those 11 stars in Orion that I already have. Here's a list of my missing stars in Orion...

p4 Ori
θ1 Ori A
θ1 Ori B
θ1 Ori C
θ1 Ori D
θ2 Ori
μ Ori
ξ Ori
π1 Ori
π2 Ori
π5 Ori
π6 Ori
σ Ori
τ Ori
υ Ori
ϕ1 Ori
ϕ2 Ori
χ1 Ori
χ2 Ori

How you see those Greek letters will depend on the fonts available to your browser. For example, that first one isn't a small 'p', it's rho, and the small 'x' is chi, and so on.

The other ones, the non-Orion ones for which I found data but haven't found a B-V index, are...

L372–58
L726–8A
L726–8B
L789–6ABC
LP944–20
V577 Monoceri (Ross 614A)
Wolf 424A

You can see that 4 of the Orion ones and all but one of the others are in binary or multiple systems, which may be a problem for getting a good B-V index. But if you have any ideas of where to go to get these remaining B-V index values, I would greatly appreciate the help.

Rob

User avatar
Chris Peterson
Abominable Snowman
Posts: 18103
Joined: Wed Jan 31, 2007 11:13 pm
Location: Guffey, Colorado, USA
Contact:

Re: code for creating HR-Diagram?

Post by Chris Peterson » Fri Mar 01, 2013 3:39 pm

rstevenson wrote:... You can see that 4 of the Orion ones and all but one of the others are in binary or multiple systems, which may be a problem for getting a good B-V index. But if you have any ideas of where to go to get these remaining B-V index values, I would greatly appreciate the help.
I just Googled a handful of objects from the list, and all generated multiple hits. A few are ambiguous (like V577 Mon, which is a multiple star system; I assumed the star to use is the brightest). All the stars I spot checked provided spectral class, so that might be a better metric than B-V. You should be able to do a simple conversion between the two- essentially, synthesize a B-V from the spectral class. It's a bit labor intensive, but your list isn't too long.
Chris

*****************************************
Chris L Peterson
Cloudbait Observatory
https://www.cloudbait.com

User avatar
rstevenson
Quis custodiet ipsos custodes?
Posts: 2704
Joined: Fri Mar 28, 2008 1:24 pm
Location: Halifax, NS, Canada

Re: code for creating HR-Diagram?

Post by rstevenson » Fri Mar 01, 2013 4:28 pm

Chris Peterson wrote:... All the stars I spot checked provided spectral class, so that might be a better metric than B-V. You should be able to do a simple conversion between the two- essentially, synthesize a B-V from the spectral class. It's a bit labor intensive, but your list isn't too long.
I actually have spectral type for all of the stars given in the exercise, but we haven't covered yet how to do such a conversion, and the textbook doesn't cover it. (I'm getting way ahead of the class here.) For example, for V577 Mon I have M4 Ve. Do you have a link to an explanation of the conversion process?

[edit] Just found this conversion table. That should do the trick, though as it says, it converts to "unreddened colours expected for main sequence stars". But I think I have all the B-V indices for the Orion stars that are off the main sequence.

[nuther edit] Nope, that's not going to work. What they say should be the B-V for a particular spectral type isn't what I already have, in most cases, so i can't trust what they offer enough to mix it into my data. For example, I have a B0 Ia at B-V -0.19, whereas that page says it should be -0.30; and I have a B0.5 Ia at -0.17 while they say it should be -0.28. So if I mix any of that in (where I happen to need another one of each) those data points will sort out of order.

Rob

User avatar
rstevenson
Quis custodiet ipsos custodes?
Posts: 2704
Joined: Fri Mar 28, 2008 1:24 pm
Location: Halifax, NS, Canada

Re: code for creating HR-Diagram?

Post by rstevenson » Thu Mar 21, 2013 2:19 pm

In case anyone stumbles across this thread in the distant future...

I managed to find B-V index values for 79 of my 95 stars. I plotted them up in Excel, getting a good Main Sequence curve as well as the expected cluster of White Dwarfs and other standard features of an H-R Diagram. I manually added a Spectral Type x-axis using the known values of stars I had plotted. Then, using that Spectral Type axis, I placed on the chart by hand the missing 16 stars based on their given Spectral Types.

It worked, and I got a good mark.

Rob

User avatar
Ann
4725 Å
Posts: 13369
Joined: Sat May 29, 2010 5:33 am

Re: code for creating HR-Diagram?

Post by Ann » Thu Mar 21, 2013 4:34 pm

Congrats, Rob! :clap: :clap: :clap:

Ann
Color Commentator

Post Reply