diff --git a/test.py b/test.py new file mode 100644 index 00000000..2f49ad13 --- /dev/null +++ b/test.py @@ -0,0 +1,17 @@ +import fitsio +from astropy.table import Table +import numpy as np + +print('Reading X column test') +filename = 'test_x.fits' +data, header = fitsio.read(filename, header=True) +print(data.dtype) + +print('Writing test') +filename = 'test_write.fits' +t = Table([[1], [2], [3]], dtype=[np.bool, np.uint8, np.int8]).as_array() # 'b1', 'u1', 'i1' +fitsio.write(filename, t) + +data, header = fitsio.read(filename, header=True) +print(header) +print(data.dtype) diff --git a/test_x.fits b/test_x.fits new file mode 100644 index 00000000..11e9bff4 --- /dev/null +++ b/test_x.fits @@ -0,0 +1 @@ +SIMPLE = T / file does conform to FITS standard BITPIX = 8 / number of bits per data pixel NAXIS = 0 / number of data axes EXTEND = T / FITS dataset may contain extensions COMMENT FITS (Flexible Image Transport System) format is defined in 'AstronomyCOMMENT and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H HDUNAME = 'PRIMARY ' COMMENT FITS (Flexible Image Transport System) format is defined in 'AstronomyCOMMENT and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H COMMENT COMMENT / Configuration control block--------------------COMMENT ORIGIN = 'ASC ' CREATOR = 'ede ' CHECKSUM= 'NVDdNUAbNUAbNUAb' / HDU checksum updated 2016-02-12T19:50:48 DATASUM = ' ' / Data unit checksum written is ascii COMMENT COMMENT / Time information block-------------------------COMMENT DATE = '2016-01-01T15:53:29' / Date and time of file creation (UTC) DATE-OBS= '2016-01-01T00:33:46' / TT, with clock correction if clockapp DATE-END= '2016-01-01T02:23:06' / TT, with clock correction if clockapp TIMESYS = 'TT ' / Time system CLOCKAPP= T / Clock correction applied TIMEZERO= 0.0000000000000E+00 / Clock correction (if not zero) TIMEUNIT= 's ' / Unit for time measures MJDREF = 5.0814000000000E+04 / Modified Julian Day reference time TSTART = 5.6799562647749E+08 / Data file start time TSTOP = 5.6800218647786E+08 / Data file stop time COMMENT COMMENT / Observation information block------------------COMMENT MISSION = 'AXAF ' / Advanced X-Ray Astrophysics Facility TELESCOP= 'CHANDRA ' / Telescope used INSTRUME= 'OBC ' / Instrument END XTENSION= 'BINTABLE' / binary table extension BITPIX = 8 / 8-bit bytes NAXIS = 2 / 2-dimensional binary table NAXIS1 = 10 / width of table in bytes NAXIS2 = 3 / number of rows in table PCOUNT = 0 / size of special data area GCOUNT = 1 / one data group (required keyword) TFIELDS = 2 / number of fields in each row EXTNAME = 'AXAF_OBC' / name of this binary table extension HDUNAME = 'AXAF_OBC' / ASCDM block name TTYPE1 = 'TIME ' / Time-tag of the data record TFORM1 = '1D ' / format of field TUNIT1 = 's ' TTYPE2 = 'QUALITY ' / Quality Bitarray TFORM2 = '14X ' / format of field COMMENT +------------------+ COMMENT | AXAF FITS File | COMMENT +------------------+ COMMENT ********************************************************* COMMENT > This file is written following certain AXAF-ASC < COMMENT > conventions which are documented in ASC-FITS-2.0 < COMMENT ********************************************************* COMMENT COMMENT / Configuration control block--------------------COMMENT ORIGIN = 'ASC ' CREATOR = 'ede ' ASCDSVER= '10.4.3 ' / ASC-DS processing system revision (release) TLMVER = 'P014 ' / Telemetry revision number (IP&CL) REVISION= 1 / Processing system revision number CHECKSUM= '2CHP29FM2AFM29FM' / HDU checksum updated 2016-02-12T19:50:48 DATASUM = '3795491944' / data unit checksum updated 2016-02-12T19:50:48 CONTENT = 'OBC3ENG ' / What data product LONGSTRN= 'OGIP 1.0' / The HEASARC Long String Convention may be used.COMMENT This FITS file may contain long string keyword values that are COMMENT continued over multiple keywords. The HEASARC convention uses the & COMMENT character at the end of each substring which is then continued COMMENT on the next keyword which has the name CONTINUE. HDUSPEC = 'EDE Telemtry Products: Level 0 to ASC Archive ICD, Revision 1.0' / ICHDUDOC = 'ASC-FITS-2.0: McDowell, Rots: ASC FITS File Designers Guide' HDUVERS = '1.0.0 ' HDUCLASS= 'OGIP ' HDUCLAS1= 'TEMPORALDATA' HDUCLAS2= 'HKP ' COMMENT This FITS file may contain long string keyword values that are COMMENT continued over multiple keywords. This convention uses the '&' COMMENT character at the end of a string which is then continued COMMENT on subsequent keywords whose name = 'CONTINUE' COMMENT COMMENT / Time information block-------------------------COMMENT DATE = '2016-01-01T15:53:29' / Date and time of file creation (UTC) DATE-OBS= '2016-01-01T00:33:46' / TT, with clock correction if clockapp DATE-END= '2016-01-01T02:23:06' / TT, with clock correction if clockapp TIMESYS = 'TT ' / Time system MJDREF = 5.0814000000000E+04 / Modified Julian Day reference time TIMEZERO= 0.0000000000000E+00 / Clock correction (if not zero) TIMEUNIT= 's ' / Unit for time measures BTIMNULL= 5.6355450622592E+08 / Basic Time offset (s) BTIMRATE= 2.5625001447892E-01 / Basic Time clock rate (s/VCDUcount) BTIMDRFT= 4.1666115002670E-18 / Basic Time clock drift (s/VCDUcount^2) BTIMCORR= 0.0000000000000E+00 / Correction applied to basic time rate (s) TIMEREF = 'LOCAL ' / No pathlength corrections TASSIGN = 'SATELLITE' / Spacecraft clock CLOCKAPP= T / Clock correction applied TIERRELA= 1.0000000000000E-09 / Short-term clock stability TIERABSO= 5.0000000000000E-05 / Absolute precision of clock correction TIMVERSN= 'ASC-FITS-2.0' / AXAF FITS design document TSTART = 5.6799562647749E+08 / Data file start time TSTOP = 5.6800218647786E+08 / Data file stop time STARTMJF= 4328 / Major frame ctr value at start of data STARTMNF= 0 / Start minor frame ctr at start of data STARTOBT= 0.0000000000000E+00 / On-Board MET close to STARTMJF and STARTMNF STOPMJF = 4527 / Major frame ctr value at stop of data STOPMNF = 127 / Stop minor frame ctr at end of data TIMEPIXR= 0.0000000000000E+00 / Time stamp reference as bin fraction TIMEDEL = 2.0500000000000E+00 / Time resolution of data (in seconds) COMMENT COMMENT / Observation information block------------------COMMENT MISSION = 'AXAF ' / Advanced X-Ray Astrophysics Facility TELESCOP= 'CHANDRA ' / Telescope used INSTRUME= 'OBC ' / Instrument COMMENT COMMENT / Column format information block----------------COMMENT COMMENT COMMENT / History information block----------------------COMMENT HISTNUM = 37 HISTORY TOOL :engextract ASC00001HISTORY PARM :infile=/dsops/ap/sdp.10/opus/prs_run/tmp//TP_EDE____5679ASC00002HISTORY CONT :46302n144/input/engf567995626N001_xprt0.strip ASC00003HISTORY PARM :template=Unknown ASC00004HISTORY PARM :template=/vobs/ASC_DR_TLM/src/dr/tlm/template_dir/eng_stASC00005HISTORY CONT :rip_file_info.dat@@/main/5 ASC00006HISTORY PARM :template=/vobs/ASC_DR_TLM/src/dr/tlm/template_dir/missioASC00007HISTORY CONT :n_params_5_1.dat@@/main/5 ASC00008HISTORY PARM :template=/vobs/ASC_DR_TLM/src/dr/tlm/template_dir/P014/eASC00009HISTORY CONT :ng_file_info.dat@@/main/1 ASC00010HISTORY PARM :template=/vobs/ASC_DR_TLM/src/dr/tlm/template_dir/P014/eASC00011HISTORY CONT :ng_config_file.dat@@/main/1 ASC00012HISTORY PARM :template=/vobs/ASC_DR_TLM/src/dr/tlm/template_dir/P014/fASC00013HISTORY CONT :2_eng_group_info.dat@@/main/1 ASC00014HISTORY PARM :template=/vobs/ASC_DR_TLM/src/dr/tlm/template_dir/P014/fASC00015HISTORY CONT :2_eng_sampling_info.dat@@/main/1 ASC00016HISTORY PARM :template=/vobs/ASC_DR_TLM/src/dr/tlm/template_dir/P014/fASC00017HISTORY CONT :2_eng_parameter_info.dat@@/main/1 ASC00018HISTORY PARM :template=/vobs/ASC_DR_TLM/src/dr/tlm/template_dir/P014/fASC00019HISTORY CONT :2_eng_dp_info.dat@@/main/1 ASC00020HISTORY PARM :template=/vobs/ASC_DR_TLM/src/dr/tlm/template_dir/commonASC00021HISTORY CONT :_dp_info.dat@@/main/19 ASC00022HISTORY PARM :template=Unknown ASC00023HISTORY PARM :template=/vobs/ASC_DR_TLM/src/dr/tlm/template_dir/P014/fASC00024HISTORY CONT :2_eng_decom_info.dat@@/main/1 ASC00025HISTORY PARM :template=/vobs/ASC_DR_TLM/src/dr/tlm/template_dir/P014/fASC00026HISTORY CONT :2_eng_cal_info.dat@@/main/1 ASC00027HISTORY PARM :template=/vobs/ASC_DR_TLM/src/dr/tlm/template_dir/P014/eASC00028HISTORY CONT :ng_pptable_info.dat@@/main/1 ASC00029DSTYP1 = 'TLM_FMT ' / DM Keyword: Descriptor name. DSVAL1 = '1:8 ' / DM Keyword: Descriptor value. DSFORM1 = 'B ' / DM Keyword: Descriptor datatype. DSTYP2 = 'MJF ' / DM Keyword: Descriptor name. DSVAL2 = '0:131071' / DM Keyword: Descriptor value. DSFORM2 = 'J ' / DM Keyword: Descriptor datatype. DSTYP3 = 'MNF ' / DM Keyword: Descriptor name. DSVAL3 = '0:127 ' / DM Keyword: Descriptor value. DSFORM3 = 'J ' / DM Keyword: Descriptor datatype. DSTYP4 = 'OFLSWSW5' / DM Keyword: Descriptor name. DSVAL4 = '0:1048575' / DM Keyword: Descriptor value. DSFORM4 = 'J ' / DM Keyword: Descriptor datatype. DSTYP5 = 'OFLSWSW6' / DM Keyword: Descriptor name. DSVAL5 = '0:4095 ' / DM Keyword: Descriptor value. DSFORM5 = 'I ' / DM Keyword: Descriptor datatype. DSTYP6 = 'OFLVCDCT' / DM Keyword: Descriptor name. DSVAL6 = ':2147483647' / DM Keyword: Descriptor value. DSFORM6 = 'J ' / DM Keyword: Descriptor datatype. DSTYP7 = '#row ' / DM Keyword: Descriptor name. DSVAL7 = '1:3 ' / DM Keyword: Descriptor value. DSFORM7 = 'J ' / DM Keyword: Descriptor datatype. HISTORY TOOL :dmcopy 2016-02-12T19:50:48 ASC00030HISTORY PARM :infile=obcf567995626N001_3_eng0.fits.gz[#row=1:3][cols tASC00031HISTORY CONT :ime,quality] ASC00032HISTORY PARM :outfile=test_x.fits ASC00033HISTORY PARM :kernel=default ASC00034HISTORY PARM :option= ASC00035HISTORY PARM :verbose=0 ASC00036HISTORY PARM :clobber=no ASC00037END AÀívu=TAÀívvC„»AÀívwIë# \ No newline at end of file