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. 【Linux命令】mysql数据库常用操作命令

    #数据库操作: #建立数据库 create database data_name #删除数据库 drop database data_name #查看: show databases; #表操作: # ...

  2. BZOJ 1613: [Usaco2007 Jan]Running贝茜的晨练计划( dp)

    dp乱搞即可...( 我就是这样 A 的.. 后来想改快一点..然后就WA了...不理了 ------------------------------------------------------- ...

  3. 大神的vim配置

    大神的vim配置,O(∩_∩)O spf13-vim : Steve Francia's Vim Distribution __ _ _____ _ ___ _ __ / _/ |___ / __ _ ...

  4. QtInternal 之 高效使用QString(使用QLatin1String,QStringRef,QStringBuilder,QStringMatcher等相关类)

    注意:本文翻译自  http://developer.qt.nokia.com   中的  UsingQStringEffectively   ,中文译文见  简体中文版 ,如果你对翻译wiki感兴趣 ...

  5. SiteMesh

    1.导入对SiteMesh.jar的依赖 <dependency>      <groupId>org.sitemesh</groupId>      <ar ...

  6. 安装好maven后,在cmd中运行mvn报一下的错误

    当然报错,你这个路径下并没有pom.xml文件.你可以运行这个命令: mvn -version.

  7. 告别IE给我们的web开发带来的困扰(使用chrome frame v8引擎)

    茶爸爸个人微信:benyzhous,公众号:cha-baba欢迎骚扰 由于客户所有机器必须使用IE6浏览器,导致我们在开发项目过程中遇到非常多的样式与性能问题,在偶然的一次使用360软件管家搜索chr ...

  8. HDU 2227 Find the nondecreasing subsequences (线段树)

    Find the nondecreasing subsequences Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/3 ...

  9. Windows SDK笔记(经典--一定要看)

    Windows SDK笔记(一):Windows程序基本结构 一.概述 Windows程序具有相对固定的结构,对编写者而言,不需要书写整个过程,大部分过程由系统完成.程序中只要按一定的格式填写系统留给 ...

  10. 2015暑假acm短训小结

    时间很快,短训已经结束,短短20天,心里有一些思绪想要记下. 收获: 从最近发的随笔中可以看出,做得最多的是搜索——Dfs,Bfs.对于搜索,如何描述状态,如何压缩状态,如何决定下一个结点,是否可以剪 ...