API Reference
You can find automatically generated documentation for each module in the nemo package below. Note that
some functions listed here may not be used by any of the scripts found in the bin/ directory.
catalogs
This module contains tools for handling catalogs, which are usually astropy.table.Table objects.
- catalog2DS9(catalog, outFileName, constraintsList=[], addInfo=[], idKeyToUse='name', RAKeyToUse='RADeg', decKeyToUse='decDeg', color='cyan', showNames=True, writeNemoInfo=True, coordSys='fk5', regionShape='point', width=1)
Writes a DS9 region file corresponding to the given catalog.
- Parameters
catalog (
astropy.table.Table) – An astropy Table where each row represents an object.outFileName (
str) – A file name for the output DS9 region file.constraintsList (
list, optional) – A list of constraints in the same format as used byselectFromCatalog().addInfo (
list, optional) – A list of dictionaries with keys named key and fmt (e.g.,{'key': "SNR", 'fmt': "%.3f"}). These will be added to the object label shown in DS9.idKeyToUse (
str, optional) – The name of the key in each object dictionary that defines the object’s name. Used to label objects in the DS9 region file.RAKeyToUse (
str, optional) – The name of the key in each object dictionary that contains the RA of the object in decimal degrees.decKeyToUse (
str, optional) – The name of the key in each object dictionary that contains the declination of the object in decimal degrees.color (
str, optional) – The color of the plot symbol used by DS9.writeNemoInfo (
bool, optional) – IfTrue, writes a line with the nemo version and date generated at the top of the DS9 .reg file.coordSys (
str, optional) – A string defining the coordinate system used for RA, dec, as understood by DS9.
- Returns
None
- catalogListToTab(catalogList, keysToWrite=['name', 'RADeg', 'decDeg', 'SNR', 'numSigPix', 'template', 'tileName', 'galacticLatDeg', 'deltaT_c', 'err_deltaT_c', 'y_c', 'err_y_c', 'Y500_sr', 'err_Y500_sr', 'fluxJy', 'err_fluxJy', 'redshift', 'redshiftErr', 'ellipse_PA', 'ellipse_A', 'ellipse_B', 'ellipse_x0', 'ellipse_y0', 'ellipse_e', 'fixed_deltaT_c', 'fixed_err_deltaT_c', 'fixed_y_c', 'fixed_err_y_c'])
Converts a catalog in the form of a list of dictionaries (where each dictionary holds the object properties) into an
astropy.table.Tableobject.- Parameters
catalogList (
list) – Catalog in the form of a list of dictionaries.keysToWrite (
list, optional) – Keys to convert into columns in the output table.
- Returns
An
astropy.table.Tableobject, where each row corresponds to an object in the catalog.
- checkCrossMatch(distArcmin, fixedSNR, z=None, addRMpc=0.5, fitSNRFold=1.164, fitPedestal=0.685, fitNorm=38.097)
Checks the cross match offset between a cluster detection and an external catalog using a model derived from source injection sims (see
nemo.maps.positionRecoveryAnalysis()). The position recovery test itself only accounts for the effect of noise fluctuations in the maps on the recovered SZ cluster positions.- Parameters
distArcmin (
bool) – Distance of the potential cross match from the ACT position in arcmin.fixed_SNR (
float) – Signal-to-noise at reference filter scale (fixed_SNR) in ACT catalog.z (
float, optional) – If given, addRMpc will be converted to arcmin at this redshift, and then added in quadrature to the cross matching radius from the position recovery model.addRMpc (
float, optional) – Accounts for additional positional uncertainty (probably unknown) in the external cross match catalog. This will be added in quadrature.fitSNRFold (
float, optional) – Model fit parameter - e-folding (seenemo.maps.positionRecoveryAnalysis()).fitPedestal (
float, optional) – Model fit parameter - pedestal level (seenemo.maps.positionRecoveryAnalysis()).fitNorm (
float, optional) – Model fit parameter - normalization (seenemo.maps.positionRecoveryAnalysis()).
- Returns
True if distArcmin < model offset (+ optional addRMpc in arcmin at z), False if not.
Note
The default values for the fit parameters are from a run on the f090, f150 ACT DR5 co-added maps (as used in the ACT DR5 cluster catalog paper), and describe a function that recovers 99.7% of the inserted model clusters in source injection simulations.
- crossMatch(refCatalog, matchCatalog, radiusArcmin=2.5)
Cross matches matchCatalog onto refCatalog for objects found within some angular radius (specified in arcmin).
- Parameters
refCatalog (
astropy.table.Table) – The reference catalog.matchCatalog (
astropy.table.Table) – The catalog to match onto the reference catalog.radiusArcmin (
float, optional) – Cross-match radius in arcmin.
- Returns
Cross-matched reference catalog, matchCatalog, and array of angular separation in degrees, for objects in common within the matching radius. The cross matched columns are sorted such that rows in each correspond to the matched objects.
- flagTileBoundarySplits(tab, xMatchRadiusArcmin=2.5)
Flag objects that are closer than some matching radius but which appear in different tiles. These are potentially objects that have been de-blended across tile boundaries (in which case one entry in the catalog should be kept and the other discarded), but some objects in this category are genuine close pairs. At the moment, this is best resolved by visual inspection. This routine adds a flag column named tileBoundarySplit to the catalog to make it easy to spot these cases.
- Parameters
tab (
astropy.table.Table) – The object catalog to be checked.xMatchRadiusArcmin (float, optional) – Cross-match radius in arcmin.
- Returns
Catalog (
astropy.table.Table) with tileBoundarySplit column added - this is True for objects that may have been deblended across tiles, and require visual inspection.
- generateRandomSourcesCatalog(mapData, wcs, numSources, seed=None)
Generate a random source catalog (with amplitudes in deltaT uK), with random positions within the footprint of the given map (areas where pixel values == 0 are ignored). The distribution of source amplitudes is roughly similar to that seen in the 148 GHz ACT maps, but this routine should only be used for tests - it is not a serious attempt at simulating the real extragalactic source population.
- Parameters
mapData (
numpy.ndarray) – Map pixel-data, only used for determining valid area in which sources may be randomly placed (pixel values == 0 are ignored).wcs (
astWCS.WCS) – WCS corresponding to the map.numSources (
int) – Number of random sources to put into the output catalog.seed (optional,
int) – If given, generate the catalog using this random seed value. This is useful for generating the same realization across maps at different frequencies. The seed will be reset after this routine exits.
- Returns
An
astropy.table.Tableobject containing the catalog.
- generateTestCatalog(config, numSourcesPerTile, amplitudeColumnName='fixed_y_c', amplitudeRange=[0.001, 1], amplitudeDistribution='linear', selFn=None, avoidanceRadiusArcmin=20.0, maskDilationPix=0)
Generate a catalog of objects with random positions and amplitudes. This is for testing purposes - see, e.g.,
nemo.maps.sourceInjectionTest().- Parameters
config (
nemo.startup.NemoConfig) – Nemo configuration object.numSourcesPerTile (
int) – The maximum number of sources to insert into each tile. The number of sources actually inserted may be less than this depending on the value of avoidanceRadiusArcmin.amplitudeColumnName (
str) – Name of the column in the output catalog in which source (or cluster) amplitudes will be stored. Typically this should be “deltaT_c” for sources, and “fixed_y_c” for clusters.amplitudeRange (
list) – Range for the random amplitudes, in the form [minimum, maximum].amplitudeDistribution (
str) – Either ‘linear’ or ‘log’.selFn (
nemo.completeness.SelFn, optional) – Nemo selection function object, used to access area masks and coordinates info. If not given, a selFn object will be created using the info in the config. Providing this saves time, as the area mask files don’t have to be read from disk.avoidanceRadiusArcmin (
float) – Minimum separation between two objects in the output catalog. This should be set large enough to avoid crowding and spurious cross-matching problems.maskDilationPix (
int) – Avoid placing objects within this many pixels of the area mask, by dilating the holes in the mask by this number of pixels. Avoids problems with e.g., objects split across the mask boundary. If not set, gives a small number of objects with larger than expected offsets in recovered position innemo.maps.sourceInjectionTest()).
- Returns
An
astropy.table.Tableobject containing the catalog.
- getCatalogWithinImage(tab, shape, wcs, mask=None)
Returns the subset of the catalog with coordinates within the image defined by the given shape, wcs. Optionally, a mask may also be applied.
- Parameters
tab (
astropy.table.Table) – Catalog, as an astropy Table object. Must have columns called ‘RADeg’, ‘decDeg’ that contain object coordinates in decimal degrees.shape (
list) – Shape of the array corresponding to the image / map.wcs (
astWCS.WCS) – WCS of the image.mask (optional,
np.ndarray) – Mask with same dimensions and WCS as the image. Pixels with value = 1 indicate valid area, and pixels with value = 0 are considered to be outside the mask. If this is given, the returned catalog will contain only objects in the valid area defined by this image mask.
- Returns
An astropy Table containing the subset of objects within the image.
- getTableRADecKeys(tab)
Returns the column names in the table in which RA, dec coords are stored, after trying a few possible name variations.
- Parameters
tab (
astropy.table.Table) – The table to search.- Returns
Name of the RA column, name of the dec. column
- makeLongName(RADeg, decDeg, prefix='ACT-CL')
Makes a long format object name string from the given object coordinates, following the IAU convention.
- Parameters
RADeg (
float) – Right ascension of the object in J2000 decimal degrees.decDeg (
float) – Declination of the object in J2000 decimal degrees.prefix (
str, optional) – Prefix for the object name.
- Returns
Object name string in the format prefix JHHMMSS.s+/-DDMMSS.
- makeName(RADeg, decDeg, prefix='ACT-CL')
Makes an object name string from the given object coordinates, following the IAU convention.
- Parameters
RADeg (
float) – Right ascension of the object in J2000 decimal degrees.decDeg (
float) – Declination of the object in J2000 decimal degrees.prefix (
str, optional) – Prefix for the object name.
- Returns
Object name string in the format prefix JHHMM.m+/-DDMM.
- makeOptimalCatalog(catalogDict, constraintsList=[])
Identifies common objects between every catalog in the input dictionary of catalogs, and creates a master catalog with one entry per object, keeping only the details of the highest signal-to-noise detection.
- Parameters
catalogDict (
dict) – Dictionary where each key points to a catalog of objects.constraintsList (
list, optional) – A list of constraints (for the format, seeselectFromCatalog()).
- Returns
None - an
optimalCatalogkey is added tocatalogDictin place.
- removeCrossMatched(refCatalog, matchCatalog, radiusArcmin=2.5)
Cross matches matchCatalog onto refCatalog for objects found within some angular radius (specified in arcmin), and returns refCatalog with the matching entries removed.
- Parameters
refCatalog (
astropy.table.Table) – The reference catalog.matchCatalog (
astropy.table.Table) – The catalog to match onto the reference catalog.radiusArcmin (
float, optional) – Cross-match radius in arcmin.
- Returns
Cross-matched reference catalog (
astropy.table.Table) with matches to matchCatalog removed.
- removeDuplicates(tab)
Removes duplicate objects from the catalog - keeping the highest SNR detection for each duplicate. This routine is used to clean up the output of MPI runs (where we have overlapping tiles).
- Parameters
tab (
astropy.table.Table) – The object catalog to be checked for duplicates.- Returns
Table with duplicates removed (
astropy.table.Table), the number of duplicates found, and a list of names for the duplicated objects.
- selectFromCatalog(catalog, constraintsList)
Return a table of objects matching the given constraints from the catalog.
- Parameters
catalog (
astropy.table.Table) – The catalog from which objects will be selected.constraintsList (
list) – A list of constraints, where each item is a string of the form “key < value”, “key > value”, etc.. Note that the spaces between the key, operator (e.g. ‘<’), and value are essential.
- Returns
An astropy Table object.
- tabToCatalogList(tab)
Converts an
astropy.table.Tableobject into a list of dictionaries.- Parameters
tab (
astropy.table.Table) – Catalog in the form of an astropy Table object.- Returns
A list of dictionaries, where each dictionary represents an object in the catalog.
- writeCatalog(catalog, outFileName, constraintsList=[])
Writes the catalog to disk, including meta data on the Nemo version used to create the catalog in the header.
- Parameters
catalog (
astropy.table.Table) – The object catalog.outFileName (
str) – The output filename. The format depends upon the extension given. Note that CSV format (resulting from using the.csvextension) is written tab-delimited.constraintsList (
list, optional) – A list of constraints, where each item is a string of the form “key < value”, “key > value”, etc.. Note that the spaces between the key, operator (e.g. ‘<’), and value are essential.
- Returns
None
completeness
This module contains tools for calculating the completeness of cluster samples and handling area masks.
- class SelFn(selFnDir, SNRCut, configFileName=None, footprintLabel=None, zStep=0.01, tileNames=None, enableDrawSample=False, mockOversampleFactor=1.0, downsampleRMS=True, applyMFDebiasCorrection=True, applyRelativisticCorrection=True, setUpAreaMask=False, enableCompletenessCalc=True, delta=500, rhoType='critical')
An object that describes the survey selection function. It uses the output in the
selFn/directory (produced by the nemo command) to calculate the survey completeness for a given signal-to-noise cut on a (log10 mass, z) grid for a given set of cosmological and scaling relation parameters.- Parameters
selFnDir (
str) – Path to aselFn/directory, as produced by the nemo command. This directory contains information such as the survey noise maps, area masks, and information needed to construct the filter mismatch function, Q, used in mass modeling.SNRCut (
float) – Completeness will be computed relative to this signal-to-noise selection cut (labelled as fixed_SNR in the catalogs produced by nemo).configFileName (
str, optional) – Path to a Nemo configuration file. If not given, this will be read fromselFnDir/config.yml, which is the config file for the nemo run that produced theselFndirectory.footprintLabel (
str, optional) – Use this to specify a footprint, if any are defined in the Nemo config used to produce theselFndir (e.g., ‘DES’, ‘HSC’, ‘KiDS’ etc.). The default value ofNoneuses the whole survey footprint.zStep (
float, optional) – Use this to set the binning in redshift for completeness calculations.tileNames (
list, optional) – If given, restrict theSelFnobject to use only these tiles.enableDrawSample (
bool, optional) – This only needs to be set to True for generating mock catalogs.mockOversampleFactor (
float, optional) – Used only bygenerateMockSample(). Sets the oversampling level for the generated mock sample.downsampleRMS (
float, optional) – Downsample the resolution of the RMS (noise) tables by this factor. The RMS tables are generated from the noise maps, and are just a listing of noise level versus survey area. Downsampling speeds up completeness calculations considerably.applyMFDebiasCorrection (
bool, optional) – Set to False to disable the Eddington bias correction of mass estimates. Probably only useful for debugging.applyRelativisticCorrection (
bool, optional) – Set to False to disable inclusion of the relativistic correction in completeness calculations.setupAreaMask (
bool, optional) – If True, read in the area masks so that quick position checks can be done (e.g., bySelFn.checkCoordsAreInMask()).enableCompletenessCalc (
bool, optional) – If True, set up the machinery needed to do completeness calculations.
- SNRCut
Completeness will be computed relative to this signal-to-noise selection cut (labelled as fixed_SNR in the catalogs produced by nemo).
- Type
float
- footprintLabel
Use this to specify a footprint, if any are defined in the Nemo config used to produce the
selFndir (e.g., ‘DES’, ‘HSC’, ‘KiDS’ etc.). The default ofNoneuses the whole survey footprint.- Type
str
- applyMFDebiasCorrection
Set to False to disable the Eddington bias correction of mass estimates. Probably only useful for debugging.
- Type
bool
- zStep
Use this to set the binning in redshift for completeness calculations.
- Type
float
- tileNames
The list of tiles used by the SelFn object (default of None uses all tiles).
- Type
list
- WCSDict
A dictionary indexed by tileName, containing
astWCS.WCSobjects that describe the mapping between pixel coords and (RA, dec) coords in each tile.- Type
dict
- areaMaskDict
A dictionary containing the survey area masks, indexed by tileName. Values > 0 in these masks define the cluster or source search area.
- Type
dict
- scalingRelationDict
A dictionary of scaling relation parameters (see example Nemo config files for the format).
- Type
dict
- Q
An object for calculating the filter mismatch function, referred to as Q in the ACT papers from Hasselfield et al. (2013) onwards.
- Type
- RMSDict
A dictionary of RMS tables, indexed by tileName. Each RMSTable contains the noise level by area, as returned by
getRMSTab().- Type
dict
- totalAreaDeg2
The total area in square degrees, as measured from the survey mask, for the given set of tiles and footprint.
- Type
float
- fRelDict
A dictionary of weights used for relativistic corrections, indexed by tileName.
- Type
dict
- mockSurvey
A
MockSurveyobject, used for halo mass function calculations and generating mock catalogs.
Note
Some of the methods of this class are experimental and not necessarily well tested.
- addPDetToCatalog(tab)
Given a catalog, add a column named Pdet, containing the detection probability.
- Parameters
tab (
astropy.table.Table) – A Nemo cluster catalog.- Returns
Catalog with Pdet column added (
astropy.table.Table)
- checkCoordsInAreaMask(RADeg, decDeg)
Checks if the given RA, dec coords are in valid regions of the map.
- Parameters
RADeg (
floatornp.ndarray) – RA in decimal degrees.decDeg (
floatornp.ndarray) – Dec in decimal degrees.
- Returns
True if the coordinates are in the area mask mask, False if not.
- generateMockSample()
Returns a mock catalog (but with no object coordinate information).
Note
This currently uses the average noise level in each tile, rather than the full noise distribution in each tile.
- getMassLimit(completenessFraction, zBinEdges=None)
Return the mass limit (units of 1014 MSun) as a function of redshift, for the given completeness level.
- Parameters
completenessFraction (
float) – The completeness fraction (a number between 0 and 1) at which to return the mass limit.zBinEdges (
np.ndarray, optional) – The redshifts at which the completeness will be evaluated. If not given,self.mockSurvey.zwill be used.
- Returns
Mass completeness by redshift (
np.ndarray).
- projectCatalogToMz(tab)
Project a Nemo cluster catalog (an astropy Table) into the (log10 mass, z) grid, taking into account the uncertainties on y0, and redshift. Note that if the redshift error is non-zero, this is a lot slower.
- Parameters
tab (
astropy.table.Table) – A Nemo cluster catalog, containing redshift and redshiftErr columns.- Returns
A 2d array containing the projection of the catalog on the (log10 mass, z) grid.
- projectCatalogToMz_simple(tab)
Project a Nemo cluster catalog (an astropy Table) into the (log10 mass, z) grid. This version doesn’t take into account any uncertainties (which may be okay if your binning is coarse enough).
- Parameters
tab (
astropy.table.Table) – A Nemo cluster catalog, containing redshift and redshiftErr columns.- Returns
A 2d array containing the projection of the catalog on the (log10 mass, z) grid.
- update(H0, Om0, Ob0, sigma8, ns, scalingRelationDict=None)
Re-calculates the survey-average selection function for a given set of cosmological and scaling relation parameters.
- Returns
None - attributes such as
compMz, the (log10 mass, z) completeness grid, are updated in-place.
- calcCompleteness(RMSTab, SNRCut, tileName, mockSurvey, scalingRelationDict, QFit, plotFileName=None, z=None, method='fast', numDraws=2000000, numIterations=100)
Calculate completeness as a function of (log10 mass, z) on the mockSurvey grid at the given SNRCut. Intrinsic scatter in the scaling relation is taken into account.
- Parameters
RMSTab (
astropy.table.Table) – Table containing noise level by area, as returned bygetRMSTab().SNRCut (
float) – Completeness will be calculated for objects relative to this cut infixed_SNR.tileName (
str) – Name of the map tile.mockSurvey (
nemo.MockSurvey.MockSurvey) – AMockSurveyobject, used for halo mass function calculations and generating mock catalogs.scalingRelationDict (
dict) – A dictionary of scaling relation parameters (see example Nemo config files for the format).QFit (
nemo.signals.QFit) –An object for calculating the filter mismatch function, referred to as Q in the ACT papers from Hasselfield et al. (2013) onwards.
plotFileName (
str, optional) – If given, write a plot showing 90% completness limit to this path.z (
np.ndarray, optional) – Redshifts at which the completeness calculation will be performed. Alternatively, a single redshift can be specified as afloatinstead.method (
str, optional) – Two methods for doing the calculation are available: “fast” (applies the measurement errors and scatter to ‘true’ ỹ0 values on a grid) and “montecarlo” (uses samples drawn from a mock catalog, generated on the fly, to estimate the completeness). Both methods should give consistent results.numDraws (
int, optional) – Used by the “montecarlo” method - sets the number of draws from the halo mass function on each iteration.numIterations (
int, optional) – Used by the “montecarlo” method - sets the number of iterations, i.e., the number of mock catalogs from which the completeness is estimated.
- Returns
A 2d array of (log10 mass, z) completeness.
- calcCompletenessContour(compMz, log10M, z, level=0.9)
Calculates a completeness contour on the (log10 mass, z) plane.
- Parameters
compMz (
np.ndarray) – Map (2d array) of completeness on the (log10 mass, z) plane.log10M (
np.ndarray) – One dimensional array of log10 mass values corresponding to compMz.z (
np.ndarray) – One dimensional arra of redshifts corresponding to compMz.level (
float, optional) – Fractional completeness level (e.g., 0.90 is 90% completeness).
- Returns
Contour values for the given completeness level (a pair of arrays - redshifts, and log10 mass values).
- calcMassLimit(completenessFraction, compMz, mockSurvey, zBinEdges=[])
Given a completeness (log10 mass, z) grid as made by
calcCompleteness(), return the mass limit (units of 1014 MSun) as a function of redshift at the given completeness level. By default, the same binning as the given mockSurvey object is used - this can be overridden by giving zBinEdges.- Parameters
completenessFraction (
float) – Fractional completeness level (e.g., 0.90 is 90% completeness).compMz (
np.ndarray) – Map (2d array) of completeness on the (log10 mass, z) plane.mockSurvey (
nemo.MockSurvey.MockSurvey) – AMockSurveyobject, used for halo mass function calculations and generating mock catalogs.zBinEdges (
np.ndarray, optional) – Redshifts at which the mass limit is evaluated.
- Returns
The mass limit (units of 1014 MSun, 1d array) at each requested redshift.
- calcTileWeightedAverageNoise(tileName, photFilterLabel, selFnDir, footprintLabel=None)
Returns the area weighted average ỹ0 noise value in the tile.
- Parameters
tileName (
str) – The name of the tile.photFilterLabel (
str) – Name of the reference filter, as specified in, e.g., a nemo config file (see Configuration File Parameters).selFnDir (
str) – Path to aselFn/directory, as produced by the nemo command. This directory contains information such as the survey noise maps, area masks, and information needed to construct the filter mismatch function, Q, used in mass modeling.footprintLabel (
str, optional) – The name of the footprint in which the calculation will be done, as defined in the nemo config file (see selFnFootprints).
- Returns
Area-weighted average noise in ỹ0 (
fixed_y_cin Nemo cluster catalogs).
- completenessByFootprint(selFnCollection, mockSurvey, diagnosticsDir, additionalLabel='')
Write out the average (log10 mass, z) grid over all survey footprints provided in selFnCollection, weighted by fraction of total survey area within the footprint. Also prints some useful statistics and produces some plots that are written to the diagnosticsDir directory.
- Parameters
selFnCollection (
dict) – A dictionary where each key points to aSelFnobject that describes a given survey footprint. Here, “full” corresponds to the whole survey, while “DES” may represent the DES footprint, if it has been defined in the nemo config file (see selFnFootprints).mockSurvey (
nemo.MockSurvey.MockSurvey) – AMockSurveyobject, used for halo mass function calculations and generating mock catalogs.diagnosticsDir (
str) – The path to the diagnostics directory, where the output from this routine will be written.additionalLabel (
str, optional) – This will be added to the output filenames (use this for e.g., tagging with thecalcCompleteness()method used).
- Returns
None
Note
Output is written to files named e.g.
diagnosticsDir/MzCompleteness_label.npz, where label is the footprint name (i.e., a key in selFnCollection); ‘full’ is the default (survey-wide average).
- cumulativeAreaMassLimitPlot(z, diagnosticsDir, selFnDir, tileNames)
Makes cumulative plots of the 90%-completeness mass limit versus survey area, at the given redshift.
- Parameters
z (
float) – The redshift at which the mass completeness is evaluated.diagnosticsDir (
str) – Path to thediagnostics/directory, as produced by the nemo command.selFnDir (
str) – Path to aselFn/directory, as produced by the nemo command. This directory contains information such as the survey noise maps, area masks, and information needed to construct the filter mismatch function, Q, used in mass modeling.tileNames (
list) – List of tiles to use.
Note
This routine writes plots into the diagnosticsDir directory (one for the cumulative mass completeness limit over the whole survey area, and one for the deepest 20% only).
- Returns
None
- downsampleRMSTab(RMSTab, stepSize=1.0000000000000001e-07)
Downsamples RMSTab (see
getRMSTab()) in terms of noise resolution, binning by stepSize.- Parameters
RMSTab (
astropy.table.Table) – An RMS table, as produced bygetRMSTab().stepSize (
float, optional) – Sets the re-binning in terms of y0.
- Returns
A table of RMS (noise level) values versus area in square degrees (
astropy.table.Table).
- getRMSTab(tileName, photFilterLabel, selFnDir, footprintLabel=None)
Makes a table containing map area in the tile refered to by tileName against RMS (noise level) values, compressing the information in the RMS maps. Results are cached under selFnDir, and read from disk if found.
- Parameters
tileName (
str) – The name of the tile.photFilterLabel (
str) – Name of the reference filter, as specified in, e.g., a nemo config file (see Configuration File Parameters).selFnDir (
str) – Path to aselFn/directory, as produced by the nemo command. This directory contains information such as the survey noise maps, area masks, and information needed to construct the filter mismatch function, Q, used in mass modeling.footprintLabel (
str, optional) – The name of the footprint in which the calculation will be done, as defined in the nemo config file (see selFnFootprints).
- Returns
A table of RMS (noise level) values versus area in square degrees (
astropy.table.Table).
- getTileTotalAreaDeg2(tileName, selFnDir, masksList=[], footprintLabel=None)
Returns the total area of the tile given by tileName (taking into account masked regions).
- Parameters
tileName (
str) – The name of the tile for which the area will be calculated.selFnDir (
str) – Path to aselFn/directory, as produced by the nemo command. This directory contains information such as the survey noise maps, area masks, and information needed to construct the filter mismatch function, Q, used in mass modeling.masksList (
list, optional) – A list of paths to FITS-format mask images, which contain pixels with values of 1 to indicate valid survey area, 0 otherwise. If given, the area is calculated for the intersection of these masks with the survey area mask.footprintLabel (
str, optional) – The name of the footprint for which the intersection will be calculated, as defined in the nemo config file (see selFnFootprints).
- Returns
Tile area, after masking, in square degrees.
- loadAreaMask(tileName, selFnDir)
Loads the survey area mask, i.e., the area searched for sources and clusters, for the given tile.
- Parameters
tileName (
str) – The name of the tile for which the area mask will be loaded.selFnDir (
str) – Path to aselFn/directory, as produced by the nemo command. This directory contains information such as the survey noise maps, area masks, and information needed to construct the filter mismatch function, Q, used in mass modeling.
- Returns
Map array (2d
np.ndarray), WCS object (astWCS.WCS)
- loadIntersectionMask(tileName, selFnDir, footprint)
Loads the intersection mask for the given tile and footprint.
- Parameters
tileName (
str) – The name of the tile for which the intersection mask will be loaded.selFnDir (
str) – Path to aselFn/directory, as produced by the nemo command. This directory contains information such as the survey noise maps, area masks, and information needed to construct the filter mismatch function, Q, used in mass modeling.footprint (
str) – The name of the footprint for which the intersection will be calculated, as defined in the nemo config file (see selFnFootprints).
- Returns
Map array (2d
np.ndarray), WCS object (astWCS.WCS)
- loadMassLimitMap(tileName, diagnosticsDir, z)
Loads the mass limit map for the given tile at the given redshift.
- Parameters
- Returns
Map array (2d
np.ndarray), WCS object (astWCS.WCS)
- loadRMSMap(tileName, selFnDir, photFilter)
Loads the RMS (noise) map for the given tile.
- Parameters
tileName (
str) – The name of the tile for which the RMS (noise) map will be loaded.selFnDir (
str) – Path to aselFn/directory, as produced by the nemo command. This directory contains information such as the survey noise maps, area masks, and information needed to construct the filter mismatch function, Q, used in mass modeling.photFilter (
str) – Name of the reference filter, as specified in, e.g., a nemo config file (see Configuration File Parameters).
- Returns
Map array (2d
np.ndarray), WCS object (astWCS.WCS)
- makeFullSurveyMassLimitMapPlot(z, config)
Makes full area mass limit map by reprojecting the tile mass limit maps onto the full map pixelisation. Creates both a plot and a FITS image.
- Parameters
z (
float) – The redshift at which the mass completeness is evaluated.config (
nemo.startUp.NemoConfig) – A NemoConfig object.
Note
Output is written to the diagnostics directory, as produced by the nemo command.
- Returns
None
- makeIntersectionMask(tileName, selFnDir, label, masksList=[])
Creates an intersection mask between the survey mask, and the mask files given in masksList.
- Parameters
tileName (
str) – The name of the tile for which the intersection mask will be made (or loaded from disk, if cached).selFnDir (
str) – Path to aselFn/directory, as produced by the nemo command. This directory contains information such as the survey noise maps, area masks, and information needed to construct the filter mismatch function, Q, used in mass modeling.label (
str) – The name of the footprint for which the intersection will be calculated, as defined in the nemo config file (see selFnFootprints).masksList (
list, optional) – A list of paths to FITS-format mask images, which contain pixels with values of 1 to indicate valid survey area, 0 otherwise. If given, the area is calculated for the intersection of these masks with the survey area mask.
- Returns
Intersection mask (1 = valid area, 0 = outside of intersection area; 2d
np.ndarray)
Note
For speed, it is assumed that the declination axis is aligned with the vertical axis in each mask image. This routine caches the intersection masks in selFnDir.
- makeMassLimitMap(SNRCut, z, tileName, photFilterLabel, mockSurvey, scalingRelationDict, QFit, diagnosticsDir, selFnDir)
Makes a map of 90% mass completeness (for now, this fraction is fixed and not adjustable). The map is written as a FITS file in the diagnosticsDir directory.
- Parameters
SNRCut (
float) – Completeness will be calculated for objects relative to this cut infixed_SNR.z (
float) – The redshift at which the mass limit map will be produced.tileName (
str) – The name of the tile.photFilterLabel (
str) – Name of the reference filter, as specified in, e.g., a nemo config file (see Configuration File Parameters).mockSurvey (
nemo.MockSurvey.MockSurvey) – AMockSurveyobject, used for halo mass function calculations and generating mock catalogs.scalingRelationDict (
dict) – A dictionary of scaling relation parameters (see example Nemo config files for the format).QFit (
nemo.signals.QFit) –An object for calculating the filter mismatch function, referred to as Q in the ACT papers from Hasselfield et al. (2013) onwards.
diagnosticsDir (
str) – Path to thediagnostics/directory, as produced by the nemo command.selFnDir (
str) – Path to aselFn/directory, as produced by the nemo command. This directory contains information such as the survey noise maps, area masks, and information needed to construct the filter mismatch function, Q, used in mass modeling.
- makeMassLimitVRedshiftPlot(massLimit_90Complete, zRange, outFileName, title=None)
Makes a plot of 90%-completeness mass limit versus redshift. Uses spline interpolation.
- Parameters
massLimit_90Complete (
np.ndarray) – Mass limit at each redshift, corresponding to 90% completeness.zRange (
np.ndarray) – Redshifts at which mass completeness was evaluted.outFileName (
str) – Path to which the plot file will be written. The format is determined by the file extension.title (
str) – The title that will be written at the top of the plot.
- Returns
None
- makeMzCompletenessPlot(compMz, log10M, z, title, outFileName)
Makes a (log10 mass, z) completeness plot.
- Parameters
compMz (
np.ndarray) – Map (2d array) of completeness on the (log10 mass, z) plane.log10M (
np.ndarray) – One dimensional array of log10 mass values corresponding to compMz.z (
np.ndarray) – One dimensional arra of redshifts corresponding to compMz.title (
str) – Title that will be written at the top of the plot.outFileName (
str) – Path where the plot will be written to a file, with the format being determined by the file extension.
- Returns
None
- tidyUp(config)
Tidies up the selFn directory, constructing multi-extension FITS files from individual tile images and tables, deleting the individual tile files when complete. This routine also copies the given Nemo configuration into the selFn directory, and writes a plain text file that lists the tile names, and the areas covered by each tile.
- Parameters
config (
nemo.startUp.NemoConfig) – A NemoConfig object.- Returns
None
filters
This module defines several filter classes, together with a function that uses them to filter maps.
New base classes can be derived from the overall base class MapFilter. There are two main
classes of filter that are currently implemented - MatchedFilter and RealSpaceMatchedFilter.
There are also base classes corresponding to filters with different signal templates (BeamFilter,
ArnaudModelFilter, BattagliaModelFilter). The actual filters that can be used are
derived from these:
- class ArnaudModelFilter(label, unfilteredMapsDictList, paramsDict, tileName='PRIMARY', writeFilter=False, forceRebuild=False, diagnosticsDir=None, selFnDir=None)
Base class for filters using the GNFW profile as described in Arnaud et al. (2010). Derived from
MapFilter.- makeSignalTemplateMap(beamFileName, amplitude=None)
Makes a model signal template map. Shape parameters (if applicable) are taken from the object’s params attribute.
- Parameters
beam (
nemo.signals.BeamProfileor str) – Either anemo.signals.BeamProfileobject, or a string that gives the path to a text file that describes the beam profile.amplitude (
float) – Amplitude of the signal template.
- Returns
Model map (2d
np.ndarray).
- class ArnaudModelMatchedFilter(label, unfilteredMapsDictList, paramsDict, tileName='PRIMARY', writeFilter=False, forceRebuild=False, diagnosticsDir=None, selFnDir=None)
Fourier-space multi-frequency matched filter implementation, using the GNFW profile as described in Arnaud et al. (2010). Derived from
MapFilter.
- class ArnaudModelRealSpaceMatchedFilter(label, unfilteredMapsDictList, paramsDict, tileName='PRIMARY', writeFilter=False, forceRebuild=False, diagnosticsDir=None, selFnDir=None)
Real-space filter kernel, built using the GNFW profile as described in Arnaud et al. (2010). Derived from
MapFilter.
- class BattagliaModelFilter(label, unfilteredMapsDictList, paramsDict, tileName='PRIMARY', writeFilter=False, forceRebuild=False, diagnosticsDir=None, selFnDir=None)
Base class for filters using the GNFW profile as described in Battaglia et al. (2012). Derived from
MapFilter.Note
This is the same as
ArnaudModelFilter(it is still a GNFW profile), but has non-self-similar evolution with redshift, which is accounted for here. The convention for how the GNFW parameters are defined follows Arnaud et al. (2010), rather than Battaglia et al. (2012).- makeSignalTemplateMap(beamFileName, amplitude=None)
Makes a model signal template map. Shape parameters (if applicable) are taken from the object’s params attribute.
- Parameters
beam (
nemo.signals.BeamProfileor str) – Either anemo.signals.BeamProfileobject, or a string that gives the path to a text file that describes the beam profile.amplitude (
float) – Amplitude of the signal template.
- Returns
Model map (2d
np.ndarray).
- class BattagliaModelMatchedFilter(label, unfilteredMapsDictList, paramsDict, tileName='PRIMARY', writeFilter=False, forceRebuild=False, diagnosticsDir=None, selFnDir=None)
Fourier-space multi-frequency matched filter implementation, using the GNFW profile as described in Battaglia et al. (2012). Derived from
MapFilter.Note
This is the same as
ArnaudModelFilter(it is still a GNFW profile), but has non-self-similar evolution with redshift, which is accounted for here. The convention for how the GNFW parameters are defined follows Arnaud et al. (2010), rather than Battaglia et al. (2012).
- class BattagliaModelRealSpaceMatchedFilter(label, unfilteredMapsDictList, paramsDict, tileName='PRIMARY', writeFilter=False, forceRebuild=False, diagnosticsDir=None, selFnDir=None)
Real-space filter kernel, built using the GNFW profile as described in Battaglia et al. (2012). Derived from
MapFilter.
- class BeamFilter(label, unfilteredMapsDictList, paramsDict, tileName='PRIMARY', writeFilter=False, forceRebuild=False, diagnosticsDir=None, selFnDir=None)
Base class for filters using ACT-style beam profile files. Derived from
MapFilter.- makeSignalTemplateMap(beamFileName, amplitude=None)
Makes a model signal template map. Shape parameters (if applicable) are taken from the object’s params attribute.
- Parameters
beam (
nemo.signals.BeamProfileor str) – Either anemo.signals.BeamProfileobject, or a string that gives the path to a text file that describes the beam profile.amplitude (
float) – Amplitude of the signal template.
- Returns
Model map (2d
np.ndarray).
- class BeamMatchedFilter(label, unfilteredMapsDictList, paramsDict, tileName='PRIMARY', writeFilter=False, forceRebuild=False, diagnosticsDir=None, selFnDir=None)
Fourier-space multi-frequency matched filter implementation using ACT-style beam profile files. Derived from
MapFilter.
- class BeamRealSpaceMatchedFilter(label, unfilteredMapsDictList, paramsDict, tileName='PRIMARY', writeFilter=False, forceRebuild=False, diagnosticsDir=None, selFnDir=None)
Real-space filter kernel, built using ACT-style beam profile files. Derived from
MapFilter.
- class MapFilter(label, unfilteredMapsDictList, paramsDict, tileName='PRIMARY', writeFilter=False, forceRebuild=False, diagnosticsDir=None, selFnDir=None)
Base class for Fourier space filters, defining a common interface.
- Parameters
label (
str) – Unique label for the filter, can be anything.unfilteredMapsDictList (
list) – A list of dictionaries, each of which describes a map of the sky at some frequency (see Input Maps and Masks).paramsDict (
dict) – Dictionary of filter settings (see Filters).tileName (
str) – Name of the tile in which the filter will be constructed.writeFilter (
bool) – If True, save the filter to disk in the diagnosticsDir directory.forceRebuild (
bool) – If True, rebuild the filter, even a previously calculated filter is found cached to disk.diagnosticsDir (
str, optional) – Path to the diagnostics directory, where the filters may be written to disk.selFnDir (
str, optional) – Path to the selFn directory, where area masks may be written.
- label
Unique label for the filter, can be anything.
- Type
str
- diagnosticsDir
Path to the diagnostics directory, where the filters may be written to disk.
- Type
str, optional
- selFnDir
Path to the selFn directory, where area masks may be written.
- Type
str, optional
- tileName
Name of the map tile.
- Type
str
- filterFileName
Path (under diagnosticsDir) where the cached filter is written.
- Type
str
- unfilteredMapsDictList
A list of dictionaries, each of which describes a map of the sky at some frequency (see Input Maps and Masks).
- Type
list
- wcs
Object that contains the map World Coordinate System.
- Type
astWCS.WCS
- shape
Dimensions of the map (height, width) in pixels.
- Type
tuple
- beamSolidAnglesDict
Dictionary, indexed by map frequency in GHz, holding the beam solid angles in nano steradians. Used only for conversion of source amplitudes to flux densities in Jy.
- Type
dict
- buildAndApply()
Builds and applies the filter to the unfiltered map(s).
- Returns
data (
np.ndarray): The filtered map, in signal units.wcs (
astWCS.WCS): WCS object for the map.obsFreqGHz (
float): The observing frequency (in GHz) for the map. This is set to yc if the output units are set to the central Comptonization parameter.SNMap (
np.ndarray): Signal-to-noise map.surveyMask (
np.ndarray): Survey mask, where pixels with value 1 indicate valid area that can be searched for objects.mapUnits (
str): Either uK (for ΔTemperature (μK) with respect to the CMB) or yc (for central Comptonization parameter).beamSolidAngle_nsr (
float): The beam solid angle in nanosteradians. This is only used for conversion of source amplitudes to flux densities in Jy.label (
str): User-defined label for the filter (see Filters).tileName (
str): Name of the tile this filtered map corresponds to.
- Return type
A dictionary, containing the listed keys
- loadFRelWeights()
Reads frequency weights used for relativistic corrections from the filter header.
- Returns
None
- makeForegroundsPower()
Returns 2d power spectrum in k-space, with the power set by a Planck-like CMB power spectrum.
- Returns
A 2d
np.ndarraycontaining the noise power.
- makeNoiseMap(mapData)
Estimate the noise map using local measurements in grid cells, over the whole filtered map (see Filters for the config file parameters that control this).
- Parameters
mapData (
np.ndarray) – A filtered map.- Returns
Noise map (
np.ndarray).
- makeRadiansMap()
Makes a map of distance in radians from the centre of the map being filtered.
- Returns
None
- makeRealSpaceFilterProfile()
Makes a 1d real-space profile of the filter, with amplitude normalised to 1 at the frequency of the first map given in the unfiltered maps list.
- Returns
One dimensional profile (
np.ndarray), corresponding angular range in arcmin (np.ndarray).
- makeSignalTemplateMap(beam, amplitude=None)
Makes a model signal template map. Shape parameters (if applicable) are taken from the object’s params attribute.
- Parameters
beam (
nemo.signals.BeamProfileor str) – Either anemo.signals.BeamProfileobject, or a string that gives the path to a text file that describes the beam profile.amplitude (
float) – Amplitude of the signal template.
- Returns
Model map (2d
np.ndarray).
- saveRealSpaceFilterProfile()
Saves a real-space profile of the filter as a PNG plot under the diagnosticsDir directory.
- Returns
None
- class MatchedFilter(label, unfilteredMapsDictList, paramsDict, tileName='PRIMARY', writeFilter=False, forceRebuild=False, diagnosticsDir=None, selFnDir=None)
A multi-frequency matched filter, implemented in Fourier space. Derived from
MapFilter.- applyFilter(mapDataToFilter)
Apply the filter to the given map data (must be 3d array, i.e., a cube, with each plane corresponding to a different frequency). If the map data is not complex, it will be Fourier transformed. If the map data is not the same shape as the filter, the filter will be interpolated to match.
- Parameters
mapDataToFilter (
np.ndarray) – A 3d array, where each plane corresponds to a map at a different observed frequency. This must match with how the filter was defined (see Filters and Input Maps and Masks).- Returns
Filtered map (2d
np.ndarray)
- buildAndApply()
Builds and applies the filter to the unfiltered map(s).
- Returns
data (
np.ndarray): The filtered map, in signal units.wcs (
astWCS.WCS): WCS object for the map.obsFreqGHz (
float): The observing frequency (in GHz) for the map. This is set to yc if the output units are set to the central Comptonization parameter.SNMap (
np.ndarray): Signal-to-noise map.surveyMask (
np.ndarray): Survey mask, where pixels with value 1 indicate valid area that can be searched for objects.mapUnits (
str): Either uK (for ΔTemperature (μK) with respect to the CMB) or yc (for central Comptonization parameter).beamSolidAngle_nsr (
float): The beam solid angle in nanosteradians. This is only used for conversion of source amplitudes to flux densities in Jy.label (
str): User-defined label for the filter (see Filters).tileName (
str): Name of the tile this filtered map corresponds to.
- Return type
A dictionary, containing the listed keys
- loadFilter()
Loads in a previously saved filter.
- Returns
None
- reshapeFilter(shape)
Uses linear interpolation to transform the filter to the given shape.
- Returns
Reshaped filter (2d
np.ndarray)
- class RealSpaceMatchedFilter(label, unfilteredMapsDictList, paramsDict, tileName='PRIMARY', writeFilter=False, forceRebuild=False, diagnosticsDir=None, selFnDir=None)
Makes a matched-filter kernel using the noise properties of a specified region of the map (e.g., the deepest part) in Fourier space, which is converted into real space and truncated such that the kernel is small enough in footprint to be applied by direct convolution with the map in a (relatively) short amount of time. Derived from
MapFilter.- applyFilter(mapDataToFilter, calcFRelWeights=False)
Apply the filter to the given map data (must be 3d array, i.e., a cube, with each plane corresponding to a different frequency).
- Parameters
mapDataToFilter (
np.ndarray) – A 3d array, where each plane corresponds to a map at a different observed frequency. This must match with how the filter was defined (see Filters and Input Maps and Masks).calcFRelWeights (
bool, optional) – This should only be set to True if this routine is being applied to an ideal signal map.
- Returns
Filtered map (2d
np.ndarray)
- buildAndApply()
Builds and applies the filter to the unfiltered map(s).
- Returns
data (
np.ndarray): The filtered map, in signal units.wcs (
astWCS.WCS): WCS object for the map.obsFreqGHz (
float): The observing frequency (in GHz) for the map. This is set to yc if the output units are set to the central Comptonization parameter.SNMap (
np.ndarray): Signal-to-noise map.surveyMask (
np.ndarray): Survey mask, where pixels with value 1 indicate valid area that can be searched for objects.mapUnits (
str): Either uK (for ΔTemperature (μK) with respect to the CMB) or yc (for central Comptonization parameter).beamSolidAngle_nsr (
float): The beam solid angle in nanosteradians. This is only used for conversion of source amplitudes to flux densities in Jy.label (
str): User-defined label for the filter (see Filters).tileName (
str): Name of the tile this filtered map corresponds to.
- Return type
A dictionary, containing the listed keys
- buildKernel(RADecSection, RADeg='centre', decDeg='centre')
Builds the real space filter kernel.
- Parameters
RADecSection (
list) – List of coordinates (minimum RA, maximum RA, minimum declination, maximum declination) that defines the region of map from which the filter kernel will be constructed.RADeg (
strorfloat, optional) – Coordinate at which the kernel pixel scale will be determined (use centre for the middle of the map section).decDeg (
strorfloat, optional) – Coordinate at which the kernel pixel scale will be determined (use centre for the middle of the map section).
- Returns
None
- loadFilter()
Loads in a previously saved filter kernel.
- Returns
None
- filterMaps(unfilteredMapsDictList, filterParams, tileName, filteredMapsDir='.', diagnosticsDir='.', selFnDir='.', verbose=True, undoPixelWindow=True, useCachedMaps=True, returnFilter=False)
Builds and applies filters to the unfiltered map(s).
- Parameters
unfilteredMapsDictList (
list) – A list of dictionaries, each of which describes a map of the sky at some frequency (see Input Maps and Masks).filterParams (
dict) – A dictionary containing filter settings (see Filters).tileName (
str) – The name of the tile.filteredMapsDir (
str, optional) – The path to the directory where the filtered maps may be written.diagnosticsDir (
str, optional) – Path to the diagnostics directory, where the filters may be written to disk.selFnDir (
str, optional) – Path to the selFn directory, where area masks may be written.verbose (
bool, optional) – If True, write information about progress to the terminal.undoPixelWindow (
bool, optional) – If True, undo the pixel window effect on the output filtered maps.useCachedMaps (
bool, optional) – If True, and previously made maps are found, these will be read from disk, rather than re-calculating and re-applying the filter.returnFilter (
bool, optional) – If True, the filter object is returned, as well as a dictionary containing the filtered map.
- Returns
A dictionary containing the filtered map in signal units, a signal-to-noise-map, area mask, WCS, and a label (for housekeeping).
gnfw
Routines to perform line-of-sight integrals of the GNFW model.
This code was originally written by Matthew Hasselfield, and has been slightly extended.
- func(x, params)
The GNFW radial profile.
- Parameters
x (
np.ndarray) – Radial coordinate.params (
dict) – Dictionary with keys alpha, beta, gamma, c500, and P0 that defines the GNFW profile shape.
- Returns
Profile (1d
np.ndarray).
- integrated(b, params={'P0': 8.403, 'alpha': 1.051, 'beta': 5.4905, 'c500': 1.177, 'gamma': 0.3081, 'npts': 100, 'tol': 1e-07})
Returns the line of sight integral of the GNFW profile at impact parameter b.
- Parameters
b (
float) – Impact parameter.params (
dict) – Dictionary with keys alpha, beta, gamma, c500, and P0 that defines the GNFW profile shape.
- Returns
Line of sight integral at given impact parameter.
- xfunc(x, b, params)
The log-scaled integrand for GNFW cylindrical integration along the line-of-sight coordinate x, with impact parameter b.
- Parameters
x (
np.ndarray) – Line-of-sight coordinate.b (
float) – Impact parameter.params (
dict) – Dictionary with keys alpha, beta, gamma, c500, and P0 that defines the GNFW profile shape.
- Returns
Value of integrand.
maps
This module contains tools for manipulating maps.
- addAutoTileDefinitions(parDict, DS9RegionFileName=None, cacheFileName=None)
Runs autotiler to add automatic tile definitions into the parameters dictionary in-place.
- Parameters
parDict (
dict) – Dictionary containing the contents of the Nemo config file.DS9RegionFileName (str, optional) – Path to DS9 regions file to be written.
cacheFileName (str, optional) – Path to output a cached .yml file which will can be read instead on repeated runs (for speed).
- addWhiteNoise(mapData, noisePerPix)
Adds Gaussian distributed white noise to mapData.
- applyPointSourceMask(maskFileName, mapData, mapWCS, mask=0.0, radiusArcmin=2.8)
Given file name pointing to a point source mask (as made by maskOutSources), apply it to given mapData.
- autotiler(surveyMask, wcs, targetTileWidth, targetTileHeight)
Given a survey mask (where values > 0 indicate valid area, and 0 indicates area to be ignored), figure out an optimal tiling strategy to accommodate tiles of the given dimensions. The survey mask need not be contiguous (e.g., AdvACT and SO maps, using the default pixelization, can be segmented into three or more different regions).
- Parameters
surveyMask (numpy.ndarray) – Survey mask image (2d array). Values > 0 will be taken to define valid area.
wcs (astWCS.WCS) – WCS associated with survey mask image.
targetTileWidth (float) – Desired tile width, in degrees (RA direction for CAR).
targetTileHeight (float) – Desired tile height, in degrees (dec direction for CAR).
- Returns
Dictionary list defining tiles in same format as config file.
Note
While this routine will try to match the target file sizes, it may not match exactly. Also, makeTileDir will expand tiles by a user-specified amount such that they overlap.
- checkMask(fileName)
Checks whether a mask contains negative values (invalid) and throws an exception if this is the case.
- Parameters
fileName (str) – Name of the .fits format mask file to check
- convertToDeltaT(mapData, obsFrequencyGHz=148, TCMBAlpha=0.0, z=None)
Converts an array (e.g., a map) of Compton y parameter values to ΔTemperature (μK) with respect to the CMB at the given frequency.
- Parameters
mapData (
np.ndarray) – An array containing Compton y parameter values.obsFrequencyGHz (
float) – Frequency in GHz at which to do the conversion.TCMBAlpha (
float, optional) – This should always be zero unless you really do want to make a model where CMB temperature evolves as T0 * (1+z)1-TCMBAlpha.z (
float, optional) – Redshift - needed only if TCMBAlpha is non-zero.
- Returns
An array of ΔT (μK) values.
- convertToY(mapData, obsFrequencyGHz=148)
Converts an array (e.g., a map) in ΔTemperature (μK) with respect to the CMB to Compton y parameter values at the given frequency.
- Parameters
mapData (
np.ndarray) – An array containing delta T (micro Kelvin, with respect to CMB) values.obsFrequencyGHz (
float) – Frequency in GHz at which to do the conversion.
- Returns
An array of Compton y parameter values.
- convolveMapWithBeam(data, wcs, beam, maxDistDegrees=1.0)
Convolves map defined by data, wcs with the beam.
- Parameters
data (
numpy.ndarray) – Map to convolve, as 2d array.wcs (
astWCS.WCS) – WCS corresponding to data (i.e., the map).beam (
BeamProfileor str) – Either a BeamProfile object, or a string that gives the path to a text file that describes the beam profile.maxDistDegrees (float) – Sets the size of the convolution kernel, for optimization purposes.
- Returns
Beam-convolved map (numpy array).
Note
The pixel scale used to define the convolution kernel is evaluated at the central map pixel. So, this routine should only be used with either pixelisations where the scale is constant or on relatively small tiles.
- estimateContamination(contamSimDict, imageDict, SNRKeys, label, diagnosticsDir)
Performs the actual contamination estimate, makes output under diagnosticsDir.
Use label to set a prefix for output (plots / .fits tables), e.g., label = “skySim”
- estimateContaminationFromInvertedMaps(config, imageDict)
Run the whole filtering set up again, on inverted maps.
Writes a DS9. reg file, which contains only the highest SNR contaminants (since these are most likely to be associated with artefacts in the map - e.g., point source masking).
Writes a plot and a .fits table to the diagnostics dir.
Runs over both SNR and fixed_SNR values.
Returns a dictionary containing the results
- estimateContaminationFromSkySim(config, imageDict)
Estimate contamination by running on source-free sky simulations (CMB plus noise that we generate here on the fly).
This uses the same kernels that were constructed and used on the real maps. The whole filtering and object detection pipeline is run on the simulated maps repeatedly. The number of sky sims used (set by numSkySims in the .yml config file) should be fairly large (~100) for the results to be robust (results on individual sims can vary by a lot).
- Parameters
config (
startUp.NemoConfig) – Nemo configuration object.imageDict (
dict) – A dictionary containing the output filtered maps and catalogs from running on the real data (i.e., the output of pipelines.filterMapsAndMakeCatalogs). This will not be modified, but is used for estimating the contamination rate by comparison to the source-free sims.
- Returns
A dictionary where each key points to an astropy Table object containing the average contamination estimate corresponding to SNR (maximal estimate) and fixed_SNR (for the chosen reference filter scale).
- getPixelAreaArcmin2Map(shape, wcs)
Returns a map of pixel area in arcmin2
- loadTile(pathToTileImages, tileName, returnWCS=False)
Given a path to a directory full of tiles, or a .fits file, return the map array and (optionally) the WCS.
- Parameters
pathToTileImages (str) – Path to either a .fits file, or a directory full of .fits files named by tileName.
tileName (str) – The name of the tile to load.
- Returns
Map data (and optionally wcs)
- makeModelImage(shape, wcs, catalog, beamFileName, obsFreqGHz=None, GNFWParams='default', profile='A10', cosmoModel=None, applyPixelWindow=True, override=None, validAreaSection=None, minSNR=0.0, TCMBAlpha=0)
Make a map with the given dimensions (shape) and WCS, containing model clusters or point sources, with properties as listed in the catalog. This can be used to either inject or subtract sources from real maps.
- Parameters
shape (tuple) – The dimensions of the output map (height, width) that will contain the model sources.
wcs (
astWCS.WCS) – A WCS object that defines the coordinate system of the map.catalog (
astropy.table.Tableor str) – An astropy Table object containing the catalog, or a string containing the path to a catalog that astropy Table understands. The catalog must include columns named ‘RADeg’, ‘decDeg’ that give object coordinates. For point sources, the amplitude in uK must be given in a column named ‘deltaT_c’. For clusters, either ‘M500’ (in units of 10^14 MSun), ‘z’, and ‘fixed_y_c’ must be given (as in a mock catalog), OR the catalog must contain a ‘template’ column, with templates named like, e.g., Arnaud_M1e14_z0p2 (for a z = 0.2, M500 = 1e14 MSun cluster; see the example .yml config files included with nemo).beamFileName – Path to a text file that describes the beam.
obsFreqGHz (float, optional) – Used only by cluster catalogs - if given, the returned map will be converted into delta T uK, assuming the given frequency. Otherwise, a y0 map is returned.
GNFWParams (str or dict, optional) – Used only by cluster catalogs. If ‘default’, the Arnaud et al. (2010) Universal Pressure Profile is assumed. Otherwise, a dictionary that specifies the profile parameters can be given here (see gnfw.py).
profile (str, optional) – Used by cluster models only - sets the profile shape to use: ‘A10’ for Arnaud et al. (2010) UPP models, or ‘B12’ for Battaglia et al. (2012) models.
override (dict, optional) – Used only by cluster catalogs. If a dictionary containing keys {‘M500’, ‘redshift’} is given, all objects in the model image are forced to have the corresponding angular size. Used by
sourceInjectionTest().applyPixelWindow (bool, optional) – If True, apply the pixel window function to the map.
validAreaSection (list, optional) – Pixel coordinates within the wcs in the format [xMin, xMax, yMin, yMax] that define valid area within the model map. Pixels outside this region will be set to zero. Use this to remove overlaps between tile boundaries.
minSNR (float, optional) – Only include objects with SNR (or fixed_SNR) > this value in the model. If found, the ‘SNR’ column will be used, otherwise the ‘fixed_SNR’ column will be used. If neither is present, no cuts on the catalog will be performed.
TCMBAlpha (float, optional) – This should always be zero unless you really do want to make a cluster model image where CMB temperature evolves as T0*(1+z)^{1-TCMBAlpha}.
- Returns
Map containing injected sources, or None if there are no objects within the map dimensions.
- makeTileDir(parDict, writeToDisk=True)
Update this later. Revised version. Instead of making a MEF, makes a directory for each map and puts individual tile images there. We’ll only need to edit preprocessMapDict to handle the difference. Why are we doing this? Just in case reading from the same file is gumming up MPI runs on hippo when using lots of nodes.
Makes a tileDir (directory containing .fits images, one per tile) file, if the needed parameters are given in parDict. Adjusts unfilteredMapsDictList accordingly and returns it.
If the options for making a tileDir image aren’t given in parDict, then we pass through a standard single extension file (or rather the path to it, as originally given)
NOTE: If the map given in unfilteredMaps is 3d (enki gives I, Q, U as a datacube), then this will extract only the I (temperature) part and save that in the tileDir file. This will need changing if hunting for polarized sources…
Returns unfilteredMapsDictList [input for filterMaps], list of extension names, dictionary of clip coords
NOTE: Under MPI, this should only be called by the rank = 0 process
- maskOutSources(mapData, wcs, catalog, radiusArcmin=7.0, mask=0.0, growMaskedArea=1.0)
Given a mapData array and a catalog of source positions, replace the values at the object positions in the map within radiusArcmin with replacement values. If mask == ‘whiteNoise’, this will be white noise with mean and sigma set by the pixel values in an annulus of 1 < r < 2 * radiusArcmin.
growMaskedArea sets factor larger than radiusArcmin to set masked area to in returned mask. This can avoid any weird artefacts making it into source lists.
Returns a dictionary with keys ‘data’ (mapData with mask applied), ‘mask’ (0-1 mask of areas masked).
- noiseBiasAnalysis(sourceInjTable, plotFileName, sourceInjectionModel=None)
Estimate the noise bias from the ratio of input to recovered flux as a function of signal-to-noise.
- Parameters
posRecTable (
astropy.table.Table) – Table containing recovered position offsets versus fixed_SNR for various cluster/source models (produced by sourceInjectionTest).plotFileName (str) – Path where the plot file will be written.
clipPercentile (float, optional) – Clips offset values outside of this percentile of the whole position offsets distribution, to remove a small number of outliers (spurious next-neighbour cross matches) that otherwise bias the contours high for large (99%+) percentile cuts in individual fixed_SNR bins.
sourceInjectionModel (str, optional) – If given, restrict analysis to only objects matching this.
Notes
For clusters, bear in mind this only makes sense if any mismatch between the inserted cluster’s shape and the signal assumed by the filter is taken into account. This is done using the Q-function in sourceInjectionTest.
- plotContamination(contaminTabDict, diagnosticsDir)
Makes contamination rate plots, output stored under diagnosticsDir
While we’re at it, we write out a text file containing interpolated values for e.g., 5%, 10% contamination levels
- positionRecoveryAnalysis(posRecTable, plotFileName, percentiles=[50, 95, 99.7], sourceInjectionModel=None, plotRawData=True, rawDataAlpha=1, pickleFileName=None, selFnDir=None)
Estimate and plot position recovery accuracy as function of fixed filter scale S/N (fixed_SNR), using the contents of posRecTable (see positionRecoveryTest).
- Parameters
posRecTable (
astropy.table.Table) – Table containing recovered position offsets versus SNR or fixed_SNR for various cluster/source models (produced by sourceInjectionTest).plotFileName (str) – Path where the plot file will be written.
percentiles (list, optional) – List of percentiles to plot (some interpolation will be done) and for which corresponding model fit parameters will be saved (if selFnDir is not None).
sourceInjectionModel (str, optional) – If given, select only objects matching the given source injection model name from the input table. This can be used to get results for individual cluster scales, for example.
plotRawData (bool, optional) – Plot the raw (fixed_SNR, positional offset) data in the background.
pickleFileName (string, optional) – Saves the percentile contours data as a pickle file if not None. This is saved as a dictionary with top-level keys named according to percentilesToPlot.
selFnDir (string, optional) – If given, model fit parameters will be written to a file named posRecModelParameters.txt under the given selFn directory path.
- preprocessMapDict(mapDict, tileName='PRIMARY', diagnosticsDir=None)
Applies a number of pre-processing steps to the map described by mapDict, prior to filtering.
The first step is to load the map itself and the associated weights. Some other operations that may be applied are controlled by keys added to mapDict. Some of these may be specified in the .yml configuration file, while others are applied by particular filter objects or by routines that generate simulated data. The following keys are understood:
- surveyMask (
str) Path to a mask (.fits image; 1 = valid, 0 = masked) that defines the valid object search area.
- pointSourceMask (
str) Path to a mask (.fits image; 1 = valid, 0 = masked) that contains holes at the locations of point sources, defining regions that are excluded from the object search area.
- RADecSection (
list) Defines a region to extract from the map. Use the format [RAMin, RAMax, decMin, decMax] (units: decimal degrees).
- CMBSimSeed (
int) If present, replace the map with a source-free simulated CMB realisation, generated using the given seed number. Used by
estimateContaminationFromSkySim().- applyBeamConvolution (:obj: str)
If True, the map is convolved with the beam given in the beamFileName key. This should only be needed when using preliminary y-maps made by tILe-C.
- Parameters
mapDict (
dict) – A dictionary with the same keys as given in the unfilteredMaps list in the .yml configuration file (i.e., it must contain at least the keys ‘mapFileName’, ‘units’, and ‘weightsFileName’, and may contain some of the optional keys listed above).tileName (
str) – Name of the map tile (extension name) to operate on.diagnosticsDir (
str) – Path to a directory where miscellaneous diagnostic data are written.
- Returns
A dictionary with keys that point to the map itself (‘data’), weights (‘weights’), masks (‘surveyMask’, ‘pointSourceMask’), and WCS object (‘wcs’).
- surveyMask (
- saveFITS(outputFileName, mapData, wcs, compressed=False, compressionType='RICE_1')
Writes a map (2d image array) to a new .fits file.
- Parameters
outputFileName (str) – Filename of output FITS image.
mapData (
np.ndarray) – Map data array.wcs (
astWCS.WCS) – Map WCS object.compressed (bool, optional) – If True, writes a compressed image.
compressionType (str, optional) – The type of compression to use (‘PLIO_1’ for masks and ‘RICE_1’ for images are recommended).
- saveTilesDS9RegionsFile(parDict, DS9RegionFileName)
Writes a DS9 .reg file containing the locations of tiles defined in parDict.
- Parameters
parDict (
dict) – Dictionary containing the contents of the Nemo config file.DS9RegionFileName (str) – Path to DS9 regions file to be written.
- shrinkWCS(origShape, origWCS, scaleFactor)
Given an astWCS object and corresponding image shape, scale the WCS by scaleFactor. Used for making downsampled quicklook images (using stitchMaps).
- Parameters
origShape (tuple) – Shape of the original image.
origWCS (astWCS.WCS object) – WCS for the original image.
scaleFactor (float) – The factor by which to scale the image WCS.
- Returns
shape (tuple), WCS (astWCS.WCS object)
- simCMBMap(shape, wcs, noiseLevel=0.0, beamFileName=None, seed=None, fixNoiseSeed=False)
Generate a simulated CMB map, optionally convolved with the beam and with (white) noise added.
- Parameters
shape (
tuple) – A tuple describing the map (numpy array) shape in pixels (height, width).wcs (
astWCS.WCS) – An astWCS object.noiseLevel (
numpy.ndarrayor float) – If a single number, this is taken as sigma (in map units, usually uK) for generating white noise that is added across the whole map. Alternatively, an array with the same dimensions as shape may be used, specifying sigma (in map units) per corresponding pixel. Noise will only be added where non-zero values appear in noiseLevel.beamFileName (
str) – The file name of the text file that describes the beam with which the map will be convolved. If None, no beam convolution is applied.seed (
int) – The seed used for the random CMB realisation.fixNoiseSeed (
bool) – If True, forces white noise to be generated with given seed.
- Returns
A map (
numpy.ndarray)
- smoothMap(data, wcs, RADeg='centre', decDeg='centre', smoothScaleDeg=0.08333333333333333)
Smoothes map with Gaussian of given scale.
If RADeg, decDeg = ‘centre’, then the pixel scales used to set the kernel shape will be set from that at the centre of the WCS. Otherwise, they will be taken at the given coords.
Note that wcs is only used to figure out the pixel scales here.
- sourceInjectionTest(config, writeRankTable=True)
Insert sources with known positions and properties into the map, apply the filter, and record their offset with respect to the true location as a function of S/N (for the fixed reference scale only). If the inserted sources are clusters, the Q function will be applied to the output fluxes, to account for any mismatch between the reference filter scale and the inserted clusters.
Writes output to the diagnostics/ directory.
- Parameters
config (
nemo.startUp.NemoConfig) – Nemo configuration object.writeRankTable (bool, optional) – If True, saves a table as output for this MPI rank under the diagnostics/ directory. Useful for MPI debugging only.
- Returns
An astropy Table containing recovered position offsets and fluxes versus fixed_SNR for inserted sources.
- stitchTiles(config)
Stitches together full size filtered maps, SN maps, area maps, and noise maps that have been previously been saved as tiles.
- stitchTilesQuickLook(filePattern, outFileName, outWCS, outShape, fluxRescale=1.0)
Fast routine for stitching map tiles back together. Since this uses interpolation, you probably don’t want to do analysis on the output - this is just for checking / making plots etc.. This routine sums images as it pastes them into the larger map grid. So, if the zeroed (overlap) borders are not handled, correctly, this will be obvious in the output.
NOTE: This assumes RA in x direction, dec in y direction (and CAR projection).
NOTE: This routine only writes output if there are multiple files that match filePattern (to save needless duplicating maps if nemo was not run in tileDir mode).
Output map will be multiplied by fluxRescale (this is necessary if downsampling in resolution).
Takes 10 sec for AdvACT S16-sized downsampled by a factor of 4 in resolution.
- subtractBackground(data, wcs, RADeg='centre', decDeg='centre', smoothScaleDeg=0.5)
Smoothes map with Gaussian of given scale and subtracts it, to get rid of large scale power.
If RADeg, decDeg = ‘centre’, then the pixel scales used to set the kernel shape will be set from that at the centre of the WCS. Otherwise, they will be taken at the given coords.
Note that wcs is only used to figure out the pixel scales here.
MockSurvey
This module defines the MockSurvey class, used for mass function calculations, obtaining de-biased cluster mass estimates, selection function calculations, and generating mock catalogs.
- class MockSurvey(minMass, areaDeg2, zMin, zMax, H0, Om0, Ob0, sigma8, ns, zStep=0.01, enableDrawSample=False, delta=500, rhoType='critical', transferFunction='boltzmann_camb')
An object that provides routines calculating cluster counts (using CCL) and generating mock catalogs for a given set of cosmological and mass scaling relation parameters. The Tinker et al. (2008) halo mass function is used (hardcoded at present, but in principle this can easily be swapped for any halo mass function supported by CCL).
- areaDeg2
Survey area in square degrees.
- Type
float
- zBinEdges
Defines the redshift bins for the cluster counts.
- Type
np.ndarray
- z
Centers of the redshift bins.
- Type
np.ndarray
- log10M
Centers of the log10 mass bins for the cluster counts (in MSun, with mass defined according to delta and rhoType).
- Type
np.ndarray
- a
Scale factor (1/(1+z)).
- Type
np.ndarray
- rhoType
Density definition, either ‘matter’ or ‘critical’, used for mass definition.
- Type
str
- mdef
CCL mass definition object, defined by delta and rhoType.
- Type
pyccl.halos.massdef.MassDef
- transferFunction
Transfer function to use, as understood by CCL (e.g., ‘eisenstein_hu’, ‘boltzmann_camb’).
- Type
str
- H0
The Hubble constant at redshift 0, in km/s/Mpc.
- Type
float
- Om0
Dimensionless total (dark + baryonic) matter density parameter at redshift 0.
- Type
float
- Ob0
Dimensionless baryon matter density parameter at redshift 0.
- Type
float
- sigma8
Defines the amplitude of the matter power spectrum.
- Type
float
- ns
Scalar spectral index of matter power spectrum.
- Type
float
- volumeMpc3
Co-moving volume in Mpc3 for the given survey area and cosmological parameters.
- Type
float
- numberDensity
Number density of clusters (per cubic Mpc) on the (z, log10M) grid.
- Type
np.ndarray
- clusterCount
Cluster counts on the (z, log10M) grid.
- Type
np.ndarray
- numClusters
Total number of clusters in the survey area above the minimum mass limit.
- Type
float
- numClustersByRedshift
Number of clusters in the survey area above the minimum mass limit, as a function of redshift.
- Type
np.ndarray
Create a MockSurvey object, for performing calculations of cluster counts or generating mock catalogs. The Tinker et al. (2008) halo mass function is used (hardcoded at present, but in principle this can easily be swapped for any halo mass function supported by CCL).
- Parameters
minMass (
float) – The minimum mass, in MSun. This should be set considerably lower than the actual survey completeness limit, otherwise completeness calculations will be wrong.areaDeg2 (
float) – Specifies the survey area in square degrees, which scales the resulting cluster counts accordingly.zMin (
float) – Minimum redshift for the (z, log10M) grid.zMax (
float) – Maximum redshift for the (z, log10M) grid.H0 (
float) – The Hubble constant at redshift 0, in km/s/Mpc.Om0 (
float) – Dimensionless total (dark + baryonic) matter density parameter at redshift 0.Ob0 (
float) – Dimensionless baryon matter density parameter at redshift 0.sigma8 (
float) – Defines the amplitude of the matter power spectrum.ns (
float) – Scalar spectral index of matter power spectrum.zStep (
float, optional) – Sets the linear spacing between redshift bins.enableDrawSample (
bool, optional) – This needs to be set to True to enable use of theself.drawSample()function. Setting this to False avoids some overhead.delta (:obj:``float`) – Overdensity parameter, used for mass definition (e.g., 200, 500).
rhoType (
str) – Density definition, either ‘matter’ or ‘critical’, used for mass definition.transferFunction (
str) – Transfer function to use, as understood by CCL (e.g., ‘eisenstein_hu’, ‘boltzmann_camb’).
- calcNumClustersExpected(MLimit=10000000000000.0, zMin=0.0, zMax=2.0, compMz=None)
Calculate the number of clusters expected above a given mass limit, for the mass definition set when the MockSurvey object was constructed.
- Parameters
MLimit (
float, optional) – Mass limit above which to count clusters, in MSun.zMin (
float, optional) – Count clusters above this minimum redshift.zMax (
float, optional) – Count clusters below this maximum redshift.compMz (
np.ndarray, optional) – If given, a 2d array with the same dimensions and binning as the (z, log10M) grid, as calculated by thenemo.completeness.SelFnclass, that describes the completeness as a function of mass and redshift.
- Returns
The number of clusters in the survey area, according to the chose sample selection cuts.
- drawSample(y0Noise, scalingRelationDict, QFit, wcs=None, photFilterLabel=None, tileName=None, SNRLimit=None, makeNames=False, z=None, numDraws=None, areaDeg2=None, applySNRCut=False, applyPoissonScatter=True, applyIntrinsicScatter=True, applyNoiseScatter=True)
Draw a cluster sample from the mass function, generating mock y0~ values (called fixed_y_c in Nemo catalogs) by applying the given scaling relation parameters, and then (optionally) applying a survey selection function.
- Parameters
y0Noise (
floatornp.ndarray) – Either a single number (if using e.g., a survey average) or a noise map (2d array). A noise map must be provided here if you want the output catalog to contain RA, dec coordinates (in addition, a WCS object must also be provided - see below).scalingRelationDict (
dict) – A dictionary containing keys ‘tenToA0’, ‘B0’, ‘Mpivot’, ‘sigma_int’ that describes the scaling relation between y0~ and mass (this is the format of massOptions in Nemo .yml config files).tckQFitDict (
dict) – A dictionary of interpolation spline knots indexed by tileName, that can be used to estimate Q, the filter mismatch function (seenemo.signals.loadQ()).wcs (
astWCS.WCS, optional) – WCS object corresponding to y0Noise, if y0Noise is as noise map (2d image array). Needed if you want the output catalog to contain RA, dec coordinates.photFilterLabel (
str, optional) – Name of the reference filter (as defined in the Nemo .yml config file) that is used to define y0~ (fixed_y_c) and the filter mismatch function, Q.tileName (
str, optional) – Name of the tile for which the sample will be generated.SNRLimit (
float, optional) – Signal-to-noise detection threshold used for the output catalog (corresponding to a cut on fixed_SNR in Nemo catalogs). Only applied if applySNRCut is also True (yes, this can be cleaned up).makeNames (
bool, optional) – If True, add names of the form MOCK CL JHHMM.m+/-DDMM to the output catalog.z (
float, optional) – If given produce a sample at the nearest z in the MockSurvey z grid. The default behaviour is to use the full redshift grid specified by self.z.numDraws (
int, optional) – If given, the number of draws to perform from the mass function, divided equally among the redshift bins. The default is to use the values contained in self.numClustersByRedshift.areaDeg2 (
float, optional) – If given, the cluster counts will be scaled to this area. Otherwise, they correspond to self.areaDeg2. This parameter will be ignored if numDraws is also given.applySNRCut (
bool, optional) – If True, cut the output catalog according to the fixed_SNR threshold set by SNRLimit.applyPoissonScatter (
bool, optional) – If True, add Poisson noise to the cluster counts (implemented by modifiying the number of draws from the mass function).applyIntrinsicScatter (
bool, optional) – If True, apply intrinsic scatter to the SZ measurements (fixed_y_c), as set by the sigma_int parameter in scalingRelationDict.applyNoiseScatter (
bool, optional) – If True, apply measurement noise, generated from the given noise level or noise map (y0Noise), to the output SZ measurements (fixed_y_c).
- Returns
A catalog as an
astropy.table.Tableobject, in the same format as produced by the main nemo script.
Notes
If both applyIntrinsicScatter, applyNoiseScatter are set to False, then the output catalog fixed_y_c values will be exactly the same as true_y_c, although each object will still have an error bar listed in the output catalog, corresponding to its location in the noise map (if given).
- getPLog10M(z)
Returns the log10(mass) probability distribution at the given z, for the logarithmic mass binning and mass definition set when the MockSurvey object was constructed.
- Parameters
z (
float) – Redshift at which to calculate P(log10(M)).- Returns
Array corresponding to the log10(mass) probability distribution.
- update(H0, Om0, Ob0, sigma8, ns)
Recalculate cluster counts for the updated cosmological parameters given.
- Parameters
H0 (
float) – The Hubble constant at redshift 0, in km/s/Mpc.Om0 (
float) – Dimensionless total (dark + baryonic) matter density parameter at redshift 0.Ob0 (
float) – Dimensionless baryon matter density parameter at redshift 0.sigma8 (
float) – Defines the amplitude of the matter power spectrum.ns (
float) – Scalar spectral index of matter power spectrum.
nemoCython
- convolve()
Convolves image arr with kernel kern. Hopefully faster than ndimage.convolve.
Returns 2d array
- makeDegreesDistanceMap()
Fills (in place) the 2d array degreesMap with distance in degrees from the given position, out to some user-specified maximum distance.
- Parameters
degreesMap (
np.ndarray) – Map (2d array) that will be filled with angular distance from the given coordinates. Probably you should feed in an array set to some extreme initial value (e.g., 1e6 everywhere) to make it easy to filter for pixels near the object coords afterwards.wcs (
astWCS.WCS) – WCS corresponding to degreesMap.RADeg (float) – RA in decimal degrees of position of interest (e.g., object location).
decDeg (float) – Declination in decimal degrees of position of interest (e.g., object location).
maxDistDegrees – The maximum radius out to which distance will be calculated.
- Returns
A map (2d array) of distance in degrees from the given position, (min x, max x) pixel coords corresponding to maxDistDegrees box, (min y, max y) pixel coords corresponding to maxDistDegrees box
Note
This routine measures the pixel scale local to the given position, then assumes that it does not change. So, this routine may only be accurate close to the given position, depending upon the WCS projection used.
- makeLocalSNMap()
Makes local S/N map - measuring noise in an annulus using the standard deviation. Measures background using mean in annulus. Since there is no sorting involved, this is much quicker than using rank filters. But it may not give quite the same results.
- makeXYDegreesDistanceMaps()
Returns an array of distance along x, y axes in degrees from given position. maxDistDegrees sets the limit around the given RADeg, decDeg position to which the distance is calculated.
- rankFilter()
Rank is relative, with 0 lowest, 1 max.
- standardDeviationFilter()
Standard deviation filter using pixels within rPix.
photometry
This module contains source finding and photometry routines.
- JyPerSrToDeltaT(JySr, obsFreqGHz)
Convert Jy/sr to delta T (uK) at the given frequency in GHz
- addFreqWeightsToCatalog(imageDict, photFilter, diagnosticsDir)
Add relative weighting by frequency for each object in the optimal catalog, extracted from the data cube saved under diagnosticsDir (this is made by makeSZMap in RealSpaceMatchedFilter). This is needed for multi-frequency cluster finding / analysis - for, e.g., weighting relativistic corrections to y0~ (which was estimated from the inverse variance weighted average of y0~ from each frequency map).
NOTE: this is only applied for the reference filter (pointed to by photFilter)
- deltaTToJyPerSr(temp, obsFreqGHz)
Convert delta T (uK) to Jy/sr at the given frequency in GHz
- findObjects(filteredMapDict, threshold=3.0, minObjPix=3, rejectBorder=10, findCenterOfMass=True, removeRings=True, ringThresholdSigma=0, invertMap=False, objIdent='ACT-CL', longNames=False, verbose=True, useInterpolator=True, measureShapes=False, DS9RegionsPath=None)
Finds objects in the filtered maps pointed to by the imageDict. Threshold is in units of sigma (as we’re using S/N images to detect objects). Catalogs get added to the imageDict.
Throw out objects within rejectBorder pixels of edge of frame if rejectBorder != None
Set invertMap == True to do a test of estimating fraction of spurious sources
Set measureShapes == True to fit ellipses in a similar style to how SExtractor does it (may be useful for automating finding of extended sources).
This now find rings around extremely bright sources and adds them to the survey mask if removeRings is True
- getObjectPositions(mapData, threshold, findCenterOfMass=True)
Creates a segmentation map and find objects above the given threshold.
- Parameters
mapData (
numpy.ndarray) – The 2d map to segment.threshold (float) – The threshold above which objects will be selected.
findCenterOfMass – If True, return the object center weighted according to the values in mapData. If False, return the pixel that holds the maximum value.
- Returns
Array of object ID numbers. objPositions (list): List of corresponding (y, x) positions. objNumPix (
numpy.ndarray): Array listing number of pixels per object. segmentationMap (numpy.ndarray): The segmentation map (2d array).- Return type
objIDs (
numpy.ndarray)
- getPixelsDistanceMap(objDict, data)
Returns an array of same dimensions as data but containing radial distance to the object specified in the objDict in units of pixels
- getRadialDistanceMap(objDict, data, wcs)
Returns an array of same dimensions as data but containing radial distance to the object specified in the objDict in units degrees on the sky
- getSNRValues(catalog, SNMap, wcs, useInterpolator=True, invertMap=False, prefix='')
Measures SNR values in given map at catalog positions.
Set invertMap == True, to do a test for estimating the spurious source fraction
Use prefix to add prefix before SNR in catalog (e.g., fixed_SNR)
Use template to select a particular filtered map (i.e., label of mapFilter given in .par file, e.g., a filter used to measure properties for all objects at fixed scale).
- makeAnnulus(innerScalePix, outerScalePix)
Makes the footprint of an annulus for feeding into the rank filter
Returns annulus, numValues
- makeForcedPhotometryCatalog(filteredMapDict, inputCatalog, useInterpolator=True, DS9RegionsPath=None)
Make a catalog on which we can do forced photometry at the locations of objects in it.
inputCatalog is either a path or a table object.
- measureFluxes(catalog, filteredMapDict, diagnosticsDir, photFilteredMapDict=None, useInterpolator=True, ycObsFreqGHz=148.0)
Add flux measurements to each catalog pointed to in the imageDict. Measured in ‘outputUnits’ specified in the filter definition in the .par file (and written to the image header as ‘BUNIT’).
Maps should have been normalised before this stage to make the value of the filtered map at the object position equal to the flux that is wanted (yc, uK or Jy/beam). This includes taking out the effect of the beam.
Use ‘photFilter’ to choose which filtered map in which to make flux measurements at fixed scale (fixed_delta_T_c, fixed_y_c etc.). Set to None if you don’t want these.
If the filtered map is in yc, then columns that contain the amplitude in in uK CMB delta temperature will be added, named deltaT_c, assuming that the observing frequency is as set by ycObsFreqGHz
pipelines
This module defines pipelines - sets of tasks in nemo that we sometimes want to do on different inputs (e.g., real data or simulated data).
- extractSpec(config, tab, method='CAP', diskRadiusArcmin=4.0, highPassFilter=False, estimateErrors=True, saveFilteredMaps=False)
Returns a table containing the spectral energy distribution, extracted using either compensated aperture photometry (CAP) at each object location in the input catalog, or using a matched filter. Maps at different frequencies will first be matched to the lowest resolution beam, using a Gaussian kernel.
For the CAP method, at each object location, the temperature fluctuation is measured within a disk of radius diskRadiusArcmin, after subtracting the background measured in an annulus between diskRadiusArcmin < r < sqrt(2) * diskRadiusArcmin (i.e., this should be similar to the method described in Schaan et al. 2020).
For the matched filter method, the catalog must contain a template column, as produced by the main nemo script, with template names in the format Arnaud_M2e14_z0p4 (for example). This will be used to set the signal scale used for each object. All definitions of filters in the config will be ignored, in favour of a filter using a simple CMB + white noise model. Identical filters will be used for all maps (i.e., the method of Saro et al. 2014).
- Parameters
config (
startup.NemoConfig) – Nemo configuration object.tab (
astropy.table.Table) – Catalog containing input object positions. Must contain columns ‘name’, ‘RADeg’, ‘decDeg’.method (str, optional) –
diskRadiusArcmin (float, optional) – If using CAP method: disk aperture radius in arcmin, within which the signal is measured. The background will be estimated in an annulus between diskRadiusArcmin < r < sqrt(2) * diskRadiusArcmin.
highPassFilter (bool, optional) – If using CAP method: if set, subtract the large scale background using maps.subtractBackground, with the smoothing scale set to 2 * sqrt(2) * diskRadiusArcmin.
estimateErrors (bool, optional) – If used CAP method: if set, estimate uncertainties by placing random apertures throughout the map. For now, this is done on a tile-by-tile basis, and doesn’t take into account inhomogeneous noise within a tile.
saveFilteredMaps (bool, optional) – If using matchedFilter method: save the filtered maps under the nemoSpecCache directory (which is created in the current working directory, if it doesn’t already exist).
- Returns
Catalog containing spectral energy distribution measurements for each object. For the CAP method, units of extracted signals are uK arcmin^2. For the matchedFilter method, extracted signals are deltaT CMB amplitude in uK.
- filterMapsAndMakeCatalogs(config, rootOutDir=None, copyFilters=False, measureFluxes=True, invertMap=False, verbose=True, useCachedMaps=True)
Runs the map filtering and catalog construction steps according to the given configuration.
- Parameters
( (config) – obj: ‘startup.NemoConfig’): Nemo configuration object.
rootOutDir (str) – If None, use the default given by config. Otherwise, use this to override where the output filtered maps and catalogs are written.
copyFilters (bool, optional) – If True, and rootOutDir is given (not None), then filters will be copied from the default output location (from a pre-existing nemo run) to the appropriate directory under rootOutDir. This is used by, e.g., contamination tests based on sky sims, where the same kernels as used on the real data are applied to simulated maps. If rootOutDir = None, setting copyKernels = True has no effect.
measureFluxes (bool, optional) – If True, measure fluxes. If False, just extract S/N values for detected objects.
invertMap (bool, optional) – If True, multiply all maps by -1; needed by :meth:maps.estimateContaminationFromInvertedMaps).
- Returns
Optimal catalog (keeps the highest S/N detection when filtering at multiple scales).
Note
See bin/nemo for how this pipeline is applied to real data, and maps.sourceInjectionTest for how this is applied to source-free sims that are generated on the fly.
- makeMockClusterCatalog(config, numMocksToMake=1, combineMocks=False, writeCatalogs=True, writeInfo=True, verbose=True)
Generate a mock cluster catalog using the given nemo config.
- Returns
List of catalogs (each is an astropy Table object)
- makeSelFnCollection(config, mockSurvey)
Makes a collection of selection function dictionaries (one per footprint specified in selFnFootprints in the config file, plus the full survey mask), that contain information on noise levels, area covered, and completeness.
Returns a dictionary (keys: ‘full’ - corresponding to whole survey, plus other keys named by footprint).
plotSettings
This module contains global plot settings.
For any routine that makes a plot using matplotlib, call plotSettings.update_rcParams() first.
- update_rcParams(dict={})
Based on Cristobal’s preferred settings. Updates matplotlib rcParams in place.
signals
This module contains routines for modeling cluster and source signals.
- class BeamProfile(beamFileName=None, profile1d=None, rDeg=None)
Describes the beam profile (i.e., the point spread function for some instrument in real space). This can be either read from a white-space delimited text file (with the angle in degrees in the first column and the response in the second column), or can be set directly using arrays.
- Parameters
beamFileName (
str, optional) – Path to text file containing a beam profile in the ACT format.profile1d (
np.ndarray, optional) – One dimensional beam profile, with index 0 at the centre.rDeg (
np.ndarray, optional) – Corresponding angular distance in degrees from the centre for the beam profile.
- profile1d
One dimensional beam profile, with index 0 at the centre.
- Type
np.ndarray
- rDeg
Corresponding angular distance in degrees from the centre for the beam profile.
- Type
np.ndarray
- tck
Spline knots for interpolating the beam onto different angular binning (in degrees), for use with
scipy.interpolate.splev().- Type
tuple
- FWHMArcmin
Estimate of the beam FWHM in arcmin.
- Type
float
- M500cToMdef(M500c, z, massDef, cosmoModel)
Convert M500c to some other mass definition.
massDef (obj:ccl.halos.MassDef): CCL halo mass definition
- class QFit(QFitFileName=None, tileNames=None)
A class for managing the filter mismatch function, referred to as Q in the ACT papers from Hasselfield et al. (2013) onwards.
- Parameters
QFitFileName (
str) – Path to a FITS-table format file as made byfitQ().tileNames (
list) – If given, the Q-function will be defined only for these tiles (their names must appear in the file specified by QFitFileName).
- fitDict
Dictionary of interpolation objects, indexed by tileName. You should not need to access this directly - use
getQ()instead.- Type
dict
- getQ(theta500Arcmin, z=None, tileName=None)
Return the value of Q (the filter mismatch function) using interpolation.
- Parameters
theta500Arcmin (
floatornp.ndarray) – The angular scale at which Q will be calculated. This can be an array or a single value.z (
float, optional) – Redshift, only used if Q is a function of redshift, otherwise it is ignored. This must be a single value only, i.e., not an array.tileName (
str, optional) – The name of the tile to use for the Q function.
- Returns
The value of Q (an array or a single float, depending on the input).
Note
In the case where Q is a function of redshift, values outside of the range for which Q has been calculated will be filled with zeros (i.e., there is no extrapolation in redshift).
- loadQ(source, tileNames=None)
Load the filter mismatch function Q (see Hasselfield et al. 2013) as a dictionary of spline fits.
- Parameters
source (
nemo.startUp.NemoConfigor str) – Either the path to a .fits table (containing Q fits for all tiles - this is normallyselFn/QFit.fits), or anemo.startUp.NemoConfigobject (from which the path and tiles to use will be inferred).tileNames (optional, list) – A list of tiles for which the Q function spline fit coefficients will be extracted. If source is a
nemo.startUp.NemoConfigobject, this should be set toNone.
- Returns
A dictionary (with tilNames as keys), containing spline knots for the Q function for each tile. Q values can then be obtained by using these with
scipy.interpolate.splev().
- calcDz(zIn)
Calculate linear growth factor, normalised to D(z) = 1.0 at z = 0.
- calcFRel(z, M500, Ez, obsFreqGHz=148.0)
Calculates relativistic correction to SZ effect at specified frequency, given z, M500 in MSun.
This assumes the Arnaud et al. (2005) M-T relation, and applies formulae of Itoh et al. (1998)
As for H13, we return fRel = 1 + delta_SZE (see also Marriage et al. 2011)
- calcMass(y0, y0Err, z, zErr, QFit, mockSurvey, tenToA0=4.95e-05, B0=0.08, Mpivot=300000000000000.0, sigma_int=0.2, Ez_gamma=2, onePlusRedshift_power=0.0, applyMFDebiasCorrection=True, applyRelativisticCorrection=True, calcErrors=True, fRelWeightsDict={148.0: 1.0}, tileName=None)
Returns M500 +/- errors in units of 10^14 MSun, calculated assuming a y0 - M relation (default values assume UPP scaling relation from Arnaud et al. 2010), taking into account the steepness of the mass function. The approach followed is described in H13, Section 3.2.
Here, mockSurvey is a MockSurvey object. We’re using this to handle the halo mass function calculations (in turn using the Colossus module). Supplying mockSurvey is no longer optional (and handles setting the cosmology anyway when initialised or updated).
tckQFit is a set of spline knots, as returned by fitQ.
If applyMFDebiasCorrection == True, apply correction that accounts for steepness of mass function.
If applyRelativisticCorrection == True, apply relativistic correction (weighted by frequency using the contents of fRelWeightsDict).
If calcErrors == False, error bars are not calculated, they are just set to zero.
fRelWeightsDict is used to account for the relativistic correction when y0~ has been constructed from multi-frequency maps. Weights should sum to 1.0; keys are observed frequency in GHz.
Returns dictionary with keys M500, M500_errPlus, M500_errMinus
- calcPMass(y0, y0Err, z, zErr, QFit, mockSurvey, tenToA0=4.95e-05, B0=0.08, Mpivot=300000000000000.0, sigma_int=0.2, Ez_gamma=2, onePlusRedshift_power=0.0, applyMFDebiasCorrection=True, applyRelativisticCorrection=True, fRelWeightsDict={148.0: 1.0}, return2D=False, tileName=None)
Calculates P(M500) assuming a y0 - M relation (default values assume UPP scaling relation from Arnaud et al. 2010), taking into account the steepness of the mass function. The approach followed is described in H13, Section 3.2. The binning for P(M500) is set according to the given mockSurvey, as are the assumed cosmological parameters.
This routine is used by calcMass.
Ez_gamma is E(z)^gamma factor (we assumed E(z)^2 previously)
onePlusRedshift_power: added multiplication by (1+z)**onePlusRedshift_power (for checking evolution)
If return2D == True, returns a grid of same dimensions / binning as mockSurvey.z, mockSurvey.log10M, normalised such that the sum of the values is 1.
- calcR500Mpc(z, M500c, cosmoModel)
Calculate R500 (in Mpc), with respect to critical density.
- Parameters
z (float) – Redshift.
M500c (float) – Mass within R500c (i.e., with respect to critical density) in units of solar masses.
cosmoModel (:obj:`pyccl.Cosmology) – Cosmology object.
- Returns
R500c (in Mpc)
- calcRDeltaMpc(z, MDelta, cosmoModel, delta=500, wrt='critical')
Calculate RDelta (e.g., R500c, R200m etc.) in Mpc, for a halo with the given mass and redshift.
- Parameters
z (float) – Redshift.
MDelta (float) – Halo mass in units of solar masses, using the definition set by delta and wrt.
cosmoModel (
pyccl.Cosmology) – Cosmology object.delta (float, optional) – Overdensity (e.g., typically 500 or 200).
wrt (str, optional) – Use ‘critical’ or ‘mean’ to set the definition of density with respect to the critical density or mean density at the given redshift.
- Returns
RDelta (in Mpc)
- calcTheta500Arcmin(z, M500, cosmoModel)
Given z, M500 (in MSun), returns the angular size equivalent to R:sub:500c, with respect to the critical density.
- Parameters
z (float) – Redshift.
M500 (float) – Mass within R500c (i.e., with respect to critical density) in units of solar masses.
cosmoModel (:obj:`pyccl.Cosmology) – Cosmology object.
- Returns
theta500c (in arcmin)
- calcWeightedFRel(z, M500, Ez, fRelWeightsDict)
Return fRel for the given (z, M500), weighted by frequency according to fRelWeightsDict
- convertM200mToM500c(M200m, z)
Returns M500c (MSun), R500c (Mpc) for given M200m and redshift. Uses the Bhattacharya et al. c-M relation: http://adsabs.harvard.edu/abs/2013ApJ…766…32B
See also Hu & Kravtsov: http://iopscience.iop.org/article/10.1086/345846/pdf
- convertM500cToM200m(M500c, z)
Returns M200m given M500c
- criticalDensity(z)
Returns the critical density at the given z.
- fSZ(obsFrequencyGHz, TCMBAlpha=0.0, z=None)
Returns the frequency dependence of the (non-relativistic) Sunyaev-Zel’dovich effect.
- Parameters
obsFrequencyGHz (float) – Frequency in GHz at which to calculate fSZ.
TCMBAlpha (float, optional) – This should always be zero unless you really do want to make a model where CMB temperature evolves T0*(1+z)^{1-TCMBAlpha}.
z (float, optional) – Redshift - needed only if TCMBAlpha is non-zero.
- Returns
Value of SZ spectral shape at given frequency (neglecting relativistic corrections).
- fitQ(config)
Calculates the filter mismatch function Q on a grid of scale sizes for each tile in the map. The results are initially cached (with a separate .fits table for each tile) under the selFn directory, before being combined into a single file at the end of a nemo run.
The GNFWParams key in the config dictionary can be used to specify a different cluster profile shape.
- Parameters
config (
startUp.NemoConfig) – A NemoConfig object.
Note
See
QFitfor how to read in and use the output of this function.
- getFRelWeights(config)
Returns a dictionary of frequency weights used in relativistic corrections for each tile. This is cached in the selFn/ dir after the first time this routine is called.
- getM500FromP(P, log10M, calcErrors=True)
Returns M500 as the maximum likelihood value from given P(log10M) distribution, together with 1-sigma error bars (M500, -M500Err, +M500 err).
- gz(zIn, zMax=1000, dz=0.1)
Calculates linear growth factor at redshift z. Use Dz if you want normalised to D(z) = 1.0 at z = 0.
See http://www.astronomy.ohio-state.edu/~dhw/A873/notes8.pdf for some notes on this.
- loadFRelWeights(fRelWeightsFileName)
Returns a dictionary of frequency weights used in relativistic corrections for each tile (stored in a .fits table, made by getFRelWeights).
- makeArnaudModelProfile(z, M500, GNFWParams='default', cosmoModel=None)
Given z, M500 (in MSun), returns dictionary containing Arnaud model profile (well, knots from spline fit, ‘tckP’ - assumes you want to interpolate onto an array with units of degrees) and parameters (particularly ‘y0’, ‘theta500Arcmin’).
Use GNFWParams to specify a different shape. If GNFWParams = ‘default’, then the default parameters as listed in gnfw.py are used, i.e.,
- GNFWParams = {‘P0’: 8.403, ‘c500’: 1.177, ‘gamma’: 0.3081, ‘alpha’: 1.0510, ‘beta’: 5.4905, ‘tol’: 1e-7,
‘npts’: 100}
Otherwise, give a dictionary that specifies the wanted values. This would usually be specified as GNFWParams in the filter params in the nemo .par file (see the example .par files).
If cosmoModel is None, use default (Om0, Ol0, H0) = (0.3, 0.7, 70 km/s/Mpc) cosmology.
Used by ArnaudModelFilter
- makeArnaudModelSignalMap(z, M500, degreesMap, wcs, beam, GNFWParams='default', amplitude=None, maxSizeDeg=15.0, convolveWithBeam=True)
Makes a 2d signal only map containing an Arnaud model cluster.
- Parameters
z (float) – Redshift; used for setting angular size.
M500 (float) – Mass within R500, defined with respect to critical density; units are solar masses.
degreesMap (
numpy.ndarray) – A 2d array containing radial distance measured in degrees from the centre of the model to be inserted. The output map will have the same dimensions and pixel scale (see nemoCython.makeDegreesDistanceMap).GNFWParams (dict, optional) – Used to specify a different profile shape to the default (which follows Arnaud et al. 2010). If GNFWParams = ‘default’, then the default parameters as listed in gnfw.py are used, i.e., GNFWParams = {‘gamma’: 0.3081, ‘alpha’: 1.0510, ‘beta’: 5.4905, ‘tol’: 1e-7, ‘npts’: 100}. Otherwise, give a dictionary that specifies the wanted values. This would usually be specified using the GNFWParams key in the .yml config used when running nemo (see the examples/ directory).
amplitude (float, optional) – Amplitude of the cluster, i.e., the central decrement (in map units, e.g., uK), or the central Comptonization parameter (dimensionless), before beam convolution. Not needed for generating filter kernels.
maxSizeDeg (float, optional) – Use to limit the region over which the beam convolution is done, for optimization purposes.
convolveWithBeam (bool, optional) – If False, no beam convolution is done (it can be quicker to apply beam convolution over a whole source-injected map rather than per object).
- Returns
signalMap (
np.ndarray).
Note
The pixel window function is not applied here; use pixell.enmap.apply_window to do that (see nemo.filters.filterMaps).
- makeBattagliaModelProfile(z, M500c, GNFWParams='default', cosmoModel=None)
Given z, M500 (in MSun), returns dictionary containing Battaglia+2012 model profile (well, knots from spline fit, ‘tckP’ - assumes you want to interpolate onto an array with units of degrees) and parameters (particularly ‘y0’, ‘theta500Arcmin’).
Use GNFWParams to specify a different shape. If GNFWParams = ‘default’, then the default parameters as listed in Battaglia et al. 2012 are used, i.e., GNFWParams = {‘gamma’: 0.3, ‘alpha’: 1.0, ‘beta’: 4.49, ‘c500’: 1.408, ‘tol’: 1e-7, ‘npts’: 100}. Note that the definitions/sign convention is slightly different in Battaglia+2012 compared to Arnaud+2010 (we follow the latter).
Otherwise, give a dictionary that specifies the wanted values. This would usually be specified as GNFWParams in the filter params in the nemo .par file (see the example .par files).
If cosmoModel is None, use default (Om0, Ol0, H0) = (0.3, 0.7, 70 km/s/Mpc) cosmology.
Used by ArnaudModelFilter
- makeBattagliaModelSignalMap(z, M500, degreesMap, wcs, beam, GNFWParams='default', amplitude=None, maxSizeDeg=15.0, convolveWithBeam=True)
Makes a 2d signal only map containing a Battaglia+2012 model cluster (taking into account the redshift evolution described in Table 1 and equation 11 there).
- Parameters
z (float) – Redshift; used for setting angular size.
M500 (float) – Mass within R500, defined with respect to critical density; units are solar masses.
degreesMap (
numpy.ndarray) – A 2d array containing radial distance measured in degrees from the centre of the model to be inserted. The output map will have the same dimensions and pixel scale (see nemoCython.makeDegreesDistanceMap).GNFWParams (dict, optional) – Used to specify a different profile shape to the default (which follows Battaglia et al. 2012). If GNFWParams = ‘default’, then the default parameters as listed in Battaglia et al. 2012 are used, i.e., GNFWParams = {‘gamma’: 0.3, ‘alpha’: 1.0, ‘beta’: 4.49, ‘c500’: 1.408, ‘tol’: 1e-7, ‘npts’: 100}. Note that the definitions/sign convention is slightly different in Battaglia+2012 compared to Arnaud+2010 (we follow the latter). Otherwise, give a dictionary that specifies the wanted values. This would usually be specified using the GNFWParams key in the .yml config used when running nemo (see the examples/ directory).
amplitude (float, optional) – Amplitude of the cluster, i.e., the central decrement (in map units, e.g., uK), or the central Comptonization parameter (dimensionless), before beam convolution. Not needed for generating filter kernels.
maxSizeDeg (float, optional) – Use to limit the region over which the beam convolution is done, for optimization purposes.
convolveWithBeam (bool, optional) – If False, no beam convolution is done (it can be quicker to apply beam convolution over a whole source-injected map rather than per object).
- Returns
signalMap (
np.ndarray).
Note
The pixel window function is not applied here; use pixell.enmap.apply_window to do that (see nemo.filters.filterMaps).
- makeBeamModelSignalMap(degreesMap, wcs, beam, amplitude=None)
Makes a 2d signal only map containing the given beam.
- Parameters
degreesMap (
np.ndarray) – Map of angular distance from the object position.wcs (
astWCS.WCS) – WCS corresponding to degreesMap.beam (
BeamProfileor str) – Either a BeamProfile object, or a string that gives the path to a text file that describes the beam profile.( (amplitude) – obj: float, optional): Specifies the amplitude of the input signal (in map units, e.g., uK), before beam convolution. This is only needed if this routine is being used to inject sources into maps. It is not needed for making filter kernels.
- Returns
signalMap (
np.ndarray)
Note
The pixel window function is not applied here; use pixell.enmap.apply_window to do that (see nemo.filters.filterMaps).
- makeCombinedQTable(config)
Writes dictionary of tables (containing individual tile Q fits) as a single .fits table.
Returns combined Q astropy table object
- meanDensity(z)
Returns the mean density at the given z.
- y0FromLogM500(log10M500, z, tckQFit, tenToA0=4.95e-05, B0=0.08, Mpivot=300000000000000.0, sigma_int=0.2, cosmoModel=None, applyRelativisticCorrection=True, fRelWeightsDict={148.0: 1.0})
Predict y0~ given logM500 (in MSun) and redshift. Default scaling relation parameters are A10 (as in H13).
Use cosmoModel (
pyccl.Cosmology) to change/specify cosmological parameters.fRelWeightsDict is used to account for the relativistic correction when y0~ has been constructed from multi-frequency maps. Weights should sum to 1.0; keys are observed frequency in GHz.
Returns y0~, theta500Arcmin, Q
NOTE: Depreciated? Nothing we have uses this.
startUp
This module contains basic set-up stuff (making directories, parsing config etc.) used by all the scripts in bin/ (nemo, nemoMass, nemoSelFn etc.).
- class NemoConfig(config, makeOutputDirs=True, setUpMaps=True, writeTileDir=True, selFnDir=None, calcSelFn=True, sourceInjectionTest=False, MPIEnabled=False, divideTilesByProcesses=True, verbose=True, strictMPIExceptions=True)
An object that keeps track of nemo’s configuration, maps, and output directories etc..
- parDict
Dictionary containing the contents of the config file.
- Type
dict
- rootOutDir
Path to the directory where all output will be written.
- Type
str
- filteredMapsDir
Name of the directory where filtered maps will be written.
- Type
str
- diagnosticsDir
Path to the directory where miscellaneous diagnostic data (e.g., filter kernel plots) will be written.
- Type
str
- unfilteredMapsDictList
List of dictionaries corresponding to maps needed.
- Type
list
- tileNames
List of map tiles (extension names) to operate on.
- Type
list
- MPIEnabled
If True, use MPI to divide tileNames list among processes.
- Type
bool
- comm
Used by MPI.
- Type
MPI.COMM_WORLD
- rank
Used by MPI.
- Type
int
- size
Used by MPI.
- Type
int
Creates an object that keeps track of nemo’s configuration, maps, output directories etc..
- Parameters
config (
strordict) – Either the path to a nemo .yml configuration file, or a dictionary containing nemo configuration parameters.makeOutputDirs (
bool, optional) – If True, create output directories (where maps, catalogs are stored).setUpMaps (
bool, optional) – If True, set-up data structures for handling maps (inc. breaking into tiles if wanted).writeTileDir (
bool, optional) – If True and set-up to break maps into tiles, write the tiles to disk with a subdirectory for each tile.selFnDir (
str, optional) – Path to the selFn directory (use to override the default location).calcSelFn (
bool, optional) – Overrides the value given in the config file if True.sourceInjectionTest (
bool, optional) – Overrides the value given in the config file if True.MPIEnabled (
bool, optional) – If True, use MPI to divide the map into tiles, distributed among processes. This requires tileDefinitions and tileNoiseRegions to be given in the .yml config file.divideTilesByProcesses (
bool, optional) – If True, divides up the list of tiles optimally among the available MPI processes.strictMPIExceptions (
bool) – If True, MPI will abort if an Exception is encountered (the downside is that you will not get the full traceback, but at least you will not waste CPU cycles). If False, MPI probably will not abort if an Exception is encountered, but you will get the full traceback (the downside is your MPI job may never complete). These options are a compromise due to how mpi4py handles MPI errors (the default handling for mpi4py corresponds to strictMPIExceptions = False).verbose (
bool) – If True, print some info to the terminal while we set-up the config file.
- restoreConfig()
Restores the parameters dictionary (self.parDict) to the original state specified in the config .yml file.
- parseConfigFile(parDictFileName)
Parse a nemo .yml config file.
- Parameters
parDictFileName (
str) – Path to a nemo .yml configuration file.- Returns
A dictionary of parameters.