API Reference
Main Routines (projected space)
These are the main routines for counting pairs and estimating correlation functions. They encapsulate all required steps to provide a true end-user experience : you only need to provide data+parameters to receive final results, and perhaps that amazing plot of your next paper
- pcf(tab, tab1, par, nthreads=-1, write=True, plot=False, **kwargs)[source]
Given two astropy tables corresponding to data and random samples, calculate the two-point projected auto-correlation function (pcf)
All input parameters that control binning, cosmology, estimator, etc. are passed in a single dictionary
par, which can be easily generated with default values usinggundam.packpars()and customized laterParameters
- tabastropy table
Table with data particles (D)
- tab1astropy table
Table with random particles (R)
- parMunch dictionary
Input parameters. See Input Parameters Dictionary (pcf) for a detailed description
- nthreadsinteger. Default=-1
Number of threads to use. Default to -1, which means all available cpu cores
- writebool. Default=True
True : write several output files for DD/RR/DR counts, correlations, etc.
False : do not write any output files (except for logs, which are always saved)
- plotbool. Default=False
True : generate the CF plot on screen (and saved to disk when
write=True)False : do not generate any plots
- kwargsdict
Extra keywords passed to
gundam.plotcf()
Returns
- countsMunch dictionary
Munch dictionary, containing all counts and correlations accesible by field keys, e.g. counts.dd, counts.rr, counts.wrp, etc. It also stores the complete log and all input parameters. See Output Dictionary (pcf) for a detailed description.
Examples
import gundam as gun ; from astropy.table import Table gals = Table.read('redgal.fits') # read data rans = Table.read('redgal_rand.fits') # read randoms par = gun.packpars(kind='pcf',outfn='redgal') # generate default parameters cnt = gun.pcf(gals, rans, par, write=True, plot=True) # get pcf and plot
- pccf(tab, tab1, tab2, par, nthreads=-1, write=True, plot=False, **kwargs)[source]
Given three astropy tables corresponding to data, random, and cross samples, this routine calculates the two-point projected cross-correlation function (pccf)
All input parameters that control binning, cosmology, estimator, etc. are passed in a single dictionary
par, which can be easily generated with default values usinggundam.packpars()and customized laterParameters
- tabastropy table
Table with data particles (D)
- tab1astropy table
Table with random particles (R)
- tab2astropy table
Table with cross sample particles (C)
- parMunch dictionary
Input parameters. See Input Parameters Dictionary (pccf) for a detailed description
- nthreadsinteger. Default=-1
Number of threads to use. Default to -1, which means all available cpu cores
- writebool. Default=True
True : write several output files for CD/CR counts, correlations, etc.
False : do not write any output files (except for logs, which are always saved)
- plotbool. Default=False
True : generate the CF plot on screen (and saved to disk when
write=True)False : do not generate any plots
- kwargsdict
Extra keywords passed to
gundam.plotcf()
Returns
- countsMunch dictionary
Munch dictionary, containing all counts and correlations accesible by field keys, e.g. counts.cd, counts.cr, counts.wrp, etc. It also stores the complete log and all input parameters. See Output Dictionary (pccf) for a detailed description
Examples
import gundam as gun ; from astropy.table import Table gals = Table.read('redgal.fits') # read data files rans = Table.read('redgal_rand.fits') qsos = Table.read('qso.fits') par = gun.packpars(kind='pccf',outfn='redgal_qso') # generate default parameters cnt = gun.pccf(gals, rans, qsos, par, write=True ) # get pcf
- rppi_A(tab, par, nthreads=-1, write=True, plot=False, **kwargs)[source]
Given an astropy data table, count pairs in the projected-radial space (\(r_p\) vs \(\pi\) space).
All input parameters that control binning, cosmology, column names, etc. are passed in a single dictionary
par, which can be easily generated with default values usinggundam.packpars()and customized laterParameters
- tabastropy table
Table with data particles
- parMunch dictionary
Input parameters. See Input Parameters Dictionary (rppiA) for a detailed description
- nthreadsinteger. Default=-1
Number of threads to use. Default to -1, which means all available cpu cores
- writebool. Default=True
True : write several output files for counts, correlations, etc.
False : do not write any output files (except for logs, which are always saved)
- plotbool. Default=True
True : generate a plot of counts (integrated radially) vs proj. radius
False : do not generate any plots
- kwargsdict
Extra keywords passed to
gundam.plotcf()
Returns
- countsMunch dictionary
Munch dictionary, containing all counts and correlations accesible by field keys, e.g. counts.dd, counts.bdd, etc. It also stores the complete log and all input parameters. See Output Dictionary (rppiA) for a detailed description
Examples
import gundam as gun ; from astropy.table import Table gals = Table.read('redgal.fits') # read data par = gun.packpars(kind='rppiA',outfn='redgalpairs') # generate default parameters cnt = gun.rppiA(gals, par, write=True, plot=True) # get pair counts and plot
- rppi_C(tab, tab1, par, nthreads=-1, write=True, plot=False, **kwargs)[source]
Given two astropy data tables, cross-count pairs in the projected-radial space (\(r_p\) vs \(\pi\) space).
All input parameters that control binning, cosmology, column names, etc. are passed in a single dictionary
par, which can be easily generated with default values usinggundam.packpars()and customized laterParameters
- tabastropy table
Table with particles (sample D)
- tab1astropy table
Table with particles (sample R)
- parMunch dictionary
Input parameters. See Input Parameters Dictionary (rppiC) for a detailed description
- nthreadsinteger. Default=-1
Number of threads to use. Default to -1, which means all available cpu cores
- writebool. Default=True
True : write several output files for counts, correlations, etc.
False : do not write any output files (except for logs, which are always saved)
- plotbool. Default=True
True : generate a plot of counts (integrated radially) vs proj. radius
False : do not generate any plots
- kwargsdict
Extra keywords passed to
gundam.plotcf()
Returns
- countsMunch dictionary
Munch dictionary, containing all counts and correlations accesible by field keys, e.g. counts.dr, counts.bdr, etc. It also stores the complete log and all input parameters. See Output Dictionary (rppiC) for a detailed description
Examples
import gundam as gun ; from astropy.table import Table qsos = Table.read('qso.fits') # read data gals = Table.read('redgal.fits') # read data par = gun.packpars(kind='rppiC',outfn='qso_rg_pairs') # generate default parameters cnt = gun.rppiC(qsos, gals, par, write=True) # get pair counts
Main Routines (redshift space)
These are the main routines for counting pairs and estimating correlation functions. They encapsulate all required steps to provide a true end-user experience : you only need to provide data+parameters to receive final results, and even that amazing plot of your next paper
- rcf(tab, tab1, par, nthreads=-1, write=True, para=False, plot=False, **kwargs)[source]
Given two astropy tables corresponding to data and random samples, this routine calculates the two-point redshift space auto-correlation function (rcf)
All input parameters that control binning, cosmology, estimator, etc. are passed in a single dictionary
par, which can be easily generated with default values usinggundam.packpars()and customized laterParameters
- tabastropy table
Table with data particles (D)
- tab1astropy table
Table with random particles (R)
- parMunch dictionary
Input parameters. See Input Parameters Dictionary (rcf) for a detailed description
- writebool. Default=True
True : write several output files for DD/RR/DR counts, correlations, etc.
False : do not write any output files (except for logs, which are always saved)
- parabool. Default=False
True : run in parallel over all available ipyparallel engines
False : run serially. No need for any ipyparallel cluster running
- plotbool. Default=False
True : generate the CF plot on screen (and saved to disk when
write=True)False : do not generate any plots
Returns
- countsMunch dictionary
Munch dictionary, containing all counts and correlations accesible by field keys, e.g. counts.dd, counts.rr, counts.xis, etc. It also stores the complete log and all input parameters. See Output Dictionary (rcf) for a detailed description.
Examples
import gundam as gun ; from astropy.table import Table gals = Table.read('redgal.fits') # read data rans = Table.read('redgal_rand.fits') # read randoms par = gun.packpars(kind='rcf',outfn='redgal') # generate default parameters cnt = gun.rcf(gals, rans, par, write=True, plot=True) # get rcf and plot
- rccf(tab, tab1, tab2, par, nthreads=-1, write=True, plot=False, **kwargs)[source]
Given three astropy tables corresponding to data, random, and cross samples, this routine calculates the two-point redshift space cross-correlation function (rccf)
All input parameters that control binning, cosmology, estimator, etc. are passed in a single dictionary
par, which can be easily generated with default values usinggundam.packpars()and customized laterParameters
- tabastropy table
Table with data particles (D)
- tab1astropy table
Table with random particles (R)
- tab2astropy table
Table with cross sample particles (C)
- parMunch dictionary
Input parameters. See Input Parameters Dictionary (rccf) for a detailed description
- nthreadsinteger. Default=-1
Number of threads to use. Default to -1, which means all available cpu cores
- writebool. Default=True
True : write several output files for CD/CR counts, correlations, etc.
False : do not write any output files (except for logs, which are always saved)
- plotbool. Default=False
True : generate the CF plot on screen (and saved to disk when
write=True)False : do not generate any plots
- kwargsdict
Extra keywords passed to
gundam.plotcf()
Returns
- countsMunch dictionary
Munch dictionary, containing all counts and correlations accesible by field keys, e.g. counts.cd, counts.cr, counts.xis, etc. It also stores the complete log and all input parameters. See Output Dictionary (rccf) for a detailed description
Examples
import gundam as gun ; from astropy.table import Table gals = Table.read('redgal.fits') # read data files rans = Table.read('redgal_rand.fits') qsos = Table.read('qso.fits') par = gun.packpars(kind='pccf',outfn='redgal_qso') # generate default parameters cnt = gun.rccf(gals, rans, qsos, par, write=True ) # get rcf
- s_A(tab, par, nthreads=-1, write=True, para=False, plot=False, **kwargs)[source]
Given an astropy table, count pairs in redshift space
All input parameters that control binning, cosmology, column names, etc. are passed in a single dictionary
par, which can be easily generated with default values usinggundam.packpars()and customized laterParameters
- tabastropy table
Table with data particles
- parMunch dictionary
Input parameters. See Input Parameters Dictionary (sA) for a detailed description
- writebool. Default=True
True : write several output files for counts, correlations, etc.
False : do not write any output files (except for logs, which are always saved)
- parabool. Default=False
True : run in parallel over all available ipyparallel engines
False : run serially. No need for any ipyparallel cluster running
- plotbool. Default=False
True : generate a plot of counts vs redshift separation
False : do not generate any plots
Returns
- countsMunch dictionary
Munch dictionary, containing all counts and correlations accesible by field keys, e.g. counts.dd, counts.bdd, etc. It also stores the complete log and all input parameters. See Output Dictionary (sA) for a detailed description
Examples
import gundam as gun ; from astropy.table import Table gals = Table.read('redgal.fits') # read data par = gun.packpars(kind='sA',outfn='redgalpairs') # generate default parameters cnt = gun.s_A(gals, par, write=True, plot=True ) # get counts and plot
- s_C(tab, tab1, par, nthreads=-1, write=True, para=False, plot=False, **kwargs)[source]
Given two astropy tables, cross-count pairs in redshift space
All input parameters that control binning, cosmology, column names, etc. are passed in a single dictionary
par, which can be easily generated with default values usinggundam.packpars()and customized laterParameters
- tabastropy table
Table with particles (sample D)
- tab1astropy table
Table with particles (sample R)
- parMunch dictionary
Input parameters. See Input Parameters Dictionary (sC) for a detailed description
- writebool. Default=True
True : write several output files for counts, correlations, etc.
False : do not write any output files (except for logs, which are always saved)
- parabool. Default=False
True : run in parallel over all available ipyparallel engines
False : run serially. No need for any ipyparallel cluster running
- plotbool. Default=False
True : generate a plot of counts vs redshift separation
False : do not generate any plots
Returns
- countsMunch dictionary
Munch dictionary, containing all counts and correlations accesible by field keys, e.g. counts.dr, counts.bdr, etc. It also stores the complete log and all input parameters. See Output Dictionary (sC) for a detailed description
Examples
import gundam as gun ; from astropy.table import Table qsos = Table.read('qso.fits') # read data gals = Table.read('redgal.fits') # read data par = gun.packpars(kind='sC',outfn='qso_rg_pairs') # generate default parameters cnt = gun.rppiC(qsos, gals, par, write=True) # get pair counts
Main Routines (angular space)
These are the main routines for counting pairs and estimating correlation functions. They encapsulate all required steps to provide a true end-user experience : you only need to provide data+parameters to receive final results, and even that amazing plot of your next paper
- acf(tab, tab1, par, nthreads=-1, write=True, plot=False, **kwargs)[source]
Given two astropy tables corresponding to data and random samples, this routine calculates the two-point angular space auto-correlation function (acf)
All input parameters that control binning, cosmology, estimator, etc. are passed in a single dictionary
par, which can be easily generated with default values usinggundam.packpars()and customized laterParameters
- tabastropy table
Table with data particles (D)
- tab1astropy table
Table with random particles (R)
- parMunch dictionary
Input parameters. See Input Parameters Dictionary (acf) for a detailed description
- nthreadsinteger. Default=-1
Number of threads to use. Default to -1, which means all available cpu cores
- writebool. Default=True
True : write several output files for DD/RR/DR counts, correlations, etc.
False : do not write any output files (except for logs, which are always saved)
- plotbool. Default=False
True : generate the CF plot on screen (and saved to disk when
write=True)False : do not generate any plots
- kwargsdict
Extra keywords passed to
gundam.plotcf()
Returns
- countsMunch dictionary
Munch dictionary, containing all counts and correlations accesible by field keys, e.g. counts.dd, counts.rr, counts.xis, etc. It also stores the complete log and all input parameters. See Output Dictionary (acf) for a detailed description.
Examples
import gundam as gun ; from astropy.table import Table gals = Table.read('redgal.fits') # read data rans = Table.read('redgal_rand.fits') # read randoms par = gun.packpars(kind='rcf',outfn='redgal') # generate default parameters cnt = gun.rcf(gals, rans, par, write=True, plot=True) # get rcf and plot
- accf(tab, tab1, tab2, par, nthreads=-1, write=True, plot=False, **kwargs)[source]
Given three astropy tables corresponding to data, random, and cross samples, this routine calculates the two-point angular space cross-correlation function (accf)
All input parameters that control binning, estimator, column names, etc. are passed in a single dictionary
par, which can be easily generated with default values usinggundam.packpars()and customized laterParameters
- tabastropy table
Table with data particles (D)
- tab1astropy table
Table with random particles (R)
- tab2astropy table
Table with cross sample particles (C)
- parMunch dictionary
Input parameters. See Input Parameters Dictionary (accf) for a detailed description
- nthreadsinteger. Default=-1
Number of threads to use. Default to -1, which means all available cpu cores
- writebool. Default=True
True : write several output files for CD/CR counts, correlations, etc.
False : do not write any output files (except for logs, which are always saved)
- plotbool. Default=False
True : generate the CF plot on screen (and saved to disk when
write=True)False : do not generate any plots
- kwargsdict
Extra keywords passed to
gundam.plotcf()
Returns
- countsMunch dictionary
Munch dictionary, containing all counts and correlations accesible by field keys, e.g. counts.cd, counts.cr, counts.wth, etc. It also stores the complete log and all input parameters. See Output Dictionary (accf) for a detailed description
Examples
import gundam as gun ; from astropy.table import Table gals = Table.read('redgal.fits') # read data files rans = Table.read('redgal_rand.fits') qsos = Table.read('qso.fits') par = gun.packpars(kind='accf',outfn='redgal_qso') # generate default parameters cnt = gun.accf(gals, rans, qsos, par, write=True ) # get accf
- th_A(tab, par, nthreads=-1, write=True, plot=False, **kwargs)[source]
Given an astropy data table, count pairs in angular space
All input parameters that control binning, column names, etc. are passed in a single dictionary
par, which can be easily generated with default values usinggundam.packpars()and customized laterParameters
- tabastropy table
Table with data particles
- parMunch dictionary
Input parameters. See Input Parameters Dictionary (thA) for a detailed description
- nthreadsinteger. Default=-1
Number of threads to use. Default to -1, which means all available cpu cores
- writebool. Default=True
True : write several output files for counts, correlations, etc.
False : do not write any output files (except for logs, which are always saved)
- plotbool. Default=False
True : generate a plot of counts vs angular separation
False : do not generate any plots
- kwargsdict
Extra keywords passed to
gundam.plotcf()
Returns
- countsMunch dictionary
Munch dictionary, containing all counts and correlations accesible by field keys, e.g. counts.dd, counts.bdd, etc. It also stores the complete log and all input parameters. See Output Dictionary (thA) for a detailed description
Examples
import gundam as gun ; from astropy.table import Table gals = Table.read('redgal.fits') # read data par = gun.packpars(kind='thA',outfn='redgalpairs') # generate default parameters cnt = gun.th_A(gals, par, write=True, plot=True ) # get counts and plot
- th_C(tab, tab1, par, nthreads=-1, write=True, plot=False, **kwargs)[source]
Given two astropy data tables, cross-count pairs in angular space
All input parameters that control binning, column names, etc. are passed in a single dictionary
par, which can be easily generated with default values usinggundam.packpars()and customized laterParameters
- tabastropy table
Table with particles (sample D)
- tab1astropy table
Table with particles (sample R)
- parMunch dictionary
Input parameters. See Input Parameters Dictionary (thC) for a detailed description
- nthreadsinteger. Default=-1
Number of threads to use. Default to -1, which means all available cpu cores
- writebool. Default=True
True : write several output files for counts, correlations, etc.
False : do not write any output files (except for logs, which are always saved)
- plotbool. Default=False
True : generate a plot of counts vs angular separation
False : do not generate any plots
- kwargsdict
Extra keywords passed to
gundam.plotcf()
Returns
- countsMunch dictionary
Munch dictionary, containing all counts and correlations accesible by field keys, e.g. counts.dr, counts.bdr, etc. It also stores the complete log and all input parameters. See Output Dictionary (thC) for a detailed description
Examples
import gundam as gun ; from astropy.table import Table qsos = Table.read('qso.fits') # read data gals = Table.read('redgal.fits') # read data par = gun.packpars(kind='thC',outfn='qso_rg_pairs') # generate default parameters cnt = gun.th_C(qsos, gals, par, write=True) # get pair counts
Auxiliary Routines
These are helper routines that make it easy to work with correlations, visualize
count data, optimize grid size, sort data, etc. For examples of how to use them
check their individual help, or even better, the source code of gundam.pcf()
- bestSKgrid2d(par, npts, ras, dens=None)[source]
Try to find the optimum size (mxh1,mxh2) of a 2D skip grid, for an arbitrary sample of (ra,dec) points.
This is far from trivial, so for the moment, this routine works as follows:
Choose an “optimum” target cell density (around 22 ppcell in many tests)
Find the best
mxh1from an empirical best fit relation of npts vs mxh1Adjust
mxh2to reach the target cell density
Parameters
- parMunch dictionary
Input parameters dictionary
- nptsinteger or list of integers
Nr. of objects in the sample(s). For cross-correlations it should be a list of the form [sample_D_size, sample_R,size] and the effective
nptsadopted is their sum- rasfloat array or list of arrays
Right ascention of objects in the samples(s). For cross-correlations, the two samples are concatenated
- densfloat. Default=None
Target cell density. Note that dens=None implicates a default value of 22 if npts>50000 and 16 otherwise.
Returns
- mxh1, mxh2integer
Nr. of DEC and RA cells of the SK table, respectively
- densfloat
The effective cell density adopted
- bestSKgrid3d(par, npts, ras, dens=None)[source]
Try to find the optimum size (mxh1,mxh2,mxh3) of a 3D skip grid, for an arbitrary sample of (ra,dec,dcom) points.
This is far from trivial, so for the moment, this routine works as follows:
Choose an “optimum” target cell density according to the type of correlation
Choose the best
mxh3asmxh3=int((dcmax-dcmin)/rvmax)Find the best
mxh1from an empirical best fit relation of npts vs mxh1Adjust
mxh2to reach the target cell density
Parameters
- parMunch dictionary
Input parameters dictionary
- nptsinteger or list of integers
Nr. of objects in the sample(s). For cross-correlations it should be a list of the form [sample_D_size, sample_R,size] and the effective
nptsadopted is their sum- rasfloat array or list of arrays
Right ascention of objects in the samples(s). For cross-correlations, the two samples are joined together
- densfloat. Default=None
Target cell density. Note that dens=None implicates different default values. See function code.
Returns
- mxh1, mxh2, mxh3integer
Nr. of DEC, RA, DCOM cells of the SK table, respectively
- densfloat
The effective cell density adopted
- cfindex(path='./')[source]
List file_name + description of all count (.cnt) files in a given path. Useful to quickly check a dir with dozens of correlation function runs and therefore hundreds of files.
Parameters
- pathstring
Path to list descriptions of .cnt files inside
- cnttable(cfi, fmt1=None, fmt2=None, write=False, browser=True)[source]
Shows a nicely formatted tabular view of the count data stored in a counts output dictionary. The table is printed in stdout and optionally displayed in the default web browser.
Parameters
- cfistring or Munch dictionary
Filepath for the counts (.cnt) file, or the counts dictionary itself
- fmt1string
Ouput format of numeric fields (bins, correlations and errors). Default=’.4f’
- fmt2string
Ouput format of numeric fields (counts). Default=’.2f’
- writebool
If
write=True, save table to disk. Filename will be asked for. Default=False- browserbool
If
browser=True, display HTML table in browser. Default=True
Returns
- tabastropy table
Single table with all relevant counts as columns. Use
print(tab)ortab.show_in_browser()
Examples
# show info for a projected correlation from file on disk cnttable('/proj/galred.cnt') # show info a from variable in the session's memory cnttable(galred)
- makebins(nsep, sepmin, dsep, logsep)[source]
Create arrays of bins in which Gundam will count pairs and estimate correlation functions, given the number of bins desired, the minimum bin value and the chosen bin width.
Note units are not needed, but should be interpreted according to the input parameters
Parameters
- nsepinteger
Number of bins
- sepminfloat
Minimum bin location
- dsepfloat
Bin width (dex if
logsep=1)- logsepbool
If
True, do log-space binning. IfFalse, do linear-space binning
Returns
- sepfloat array
Bin locations used by Gundam (left-side + extra bin at right limit)
- sepoutfloat array
Left, middle and right-side points of each bin. Useful to plot more easily
Examples
# Create 18 log bins of size=0.2 dex in redshift and projected space seps,sepsout = makebins(18,0.01,0.2,1) sepp,seppout = makebins(18,0.01,0.2,1) # Create 25 bins of size 2 Mpc in radial space, from 0 to 50 Mpc sepv = makebins(25,0.,2.,0)[0] # Create instead 1 bin of size 50 Mpc, e.g. to work out the pcf integrated from 0 to 50 Mpc sepv = makebins(1,0.,50.,0)[0]
- pixsort(tab, colnms, par)[source]
Arrange an astropy table with (ra,dec) or (ra,dec,z) data into a grid of SK pixels and sort the rows of the table according to the pixel index, ordered by a given methodology. This way data in a given pixel sits closer in memory, largely increasing the efficiency of the cache.
Several (experimental) orders such as Morton and Hilbert are available
Parameters
- tab: astropy table
Data table with ra/dec or ra/dec/z points
- colnms: list of strings
Colum names for coordinates and redshift, e.g. [‘ra’,’dec’,’z’], [‘RAJ2000’,’DEJ2000’,’redshift’]
- par: Munch dictionary
Input parameters dictionary. Must contain
mxh1,mxh2,mxh3(when appropiate), the survey boundariessboundand the desired method for orderingpxorder. For samples that cross the RA=0 limit, it can is useful to specify a custom RA boundary. See Custom RA boundaries
Returns
- sidxarray
Sort index. Use
tab=tab[sidx]to actually sort the data
- qprint(self)[source]
Prints a quick, nicely formatted version of Munch dictionaries, such as the counts ouput dictionary or the par input dictionary used by Gundam routines. Very useful to quickly explore what is stored inside.
This routine is added dynamically to the Munch class, so it can be accessed as
any_munch_obj.qprint()Note counts output dictionaries can also be explored using
gundam.cnttable()to display a more elaborated tabular view of (exclusively) the counts calculated.Examples
import gundam as gun # Explore the many arrays and counts of a typical run cred = gun.readcounts('redgalaxies.cnt') cred.qprint() # Check the parameters used to create the run cred.par.qprint()
- radec2xyz(ra, dec, r=0.5)[source]
Converts a (ra,dec) coordinates to rectangular (x,y,z) coordinates in a sphere of radius r.
For
r=0.5, this allows to speed up subsecuent haversine distance calculations between two points, by simply computing \(dhav^2 = (x1-x2)^2 + (y1-y2)^2 + (z1-z2)^2\)Parameters
- ra,decfloat arrays
Right ascention an declination coordinates
- rfloat. Default=0.5
Sphere radius
Returns
- (x,y,z)tuple
Rectangular coordinates
- tpcf(npt, nrpt, dd, bdd, rr, dr, estimator)[source]
Return the (auto)correlation function for a given estimator and arrays of data and random counts
If DR counts are not needed (e.g. the ‘NAT’ estimator), just set
dr=0If boostrap errors are not needed or available, just set
bddto a zero-valued array with null 2nd dimension, e.g.bdd=np.zeros([len(dd),0])Parameters
- npt,nrptinteger
Number of data and random particles
- ddfloat array
DD counts
- bddfloat array
Bootstrap DD counts
- rrfloat array
RR counts in projected and radial separations
- drfloat array
DR counts in projected and radial separations
- estimatorstring
Statistical estimator of the correlation function. Default=`NAT`
‘NAT’ : Natural -> \(DD/RR - 1\)
‘HAM’ : Hamilton -> \(DD*RR/DR^{2} - 1\)
‘LS’ : Landy-Szalay -> \((DD - 2DR + RR) / RR\)
‘DP’ : Davis-Peebles -> \(DD/DR - 1\)
Returns
- xifloat array
Correlation function
- xierrfloat array
Boostrap error estimate. Set to zero if
bddis nulled as explained above
Notes
See this paper for a nice review on estimators and their normalization factors. Here, the normalization factors are derived to : (1) keep estimator formulae clean, (2) avoid having operations such as (npt*(npt-1)) * dd, where counts are multiplied/divided by very big numbers when npt is large.
Examples
# Calculate the angular CF using the Landy-Szalay estimator acf, acferr = gun.tpcf(npt,nrpt,dd,bdd,rr,dr,estimator='LS')
- tpccf(npt, nrpt, cd, bcd, cr, estimator)[source]
Return the (cross)correlation function for a given estimator and count arrays for data (D), random (R) and cross (C) samples.
For the moment the only estimator implemented is the Davis-Peebles : \(\xi=CD/CR-1\)
If bootstrap errors are not needed or available, just set
bddto a zero-valued array, e.g.bdd=np.zeros([len(dd),0])Parameters
- npt,nrptinteger
Number of particles in data (D) and random (R) samples
- cdfloat array
CD counts
- bcdfloat array
Bootstrap CD counts
- crfloat array
CR counts
- estimatorstring
‘DP’ : Davis-Peebles -> \(CD/CR-1\)
Notes
C and D are data samples while R is random sample corresponding to D
Returns
- fxifloat array
Cross-correlation function
- fxierrfloat array
Boostrap error estimates
Examples
import gundam as gun c = gun.readcounts('qso_gal.cnt') (ccf,ccferr) = tpccf(c.npt, c.nrpt, c.cd, c.bcd, c.cr, estimator='DP')
- tpcf_wrp(npt, nrpt, dd, bdd, rr, dr, dsepv, estimator)[source]
Return the projected (auto)correlation function for a given estimator and arrays of data and random counts
If DR counts are not needed (e.g. the ‘NAT’ estimator), just set
dr=0If boostrap errors are not needed or available, just set
bddto a zero-valued array with null 2nd dimension, e.g.bdd=np.zeros([len(dd),0])Parameters
- npt,nrptinteger
Number of data and random particles
- ddfloat array
DD counts in projected and radial separations
- bddfloat array
Bootstrap DD counts in projected and radial separations
- rrfloat array
RR counts in projected and radial separations
- drfloat array
DR counts in projected and radial separations
- dsepvfloat
Bin size in radial direction
- estimatorstring
Statistical estimator of the correlation function
‘NAT’ : Natural -> \(DD/RR - 1\)
‘HAM’ : Hamilton -> \(DD*RR/DR^{2} - 1\)
‘LS’ : Landy-Szalay -> \((DD - 2DR + RR) / RR\)
‘DP’ : Davis-Peebles -> \(DD/DR - 1\)
Returns
- wrpfloat array
Correlation function
- wrperrfloat array
Boostrap error estimate. Set to zero if
bddis nulled as explained above
Notes
See this paper for a nice review on estimators and their normalization factors. Here, the normalization factors are derived to : (1) keep estimator formulae clean, (2) avoid having operations such as (npt*(npt-1)) * dd, where counts are multiplied/divided by very big numbers when npt is large.
Examples (xxxx TODO)
(wrp,wrperr) = tpcf_wrp(npt,nrpt,ddpv,bddpv,rrpv,drpv,dsepv,estimator='HAM')
- tpccf_wrp(npt, nrpt, cd, bcd, cr, dsepv, estimator)[source]
Return the projected (cross)correlation function for a given estimator and count arrays
If boostrap errors are not needed or available, just set
bcdto a zero-valued array with null 2nd dimension, e.g.bcd=np.zeros([len(ddXXX),0])Parameters
- nptinteger
Number of data particles
- nrptinteger
Number of random particles
- cdfloat array
CD counts in projected and radial separations
- bcdfloat array
Bootstrap CD counts in projected and radial separations
- crfloat array
CR counts in projected and radial separations
- dsepvfloat
Radial bin size
- estimatorstring
Statistical estimator of the correlation function
‘DP’ : Davis-Peebles -> \(CD/CR - 1\) (C,D data samples, R is random of D)
Returns
- wrpfloat array
Projected cross-correlation function
- wrperrfloat array
Boostrap error estimate
Examples
# remains to do XXXXX (wrp,wrperr) = tpccf_wrp(npt,nrpt,cd,bcd,cr,dsepv,estimator='DP')
Plotting Routines
- cntplot(cnt, **kwargs)[source]
Plot a correlation function from a counts output dictionary (either read from disk or passed directly). Both axes are set to log-space and axes labels are selected automatically according to the type of correlation (i.e. given by
par.kind)This is a wrapper for
gundam.plotcf(), so all of its parameters can be specified too.Parameters
- cntstring or Munch dictionary
Filepath for the counts (.cnt) file, or the counts dictionary itself
- kwargskeyword list
Any extra [key]=value pairs are passed to the underlying
gundam.plotcf()routine
Examples
import gundam as gun # Read a pcf run and plot the correlation function cnt1 = gun.readcounts('/p01/redgalsP.cnt') cntplot(cnt1) # Plot the correlation function from a .cnt file cntplot('/p01/redgalsA.cnt', label='angcf of redgals', fill=True)
- cntplot2D(cnt, estimator=None, slevel=5, write=False, figfile=None, xlabel=None, ylabel=None, cmap='jet', **kwargs)[source]
Plot the 2D correlation function in the projected-radial space (\(r_p\) vs \(\pi\) space) with optional gaussian smoothing and contour levels
Parameters
- cntstring or Munch dictionary
Filepath for the counts (.cnt) file or the counts output dictionary
- estimatorstring. Default=None
Estimator for the correlation function. Any of (‘NAT’,’LS’,’HAM’,’DP’). If
estimator=None, then it is taken fromcnt.par.estimator- slevelfloat. Default=5
Smoothing level (namely the size of the Gaussian smothing kernel)
- writebool. Default=False
Save the figure to disk (default format is pdf). See Notes to save in other graphic formats
- figfilestring. Default=None
Specify an alternative file name for the figure. If
None, then choosecnt.par.outfnas default. Do not add extension.- xlabel, ylabelstring. Default=None
X-axis and Y-axis labels. If supplied, they override the default labels (\(r_p \ [h^{-1} Mpc]\) and \(\pi \ [h^{-1} Mpc]\))
- cmapstring. Default=’jet’
Colormap for the plot
- kwargskeyword list
Any extra [key]=value pairs are passed to
matplolib.pyplot.pcolor()Use this to customize shading, edges, alpha, etc.
Notes
The graphic format can be changed by passing the
figformatkey inkwargs, e.g.figformat='pdf'. Any format supported by matplotlib is valid.
Examples
# Check some nice Fingers of God and the Kaiser squashing cntplot2D('lum_red_gals.cnt', cmap='viridis')
- comparecf(clist1, clist2=None, shift=0.0, fac=1.0, ploterrbar=True, fill=False, filtneg=False, label=None, plotratio=False, ratioxrange=None, color1=None, marker1=None, markers1=None, linestyle1=None, linewidth1=None, color2=None, marker2=None, markers2=None, linestyle2=None, linewidth2=None, f=None, ax1=None, ax2=None)[source]
Plot multiple correlation functions in a single figure for easy comparison. Optionally show an additional lower panel displaying the ratio of each function respect to a single “control” correlation (many-to-one) or to multiple correlations (one-to-one).
Parameters
- clist1list of Munch dictionaries / list of strings
Count dictionaries or filepaths of .cnt files of correlations
- clist2list of Munch dictionaries / list of strings. Default=None
List of control correlations. When
plotratio=True, the y-values of each correlation curve inclist1are divided by those inclist2(one-to-one) and plotted in a lower panel. Ifclist2has a single element, the ratios are from allclist1divided by the singleclist1. See Notes for more details- shiftfloat. Default=0.0
Fraction of bin size by which
xvalues are shifted. Useful to slightly separate overlapping curves- facfloat. Default=1.0
Multiplication factor for
yandyerr- ploterrbarbool. Default=True
If
ploterrbar=True, plot error bars according toyerr- fillbool. Default=False
If
fill=True, plot a filled semi-transparent error region instead of the usual error bars- filtnegbool. Default=False
If
filtneg=True, filter out points where (y-yerr)<0, i.e. those with large errors in a log plot- label: list
Optional list of strings to label each correlation function. If ommited, the values are taken from the
outfnkey stored in the count objects- plotratiobool. Default=False
If
plotratio=True, plot also a lower panel with ratios ofclist1respect toclist2- ratioxrangelist of form [xmin,xmax]
Only plot the ratio between xmin and xmax
- color1,marker1,markers1,linestyle1,linewidth1lists
List of colors, marker symbols, marker sizes, line styles and line widths for curves in
clist1- color2,marker2,markers2,linestyle2,linewidth2lists
List of colors, marker symbols, marker sizes, line styles and line widths for control curves in
clist2- ffigure instance
Handle of existing Figure instance
- ax1,ax2axes instances
Handles of correlation plot and ratio plot axes
Notes
The correlation curves in
clist2are not plotted in the correlation function panel while curves present in both clists are not shown in the ratio panel (i.e. to avoid ratios of curves respect to themselves).Returns
- (f,ax1,ax2) or (f,ax1)tuple of handles
Handles of figure, correlation axis (ax1) and ratio axis (ax2), if present
Examples
# Compare two w(rp) correlations comparecf(['galred.cnt', 'galblue.cnt']) # Compare one acf on disk with another passed as a counts ouput dictionary comparecf(['/proj/galred.cnt', qso]) # Compare multiple samples and plot sample/control ratios f,ax1,ax2 = comparecf(['galred.cnt', 'galblue.cnt', 'galgreen.cnt'], clist2=['allgals.cnt'], fill=True, plotratio=True) # Add another curve to previous plot comparecf(['qso.cnt'], clist2=['control_qso.cnt'], color2=['k'], f=f, ax1=ax1, ax2=ax2, plotratio=True)
- fitpowerlaw(x, y, yerr, iguess=[1.0, -1.0], fitrange=None, plot=False, markfitrange=False, **kwargs)[source]
Fit a power-law of the form \(ax^{\gamma}\) to a correlation function over a given x-coordinate range. Optionally plot the fitted curve
Parameters
- xfloat array
x-coordinates such as cnt.rpm, cnt.thm, etc.
- yfloat array
x-coordinates such as cnt.wrp, cnt.wth, etc.
- yerrfloat array
Errors in y-coordinates such as cnt.wrperr, cnt.wtherr, etc.
- iguesslist of floats. Default=[1., -1.]
Initial guesses for \(a\) and \(\gamma\)
- fitrangefloat array of form [xmin,xmax]. Default=None
Restrict fit to points inside the given interval
- plotbool. Default=False
Plot the fitted power-law curve
- markfitrangebool. Default=False
Overlay marks for points actually used in the fitting
- kwargskeyword list
Any extra [key]=value pairs are passed to
matplolib.pyplot.plot()Use this to customize colors, linestyles, markers, etc.
Examples
import gundam as gun c1 = gun.readcounts('galaxies.cnt') cntplot(c1) gun.fitpowerlaw(c1.rpm, c1.wrp, c1.wrperr, plot=True)
- plotcf(x, y, yerr, fac=1.0, write=False, figfile=None, par=None, angunit='deg', xlabel=None, ylabel=None, label=None, shift=0.0, ploterrbar=True, fill=False, filtneg=False, **kwargs)[source]
Plot a correlation function from arrays of x, y and yerr values. Both axes are set to log-space and axes labels are selected automatically according to the type of correlation (i.e. given by
par.kind)Parameters
- x,y,yerrfloat arrays
x, y coordinates and corresponding errors of the correlation function. If
yerr=0or all elements of yerr are <=0 orploterrbar=False, no errorbar is plotted- facfloat. Default=1.0
Multiplication factor for
yandyerr- writebool. Default=False
Save the figure to disk (default format is pdf). See Notes to save in other graphic formats
- figfilestring. Default=None
Specify an alternative file name for the figure. If specified, overrides the default which is to take it from
par.outfn. Do not add extension.- pardictionary of type Munch. Default=None
Used to pass
outfnname to name saved figures whenwrite=True- angunitstring. Default=’deg’
‘arcsec’ : set ouput axis in arcsec (
xvalues are unscaled)‘arcmin’ : set ouput axis in arcmin (
xvalues are scaled asx/60)‘deg’ : set ouput axis in degrees (
xvalues are scaled asx/3600)
- xlabel, ylabelstring. Default=None
X-axis and Y-axis labels. If supplied, they override the default labels deduced from
par.kind- labelstring. Default=None
Label for the legend of the curve. If supplied, it will override the default label which is the basename of
par.outfn. Note you have to issue at least a plt.legend() to actually display the legend box- shiftfloat. Default=0.0
Fraction of bin size by which
xvalues are shifted. Useful to slightly separate overlapping curves- ploterrbarbool. Default=True
If
ploterrbar=True, plot error bars according toyerr- fillbool. Default=False
If
fill=True, plot a filled semi-transparent error region instead of the usual error bars- filtnegbool. Default=False
If
filtneg=True, filter out points where (y-yerr)<0, i.e. those with large errors in a log plot- kwargskeyword list
Any extra [key]=value pairs are passed to the underlying
matplotlib.pyplot.plot()routine, except foralphawhich is passed topyplot.fill_between(),capsizewhich is passed topyplot.errorbar(), andfigformatwhich is passed topyplot.savefig(). Use this to customize colors, linestyles, markers, etc.
Notes
Sucessive calls cycle between 4 predefined styles (for color, marker, linewidth, etc.) that can be overrriden by passing the corresponding [key]=value pairs in
kwargsThe output graphic format can be changed by passing the
figformatkey inkwargs, e.g.figformat='pdf'. Any format supported by matplotlib is valid.
Examples
import gundam as gun c1 = gun.readcounts('redgalPCF.cnt') c2 = gun.readcounts('redgalRCF.cnt') plt.figure(1) # Plot w(rp) gun.plotcf(c1.rpm,c1.wrp,c1.wrperr,par=c1.par) plt.figure(2) # Plot xi(s) gun.plotcf(c2.sm,c2.xis,c2.xiserr,par=c2.par,color='yellow')
Comprehensive Auxiliary Routines
These are helper routines that perform many common tasks (in the Python side)
during a correlation run, such as collecting counts, i/o functions, initialization,
logging, etc. For a nice example of how to use them, see source code of
gundam.pcf()
- addlog(file, key, m)[source]
Read a text file and dump it into a key of a given dictionary. Useful to add entire logs from disk into Munch objects
Parameters
- filestring
Complete path of file, usually any log file
- keystring
Name of the key to be created
- mMunch dictionary
The dictionary where the key
m.keywill be created
- allequal(v)[source]
Fast way to check if all elements of a 1D-array have the same value. Useful to detect when all weights are set to 1.0, and hence to call faster versions of the counting routines
Parameters
- varray_like
Array to be checked
Returns
- resbool
True if all elements have the same value
- addpvcols(x, cfo, basecolname, **kwargs)[source]
Auxiliary function used by
gundam.cnttable()to append columns to a table populated with the fields of counts ouput dictionary that store pair counts, all with nice column names. Works with 1d counts or 2d counts arrays (e.g. those from a pcf run whennsepv>1).Parameters
- xastropy table
Table to add data
- cfoMuch dictionary
Counts dictionary with the count arrays, e.g. cfo.dd, cfo.rr, etc.
- basecolnamestring
The name of the field to add, e.g. dd, and also the prefix for the column name, which if needed will be appended with _001, _002, etc. for each radial bin
- kwargs :
Any [key]=value pair to pass to the astropy Column constructor. Intended to pass a format specification for the column, such as
format='.4f'
Returns
None, it modifies the input table
x
- bound2d(decs)[source]
Return the (maximal) survey boundaries in (RA,DEC) for multiple samples. Note in the RA direction, the limits are always set as ramin=0. and ramax=360. to make the pair counting valid for surveys that cross the origin of coordinates
Parameters
- decsfloat array or list of arrays
DEC coordinates of one or more samples [deg]
Returns
- boundtuple
The limits (ramin,ramax,decmin,decmax) that enclose all input samples
- bound3d(decs, dcs)[source]
Return the (maximal) survey boundaries in (RA,DEC,DCOM) for multiple samples. Note in the RA direction, the limits are always set as ramin=0. and ramax=360. to make the pair counting valid for surveys that cross the origin of coordinates
Parameters
- decsfloat array or list of arrays
DEC coordinates of one or more samples [deg]
- dcsfloat array or list of arrays
Comoving distances of one or more samples [Mpc/h]
Returns
- boundtuple
The limits (ramin,ramax,decmin,decmax,dcmin,dcmax) that enclose all input samples
- cross0guess(ra)[source]
Guess if a set of RA coordinates cross the RA=0 division (by finding one source 1deg to the left and another 1deg to the right of RA=0, at least)
Parameters
- raarray
Right ascention coordiantes
Returns
- resbool
True if the sample seems to cross the RA=0 boundary
- buildoutput(par, npts=[], binslmr=[], dd=None, rr=None, dr=None, cd=None, cr=None, bootc=None, cf=None, cferr=None)[source]
Given a set of pair count arrays, assemble the final counts output dictionary, adding also bins, input parameters and relevant sample sizes.
This is for the main Gundam functions that calculate a multiple pair counts, i.e.
gundam.pcf(),gundam.pccf(),gundam.rcf(),gundam.rccf(),gundam.acf(),gundam.accf()Parameters
- parMunch dictionary
Input parameters
- nptslist of int. Default=[]
A list with the nr. of points in each sample, i.e. [npt, npt1]. For example npts=[400, 4000] in cross-count cases; npts=[400] for auto-count cases
- binslmrlist. Default=[]
The left, mid and right-side locations of each bin, returned of example by
gundam.makebins()- dd,rr,drarray. Default=None
The “dd”, “rr” and “dr” count arrays, if available
- cd,crarray. Default=None
The “cd” and “cr” count arrays, if available
- bootcarray. Default=None
The boostrap count array, if available
- cf,cferrarray. Default=None
The correlation function and its error
Returns
- countsMunch dictionary
The ouput dictionary
- buildoutputC(par, npts=[], binslmr=[], dd=None, dr=None, bootc=None, intpi=None, intpib=None)[source]
Given a set of pair count arrays, assemble the final counts output dictionary, adding also bins, input parameters and relevant sample sizes.
This is for the main Gundam functions that calculate a single pair count, i.e.
gundam.rppi_A(),gundam.rppi_C(),gundam.s_A(),gundam.s_C(),gundam.th_A(),gundam.th_C()Parameters
- parMunch dictionary
Input parameters
- nptslist of int. Default=[]
A list with the nr. of points in each sample, i.e. [npt, npt1]. For example npts=[400, 4000] in cross-count cases; npts=[400] for auto-count cases
- binslmrlist. Default=[]
The left, mid and right-side locations of each bin, returned of example by
gundam.makebins()- dd,drarray. Default=None
The “dd” and “dr” count arrays, if available
- bootcarray. Default=None
The boostrap count array, if available
- intpi, intpibarray. Default=None
“dd” counts and boostrap “dd” counts integrated along all radial bins, if available
Returns
- countsMunch dictionary
The ouput dictionary
- check_kind(par, kind)[source]
Check that
par.kind = kind. Useful to test, for example, if you are passing the right par object before really counting pairsParameters
- parMunch dictionary
Input parameters dictionary for Gundam routines
- kindstring
The kind to check against, e.g. ‘pcf’, ‘accf’, ‘rppiA’, etc.
- closelog(log, runspyder=True)[source]
Close the log machinery used by the main counting routines by removing the handlers
Parameters
- loglogging object
The log object
- runspyderbool. Default=True
If
runspyder=True, remove the extra handler for stdout added when running under a Spyder console
- finalize(log, logf, logff, Ltime, t0, counts)[source]
Perform some finalization tasks common to all correlation runs, by logging loop/total times and adding the contents of log files to the counts output dictionary
Parameters
- loglogging object
The log object
- logfilestring
The complete path of the .log file
- Ltime, Ttimefloat
Loop time and total compute time of a correlation run
- countsMunch dictionary
Output dictionary containing all counts and correlations
- initialize(kind, par, nthreads=None, write=None, plot=None)[source]
Perform some initialization tasks common to all correlation function runs, such as reading par from disk file if needed, check the parameter kind, find out if running under Spyder, initialize the logs, etc.
Parameters
- kindstring
The kind to check against, e.g. ‘pcf’, ‘accf’, ‘rppiA’, etc.
- parMunch dictionary
Input parameters dictionary for Gundam routines
- nthreadsinteger.
Number of threads to use. Passed just to store it under par
- writebool. Default=True
Flag to generate output count files. Passed just to store it under par
- plotbool. Default=True
Flag to generate plot. Passed just to store it under par
Returns
- parMunch dictionary
Input parameters dictionary for Gundam routines
- loglogging object
The log object
- logfile, logfilefortstring
The complete path of the .log file and the .fotran.log file
- runspyderbool. Default=True
Detect if running under a Spyder console
- logcallinfo(log, par, npts=[])[source]
Write to log some useful runtime parameters of the main counting routines
Parameters
- loglogging object
The log object
- parMunch dictionary
Input parameters dictionary for Gundam routines
- nptslist of 1, 2 or 3 integers
The nr of objects in the input data table, random table, and cross sample table
- logtimming(log, cntid, t)[source]
Write a message to a log instance, showing the compute time for the counts identified with a certain ID string
Parameters
- loglogging object
Log object
- cntidstring
String to ID a certain type of counts, e.g. ‘DD’, ‘RR’, DR’, etc.
- tfloat
The time elapsed [s]
- readcounts(cfile, silent=False)[source]
Read from disk the counts dictionary generated by the main counting routines.
Parameters
- cfilestring
Filepath for the counts (.cnt) file
- silentbool
If False, print a status message indicating the file was read. Default=False
Returns
- countsMunch dictionary
The counts object
- readpars(filename)[source]
Load from a JSON (.par) file the input parameters dictionary used by many Gundam routines.
Parameters
- filenamestring
Filepath of .par file
- savecounts(cnt, altname=None)[source]
Save to disk the counts output dictionary returned by the main counting routines.
The default file name is
cnt.par.outfn+ .cnt, which can be overriden asaltname+ .cnt, if suppliedParameters
- cntMunch dictionary
The counts object
- altnamestring. Default=None
If supplied, use an alternative file name instead of
cnt.par.outfn
- savepars(par, altname=None)[source]
Save the parameters dictionary par, such as the one generated by
gundam.packpars(), in a JSON file. By default it is named aspar.outfn+ .parParameters
- parMunch dictionary
Input parameters dictionary for Gundam routines
- altnamestring. Default=None
If supplied, use an alternative file name instead of
par.outfn+ .par
Examples
import gundam as gun # Get default values for an angular CF run and save to disk par = gun.packpars(kind='acf', outfn='/proj/acfrun01') gun.savepars(par)
- setlogs(par, runspyder=True)[source]
Set up the log machinery used by the main counting routines by creating the logger object, adding the required handlers and cleaning previous logs if present
Parameters
- parMunch dictionary
Input parameters dictionary for Gundam routines
- runspyderbool. Default=True
If
runspyder=True, add an extra handler for stdout when running under a Spyder console
Returns
- loglogging object
The log object
- logfilestring
The complete path of the .log file
- writeasc_cf(lb, mb, rb, f, ferr, par, fmt='%17.5f', altname=None)[source]
Write an ASCII file for w(rp) / xi(s) / w(th) ouput counts produced by the code
Parameters
- lb,mb,rbfloat arrays
Left, mid and rigth-side of bins
- f, ferrfloat arrays
Correlation function and its error
- parMunch dictionary
Used to pass
par.outfnto name the output file- fmtstring. Default=’%17.5f’
Numeric formatting string
- altnamestring. Default=None
If supplied, use an alternative file name instead of
par.outfn
Examples
import gundam as gun c1 = gun.readcounts('redgals.cnt') writeasc_cf(c1.rpl, c1.rpm, c1.rpr, c1.wrp, c1.wrperr, c1.par)
- writeasc_rppicounts(lb, mb, rb, rppi, par, fmt='%17.5f', cntid=None, altname=None)[source]
Write an ASCII file for a rp-pi count array produced by the code. This is a 2D array of counts in the projected (rp) and radial (pi) directions.
The columns in the output will be [lb mb rb tot_counts rppi] where the first 3 are the left, mid and right-side of bins, tot_counts are the counts integrated for all radial bins, and rppi has one column for each radial bin
Parameters
- lb,mb,rbfloat
Left, mid and rigth-side of bins
- rppifloat array
2-dimensional count array. Usually this is one of the fields cnt.dd, cnt.rr, etc. of a projected correlation run
- parMunch dictionary
Used to pass various data, including
par.outfnto name the output file- fmtstring. Default=’%17.5f’
Numeric formatting string
- cntidstring. Default=None
ID string for column headers. Usually can be ‘dd’, ‘rr’, ‘dr’, etc. Also appended as the extension of the ouput file (when
altname=None)- altnamestring. Default=None
If supplied, use an alternative file name instead of
par.outfn+ .cntid
Examples
import gundam as gun c1 = gun.readcounts('redgals.cnt') c1.par.outfn '/home/myuser/sdss/redgals' # Write the DD counts in rp-pi dimensions gun.writeasc_rppicounts(c1.rpl, c1.rpm, c1.rpr, c1.dd, c1.par, cntid='dd') # Inspect the output file with open('redgals.dd', 'r') as f: print(f.read(), end="") # lb mb rb dd dd_001 dd_002 dd_003 ... # 0.10000 0.12417 0.14835 11509.00 2082.00 1500.00 1168.00 ... # 0.14835 0.18421 0.22007 20273.00 3122.00 2378.00 1899.00 ... # 0.22007 0.27327 0.32647 36169.00 4940.00 3845.00 3283.00 ... # 0.32647 0.40539 0.48431 64866.00 8453.00 6302.00 5236.00 ... # ...
- writeasc_counts(lb, mb, rb, c, par, fmt='%17.5f', cntid=None, altname=None)[source]
Write an ASCII file for a (1-dimensional) counts array produced by the code.
The columns in the output will be [lb mb rb c] where the first 3 are the left, mid and right-side of bins and c are the counts
Parameters
- lb,mb,rbfloat
Left, mid and rigth-side of bins
- cfloat array
Counts array. Usually this is one of the fields cnt.dd, cnt.dr, cnt.rr, etc. of a correlation run
- parMunch dictionary
Used to pass
par.outfnto name the output file- fmtstring. Default=’%17.5f’
Numeric formatting string
- cntidstring. Default=None
ID string for column header. Usually can be ‘dd’, ‘rr’, ‘dr’, etc. Also appended as the extension of the ouput file (when
altname=None)- altnamestring. Default=None
If supplied, use an alternative file name instead of
par.outfn+ .cntid
Examples
import gundam as gun c1 = gun.readcounts('bluegals.cnt') # Write the DD counts in angular dimensions. Use an alternative file name gun.writeasc_counts(c1.thl, c1.thm, c1.thr, c1.dd, c1.par, cntid='dd', altname='akounts') # Inspect the output file with open('akounts', 'r') as f: print(f.read(), end="") # lb mb rb dd # 0.01000 0.01206 0.01413 3178.00 # 0.01413 0.01704 0.01995 6198.00 # 0.01995 0.02407 0.02818 12765.00 # 0.02818 0.03400 0.03981 24888.00 # 0.03981 0.04802 0.05623 49863.00 # 0.05623 0.06783 0.07943 98883.00 ...
Fortran Wrapper Routines
These are the wrappers that call Fortran pair counting routines. They are intended to: (1) choose the fastest counting routine depending whether weights, bootstrap errors, etc. are requested or not; and (2): concentrate all mayor Fortran calling in one place
Unless you are building your own custom script, heavily modifying, or extending the core algorithms, you normally should not need to use these functions
- pairs_auto(par, wunit, logff, tab, x, y, z, sk, ll, dc=None)[source]
Wrapper for calling Fortran counting routines (for auto-pairs)
This function isolates the call of external Fortran routines, choosing the correct one based on geometry, and choosing the fastest depending whether, weights, bootstrap errors, etc. are requested or not.
Parameters
- parMunch dictionary
Input parameters
- wunitbool
True : all weights are equal to 1
False : at least one weight is not 1
- logffstring
File for logging the output of Fortran routines
- tabastropy table
Table with data particles
- x,y,zarrays
Rectangular coordinates of data particles
- sk,llarrays
Skip table (SK) and linked list table (see
gundam.skll2d()orgundam.skll3d())- dcarray [optional]
Array of comoving distances. Not needed for angular counts
Returns
- ttlist of ndarray
Ouput counts as returned by Fortran counting routines
- pairs_cross(par, wunit, logff, tab, x, y, z, tab1, x1, y1, z1, sk1, ll1, dc=None, dc1=None)[source]
Wrapper for calling Fortran counting routines (for cross-pairs among two tables called D(data) and Random(R))
This function isolates the call of external Fortran routines, choosing the correct one based on geometry, and choosing the fastest depending whether, weights, bootstrap errors, etc. are requested or not.
Parameters
- parMunch dictionary
Input parameters
- wunitbool
True : all weights are equal to 1
False : at least one weight is not 1
- logffstring
File for logging the output of Fortran routines
- tab,tab1astropy tables
Table with data particles (D) and random particles (R), respectively
- x,y,z,x1,y1,z1arrays
Rectangular coordinates of particles in D table and R rable, respectively
- tab1astropy table
Table with data particles (D)
- sk1,ll1arrays
Skip table (SK) and linked list table (see
gundam.skll2d()orgundam.skll3d())- dc,dc1arrays [optional]
Array of comoving distances of particles in D and R tables. Not needed for angular counts
Returns
- ttlist of ndarray
Ouput counts as returned by Fortran counting routines