def calcMoonFlag(fld, startTime, endTime, mmt): """Calculate the IGNORE_FLAG based on lunar brightness and position. Inputs: fld -- field parameter entry from obsPars startTime -- datetime formatted starting time endTime -- datetime formatted ending time Output: flag -- 0/1 flag marking if the field is too close to the moon or the moon is brighter than specified. """ moonUp = moonUpDuringObs(startTime, endTime, mmt) moonAge = MMTEphem.moonAge(startTime) # Get the distance to the moon moonDist = lunarDistance(fld, startTime, endTime) # Now do brightness flag moonReq = fld['moon'].values[0] if (moonReq == 'bright') | (moonUp == 0): # Anything works, either we were asked for bright # time or the moon isn't up during # the entirety of the observation illumFlag = 1 elif (moonReq == 'grey') & (abs(moonAge) < 9) & (moonDist < 90): # We were asked for grey time and it's grey time illumFlag = 1 elif (moonReq == 'dark') & (abs(moonAge) < 4.5) & (moonDist > 90.0): # We were asked for dark time and it's dark time illumFlag = 1 else: illumFlag = 0 # This isn't going to work here! # Flag things that are just plain too close to the moon if moonDist < 10: illumFlag = 0 return illumFlag