zoukankan      html  css  js  c++  java
  • Intermezzo: A Data Analysis Session

    # -*- coding: utf-8 -*-
    """
    Created on Wed Nov 05 15:18:17 2014
    
    @author: dell
    """
    
    import pandas as pd
    import numpy as np
    import datetime
    import matplotlib.pyplot as plt
    import matplotlib.dates as mdates
    
    if __name__ == '__main__':
        df = pd.read_table('carbon.dioxide.txt', header = None)
        data = np.array(list(df[0].values))
        
        fig = plt.figure()
        ax = fig.add_subplot(331)
        ax.plot(data)
        
        x = np.linspace(1, len(data), len(data))
        ax1 = fig.add_subplot(332)
        ax1.plot(data-315)
        ax1.plot(((x/350)**2)*35,'--')
        
        ax3 = fig.add_subplot(333)
        ax3.plot(data-315)
        ax3.plot(((x/350)**1.35)*35, '--')
        
        ax4 = fig.add_subplot(334)
        myres = data-315-((x/350)**1.35)*35
        ax4.plot(myres)
    
        ax1 = fig.add_subplot(335)
        from scipy.interpolate import UnivariateSpline
        #xs = np.linspace(1, len(data), len(data)*100)
        xs = np.linspace(1, len(data), 1000)
        s = UnivariateSpline(x, myres)
        ys = s(xs)
        ax1.plot(xs, ys)
        ax1.plot(myres)
        
        ax2 = fig.add_subplot(336)
        ax2.plot(myres)
        ax2.plot(3*np.sin(2*np.pi*x/12))
        
        ax3 = fig.add_subplot(337)
        myres1 = myres - 3*np.sin(2*np.pi*x/12) 
        #myres2 = data - 315-35*(x/350)**1.35 - 3*np.sin(np.pi*2*x/12)
        s1 = UnivariateSpline(x, myres1, s = 850)
        ys1 = s1(xs)
        ax3.plot(xs, ys1)
        ax3.plot(myres1)
        ax3.axhline(y = 1, ls = '--')
        ax3.axhline(y = -1, ls = ':')
        
        ax8 = fig.add_subplot(338)
        myfun = 315 + (x/350)**1.35*35 + 3*np.sin(2*np.pi*x/12) + 0.75*np.sin(2*np.pi*x/6) + 0.1
        ax8.plot(myfun, ls=':')
        ax8.plot(data)
        
        ax9 = fig.add_subplot(339)
        x = np.linspace(1, 800, 800)
        myfun = 315 + (x/350)**1.35*35 + 3*np.sin(2*np.pi*x/12) + 0.75*np.sin(2*np.pi*x/6) + 0.1
        ax9.plot(myfun, ls=':')
        ax9.plot(data)
        ax9.set_xlim(1, 800)
        
        plt.show()

    https://files.cnblogs.com/hluo/carbon.dioxide.rar 

    样条平滑函数还没有弄明白回事。

  • 相关阅读:
    我的操作系统复习——进程(下)
    我的操作系统复习——进程(上)
    我的操作系统复习——操作系统概述
    GO语言总结(5)——类型转换和类型断言
    GO语言总结(4)——映射(Map)
    GO语言总结(3)——数组和切片
    GO语言总结(2)——基本类型
    msl字符串截取与拆分
    ES中模糊查询的实现
    mysql纯数字的字符串排序
  • 原文地址:https://www.cnblogs.com/hluo/p/4078185.html
Copyright © 2011-2022 走看看