xpipe.xhandle.parbins.XIO

class xpipe.xhandle.parbins.XIO(lenses, randoms=None, params=None, dirpaths=None, nrandoms=None, force_centers=100)[source]

XSHEAR style input file creator

Parameters
  • lenses (dict) – dictionary with lens data

  • randoms (dict, optional) – dictionary with random points data

  • params (dict) – Pipeline settings in a dictionary format. If None then the default paths.params will be used

  • dirpaths (dict) – Pipeline directory paths in a dictionary format. If None then the default paths.dirpaths will be used

  • nrandoms (float or int) – number of random points to draw for each parameter bin with replacement. If None then the value is extracted from paths.params

  • force_centers (int or np.array) – number of JackKnife centers, or the (RA, DEC) positions of the centers

Notes

If nrandoms == -1 then all random points are used, and no random draw is made. In this case the weights are not applied properly, so be careful!

Examples

Using default parameters specified in paths.params.

load catalogs:

lenses = parbins.prepare_lenses()
randoms = parbins.prepare_random()

initiate object:

xio = parbins.XIO(lenses, randoms)

create project directory:

xio.mkdir()

loop over all parameter bins:

xio.loop_bins(norands=args.norands)

write logfile, for future reference:

logfile = xio.dpath + '/' + paths.params['tag'] + '_params.p'
pickle.dump(paths.params, open(logfile, 'wb'))
loop_bins(norands=False, match=True)[source]

Loops over (lambda, z) parameter bins and save xshear input files

Parameters
  • norands (bool) – Flag to skip random points, default False, (that is to include randoms)

  • match (bool) – Flag to match the random point distribution by their paramters to the lens distribution. The alternative is to just apply the parameter cut without further matching.

mkdir()[source]

creates project directory

randsel(match=True)[source]

Selects random points to use (weighted draw with replacement)

If self.nrandoms == -1 then all random points are used, and no random draw is made. In this case the weights are not applied properly, so be careful!

Parameters

match (bool) – Flag to match the random point distribution by their paramters to the lens distribution. The alternative is to just apply the parameter cut without further matching.

save_clust()[source]

Writes lenses to file in xshear style

save_clust_jk()[source]

writes cluster lens file for each JK patch in xshear style

save_rands()[source]

Writes random points to file in xshear style

save_rands_jk()[source]

writes random points to file for each JK patch in xshear style

savelists(norands=False)[source]

writes JK file paths to a file for future lookup

setbin(bound)[source]

Assigns index and filenames for param bin based on bounds