Friday, June 17, 2011

Summary of Work So Far:


May 28-June 17

My research so far has focused on calculating the velocities of single M dwarfs and M dwarfs in binary pairs.

This summer I am researching the velocities of close binary pairs. From SDSS, we have spectral data on these binaries for multiple exposures. Because the binary pairs that we’re examining are so close together and moving so quickly, in each exposure taken (which can be over a couple of hours), the binaries may have moved causing its spectrum to be redshifted.Using these SDSS exposures and previously compiled templates for each spectral type, we can actually calculate the velocity of these binary pairs. At this point in my research, I have calculated the velocities of over 4,000 M dwarfs that are in M dwarf and white dwarf binary pairs.

Getting Background Information

For some background information, I read and took notes on Silverstri et al (2005), West et al (2008), West et al (2011), and Hilton et al (2010). Also read the chapter “Stellar Activity” in the Textbook New Light on Dark Stars: Red Dwarfs, Low-Mass stars, Brown Dwarfs by Reid and Hawley. After doing this, I worked on some calculations on deriving velocity from wavelength change (Doppler shifts), and also the relationship between mass, separation, and velocity of binaries.

Calculating the velocities of M dwarfs in DR7 Catalogue

The first velocity calculation included calculating the velocities for the M dwarfs listed in AAW’s DR7 Catalogue. Using Doppler shifting techniques, we are able to calculate the velocities of M dwarfs from their spectra. Each binary is catalogued by plate, mjd, and fiber.Plate is the plug plate used, mjd is the mean julian time, which records the time that the exposure was taken, and fiber is the fiber number. In order to calculate a velocity of one of these dwarfs, we had to match spectral templates to the DR7 spectra. In order to normalize them, we zoomed into a flat area of the spectrum between 7300 and 8800 Angstrom and took the average over that region. We then divided the total flux by that average in order to normalize the spectrum. We did the same for the template spectra. Because there aren’t the same number of data points in the template and the DR7 spectra, we had to use the spline function in order to interpolate points in the DR7 spectra. Because we were going to apply this same process to the binary pairs, we zoomed in on the redder end of the spectrum, between 7300 and 8800 Angstroms. This range was determined to be the optimum range that focused on the redder range without giving up too much data accuracy in the spline process. Using the xcorl function, we were able to calculate the pixel shift between the template and the spectra.In order to convert pixel shift into velocity in units of km/s we multiplied the shift by 69.1.

Calculating the velocities of M dwarfs in dM-WD binaries

The same process was used with calculating the velocities of M dwarfs in M dwarf and white dwarf binary pairs. We first read in Dylan’s file, wddm_goods2.dat in order to get plate, mjd, fiber and template used (and therefore spectral type) for each of the M dwarfs in the binaries.We then matched the spectral types to each of the exposures. Depending on the binary, there were 3-9 exposures of each binary. Using the process described above, we calculated the velocities of the M dwarfs for each exposure. From these calculated velocities, we were able to calculate the expected spectrum Doppler shift; by plotting the image below, we can see how the expected shift (represented by dashed lines), corresponds with the movement in the corresponding exposure.

Estimating the separation between the binaries

The next step was to estimate the separation between the binaries. Using a two-body setup, we are able to calculate the separation, but we have to take into account the fact that the radial velocity of the entire system is also measured in our velocity calculation. To take this into consideration, we have to calculate what the radial velocity of the system is. See equations below:

wrapping up a bit

Things I've done:
- finished write-up
- backed up important files
- figured out velocity calculation so that it takes into account the radial velocity of the entire system.
- replied to summer stipend newletter entry/press release
- said goodbye for a couple weeks!

until then!

Thursday, June 16, 2011

separation calculation

Today I worked on a separation calculation for the binaries. Now that we have their velocities, based on spectral type, and making assumptions about their masses, we can estimate the separation between the M dwarf and the WD.

