obiwan.runmanager.derived_tables

Post-processes the obiwan/, tractor/, data products. Joins the psql db, input properties, and tractor catalogue measurements for easy anaylsis later. Uses mpi4py to parallelize to a full production runs’ outputs.

Classes

Bit bitmask arithmetic
RandomsTable(data_dir, dr3_or_dr5, …[, date]) Creates the uniform,obiwan_a,obiwan_b randoms tables for a single brick
SummaryTable(data_dir, dr3_or_dr5[, date]) Writes one table per brick, with brick averaged quantities
TargetSelection Applies ELG target selection using either DESI or eBOSS criteria

Functions

bin_by_mag(randoms, func_to_apply[, band, …]) bins data and result of func_to_apply(randoms) into the bucket
datarelease_dir(drNumber) the tractor catalogues for this DR are the real galaxy catalogues
depth_at_half_recovered(randoms, band) bin by mag in given mag, return bin center where frac recovered first drops below 50%
derived_field_dir(brick, data_dir, date) directory to save post-processed tables to
flux2mag(nmgy) converts nanomaggies to AB mag
fraction_recovered(randoms) Return fraction of randoms detected and measured by Legacypipe
is_bool(obj)
is_numeric(obj)
main_mpi([bricks, doWhat, dr3_or_dr5, …])
param nproc:> 1 for mpi4py
class obiwan.runmanager.derived_tables.Bit[source]

bitmask arithmetic

clear(value, bit)[source]

change bit to 0, bit is 0-indexed

set(value, bit)[source]

change bit to 1, bit is 0-indexed

class obiwan.runmanager.derived_tables.RandomsTable(data_dir, dr3_or_dr5, db_randoms_table, date='mm-dd-yyyy')[source]

Creates the uniform,obiwan_a,obiwan_b randoms tables for a single brick

Final table has same number rows as uniform table, and the obiwan
rows are filled in wherever there is a matching unique_id between uniform and obiwan. A bitmask column ‘obiwan_mask’ which says whether the random was recovered by Tractor or not, and whether the random is near a previously existing real source in a DR catalogue, like DR3 or DR5
add_flag_for_realsources(tab, brick)[source]

Flag sources also in DR3, DR5

Parameters:tab – table returned by merged_randoms_table()
add_psql_to_uniform_table(uniform, db_randoms_table)[source]

Add randoms db columns from psql to the uniform randoms table

Parameters:
  • uniform – fits table
  • db_randoms_table – name of the psql db table
get_rsdirs(brick)[source]

get list of rsdirs for a given brick

Returns:tuple of rsdirs list and whether the brick is finished or not
merge_randoms_tables(brick, rsdirs)[source]

Computes final joined randoms tables

Includes uniform randoms, info from psql db, which of these were recovered
by Tractor, and the associated tractor info for those
Parameters:brick – brickname
Returns:joined randoms table
unique_id(id_array, brick, rs_dir)[source]

For a given random injected into a brick during a given iteration

Parameters:
  • id_array – randoms ids
  • brick – brick
  • rs_dir – like rs0 or rs300
write_table(tab, fn)[source]

Write the merged randoms table is doesn’t already exist

class obiwan.runmanager.derived_tables.SummaryTable(data_dir, dr3_or_dr5, date='mm-dd-yyyy')[source]

Writes one table per brick, with brick averaged quantities

derived table “randoms.fits” must exist. Joins the brick summary quantities from a data release with a similar set from the randoms.fits table. Each brick’s table has one row and all tables get merged to make the eatmap plots

add_obiwan_to_DR_table(summary_DR, summary_obi)[source]

adds the summary_obi columsn to the summary_DR table

Parameters:
  • summary_DR – brick summary for the data release bricks
  • summary_obiwan – brick summary for the obiwan bricks
brick_summary(bricklist=[])[source]
Parameters:bricklist – Give a single brick as a list of length 1, e.g. [brick]
brick_summary_obiwan(brick, prefix='')[source]

brick summary for obiwan

Parameters:prefix – prefix for obiwan tractor columns, e.g. tractor_
brick_summary_obiwan_brief(brick, prefix='')[source]

brick_summary_obiwan but only 3-4 quantities

class obiwan.runmanager.derived_tables.TargetSelection[source]

Applies ELG target selection using either DESI or eBOSS criteria

_desi_elg(gflux=None, rflux=None, zflux=None, primary=None)[source]

VERBATIM from https://github.com/desihub/desitarget/blob/master/py/desitarget/cuts.py

Parameters:
  • rflux, zflux, w1flux, w2flux (gflux,) – array_like The flux in nano-maggies of g, r, z, w1, and w2 bands.
  • primary – array_like or None If given, the BRICK_PRIMARY column of the catalogue.
Returns:

array_like. True if and only the object is an ELG

target.

Return type:

mask

_eboss_elg(ngc_or_sgc, primary=None, ra=None, dec=None, gmag=None, rmag=None, zmag=None, anymask_g=None, anymask_r=None, anymask_z=None, allmask_g=None, allmask_r=None, allmask_z=None, psfdepth_g=None, psfdepth_r=None, psfdepth_z=None)[source]

Johan’s target selection

Does NOT do:
tycho2inblob == False SDSS bright object mask & 0 < V < 11.5 mag Tycho2 stars mask custom mask for eboss23
elg_by_measurement(tractor, name, prefix='', anymask=True)[source]

Returns bool array elgs as measured by tractor

Parameters:
  • prefix – ‘tractor_’ for randoms table, ‘’ for tractor table
  • anymask – True to apply anymask cut, False for allmask
obiwan.runmanager.derived_tables.bin_by_mag(randoms, func_to_apply, band=None, bin_minmax=(18.0, 26.0), nbins=20)[source]

bins data and result of func_to_apply(randoms) into the bucket

Parameters:
  • randoms – randoms.fits table
  • func_to_apply – operates on a randoms table, return val to store in bucket
  • band – bin by mag in this band
obiwan.runmanager.derived_tables.datarelease_dir(drNumber)[source]

the tractor catalogues for this DR are the real galaxy catalogues

obiwan.runmanager.derived_tables.depth_at_half_recovered(randoms, band)[source]

bin by mag in given mag, return bin center where frac recovered first drops below 50%

obiwan.runmanager.derived_tables.derived_field_dir(brick, data_dir, date)[source]

directory to save post-processed tables to

obiwan.runmanager.derived_tables.flux2mag(nmgy)[source]

converts nanomaggies to AB mag

obiwan.runmanager.derived_tables.fraction_recovered(randoms)[source]

Return fraction of randoms detected and measured by Legacypipe

Parameters:randoms – ra,dec, and properties of all source added to a bricks
obiwan.runmanager.derived_tables.main_mpi(bricks=[], doWhat=None, dr3_or_dr5=None, db_randoms_table=None, nproc=1, data_dir='./', date='mm-dd-yyyy')[source]
Parameters:
  • nproc – > 1 for mpi4py
  • bricks – list of bricks