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格式。

pyfits 读取bintable的更多相关文章

  1. pyfits fits图像区域选择

    在用pyfits读取fits格式的图像时,得到的数组的结构如下 f=pyfits.open('rr.fits') data1=f[0].data data1数组的第一行,对应于图像的最下面一行,数组第 ...

  2. python pyfits

    原链接:http://blog.sina.com.cn/s/blog_a046022d0101a48h.html,全文复制以备出错.   导入pyfits模块:import pyfits        ...

  3. nodejs进阶(4)—读取图片到页面

    我们先实现从指定路径读取图片然后输出到页面的功能. 先准备一张图片imgs/dog.jpg. file.js里面继续添加readImg方法,在这里注意读写的时候都需要声明'binary'.(file. ...

  4. 一步步开发自己的博客 .NET版(11、Web.config文件的读取和修改)

    Web.config的读取 对于Web.config的读取大家都很属性了.平时我们用得比较多的就是appSettings节点下配置.如: 我们对应的代码是: = ConfigurationManage ...

  5. Asp.Net MVC中使用StreamReader读取“Post body”之应用场景。

    场景:有三个市场(Global.China.USA),对前台传过来的数据有些验证需要细化到每个市场去完成. 所以就出现了基类(Global)和派生类(China.USA) 定义基类(Global)Pe ...

  6. HTML中上传与读取图片或文件(input file)----在路上(25)

    input file相关知识简例 在此介绍的input file相关知识为: 上传照片及文件,其中包括单次上传.批量上传.删除照片.增加照片.读取图片.对上传的图片或文件的判断,比如限制图片的张数.限 ...

  7. Win.ini和注册表的读取写入

    最近在做打包的工作,应用程序的配置信息可以放在注册表文件中,但是在以前的16位操作系统下,配置信息放在Win.ini文件中.下面介绍一下Win.ini文件的读写方法和注册表的编程. 先介绍下Win.i ...

  8. spring无法读取properties文件数据

    只讲述异常点,关于怎么配置文件,这里不做说明.   1. controller中无法读取config.properties文件 controller中注入的@Value配置是从servlet-cont ...

  9. 使用po模式读取豆瓣读书最受关注的书籍,取出标题、评分、评论、题材 按评分从小到大排序并输出到txt文件中

    #coding=utf-8from time import sleepimport unittestfrom selenium import webdriverfrom selenium.webdri ...

随机推荐

  1. IIS 7关闭应用程序池自动回收设置

    在web应用程序中经常有一些任务就需要在Global文件启用一个线程来实现, 那假设我们在自己的ASP.NET应用程序中加入了Quartz.NET框架,并且配置等等都OK了. 这个站点访问量很少,现在 ...

  2. Backbone入门教程

    *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* ...

  3. JavaScript constructor prototyoe

    想加深一下自己对construtcor prototype的印象所以写了这一篇文章 对象的constructor 就是Object 除了通过构造函数创建的对象意外 他的constructor 都是 都 ...

  4. sql 时间和字符串 取到毫秒级

    (select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','')+(Select ri ...

  5. 修改SQL Server登录密码(使用SQL Server身份登录)

    修改登录密码: http://blog.sina.com.cn/s/blog_631611220100iqao.html

  6. gets scanf以及缓冲区域的问题

    1:scanf scanf会忽略开头所有的空格,并以Space Enter Tab 结束输入, 不会舍弃最后的回车符(即回车符会残存在缓冲区域中) 2:getchar getchar以Enter结束, ...

  7. Median of Two Sorted Arrays-分治法

    题目意思很简单将两个有序数组合并之后的中位数找出来.题目要求使用log(m+n)的时间复杂度来做. 虽然言简意赅,但不得不承认这个题目我自己想了好久也没做出来,隐约觉得应该使用寻找第k大数的算法来做, ...

  8. 条款21: 必须返回对象时,不要强行返回对象的reference

    总结: 绝不要返回一个local栈对象的指针或引用:绝不要返回一个被分配的堆对象的引用:绝不要返回一个静态局部对象(为了它,有可能同时需要多个这样的对象的指针或引用). 条款4中给出了“在单线程环境中 ...

  9. eclipse(MyEclipse)插件之aptana安装

    1.在MyEclipse安装目录下创建文件夹, aptana2.在aptana文件夹下创建文件夹eclipse3.将aptana_update_024747.zip中的文件解压缩到aptana\ecl ...

  10. qemu核心机制分析-协程coroutine

    关于协程coroutine前面的文章已经介绍过了,本文总结对qemu中coroutine机制的分析,qemu 协程coroutine基于:setcontext函数族以及函数间跳转函数siglongjm ...