Tuesday, May 17, 2011

Reconstruction with Log Binning

I spent a while playing with the binning that goes into gximat to try to get the point in sximat to overlap more with the correlation functions, but I just couldn't get more than a couple to overlap with the current binning limitations.

Here is code that I used to play with this stuff: ../logs/110513log.py

So I've decided to re-run with some different binnings and see if this helps.

I spent the last day coding up an automation of log binning, and binning in equal-number-of-galaxies in each bin. Alexia had said she wasn't sure how the reconstruction would work with this binning, so we'll see how it turns out.

Here is the code (also in ../logs/110516log.py):

~~~~~~~~~~~

import numpy as N
from pylab import *
from matplotlib import *
import crlnew as crl
from correlationData import *
import galsphere as gals
import datetime as dt

# Makes the working directory for this run.
# Creates directory and returns string of directory name.
workingDir = getworkingdir()

# Create file names
mockLRGfile,photofile,specfile,corr2dfile,corr3dfile,photo2dfile,photoCDfile,spec2dfile,\
spec3dfile,argumentFile,runConstantsFile,wpsMatrixFile,xiMatrixFile,rbinsfile=makeFileNamesNew(workingDir)


#Angular Correlation
oversample = 5.
corrBins = 80.0 #should be one more than you want it to be
mincorr = 0.0001
maxcorr = 10.0
convo = 180./pi
tlogbin = 1 # = 0 for uniform spacing in theta, = 1 for log spacing in theta


#Auto Correlation
boxside = 1000.0 #in Mpc/h
xicorrmin = 0.0001
xicorrmax = 20.0
nxicorr = 40
rlogbin = 1 # = 0 for uniform spacing in r, = 1 for log spacing in r

#make redshift bins
#boxside = 1000.0 #in Mpc/h
zlogbin = 2 # = 0 for uniform spacing in z, = 1 for log spacing in z, = 2 for uniform spacing in number of objects
rbinmin = 0.0001 #in Mpc/h, can't be zero if doing log binning
nrbins = 100
rbinspace = boxside/nrbins #in Mpc/h
rbinmax = boxside/2.0 #in Mpc/h


if zlogbin == 0: rbins = makeRbins(rbinmin,rbinmax,rbinspace)
if zlogbin == 1: rbins = logspace(start = log10(rbinmin), stop = log10(rbinmax), num=nrbins+1, base = 10)

#Catalog sizes
psubsize=1000000
ssubsize=1000000


#Make the spectroscopic and photometric galaxies from mock catalogs
#Return selection functions for photometric and spectroscopic data sets
sfphoto,sfspec,bins=makeSpecPhotoGalaxyFiles(mockLRGfile,workingDir,nxicorr,photofile,specfile)

#Make the spectroscopic and photometric galaxies from mock catalogs
specX,specY,specZ,specDec,specRa,specCD,photoX,photoY,photoZ,photoDec,photoRa,photoCD=getSpecPhotoData(photofile,specfile,psubsize,ssubsize,boxside)

#Make rbins that are uniform in number of galaxies per bin
nspec = size(specCD)
nspecperbin = round(nspec*1.0/nrbins)
sortspecCD = sort(specCD)
rbins2 = linspace(start = min(specCD), stop = max(specCD), num = nrbins+1)
for i in range(nrbins-1): rbins2[i+1] = sortspecCD[(i+1)*nspecperbin-1]

if zlogbin == 2: rbins = rbins2


#Write rbins to a file
writeRbinsToFile(rbinsfile, rbins)

#Read rbins from file
rbins = readRbinsFromFile(rbinsfile)
rbinmin = min(rbins)
rbinmax = max(rbins)
nrbins = len(rbins) - 1


#Write these constants to a file such that if you want to rerun
#You can just read from this file.
writeRunConstantsToFileAllNew(mockLRGfile,photofile,specfile,corr2dfile,corr3dfile,photo2dfile,photoCDfile, \
spec2dfile,spec3dfile,argumentFile,runConstantsFile,wpsMatrixFile,xiMatrixFile,rbinsfile,oversample,corrBins,mincorr, \
maxcorr, boxside,xicorrmin,xicorrmax,nxicorr,rbinmin,rbinmax,nrbins,psubsize,ssubsize,tlogbin,rlogbin,zlogbin)


#get mask (this assumes that the data is in a contiguous box)
minRaP,maxRaP,minDecP,maxDecP,minCDP,maxCDP=getmask(photoRa,photoDec,photoCD)
minRaS,maxRaS,minDecS,maxDecS,minCDS,maxCDS=getmask(specRa,specDec,specCD)

#write masks to file
writemasks(workingDir,minRaP,maxRaP,minDecP,maxDecP,minCDP,maxCDP,minRaS,maxRaS,minDecS,maxDecS,minCDS,maxCDS)

#run cross-correlation function on spectroscopic and photometric data
#run if linear theta binning
if tlogbin == 0: runcrossCorr(workingDir, argumentFile, corr2dfile, spec2dfile, photo2dfile, nrbins, minRaS, maxRaS, minDecS, maxDecS, minRaP, maxRaP, minDecP, maxDecP, mincorr, maxcorr, corrBins) #no log bins


#run if log theta binning
if (tlogbin == 1) & (mincorr > 0): runcrossCorrLog(workingDir, argumentFile, corr2dfile, spec2dfile, photo2dfile, nrbins, minRaS, maxRaS, minDecS, maxDecS, minRaP, maxRaP, minDecP, maxDecP, mincorr, maxcorr, corrBins) # log bins
else: print "mincorr must be > 0"



#run auto correlation function on spectroscopic data
#run if linear r binning
if rlogbin == 0: runautoCorr(workingDir,corr3dfile,xicorrmin,xicorrmax,nxicorr,rbins,specX,specY,specZ,specRa,specDec,specCD) #no log bins


#run if log r binning
if (rlogbin == 1) & (xicorrmin > 0): runautoCorrLog(workingDir,corr3dfile,xicorrmin,xicorrmax,nxicorr,rbins,specX,specY,specZ,specRa,specDec,specCD) # log bins
else: print "xicorrmin must be > 0"

Running now, plots to follow soon!

No comments:

Post a Comment