I have a hard time determining what is a reasonable separation between binaries. The only limit that puts it into perspective is Saurav's binaries which are extremely far apart, which means more than 10^13 meters, as given in one of his papers. So if we're smaller than that, we're okay? We'll see.

I toyed around with my first sample before writing out a more automated code. IDL's inability to work with big numbers makes me miss mathematica a little. Ah well.

I've included the SDSS site on the binary I was looking, just to get an idea of 1) how cool the site is (just plug in plate, mjd, fiber and voila!), and 2) see what the spectrum and actual picture looks like.

Super cool!

Dylan reminded me that when looking at spectra to make sure to note if wavelength is in air wavelength -- good reminder, that actually might make the plot I posted yesterday look a little bit better.

Also worked on writing up some quick summaries about my work for KINSC stuff. It's been difficult knowing how much detail I need to put into explaining astronomy jargon and whatnot, but it's been fun. With a little down time today, I read up a little on astrobites, explored astrobetter and read quite a few articles that warned students from entering grad school in astronomy. Let's gooo.

Wednesday, June 15, 2011

....and it was accurate enough!

Run the entire program for the 4,274 binaries. Ran into a little holdup as I had to reindex some of my lists (had some issues with printf at index 4219), and with some help from Dylan (accidentally deleted original file paths...thought I ruined my whole code, whatevs), I've managed to put it all into a neat file that will not be written over if I decide to run my code again.

I've also outlined what I've done so far this summer, so that I can have it all written down and accounted for. Will work on writing some of that up before I head out.

spectral shifts - check!

This morning, I plotted up a couple of exposures of the same binary to make sure that we can actually see the shift we calculated.

The white spectrum is the 1st exposure of a binary, and the red spectrum is the 3rd exposure of the binary. The time between the two exposures is about 36 minutes! The space between the white and red dotted lines show the calculated shift given our calculated radial velocities. They're a little off, but a shift is definitely there! This means that in half an hour or so between exposures, the binaries were moving quickly enough to cause their spectra to be noticeably shifted.

Waiting to hear Andrew's feedback. Fingers crossed that this is accurate enough...

Tuesday, June 14, 2011

goals for today:
-convert TAI into something more relatable
-add signal-to-noise ratio to output table
-clean up code and add more comments
-write-up past couple of weeks (at least lay it out)

Monday, June 13, 2011

Went through and finished formatting my code -- it now additionally outputs, # of exposures and exposure time. Changed my range to 7300 to 8800 A, and this allowed me to lower my shift range to 10. Next up, calc signal-to-noise ratio in the flat part of my curve to make sure my velocities aren't too out of whack. Also hope to write up my work for the last couple of weeks in LaTeX (note to self: remember how to do that).

Still haven't run through the entire sample with my velocity calculation code, but I'll do that tomorrow (I think), once I'm sure the kinks are all out.

you have 30 seconds to sum up your research so far...go!

For group meeting today, I'm supposed to have a brief summary of what I'm doing this summer (think elevator pitch to astro-related folks). Here is what I'm thinking for mine:

This summer, I'm researching the velocities of close binary pairs. From SDSS, we have spectral data on these binaries for multiple exposures. Because the binary pairs that we're examining are so close together and moving so quickly, in each exposure taken (which can be over a couple of hours), the binaries may have moved causing the spectrum to be redshifted. Using these SDSS exposures and previously compiled templates for each spectral type, we can actually calculate the velocity of these binary pairs. At this point in my research, I have calculated the velocities of ~5,000 white dwarf and M dwarf binaries.

Okay, so it needs a little work, and the last line won't be true for a couple of hours, but all in all a good start.

Friday, June 10, 2011

just got to fix that count format

As of now, I have an almost fully written automated code that will go through all the spectra for each exposure and then spit out a list with plate, mjd, fiber, template, and radial velocity. I've written the count function so that counts the number of exposures for each spectrum, but I just have to finish formatting it properly and it will be complete!

Wednesday, June 8, 2011

onto automating the binary spectra velocity code

