zoukankan      html  css  js  c++  java
  • biological clock--class

    '''
    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


    class biological:
      def __init__(self,birth_day=datetime.date.today()):
        self.birthday=birth_day
        self.span=0
        self.age=0

      def dtime(self,date2=datetime.date.today()):
        self.span=(date2-self.birthday).days

      def colour(self):
        emotion=self.span % 28
        energy=self.span % 23
        intelligence=self.span % 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()

      def count_age(self):
        date2=datetime.date.today()
        days=(date2-self.birthday).days
        self.age=int(days/365)

    def test():
    b=biological() #类的实例化
    birthdate=datetime.date(1997,7,17)
    b.birthday=birthdate
    b.dtime()
    b.colour()

    test()

    #birthdate=datetime.date(2019,6,1)
    #bdate=birthdate+datetime.timedelta(days=100)
    #b.dtime(bdate)
    #b.colour()
    #colour(d2) #第二个图,代表第一百天的状态
    #b.count_age()
    #print(b.age)

  • 相关阅读:
    simpleDateFormat日期格式转换
    repo总结
    jrtplib使用注意事项
    iOS Crash获取闪回日志和上传server
    Android自己定义组件系列【5】——高级实践(1)
    TimesTen更改CacheGroup管理用户ORACLE结束和TT结束password【TimesTen操作和维修基地】
    Cordova探险系列(三)
    libpomelo 增加编译静态库cocos2d-x xcode 工程
    flex4 一些项目使用的技术
    2015华为德州扑克入境摘要——软体project
  • 原文地址:https://www.cnblogs.com/eleni/p/10944105.html
Copyright © 2011-2022 走看看