• 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) #第二个图,代表第一百天的状态

  • 相关阅读:
    Django的中间件
    电脑端调手机端
    计算两个时间戳之间相差的时间
    去除html标签 php
    Tp5 一次修改多个数据update
    ThinkPhp5.0 引入全局自定义函数global
    layer 使用教程
    phpstrom 汉化
    phpcms 电脑手机合并
    vue 中 v-model
  • 原文地址:https://www.cnblogs.com/eleni/p/10942457.html
Copyright © 2020-2023  润新知