Currently in the process of automating the binary spectra velocity code.

As of now, I've created a list of the binary spectra I'm reading in, separated it by weird time thing, and it successfully registers in my code. Next up, figure out a way to count the number of exposures and add it to the list. Then onto the radial velocity calculation. In order to do the RV calc, I need to FOR loop my code, but before (ha!) I do that, I want to make sure that all my code is indexed in the proper fashion. 'Til tomorrow.

I don't usually post in the middle of the day, but my code is finally successful!
My flux values for the binary spectra will now be fixed if there is errors on account of cosmic rays!
This will currently work if there are a max of 4 pixels in a row with mask =1. I might increase this later, but otherwise we're good.

Tuesday, June 7, 2011

oh, cosmic rays

I never thought cosmic rays would ever give me such trouble.

Before I can actually put templates to the M dwarf and white dwarf binary spectra, I have to get rid of the effects of cosmic rays. For about 20 or so pixels out of 3000 for any given spectrum, there is cosmic ray interference, causing the flux values at these wavelengths to be extremely large. In order to have a proper fit with the templates, these flux values need to seem normal for the given dwarf. Luckily there is a category titled 'mask' in the spectra files; if mask =1, then there is cosmic ray interference, if mask = 0, then flux isn't tampered with.

But because we're using templates that need to match the binary spectra, we can't just set the flux to 0 at these points; we need to have it somewhat match the rest of the spectra. To do this, we should be able to take the average of the flux values on either side of the pixel with mask =1 EXCEPT for the fact that there may be two or three pixels in a row with mask =1.

So while this should be an easy task: write a little code that searches for the closest pixel with mask value =0, and take the average, it is proving slightly more difficult.

Maybe it's because I'm having an off day (being sick is the worst), but for the life of me, I can't figure out the way to do this properly. I've ended up kind of screwing around with for, if, while statements in order to get the right code. At the moment, I have it just automated to do the average on each side of the pixel with mask =1. Hopefully tomorrow morning I'll be able to focus more and just quickly get this done.

Monday, June 6, 2011

M dwarf velocity code automated!

So I fixed my if/else statements, debugged here and there, and my code is now automated!

The program takes selected M dwarfs from Andrew's DR7 file, pulls the corresponding spectra from SDSS, matches it up with the appropriate template (based on spectral type), and calculates the shifts in spectra. This means that using this program, you can choose any set of M dwarfs from Andrew's DR7 file, and calculate their radial velocities (and compare them to the catalogued radial velocities).

So now that I've done this for individual M dwarfs, we can apply this same process to analyzing M dwarf and white dwarf binaries. Because the WD will take up the bluer end of the spectrum, I've written the code so that the velocity shifts are calculated using only the redder end of the spectrum (between 7200-8800 Angstroms), so as not to interfere with the WD.

Because there are multiple exposures from SDSS data, for close WD-Md pairs (which are moving very fast), we can calculate the velocity from the changes between exposures.

Tomorrow, I will focus on reading in the spectrum of a single WD-Md pair, and doing a similar process for the binary pair, then once that looks good, automating it. Andrew pointed out that I have to be careful as there is cosmic ray interference with some of the spectra I will be using. (It sounds really cool, but will be kind of a pain to deal with).

We had our first group meeting this afternoon -- It was great hearing about what everyone is working on.

Friday, June 3, 2011

