C++读取二进制文件,以读取UCAC星表为例
UCAC(USNO CCD Astrograph Catalog)是美国海军天文台出的一个星表,现在最新的是3.0,用一个双面DVD存储,约7.9G,数据格式为二进制。DVD中有Fortran例子读取文件,本文给出一个C++的实现方式,这也是用C++的方式进行二进制文件读取的例子。
二进制数据格式:
num item fmt unit explanation remark ------------------------------------------------------------------------ 1 ra I*4 mas right ascension at epoch J2000.0 (ICRS) (1) 2 spd I*4 mas south pole distance epoch J2000.0 (ICRS) (1) 3 im1 I*2 millimag UCAC fit model magnitude (2) 4 im2 I*2 millimag UCAC aperture magnitude (2) 5 sigmag I*2 millimag UCAC error on magnitude (larger of sc.mod)(3) 6 objt I*1 object type (4) 7 dsf I*1 double star flag (5) 16 8 sigra I*2 mas s.e. at central epoch in RA (*cos Dec) 9 sigdc I*2 mas s.e. at central epoch in Dec 10 na1 I*1 total # of CCD images of this star 11 nu1 I*1 # of CCD images used for this star (6) 12 us1 I*1 # catalogs (epochs) used for proper motions 13 cn1 I*1 total numb. catalogs (epochs) initial match 8 14 cepra I*2 0.01 yr central epoch for mean RA, minus 1900 15 cepdc I*2 0.01 yr central epoch for mean Dec,minus 1900 16 pmrac I*4 0.1 mas/yr proper motion in RA*cos(Dec) 17 pmdc I*4 0.1 mas/yr proper motion in Dec 18 sigpmr I*2 0.1 mas/yr s.e. of pmRA * cos Dec 19 sigpmd I*2 0.1 mas/yr s.e. of pmDec 16 20 id2m I*4 2MASS pts_key star identifier 21 jmag I*2 millimag 2MASS J magnitude 22 hmag I*2 millimag 2MASS H magnitude 23 kmag I*2 millimag 2MASS K_s magnitude 24 icqflg I*1 * 3 2MASS cc_flg*10 + phot.qual.flag (7) 25 e2mpho I*1 * 3 2MASS error photom. (1/100 mag) (8) 16 26 smB I*2 millimag SuperCosmos Bmag 27 smR2 I*2 millimag SC R2mag (9) 28 smI I*2 millimag SC Imag 29 clbl I*1 SC star/galaxy classif./quality flag (10) 30 qfB I*1 SC quality flag Bmag (11) 31 qfR2 I*1 SC quality flag R2mag (11) 32 qfI I*1 SC quality flag Imag (11) 10 33 catflg I*1 * 10 mmf flag for 10 major catalogs matched (12) 34 g1 I*1 Yale SPM object type (g-flag) (13) 35 c1 I*1 Yale SPM input cat. (c-flag) (14) 36 leda I*1 LEDA galaxy match flag (15) 37 x2m I*1 2MASS extend.source flag (16) 38 rn I*4 MPOS star number; identifies HPM stars (17) 18 ------------------------------------------------------------------------
PP3 -優秀的星圖繪製軟件
PP3是一個非常優秀的星圖繪製軟件,它主要用來繪製星座圖,前文介紹的 Mag-7 Star Atlas 就是用這個軟件繪製的,軟件是用CWEB/C++寫成的。分別有Linux和Windows版,該軟件可以生成PDF和EPS兩種目標檔。這樣的好處是,目標文件不是位圖文件,PDF和EPS具有非常好的縮放功能,圖形質量很不錯,就算大幅面印刷也不會影響其圖形的質量。
PP3結果生成需要LaTeX,因此使用這個軟件必須安裝TeX系統。
天文学常数软件开发包 Astroconst 简介
Astroconst 是一个自由软件包,它的内容就是包含有天文学常数表的一些头文件,这些头文件有多个,分别支持C、Fortran、Perl、java、Gnuplot和IDL等。对于程序开发人员、进行天文研究的人员来说,都是一个不错的软件包,可以省去好多功夫。
天文科学软件集 Scisoft
Scisoft 是一个天文软件集,也是欧洲南方天文台(ESO)的一个项目计划,里面的大部分软件都是ESO以为的开发,都由ESO集合到这个套件里。内容有经常使用的数据分析软件(IRAF/STSDAS, ESO-MIDAS 和 IDL等),还有其它一些小软件。
整个套件是一张光盘,内容是一个压缩包,大约500多M,但是解压之后可以达到2G多。目前该套件只支持Unix类操作系统和Mac OS,主要是支持Linux。目前最新版是V5,发布于2003年12月,支持RedHat 9及以后版本。
由于软件包内容丰富,体积庞大,因此建议专门分一个/Scisift分区安装这些文件,分区大小应该不小于3G。安装过程可以参考光盘的INSTALL文件。