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.

addFootprintColumnToCatalog(tab, label, areaMask, wcs)

Add footprint_label column to the catalog, flagging objects found within the valid area of the given mask.

Parameters:
  • tab (astropy.table.Table) – Catalog, as an astropy Table object. Must have columns called ‘RADeg’, ‘decDeg’ that contain object coordinates in decimal degrees.

  • label (str) – A column named footprint_label will be added to the catalog. Objects in the catalog that fall within the valid area of the given area mask will have footprint_label set to True.

  • areaMask (np.ndarray) – Mask image defining the footprint corresponding to the given WCS. Pixels with value = 1 indicate valid area, and pixels with value = 0 are considered to be outside the mask.

  • wcs (astWCS.WCS) – WCS of the area mask that defines the footprint.

Returns:

An astropy Table with footprint_label column added.

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 by selectFromCatalog().

  • 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) – If True, 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', 'flags', '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.Table object.

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.Table object, 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 (see nemo.maps.positionRecoveryAnalysis()).

  • fitPedestal (float, optional) – Model fit parameter - pedestal level (see nemo.maps.positionRecoveryAnalysis()).

  • fitNorm (float, optional) – Model fit parameter - normalization (see nemo.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.Table object containing the catalog.

generateTestCatalog(config, numSourcesPerTile, amplitudeColumnName='fixed_y_c', amplitudeRange=[0.001, 1], amplitudeDistribution='linear', selFn=None, avoidanceRadiusArcmin=20.0, maskDilationPix=0, tileNames=None)

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 in nemo.maps.sourceInjectionTest()).

Returns:

An astropy.table.Table object 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, see selectFromCatalog()).

Returns:

None - an optimalCatalog key is added to catalogDict in 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.Table object 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 .csv extension) 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.

exception FootprintError
class SelFn(selFnDir, SNRCut, configFileName=None, footprint=None, zStep=0.01, zMax=3.0, tileNames=None, mockOversampleFactor=1.0, downsampleRMS=True, applyMFDebiasCorrection=True, applyRelativisticCorrection=True, setUpAreaMask=False, enableCompletenessCalc=True, delta=500, rhoType='critical', massFunction='Tinker08', maxTheta500Arcmin=None, method='fast', QSource='fit', noiseCut=None, biasModel=None)

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 a selFn/ 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 from selFnDir/config.yml, which is the config file for the nemo run that produced the selFn directory.

  • footprint (str, optional) – Use this to specify a footprint, if any are defined in the Nemo config used to produce the selFn dir (e.g., ‘DES’, ‘HSC’, ‘KiDS’ etc.). The default value of None uses the whole survey footprint.

  • zStep (float, optional) – Use this to set the binning in redshift for completeness calculations.

  • tileNames (list, optional) – If given, restrict the SelFn object to use only these tiles.

  • mockOversampleFactor (float, optional) – Used only by generateMockSample(). 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., by SelFn.checkCoordsAreInMask()).

  • enableCompletenessCalc (bool, optional) – If True, set up the machinery needed to do completeness calculations.

  • massFunction (str, optional) – Name of the mass function to use, currently either ‘Tinker08’ or ‘Tinker10’. Mass function calculations are done by CCL.

  • maxTheta500Arcmin (float, optional) – If given, exclude clusters with expected angular size greater than this from the cluster counts (set their completeness to 0).

  • method (str, optional) – The method for calculating completeness. Options are: ‘fast’ (using a simple model based on the noise and the expected cluster signals), or ‘injection’ (directly using the results of end-to-end cluster injection and recovery sims).

  • QSource (str, optional) – The source to use for Q (the filter mismatch function) - either ‘fit’ (to use results from the original Q-fitting routine) or ‘injection’ (to use Q derived from source injection simulations).

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

footprint

Use this to specify a footprint, if any are defined in the Nemo config used to produce the selFn dir (e.g., ‘DES’, ‘HSC’, ‘KiDS’ etc.). The default of None uses 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

