Showing posts with label conversion. Show all posts
Showing posts with label conversion. Show all posts

Wednesday, March 24, 2010

If It Isn't One Correlation Function, It's Another!

I ran my code on the Stripe-82 data for the first time since I fixed the angular correlation functions and now my 3D correlation functions look weird:



I think this has something to do with some changes I made to the conversion from ra/dec to x, y, z. I had been doing something that I don't think is right before and I changed that, but it might now be messing up the masks so that my mask for the 3D correlation functions are now not in the same region as the data. I'm going back to look at the changes I made to investigate this. Thank goodness for repositories!

Tuesday, February 9, 2010

Davis to the Rescue

I was at the cosmology seminar today and I was complaining to Nic Ross about my correlation function woos and Marc Davis happened to be in earshot and told me that I was thinking about this all wrong. Basically what I should do is take my galaxies with coordinates of Ra and Dec and calculate their x,y,z coordinates (projecting them onto a unit sphere). Then I can calculate the 3D correlation function on these objects (which I already have code to do), where I can translate between their physical separation in x, y, z coordinates to their angular separation by the following:

Ra1, Dec1 → x1, y1, z1
Ra2, Dec2 → x2, y2, z2

Separation of objects (s) in Cartesian coordinates:
s = [(x1 - x2)2 + (y1 - y2)2 + (z1 - z2)2]½

Geometry relates the separation angle (γ) to Cartesian separation (s):
s = 2sin(γ/2)

or using the dot product of the two vectors:
x1x2 + y1y2 + z1z2 = cos( γ)

Therefore, the only change I need to make is after I grid objects, and select which objects are 'close by' using above conversion from s to γ, is to convert the 3D separation of the objects to the angular separation. This shouldn't be very difficult to do using the 3D code I already have.

Thank you Marc Davis for making my life a lot better today!

Useful links for writing equations in HTML (used above):
http://www.w3schools.com/tags/ref_entities.asp
http://www.tizag.com/htmlT/htmlsuperscript.php
http://htmlhelp.com/reference/html40/entities/symbols.html

Tuesday, January 26, 2010

My Fault

I wanted to play with the binning of my correlation functions, and so tried to run again with different bin sizes. I got the following message when I tried to run the 2D cross correlation:

In [111]: runcrossCorr(argumentFile, corr2dfile, spec2dfile, photo2dfile, nrbins, minRaS, maxRaS, minDecS, maxDecS, minRaP, maxRaP, minDecP, maxDecP, mincorr, maxcorr, corrBins)
sh: line 1: 15436 Segmentation fault ./2dcorrFinal wpsInputs0 >./wps0.dat
sh: line 1: 15445 Segmentation fault ./2dcorrFinal wpsInputs1 >./wps1.dat
sh: line 1: 15447 Segmentation fault ./2dcorrFinal wpsInputs2 >./wps2.dat
sh: line 1: 15449 Segmentation fault ./2dcorrFinal wpsInputs3 >./wps3.dat
sh: line 1: 15455 Segmentation fault ./2dcorrFinal wpsInputs4 >./wps4.dat
sh: line 1: 15460 Segmentation fault ./2dcorrFinal wpsInputs5 >./wps5.dat
sh: line 1: 15462 Segmentation fault ./2dcorrFinal wpsInputs6 >./wps6.dat
sh: line 1: 15471 Segmentation fault ./2dcorrFinal wpsInputs7 >./wps7.dat
sh: line 1: 15473 Segmentation fault ./2dcorrFinal wpsInputs8 >./wps8.dat
sh: line 1: 15482 Segmentation fault ./2dcorrFinal wpsInputs9 >./wps9.dat
sh: line 1: 15484 Segmentation fault ./2dcorrFinal wpsInputs10 >./wps10.dat
sh: line 1: 15489 Segmentation fault ./2dcorrFinal wpsInputs11 >./wps11.dat
sh: line 1: 15495 Segmentation fault ./2dcorrFinal wpsInputs12 >./wps12.dat
sh: line 1: 15508 Segmentation fault ./2dcorrFinal wpsInputs13 >./wps13.dat
sh: line 1: 15548 Segmentation fault ./2dcorrFinal wpsInputs14 >./wps14.dat
sh: line 1: 15596 Segmentation fault ./2dcorrFinal wpsInputs15 >./wps15.dat

Have I mentioned how much I hate Segmentation Faults?

After an hour of debugging I finally figured out that I had left out a line of code that converted from radians to degrees. I really need to put better error checks into the code so that it prints a message when something like this happens, rather than dying.

Kinda mad at the world now.