I want to calculate a text field call "TIME_DAY," depending of whether or not the time falls within of four time periods it should return one of four values. My script should work, but it doesn't.
def timeday(time, am, diur, pm, noc):
if(time >=am AND time < diur):
return “cerp_am”
elif(time>= diur AND time<pm):
return “diurnal”
elif(time>=pm AND time<noc):
return “cerp_pm”
else:
return “nocturnal”
timeday(!LMT_TIME!, !B_C_AM1!, !B_DIUR1!, !B_C_PM1!, !BEG_NOC1!)
I'm getting ERROR 000989: Python syntax error: Parsing error Syntax.
Here is what my attribute table looks like:
@Midavalo's solution worked well for the vast majority of my data, except for a few datasets, where it mistakenly places midnight values in the "diurnal" category.