zMax

Sets the maximum z used 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.WCS objects 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:

nemo.signals.QFit

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 MockSurvey object, used for halo mass function calculations and generating mock catalogs.

Type:

nemo.MockSurvey.MockSurvey

Note

Some of the methods of this class are experimental and not necessarily well tested.

Note

Once SNRCut is set for this object, it cannot be changed later (well, it can… but changing self.SNRCut will not update anything, for the moment).

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 (float or np.ndarray) – RA in decimal degrees.

  • decDeg (float or np.ndarray) – Dec in decimal degrees.

Returns:

True if the coordinates are in the area mask mask, False if not.

cutCatalogToSurveyArea(catalog)

Checks that the coordinates of objects in the given catalog are within the survey area (taking into account a footprint, if specified) and cuts the catalog accordingly.

Parameters:

catalog (astropy.table.Table) – The input catalog, as an astropy Table.

Returns:

A catalog (astropy.table.Table), cut to the survey area.

generateMockSample(mockOversampleFactor=None, applyPoissonScatter=True)

Returns a mock catalog (but with no object coordinate information).

Parameters:
  • mockOversampleFactor (float, optional) – Scale the number of objects in the mock by this factor (e.g., this can be used to apply an overall area re-scaling). If given, this overrides self.mockOversampleFactor.

  • applyPoissonScatter (bool, optional) – If True, apply Poisson scatter to the cluster number counts when generating the mock catalog.

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.z will 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, massOptions, QFit, plotFileName=None, z=None, method='fast', numDraws=2000000, numIterations=100, verbose=False)

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 by getRMSTab().

  • SNRCut (float) – Completeness will be calculated for objects relative to this cut in fixed_SNR.

  • tileName (str) – Name of the map tile.

  • mockSurvey (nemo.MockSurvey.MockSurvey) – A MockSurvey object, used for halo mass function calculations and generating mock catalogs.

  • massOptions (dict) – A dictionary of scaling relation, cosmological, and mass definition 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 (float, optional) – Redshift at which the completeness calculation will be performed. If None, the redshift range will be taken from the MockSurvey object.

  • 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=None)

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) – A MockSurvey object, 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 a selFn/ 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_c in Nemo cluster catalogs).

completenessByFootprint(config)

Write out the average (log10 mass, z) grid over all survey footprints defined in the config, 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:

config (nemo.startUp.NemoConfig) – A NemoConfig object.

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).

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 by getRMSTab().

  • 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 a selFn/ 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 a selFn/ 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 a selFn/ 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)

loadFlagMask(tileName, selFnDir)

Loads the flag mask, i.e., areas flagged for reasons such as point source subtraction, for the given tile.

Parameters:
  • tileName (str) – The name of the tile for which the flag mask will be loaded.

  • selFnDir (str) – Path to a selFn/ 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 a selFn/ 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:
  • tileName (str) – The name of the tile for which the mass limit map will be loaded.

  • diagnosticsDir (str) – Path to the diagnostics/ directory, as produced by the nemo command.

  • z (float) – Redshift at which the mass limit map was made (should match an entry in the nemo config file).

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 a selFn/ 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 a selFn/ 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.

makeMassLimitMapsAndPlots(config)

Makes maps of mass completeness and associated plots. Output is written to the the diagnosticsDir directory). The maps to make are controlled by the massLimitMaps parameter in the selFnOptions dictionary in the Nemo config file.

Parameters:

config (nemo.startUp.NemoConfig) – A NemoConfig object.

Returns:

None

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, massLabel, 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.

  • massLabel (str) – Label for mass quantity (e.g., “M200c”).

  • 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:
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:
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:
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

params

Dictionary of filter settings (see Filters).

Type:

