print('Assigned science: {}'.format(len(_assigned))) ## Load one tile, currently. Tile = 74057 sv_mtl = Table(fits.open(scratch + '/BGS/SV-ASSIGN/mtls/svmtl_{:06d}.fits'.format(Tile))[1].data) ## Limit to only BGS. sv_mtl = sv_mtl[sv_mtl['SV1_BGS_TARGET'].quantity.value > 0] print('Total targets in Tile {}: {}.'.format(Tile, len(sv_mtl))) ## _bitdefs = load_mask_bits("sv1") bgs_mask = BitMask('sv1_bgs_mask', _bitdefs) types = bgs_mask.names() bits = [bgs_mask.bitnum(x) for x in types] ## Those that were assigned in this tile. assigned = join(_assigned, sv_mtl, keys=['BRICKID', 'BRICK_OBJID'], join_type='inner') ## SV Target class. splits = {} title = '' ## for _type in ['BGS_FAINT', 'BGS_BRIGHT', 'BGS_FAINT_EXT', 'BGS_LOWQ', 'BGS_FIBMAG']: sample = _type.split('_') sample.pop(0) sample = ''.join(x for x in sample) splits[_type] = assigned[(assigned['SV1_BGS_TARGET'] & 2 ** bgs_mask.bitnum(_type)) != 0]
## Retain only the science targets; Dropping standards etc. _assigned = _assigned[_assigned['FA_TYPE'].quantity == 1] ## Load one tile, currently. sv_mtl = Table( fits.open(scratch + '/BGS/SV-ASSIGN/mtls/svmtl_074057.fits')[1].data) ## Limit to only BGS. sv_mtl = sv_mtl[sv_mtl['SV1_BGS_TARGET'].quantity.value > 0] ## _bitdefs = load_mask_bits("sv1") bgs_mask = BitMask('sv1_bgs_mask', _bitdefs) types = bgs_mask.names() bits = [bgs_mask.bitnum(x) for x in types] ## assigned = join(_assigned, sv_mtl, keys=['BRICKID', 'BRICK_OBJID'], join_type='inner') assert len(_assigned) == len(assigned) splits = {} title = '' for _type in [ 'BGS_FAINT', 'BGS_BRIGHT', 'BGS_FAINT_EXT', 'BGS_LOWQ', 'BGS_FIBMAG' ]: sample = _type.split('_')
scratch = os.environ['CSCRATCH'] tiles = Table( fits.open( '/global/cscratch1/sd/mjwilson/BGS/SV-ASSIGN/tiles/BGS_SV_30_3x_superset60_Sep2019.fits' )[1].data) utiles = np.unique(tiles['TILEID'].quantity) ## _bitdefs = load_mask_bits("sv1") desi_mask = BitMask('sv1_desi_mask', _bitdefs) bgs_mask = BitMask('sv1_bgs_mask', _bitdefs) types = bgs_mask.names() bits = [bgs_mask.bitnum(x) for x in types] ## L428 of https://github.com/desihub/desimodel/blob/master/py/desimodel/focalplane/geometry.py params = load_desiparams() fiber_dia = params['fibers']['diameter_um'] #- Platescales in um/arcsec ps = load_platescale() ## Add in GAMA labels. _fits = fits.open( '/global/cscratch1/sd/mjwilson/BGS/SV-ASSIGN/truth/legacy/ls-GAMA-south.fits' ) gama = Table(_fits[1].data) for tile in utiles:
)[1].data) utiles = np.unique(tiles['TILEID'].quantity) result = Table(names=[ 'TARGETID', 'FA_TYPE', 'BRICK_OBJID', 'TARGET_RA', 'TARGET_DEC', 'BRICKID' ], dtype=('i8', 'i1', 'i4', 'f8', 'f8', 'i4')) ## _bitdefs = load_mask_bits("sv1") desi_mask = BitMask('sv1_desi_mask', _bitdefs) bgs_mask = BitMask('sv1_bgs_mask', _bitdefs) types = bgs_mask.names() bits = [bgs_mask.bitnum(x) for x in types] ## L428 of https://github.com/desihub/desimodel/blob/master/py/desimodel/focalplane/geometry.py params = load_desiparams() fiber_dia = params['fibers']['diameter_um'] #- Platescales in um/arcsec ps = load_platescale() for tile in utiles: print('Solving for Tile {}.'.format(tile)) ## Scrape from the tile picker site. ## cmd = 'wget http://www.astro.utah.edu/~u6022465/SV/tiles/SV_BGS/fits_files/tile-{:06}.fits -O /global/cscratch1/sd/mjwilson/BGS/SV-ASSIGN/fiberassign/tile-{:06}.fits'.format(tile, tile) ## os.system(cmd)