biological clock

'''
this application aimed to cauculate people's biological block about emotional(28), energy(23),intelligence(33)
based on their birth date and the date you wanna analyse, current date will be used without another data applied
'''

import datetime
import math
import numpy as np
import matplotlib.pyplot as plt

def dtime(date1,date2=datetime.date.today()):
  #date1=datetime.date(1996,7,15) #随机填写一个值,有助于python明白你需要的数据类型
  delta=(date2-date1).days
  return(delta)

def colour(delta): #delta是虚参,起什么名字都是可以的,后面调用的时候赋予实际意义
  emotion=delta % 28
  energy=delta % 23
  intelligence=delta % 33
  x_e=2*math.pi*emotion/28
  y_e=math.sin(x_e)
  x_en=2*math.pi*energy/23
  y_en=math.sin(x_en)
  x_inte=2*math.pi*intelligence/33
  y_inte=math.sin(x_inte)

  x=np.arange(0,2*np.pi,0.01)
  y=np.sin(x)

  plt.plot(x,y)
  plt.plot([0,2*math.pi],[0,0])
  plt.scatter(x_e,y_e,c=u'r')
  plt.scatter(x_en,y_en,c=u'g',marker=u'*')
  plt.scatter(x_inte,y_inte,c=u'b',marker=u'^')
  plt.xlabel('o-red:emotion,*-green:energy,^-blue:intelligence')
  plt.show()

birthdate=datetime.date(1997,8,15)
d=dtime(birthdate)
colour(d) #第一个图,代表当天的状态
adate=datetime.date(2019,6,1)
bdate=birthdate+datetime.timedelta(days=100)
d2=dtime(birthdate,bdate)
colour(d2) #第二个图,代表第一百天的状态

 

posted on 2019-05-29 10:56  Eleni  阅读(291)  评论(0编辑  收藏  举报

导航