dict

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.ndarray containing 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:
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(useCachedFilter=False)

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 (str or float, optional) – Coordinate at which the kernel pixel scale will be determined (use centre for the middle of the map section).

  • decDeg (str or float, 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, diagnosticsDir='.', selFnDir='.', verbose=True, undoPixelWindow=True, useCachedFilter=False, 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.

  • 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.

  • useCachedFilter (bool, optional) – If True, and a previously made filter is found, it will be read from disk, rather than re-calculated (used by source injection simulations).

  • 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.

It now includes much faster routines based on those in Pixell by Sigurd Naess (but here we use Arnaud+2010 style notation)

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).

gnfw(x, c, alpha, beta, gamma, P0=1)

The GNFW radial profile (in the style of Hasselfield+2013, Arnaud+2010).

Parameters:
  • x (np.ndarray) – Radial coordinate.

  • c (float) – Concentration parameter (e.g. c500).

  • alpha (float) – GNFW shape parameter (see Arnaud+2010).

  • beta (float) – GNFW shape parameter (see Arnaud+2010).

  • gamma (float) – GNFW shape parameter (see Arnaud+2010).

  • P0 (float) – Pressure normalization (see Arnaud+2010).

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.

tsz_profile_los(x, c=1.177, alpha=1.051, beta=5.4905, gamma=0.3081, zmax=100000.0, npoint=100, x1=1e-08, x2=10000.0, _a=8, cache=None)

Fast, highly accurate approximate version of tsz_profile_los_exact. Interpolates the exact function in log-log space, and caches the interpolator. With the default settings, it’s accurate to better than 1e-5 up to at least x = 10000, and building the interpolator takes about 25 ms. After that, each evaluation takes 50-100 ns per data point. This makes it about 10000x faster than tsz_profile_los_exact. See tsz_profile_raw for the units.

tsz_profile_los_exact(x, c=1.177, alpha=1.051, beta=5.4905, gamma=0.3081, zmax=100000.0, _a=8)

Line-of-sight integral of the cluster_pressure_profile. See tsz_profile_raw for the meaning of the arguments. Slow due to the use of quad and the manual looping this requires. Takes about 1 ms per data point. The argument _a controls a change of variable used to improve the speed and accuracy of the integral, and should not be necessary to change from the default value of 8.

See tsz_profile_raw for the units and how to scale it to something physical. Without scaling, the profile has a peak of about 0.5 and a FWHM of about 0.12 with the default parameters.

Instead of using this function directly, consider using tsz_profile_los instead. It’s 10000x faster and more than accurate enough.

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.

class MapDict(inputDict, tileCoordsDict=None)

A dictionary for managing a sky map (a 2d array with an associated WCS) within Nemo. Keys within the dictionary can be set to values that control preprocessing of the map (usually done before filtering). Many of the keys in the dictionary map to entries in the .yml config file used by Nemo.

Parameters:
  • inputDict (dict) – Input dictionary (usually this mirrors the contents of unfilteredMaps in Nemo .yml config files).

  • tileCoordsDict (dict, optional) – A dictionary that describes the tiling of a large map, as produced by startUp.NemoConfig.getTileCoordsDict().

tileCoordsDict

A dictionary that describes the tiling of a large map, as produced by startUp.NemoConfig.getTileCoordsDict().

Type:

dict

validMapKeys

A list of keys that may contain a path to a map in FITS image format. These are: [‘mapFileName’, ‘weightsFileName’, ‘pointSourceMask’, ‘surveyMask’, ‘flagMask’].

Type:

list

copy()

Make a copy of this MapDict object.

Returns:

A deep copy of the MapDict object.

loadTile(mapKey, tileName, returnWCS=False)

Given a key in the map dictionary that contains the path to a FITS image, return the map as a 2d array and (optionally) the WCS.

Parameters:
  • mapKey (str) – Name of a key in a map dictionary that contains the path to map FITS image. See self.`validMapKeys` for a list.

  • tileName (str) – The name of the tile to load.

Returns:

Map data as a 2d array (and optionally a WCS)

Note

Tiles can be re-projected from CAR to TAN on the fly if the ‘reprojectToTan’ is set in the Nemo config.