(I've decided to do a little bit more on making this blog accessible. While it does serve as my lab notebook at times, I think it would be nice to have the blog written as clearly as possible.)

Looking back, I've done quite a few things today.

I came in needing to fix my spline procedure in order to coordinate my sample spectrum and template. From that I could use the xcorl procedure to return a shift value, which when converted to km/s from pixels (multiply by 69.1), returns the change in velocity.

Below, you can see the finished plot of a sample dM5 spectrum along with its template (blue = sample, black = template).

At the moment I am trying to automate my velocity calculation process so that you can just change the initial indexing number for the first fits file (indicating which SDSS spectrum you are selecting), and then end up with a velocity calculation.

This currently includes the task of automating my file names so that after getting the spectra from SDSS, the corresponding wavelength and flux data can be pulled. As the wavelength and flux data is categorized by file names that directly pertain to the fiber, mjd, and plate numbers, using an automated system that inserts the numbers and gets out the correct file name would quickly and efficiently continue the process. But alas, not all the fiber, mjd, and plate numbers have the same number of digits, so the troubling process of if statements and the like currently ensues.

plate: 3-4 digits
mjd: 5 digits
fiber: 1-3 digits
I thought I had my code fixed --- everything is in and is looped so you don't even have to input an index or anything. But something is still funny, as 1) some of the radial velocities are very off, and 2) running into problems with my IF and ELSE statements.

Thursday, June 2, 2011

So today the computer crashed -- aka, things that I've been working on are (temporarily?) gone.
But no worries! Data has been downloaded to this machine, and it took surprisingly little time to rewrite the codes I've worked on.

Progress report:
So yesterday I was working on downloaded SDSS spectrum.
At the end of today, I have avg flux calculations for my spectrum (neatly-ish graphed) and corresponding template. I've written the spline code out, and need to work on debugging it.

^ KEEP READING OVER SPLINE STUFF ON IDL LIBRARY! maybe it's supposed to be fitting star spectrum to template instead of the other way around?

Also, while the computer was down, I read over the template paper, and read more up about how SDSS works. Very cool.

rememeber: my average for my template seems to be a little off -- while it would make sense for the graph of the wave vs. flux/avg flux to hover between more than and less than 0, it is edging on the side of being more than 0. There's a drop at the most left-hand side of the graph that would account for this, but no matter how narrower I make my xrange, it still includes that drop. For sake of continuing with the process, i'll leave that for now and continue on.

note to self: organize this blog better

Wednesday, June 1, 2011

So far today:
-read in fits file of Andrew's DR7 spectroscopic sample
-put into fits binary table
-picked out some arbitrary values for plate, fiver, and mjd
-used to pull out corresponding spectra from sdss
-used to return wavelength and flux information

Voila, my first spectra plot!
(plate = 53789, mjd = 2212, fiber = 356)

Then I looked at a relatively flat section, in order to calculate its velocity
Also learned that putting $ before my commands allows me to go back to my directory/files from within idl. Very useful trick.

So next up is to write a program that connects the spectra to templates. Dylan helped me out and downloaded the templates for me. First off, I need to figure out which templates correspond to which star spectra. To do this, I need to use a chi-squared fit. From there, I'll need to use the spline function in order to shift the template and star's spectra so that the wavelength values for each occupy the same bin number. From there I can start to connect the spectra to templates with the xcorl procedure.

Notes to self:

Spline function:
result=spline(x,y,t, sig)
where x is star wavelength, y is star flux, t is template flux --> should return adjusted wavelength so in same bin?

result = xcorl, star, temp, range

(-->not sure about how to use adjusted wavelength in the xcorl procedure; I think the input is should be adjusted flux, and that spline returns adjusted wavelength, which would make the spline procedure useless for I definitely need to check that out)

Not quite sure about what function will make the best fit graph using a chi-squared distribution. From what I can gather, I can use the curvefit command, but definitely need to discuss with Andrew.

On another note, I also created a document that will serve as a reference list for all the codes/procedures I make. Last summer I learned the hard way that two months of coding adds up to a lot of files that you forget the purpose of. Hopefully this will help avoid this.

I couldn't have done any of this without help from Bertie, Saurav, and Dylan (and Andrew, of course)! It's great to have such wonderful resources.

things to do tomorrow morning:
-look at red part of m dwarfs (larger than 7000 A), pick a section that is relatively flat, calculate mean value --> from this, divide both template and spectra by this, and compare using where command
-look at .rv in sdss spectra -- calculate velocity change and compare to see if it is the same (Andrew's catalog says v = 18.3088?)