Emcee Fitting

I’ve changed the code to use emcee in order to fit the parameters of temperatures, flux ratio, and relative velocities of each targets visit spectrum individually.

In order to tell emcee when the parameters are a bad fit, I return the calculated chi2 value from the generated model. Emcee’s job is to minimize that calculated error.

A step by step process of this can be shown in the ipython notebook hosted here.

The current results are good for 2/3 targets that I have run against. The targets I used in my test sample are:

  • 2M03485329+3132297
  • 2M03405779+3118059
  • 2M03441568+3231282

The results are below (sorry for the screenshot but I was unable to upload the documents on WP).

screen-shot-2016-09-22-at-6-03-57-pm

screen-shot-2016-09-22-at-6-04-27-pm

screen-shot-2016-09-22-at-6-04-36-pm

The resulting parameters. (ignore Passes column, forgot to remove)

(ignore

Even the targets with a good chi2 value have the temperatures swapping every now and then and you can see to compensate for the ratio difference, the flux ratio goes above 1.0 to keep the secondary components flux ratio below the primary. I think these are cases of the initial guesses of the relative velocities were flipped for the primary and secondary.

What does seem odd though is only 2M03441568+3231282 has a consistent temperature of 3500 K. The program may need more time to run against these targets.

For the first target, 2M03405779+3118059, this target seems to require more time as well as it has with even more sporadic temperature values.

More passes may not be the answer though, as it currently takes 2 minutes per visit.

A possible approach to bring down the computation time, as it will be long, would be using multiple computers to run the software using SSH. The time it would save would be worth the time to implement it, but I’m not sure if we can use more.

 

EDIT: visit computation time.

Binary Model Generation and Changing Frames

An update on how the binary model is generated:

The binary model is now generated using martins rv tables and shifting the stars in the modeled binary by the primary and secondary rv values. I also use martins mass ratios in order to adjust the how much the secondary component of the binary is involved.

This gives an accurate (initial) representation of the binary in the rest frame.

To test this, I generated the following plot. The the unshifted spectrum is the resulting spectrum from apStar without any shift. The shifted spectrum is the observed spectrum from apStar but shifted by the visits VHELIO value in the apStars header.

0_0_6

As can be seen, the shifted spectrum is aligned with the model spectrum instead. Showing that to put the observed spectrum into the rest frame we need to shift the observed spectrum by VHELIO to bring it back to the rest frame.

CCF Generation

So far I have been able to plot the CCF between the model spectrum and the observed spectrum with two distinct peaks showing up with the code being found here. But the differences between the official CCFs by APOGEE and mine are very clear. Their CCFs are smoother and show more characteristics than mine as shown between Figure 1 (mine), and Figure 2 (APOGEE’s).

Figure 1: APOGEE Official CCF. Shows the first visits CCF against the model grid

Figure 2: My CCF. Shows the first visits CCF against the model grid.

One thing that could give us a hint of what is making the difference between the two methods is how Figures 3 and 4 below. My plots have two distinct peaks while APOGEES only have one. I think we’ll need to figure out a way to correct for this.

Figure 3: My CCF. Still show two distinct peaks.

Here is a simple way to show all the visits of target 2M05350392-0529033. All files for several targets and their visits can be found here.

Figure 5: Shows how the graph changes per visit.

Figure 6: Shows how the Official APOGEE CCF plots change over visits.

Processing Models

So far processing the models have been pretty successful, but there seems to be a problem with the cross correlation function for calculating the required shift. So far all values get a zero shift EXCEPT when I do not normalize the function. Any help would be appreciated. In the meantime I will continue to develop the code under the assumption it is right.

Everything up to the cross correlation works as it should. But the output coming from the cross correlation function is showing a shift of zero no matter the shift applied to one of the model spectra’s star.

Below is all the spectra that’s used, and the code can be found here.

At first I thought it may have been my normalization function, but it appears to be working properly as seen below:

norm

norm (line 119): The array to use to normalize the result of the cross correlation function.

The totalFlux was also verified to be working with the rest and shifted flux being added together as shown below:

binary_model_spectra

totalFlux[0] (line 113): The combined models of a rest star and one shifted using martins rv tables to determine the velocity difference and added together.

Cspec was taken from aspcap so I can only assume it is correct.

cont_norm

cspec (line 116): The official continuum-normalized spectra of the binary from aspcapStar. Used to cross correlate against the totalFlux. Currently plotting locID=4587, apogeeID= 2M03250916+3126099.

cross_corr_model_prenorm

vel (line 122): The result after cross correlating the totalFlux and cspec.

 

cross_corr_model_postnorm

velNorm (line 123): The result after cross correlating the totalFlux and cspec and normalizing it.

 

 

Model Generation

Currently what I am attempting to do is to generate a spectrum from FERRE that represents a binary system and see how well it fits the observed spectrum.

So far I’ve generated the spectra of the two stars and shifting them by using the velocities generated by martins SB2 code.

The next step is now fitting the the model spectra of the individual stars with the observed spectra.

To do this I will create a “model temperature grid” holding a range that will be tested against the observed spectra and continue to narrow that range until we have a proper approximation.

Environment Setup Complete

The environment setup is now complete. The last of my problems in the setup of the apogee python package were:

  1. was downloading a working gfortran compiler from GCC (the previous one did not work for some reason).
  2. As well as the setup.py file needing to be updated to download the most recent version of FERRE as the previous version was no longer available. (setup.py: line 56, http://www.as.utexas.edu/~hebe/ferre/)

So far I’ve been playing with the package. Mainly the FERRE wrapper.

To do this, I generated gifs of changing parameter(s) values while holding the rest of the generated values static. Some examples to of this are below (click for larger view).

The purpose of these gifs were to get use to FERRE and just see what the data looks like. To get gifs of multiple parameters being dynamic, it’d take a little more work if we would like to go in that direction. The main question would be what order to display the plots when multiple parameters are changing.

Teff

Figure 1: Varies Teff parameter while holding the rest constant.

nm

Figure 2: Varies [N/M] parameter while holding the rest constant.

metals

Figure 3: Varies [M/H] parameter while holding the rest constant.

logg

Figure 4: Varies logg parameter while holding the rest constant.

cm

Figure 5: Varies [C/M] parameter while holding the rest constant.

am

Figure 6: Varies [α/M] parameter while holding the rest constant.

 

 

Environment Setup

What I’ve done so far is followed APOGEE data tutorial found here. This was a very helpful introduction to the data format. It has made it easy to know what to search for instead of being lost.
The rest of my time has been getting the environment for apogee python package by Jo Bovy up and running (took a awhile but I have it now). They were mostly issues with being new to the Unix environment and not very experienced in python.  But it’s speeding up now after these growing pains.
These problems were not having a fortran compiler, wget, and setting permanent environment variables (still can’t, just using temporary ones right now).
I can now easily plot great looking spectra like shown in the README of apogee.
The next step for me now is to start getting the FERRE modeling up.