zoukankan      html  css  js  c++  java
  • pyfits 读取bintable

    import pyfits as pf
    import numpy as np
    import math
    import pandas as pd
    import matplotlib.pyplot as plt
    from mpl_toolkits.mplot3d import Axes3D
    from matplotlib import cm
    from matplotlib.ticker import LinearLocator, FormatStrFormatter
    
    #from matplotlib.patches import Ellipse
    hdulist = pf.open('ID301_0001.FITS')
    image = hdulist[0].data
    header = hdulist[0].header
    col = hdulist[1].columns
    print col
    print col.names
    
    table = hdulist[1].data
    print hdulist.info()
    print type(table)
    nt = np.array(table)
    print nt.shape
    tnt = nt.T
    print  tnt
    b = np.array([0,1,0,0,0,0,0])
    print (nt[b==1])
    a0 = table.field(0)
    a1 = table.field(1)
    a2 = table.field(2)
    a3 = table.field(3)
    a4 = table.field(4)
    a5 = table.field(5)
    a6 = table.field(6)
    print ( a0)
    print ( a1)
    print ( a2)
    print ( a3)
    print ( a4)
    
    print ( a5)
    print ( a6)
    table2 = table[a1==0]
    acd = np.zeros(18)
    print acd
    b0 = table2.field(0)
    b1 = table2.field(1)
    b2 = table2.field(2)
    b3 = table2.field(3)
    b4 = table2.field(4)
    b5 = table2.field(5)
    b6 = table2.field(6)
    ii =0
    print b4[0].sum()
    while ii<(table2.shape)[0]:
        for j in range(0,18):
            if b4[ii][j] ==True:
                acd[j]=acd[j]+1
    #           print acd[j]
        ii= ii+1
    
    
    print acd
    
    print b4[0].sum()

    table读取以后,用field来获得各列数据,为numpy里的array格式。

  • 相关阅读:
    Java编程思想小笔记
    JAVA中的访问权限
    重写equals、hashCode
    JAVA核心技术I之接口与内部类
    JAVA核心技术I之继承
    javascript日志-array数组去重
    vue练习项目
    vue日志-axios跨域获取豆瓣api
    在vue-cli中安装scss,且可以全局引入scss的步骤
    css参考手册
  • 原文地址:https://www.cnblogs.com/heshangaichirou/p/5319378.html
Copyright © 2011-2022 走看看