preprocess(tileName='PRIMARY', diagnosticsDir=None)

Applies a number of pre-processing steps to the map described by this MapDict object, typically used before 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 the 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 (bool)

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:
  • tileName (str) – Name of the map tile (extension name) to operate on.

  • diagnosticsDir (str) – Path to a directory where miscellaneous diagnostic data may be written.

Returns:

None - values in the map dictionary are updated in-place, and additional keys may be added.

class MapDictList(mapDictList, tileCoordsDict=None)

Blah. We want this to iterate over the mapDictList and be indexable.

Blah.

class TileDict(inputDict, tileCoordsDict=None)

A dictionary for collecting tile images, for later saving as multi-extension FITS or outputting as a single monolithic FITS image. Keys within the dictionary map to tile names. Handles on-the-fly reprojection between TAN and CAR if specified in the Nemo config.

Parameters:
  • inputDict (dict) – Input dictionary (keys map to tile names).

  • tileCoordsDict (dict, optional) – A dictionary that describes the tiling of a large map, as produced by startUp.NemoConfig.getTileCoordsDict().

tileCoordsDict

A dictionary that describes the tiling of a large map, as produced by startUp.NemoConfig.getTileCoordsDict().

Type:

dict

copy()

Make a copy of this TileDict object.

Returns:

A deep copy of the TileDict object.

saveMEF(outFileName, compressionType=None)

Save the tile images as a multi-extension FITS file.

Parameters:
  • outFileName (str) – Path where the MEF file will be written.

  • compressionType (str) – If given, the data will be compressed using the given method (as understood by astropy.io.fits). Use PLIO_1 for masks, and RICE_1 for other image data that can stand lossy compression. If None, the image data is not compressed.

Returns:

None

saveStitchedFITS(outFileName, stitchedWCS, compressionType=None)

Stitch together the tiles into a monolithic image and save in a FITS file.

Parameters:
  • outFileName (str) – Path where the stitched image FITS file will be written.

  • stitchedWCS (astWCS.WCS) – WCS object corresponding to the stitched map that will be produced.

  • compressionType (str) – If given, the data will be compressed using the given method (as understood by astropy.io.fits). Use PLIO_1 for masks, and RICE_1 for other image data that can stand lossy compression. If None, the image data is not compressed.

Returns:

None

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, startUp.NemoConfig.getTileCoordsDict() will expand tiles by a user-specified amount such that they overlap.

checkMask(fileName, numChunks=8)

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.

chunkLoadMask(fileName, numChunks=8, dtype=<class 'numpy.uint8'>, returnWCS=True)

Load a FITS-format mask file (with default 8-bit integer values) in chunks, for memory efficiency, at the expense of some speed. Masks in compressed format (see saveFITS()) are supported.

Parameters:
  • fileName (str) – Path to the FITS-format mask file.

  • numChunks (int) – Number of chunks in which to load the file. Largers numbers use less memory, but it takes a little longer for the mask to load.

  • returnWCS (bool, optional) – If given, return the WCS of the mask.

Returns:

Mask image (2d array of 8-bit unsigned integers), and optionally a WCS object.

Note

This can also be used to load large compressed maps in a memory-efficient way by setting dtype = np.float32.

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 (BeamProfile or 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

makeDegreesDistanceMap(degreesMap, wcs, RADeg, decDeg, maxDistDegrees)

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.

makeExtendedSourceMask(config, tileName)

Find extended sources in all maps, adding an extended mask to the Nemo config. Each frequency map will then have extended mask holes filled when preprocess is called.

makeMaskFromDS9PolyRegionFile(regionFileName, shape, wcs)

Make a mask from a DS9 region file. The region file must have been created with RA, dec coordinates given in decimal degrees, and the shapes defining the mask must consist of polygon regions only.

Parameters:
  • regionFileName (str) – Path to SAOImage DS9 region file.

  • origShape (tuple) – Shape of the output mask.

  • origWCS (astWCS.WCS object) – WCS for the output mask.

Returns:

Mask (2d array)

makeModelImage(shape, wcs, catalog, beamFileName, obsFreqGHz=None, GNFWParams='default', profile='A10', cosmoModel=None, applyPixelWindow=True, override=None, validAreaSection=None, minSNR=-99, TCMBAlpha=0, reportTimingInfo=False)

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.Table or 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}.

  • reportTimingInfo (bool, optional) – If True, report how long each step takes.

