def find_astro(year): ''' find new moons and solar terms needed for calculate lunar calendar Arg: year is a integer Return: list of dictionaries [ {date, newmoon/angle, placeholder for month }, ... ] ''' # find all solar terms from -120 to +270 degree, negative angle means # search backward from Vernal Equinox solarterms = [] angle = -120 while angle <= 270: jdst = solarterm(year, angle) solarterms.append([jdst, angle]) #print angle, jdftime(jdst, tz=8, ut=True) angle += 15 # search 15 newmoons start 30 days before last Winter Solstice nms = findnewmoons(solarterms[1][0] - 30) aadays = [[x, 'newmoon'] for x in nms] aadays.extend(solarterms) aadays.sort() # normalize all Julian Day to midnight for later compare aadays = [(jdptime(jdftime(d[0], '%y-%m-%d', tz=8, ut=True), '%y-%m-%d'), d[1]) for d in aadays] astro = [{'date': d[0], 'astro': d[1], 'month': None} for d in aadays] return astro