The Monte Carlo code that adds fake galaxiesto images from the Legacy Survey
Classes
BuildStamp(tim[, gain, seed]) |
Does the drawing of simulated sources on a single exposure |
Functions
build_simcat([Samp, brickwcs, meta]) |
Creates the simulated source catalog for a given brick (not CCD). |
create_ith_simcat([d]) |
Write ‘simcat’ and ‘skipped_ids’ tables for a given sample of sources |
create_metadata([kwargs]) |
fits_table with configuration-like params for the simulated sources |
do_ith_cleanup([d]) |
Moves all obiwan+legacypipe outputs to a new directory stucture |
do_one_chunk([d]) |
Runs the legacypipe/Tractor pipeline on images with simulated sources |
dobash(cmd) |
|
flag_nearest_neighbors(Samp[, radius_in_deg]) |
Returns Sample indices to keep (have > dist separations) and indices to skip |
get_checkpoint_fn(outdir, brick, rowstart) |
|
get_e1_e2(q, beta) |
Given minor to major axis ratio (q) and postion angle (beta), Returns e1,e2 tuple |
get_ellip(q) |
Given minor to major axis ratio (q) Returns ellipticity |
get_fnsuffix(**kwargs) |
|
get_parser() |
return parser object, tells it what options to look for options can come from a list of strings or command line |
get_runbrick_setup(**kwargs) |
Convert runbrick.py cmd line options into **kwargs for run_brick() |
get_sample(objtype, brick, randoms_db[, …]) |
Gets all simulated randoms for a brick from PSQl db, and applies all relevant cuts |
get_skip_ids(decals_sim_dir, brickname, objtype) |
|
get_srcimg_invvar(stamp_ivar, img_ivar) |
stamp_ivar, img_ivar – galsim Image objects |
imshow_stamp(stamp[, fn, galsimobj]) |
|
ivar_for_galaxy(gal, nano2e) |
Adds gaussian noise to perfect source |
ivar_to_var(ivar[, nano2e, camera]) |
|
main([args]) |
Main routine which parses the optional inputs. |
noise_for_galaxy(gal, nano2e) |
Returns numpy array of noise in Img count units for gal in image cnt units |
plot_radial_profs(fn, profs) |
|
ptime(text, t0) |
Timer |
read_dict(fn) |
|
saturation_e(camera) |
|
write_dict(fn, d) |
d – dictionary |
obiwan.kenobi.BuildStamp(tim, gain=4.0, seed=0)[source]¶Does the drawing of simulated sources on a single exposure
| Parameters: |
|
|---|
band¶g,r,z
gsparams¶galsim object that configures how accurate simulated source will be
gsdeviate¶galsim object that configures its random number generator
wcs¶WCS from tim
psf¶psf from tim
galsim_wcs¶wcs repackaged into galsim compatible object
zpscale¶conversion factor ‘nanomaggies’ to ‘ADU’
nano2e¶conversion factor ‘nanomaggies’ to ‘e-‘
obiwan.kenobi.build_simcat(Samp=None, brickwcs=None, meta=None)[source]¶Creates the simulated source catalog for a given brick (not CCD).
| Parameters: |
|
|---|---|
| Returns: | tuple of cat: skipping_ids: |
obiwan.kenobi.create_ith_simcat(d=None)[source]¶Write ‘simcat’ and ‘skipped_ids’ tables for a given sample of sources
| Parameters: | d – {‘Samp’: fits_table for the properties of sources in the brick ‘brickwcs’: WCS object for the brick ‘metacat’: fits_table with configuration params for the simulated sources } |
|---|---|
| Returns: | Nothing, saves the ‘simcat’ and ‘skipped_ids’ tables Adds ‘simcat’ table to dict ‘d’ |
obiwan.kenobi.create_metadata(kwargs=None)[source]¶fits_table with configuration-like params for the simulated sources
TODO: Should metacat table have a rowstart column? TODO: One metacat table per brick, instead of one per rs* directory?
| Parameters: | kwargs – configuration-like params for the simulated sources {‘brickname’: which chunk of sky ‘objtype’: star,elg,lrg,qso ‘nobj’: number of simulated sources for this run } |
|---|---|
| Returns: | Nothing writes the ‘metacat’ fits_table to disk and stores it in the kwargs input arg |
obiwan.kenobi.do_ith_cleanup(d=None)[source]¶Moves all obiwan+legacypipe outputs to a new directory stucture
| Parameters: | d – dict with keys brickname, simcat_dir |
|---|
obiwan.kenobi.do_one_chunk(d=None)[source]¶Runs the legacypipe/Tractor pipeline on images with simulated sources
| Parameters: | d – {‘args’: obiwan.kenobi.py cmd line argparse.Namespace object ‘brickname’: chunk of sky ‘metacat’: fits_table configuration params for the simulated sources ‘simcat’: fits_table simulated source catalog for a given brick (not CCD). |
|---|
Note
runb_brick() is ‘main’ for the legacypipe/Tractor pipeline
| Returns: | Nothing, but this func end ups writing out all the obiwan results |
|---|
obiwan.kenobi.flag_nearest_neighbors(Samp, radius_in_deg=0.001388888888888889)[source]¶Returns Sample indices to keep (have > dist separations) and indices to skip
| Returns: | keep,skip: indices of Samp to keep and skip |
|---|---|
| Return type: | tuple |
obiwan.kenobi.get_e1_e2(q, beta)[source]¶Given minor to major axis ratio (q) and postion angle (beta), Returns e1,e2 tuple
obiwan.kenobi.get_parser()[source]¶return parser object, tells it what options to look for options can come from a list of strings or command line
obiwan.kenobi.get_runbrick_setup(**kwargs)[source]¶Convert runbrick.py cmd line options into **kwargs for run_brick()
| Parameters: | **kwargs – dict of the cmd line options to obiwan.kenobi.py |
|---|---|
| Returns: |
|
obiwan.kenobi.get_sample(objtype, brick, randoms_db, minid=None, randoms_from_fits='', do_skipids='no', outdir=None, dont_sort_sampleid=False)[source]¶Gets all simulated randoms for a brick from PSQl db, and applies all relevant cuts
| Parameters: |
|
|---|---|
| Returns: | sample fits_table, seed |
| Return type: | tupe |
obiwan.kenobi.get_srcimg_invvar(stamp_ivar, img_ivar)[source]¶stamp_ivar, img_ivar – galsim Image objects
obiwan.kenobi.ivar_for_galaxy(gal, nano2e)[source]¶Adds gaussian noise to perfect source
| Parameters: |
|
|---|---|
| Returns: | nanomags |
| Return type: | galsim.Image() of invvar for the source, UNITS |