Skip to content

Commit

Permalink
stdstar selection without obsconditions
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Bailey authored and Stephen Bailey committed Sep 21, 2017
1 parent 7863154 commit 4195f10
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions py/desitarget/mock/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ def targets_truth(params, output_dir='.', realtargets=None, seed=None, verbose=F
alltargets = list()
alltruth = list()
alltrueflux = list()

for source_name in sorted(params['sources'].keys()):
# Read the mock catalog.
target_name = params['sources'][source_name]['target_name'] # Target type (e.g., ELG)
Expand Down Expand Up @@ -894,30 +895,27 @@ def _update_spectra_status(result):
# Write out the dark- and bright-time standard stars.
for stdsuffix in ('dark', 'bright'):
# Standards taken from targets
istd = inpixel.copy()

# stdfile = os.path.join(output_dir, 'standards-{}-{}.fits'.format(stdsuffix, healsuffix))
stdfile = mockio.findfile('standards-{}'.format(stdsuffix), nside, pixnum, basedir=output_dir)

# Select all targets with each of the standard star types and
# matching obsconditions.
for stdbit in ('STD_FSTAR', 'STD_BRIGHT', 'STD_WD'):
is_std_type = (targets['DESI_TARGET'] & desi_mask.mask(stdbit)) != 0

if stdsuffix == 'dark':
has_right_obsconditions = (targets['OBSCONDITIONS'] & (obsconditions.DARK | obsconditions.GRAY) != 0)
elif stdsuffix == 'bright':
has_right_obsconditions = (targets['OBSCONDITIONS'] & (obsconditions.BRIGHT) != 0)

istd &= (is_std_type & has_right_obsconditions)
# matching obsconditions
if stdsuffix == 'dark':
dark_std_mask = desi_mask.STD_FSTAR | desi_mask.STD_WD
istd = inpixel & ((targets['DESI_TARGET'] & dark_std_mask) != 0)
elif stdsuffix == 'bright':
bright_std_mask = desi_mask.STD_BRIGHT | desi_mask.STD_WD
istd = inpixel & ((targets['DESI_TARGET'] & bright_std_mask) != 0)
else:
raise RuntimeError('unknown stdsuffix {}'.format(stdsuffix))

if np.count_nonzero(istd) > 0:
log.info('Writing {} {} standards on healpix {} to {}'.format(np.sum(istd), stdsuffix, pixnum, stdfile))
write_bintable(stdfile+'.tmp', targets[istd], extname='STD',
header=targetshdr, clobber=True)
os.rename(stdfile+'.tmp', stdfile)
else:
log.info('No {} standards on healpix {}, {} not written.'.format(stdsuffix, pixnum, stdfile))
log.error('No {} standards on healpix {}, {} not written.'.format(stdsuffix, pixnum, stdfile))

# Finally write out the rest of the targets.
targetsfile = mockio.findfile('targets', nside, pixnum, basedir=output_dir)
Expand Down

0 comments on commit 4195f10

Please sign in to comment.