Returns:

Map containing injected sources, or None if there are no objects within the map dimensions.

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.

saveFITS(outputFileName, mapData, wcs, compressionType=None)

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.

  • compressionType (str, optional) – If given, the data will be compressed using the given method (as understood by astropy.io.fits). Use PLIO_1 for masks, and RICE_1 for other image data that can stand lossy compression. If None, the image data is not compressed.

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=None, beam=None, seed=None)

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.ndarray or 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.

  • beam (str or signals.BeamProfile) – Either the file name of the text file that describes the beam with which the map will be convolved, or a signals.BeamProfile object. If None, no beam convolution is applied.

  • seed (int) – The seed used for the random CMB realisation.

Returns:

A map (numpy.ndarray)

simNoiseMap(shape, noiseLevel, wcs=None, lKnee=None, alpha=-3, noiseMode='perPixel')

Generate a simulated noise map. This may contain just white noise, or optionally a 1/f noise component can be generated.

Parameters:
  • shape (tuple) – A tuple describing the map (numpy array) shape in pixels (height, width).

  • noiseLevel (numpy.ndarray or 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.

  • wcs (astWCS.WCS, optional) – WCS corresponding to the map shape.

  • lKnee (float, optional) – If given, 1/f noise will be generated using the power spectrum N_l = (1 + l/lknee)^-alpha) - see Appendix A of MacCrann et al. 2023.

  • alpha (float, optional) – Power-law exponent in the power spectrum used for generating 1/f noise. Has no effect unless lKnee is also given.

  • noiseMode (str, optional) – Either ‘perPixel’, or ‘perSquareArcmin’ - if the latter, constant noise in terms of surface brightness will be added (accounts for varying pixel scale, if present - which requires wcs to be supplied).

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)

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.

Returns:

An astropy Table containing recovered position offsets and fluxes versus fixed_SNR for inserted sources.

Note

Injection tests for clusters use the reference filter only (set with the photFilter keyword in the config). Input amplitudes for clusters are in y_c, while output is in fixed_y_c (because the reference filter is used). Similarly, output SNR is fixed_SNR, although the output column is labelled as SNR.

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, maxMass=1e+16, zStep=0.01, numMassBins=200, delta=500, rhoType='critical', transferFunction='boltzmann_camb', massFunction='Tinker08', c_m_relation='Bhattacharya13', theoryCode='CCL')

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

delta

Overdensity parameter, used for mass definition (e.g., 200, 500).

Type:

:obj:``float`

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.

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.

  • maxMass (float, optional) – The maximum mass, in MSun, used in mass function calculations.

  • zStep (float, optional) – Sets the linear spacing between redshift bins.

  • numMassBins (int, optional) – Number of mass bins to use.

  • delta (:obj:``float`, optional) – Overdensity parameter, used for mass definition (e.g., 200, 500).

  • rhoType (str, optional) – Density definition, either ‘matter’ or ‘critical’, used for mass definition.

  • transferFunction (str, optional) – Transfer function to use, as understood by CCL (e.g., ‘eisenstein_hu’, ‘boltzmann_camb’).

  • massFunction (str, optional) – Name of the mass function to use, currently either ‘Tinker08’ or ‘Tinker10’. Mass function calculations are done by CCL.

  • ( (c_m_relation) – ‘obj:str, optional): Name of the concentration – mass relation to assume, as understood by CCL (this may be used internally for conversion between mass definitions, as needed).

  • theoryCode (str, optional) – Either ‘CCL’ or ‘CLASS-SZ’.

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 the nemo.completeness.SelFn class, 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=None, wcs=None, photFilterLabel=None, tileName=None, SNRLimit=None, makeNames=False, z=None, numDraws=None, areaDeg2=None, applySNRCut=False, applyPoissonScatter=True, applyIntrinsicScatter=True, applyNoiseScatter=True, applyRelativisticCorrection=True, verbose=False, biasModel=None)

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 (float or np.ndarray) – Either a single number (if using e.g., a survey average), an RMS table (with columns ‘areaDeg2’ and ‘y0RMS’), 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).

  • QFit (nemo.signals.QFit, optional) – Object that handles the filter mismatch function, Q. If not given, the output catalog will not contain fixed_y_c columns, only true_y_c columns.

  • 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).

  • applyRelativisticCorrection (bool, optional) – If True, apply the relativistic correction.

