def tselect(t): import sdsspy from esutil.numpy_util import where1 plogic = (t['resolve_status'] & sdsspy.flagval('resolve_status','survey_primary')) != 0 blended_logic = (t['objc_flags'] & sdsspy.flagval('object1','blended')) == 0 nodeblend_logic = (t['objc_flags'] & sdsspy.flagval('object1','nodeblend')) != 0 pw = where1( plogic ) aw = where1( plogic & (blended_logic | nodeblend_logic) ) print 'primary:',pw.size print 'primary + blend cuts:',aw.size
def object1_logic(objc_flags): satur = sdsspy.flagval('object1','satur') bright = sdsspy.flagval('object1','bright') too_many_peaks = sdsspy.flagval('object1','deblend_too_many_peaks') blended = sdsspy.flagval('object1','blended') nodeblend = sdsspy.flagval('object1','nodeblend') peakcenter = sdsspy.flagval('object1','peakcenter') notchecked = sdsspy.flagval('object1','notchecked') noprofile = sdsspy.flagval('object1','noprofile') # famously worded as double negatives bdb_logic = \ ( (objc_flags & blended) == 0) | ((objc_flags & nodeblend) != 0) # now combine logic logic = \ ((objc_flags & satur) == 0) \ & ((objc_flags & bright) == 0) \ & ((objc_flags & too_many_peaks) == 0) \ & ((objc_flags & peakcenter) == 0) \ & ((objc_flags & notchecked) == 0) \ & ((objc_flags & noprofile) == 0) \ & bdb_logic return logic
def binned_logic_ri(flags): binned1 = sdsspy.flagval('object1','binned1') binned2 = sdsspy.flagval('object1','binned2') binned4 = sdsspy.flagval('object1','binned4') rflags = flags[:,2] iflags = flags[:,3] r_binned_logic = \ ((rflags & binned1) != 0 ) \ | ((rflags & binned2) != 0 ) \ | ((rflags & binned4) != 0 ) i_binned_logic = \ ((iflags & binned1) != 0 ) \ | ((iflags & binned2) != 0 ) \ | ((iflags & binned4) != 0 ) return r_binned_logic & i_binned_logic
def calib_logic(calib_status): flagval = sdsspy.flagval('calib_status', 'photometric') logic = \ ((calib_status[:,0] & flagval) != 0) \ & ((calib_status[:,1] & flagval) != 0) \ & ((calib_status[:,2] & flagval) != 0) \ & ((calib_status[:,3] & flagval) != 0) \ & ((calib_status[:,4] & flagval) != 0) return logic
def resolve_logic(resolve_status): primary_flag = sdsspy.flagval('resolve_status','survey_primary') return (resolve_status & primary_flag) != 0