Returns:

A catalog as an astropy.table.Table object, 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.

setSurveyArea(areaDeg2)

Change the area of the survey to a user-specified value, updating the cluster counts accordingly.

Parameters:

areaDeg2 (float) – Area of the survey in square degrees.

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.

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, useCachedFilters=False, useCachedRMSMap=False, useCachedFilteredMaps=False, measureFluxes=True, invertMap=False, verbose=True, writeAreaMask=False, writeFlagMask=False)

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.

  • useCachedFilters (bool, optional) – If True, and previously made filters are found, they will be read from disk, rather than re-calculated (used by source injection simulations).

  • useCachedRMSMap (bool, optional) – If True, use the previously estimated noise map, which has been saved to disk. This is only useful for source injection simulations.

  • useCachedFilteredMaps (bool, optional) – If True, and previously written maps are found, these will be read from disk, rather than re-made. This is useful for performing forced photometry using external catalogs without having to run nemo again. Otherwise, this should be set to False.

  • 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, QSource='fit')

Generate a mock cluster catalog using the given nemo config.

Returns:

List of catalogs (each is an astropy Table object)

makeRMSTables(config)

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 and area covered, and completeness. Adds footprint columns to object catalog.

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 as a beam transform file with l in the first column, and Bl in the second column), or can be set directly using arrays.

Parameters:
  • beamFileName (str, optional) – Path to text file containing a beam profile (or transform) 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, c_m_relation='Bhattacharya13')

Convert M500c to some other mass definition.

massDef (obj:ccl.halos.MassDef): CCL halo mass definition

MDef1ToMDef2(mass, z, MDef1, MDef2, cosmoModel, c_m_relation='Bhattacharya13')

Convert some mass at some z defined using MDef1 into a mass defined according to MDef2.

Parameters:
  • mass (float) – Halo mass in MSun.

  • z (float) – Redshift of the halo.

  • (obj (MDef2) – ccl.halos.MassDef): CCL halo mass definition you want to convert from.

  • (obj – ccl.halos.MassDef): CCL halo mass definition you want to convert to.

, c_m_relation (‘obj’:str): Name of the concentration – mass relation to assume, as understood by CCL.

class QFit(QSource='fit', selFnDir=None, 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:
  • QSource (str, optional) – The source to use for Q (the filter mismatch function) - either ‘fit’ (to use results from the original Q-fitting routine), ‘injection’ (to use Q derived from source injection simulations), or ‘hybrid’ (to use ‘fit’ at scales less than the reference filter scale, and ‘injection’ at scales greater than the reference filter scale). For the ‘injection’ and ‘hybrid’ methods, selFnDir must be supplied.

  • selFnDir (str, optional) – Path to a selFn/ 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.

  • QFitFileName (str, optional) – Path to a FITStable containing Q fits for all tiles - this is normally selFn/QFit.fits). This is only used if QSource is set to fit.

  • tileNames (list) – If given, the Q-function will be defined only for these tiles.

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 (float or np.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. If None, or if the given tileName is not found, then an average over all tiles is used.

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(QFitFileName, tileNames=None)

Load the filter mismatch function Q (see Hasselfield et al. 2013) as a dictionary of spline fits.

Parameters:
  • QFitFileName (str) – The path to a .fits table (containing Q fits for all tiles - this is normally selFn/QFit.fits).

  • tileNames (optional, list) – A list of tiles for which the Q function spline fit coefficients will be extracted. If source is a nemo.startUp.NemoConfig object, this should be set to None.

Returns:

None

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, returnQ=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

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 combined into a single file written under the selFn directory.

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 QFit for how to read in and use the file produced by 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).

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, binning='log')

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, shape, wcs, beam=None, RADeg=None, decDeg=None, GNFWParams='default', amplitude=None, maxSizeDeg=15.0, convolveWithBeam=True, cosmoModel=None, painter='pixell')

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.

  • shape (tuple) – A tuple describing the map (numpy array) shape in pixels (height, width).

  • wcs (astWCS.WCS) – An astWCS object.

  • beam (str or signals.BeamProfile) – Either the file name of the text file that describes the beam with which the map will be convolved, or a signals.BeamProfile object. If None, no beam convolution is applied.

  • RADeg (float, or array, optional) – If None, the signal will be inserted at the center of the generated map.

  • decDeg (float, or array, optional) – If None, the signal will be inserted at the center of the generated map.

  • 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, or array, 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.

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).

Note

If arrays of sky coordinates and amplitudes are given, multiple clusters (with the same profile) will be painted in the map. This is useful for running cluster injection simulations for estimating completeness, but only works with the ‘pixell’ object painter.

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 BattagliaModelFilter

makeBattagliaModelSignalMap(z, M500, shape, wcs, beam=None, RADeg=None, decDeg=None, GNFWParams='default', amplitude=None, maxSizeDeg=15.0, convolveWithBeam=True, cosmoModel=None)

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.

  • shape (tuple) – A tuple describing the map (numpy array) shape in pixels (height, width).

  • wcs (astWCS.WCS) – An astWCS object.

  • beam (str or signals.BeamProfile) – Either the file name of the text file that describes the beam with which the map will be convolved, or a signals.BeamProfile object. If None, no beam convolution is applied.

  • RADeg – If None, the signal will be inserted at the center of the generated map.

  • decDeg – If None, the signal will be inserted at the center of the generated map.

  • 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.

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 (BeamProfile or 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).

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, writeTileInfo=False, selFnDir=None, calcSelFn=False, sourceInjectionTest=False, MPIEnabled=False, divideTilesByProcesses=True, verbose=True, strictMPIExceptions=True)

An object that manages Nemo’s configuration (paths to maps, output directories, filter settings 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 manages Nemo’s configuration (paths to maps, output directories, filter settings etc.).

Parameters:
  • config (str or dict) – 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).

  • writeTileInfo (bool, optional) – If True and set-up to break maps into tiles, write info on the tile geometry (such as a DS9 region file) into selFnDir.

  • 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.

addAutoTileDefinitions(DS9RegionFileName=None, cacheFileName=None)

Runs the autotiler to add automatic tile definitions into the parameters dictionary in-place.

Parameters:
  • 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).

getTileCoordsDict()

Construct a dictionary that describes how a large map is broken up into smaller tiles (see Tiling for information on the relevant configuration file parameters).

Returns:

A dictionary indexed by tile name, where each entry is a dictionary containing information on pixel coordinates of each tile within the larger map, and the WCS of each tile.

restoreConfig()

Restores the parameters dictionary (self.parDict) and unfiltered maps list to the original state specified in the config .yml file.

setFilterSet(setNum)

For use with multi-pass mode, in conjunction with filterSets and filterSetOptions config file parameters.

parseConfigFile(parDictFileName, verbose=False)

Parse a Nemo .yml config file.

Parameters:
  • parDictFileName (str) – Path to a nemo .yml configuration file.

  • verbose (bool, optional) – If True, warning messages may be printed to the console, if there are any.

Returns:

A dictionary of parameters.