github.com/astrogo/fitsio@v0.3.0/hdu.go (about) 1 // Copyright 2015 The astrogo Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package fitsio 6 7 import ( 8 "fmt" 9 ) 10 11 // HDUType is the type of a Header-Data Unit 12 type HDUType int 13 14 const ( 15 IMAGE_HDU HDUType = iota // Primary Array or IMAGE HDU 16 ASCII_TBL // ASCII table HDU 17 BINARY_TBL // Binary table HDU 18 ANY_HDU // matches any HDU type 19 ) 20 21 func (htype HDUType) String() string { 22 switch htype { 23 case IMAGE_HDU: 24 return "IMAGE" 25 case ASCII_TBL: 26 return "TABLE" 27 case BINARY_TBL: 28 return "BINTABLE" 29 case ANY_HDU: 30 return "ANY_HDU" 31 default: 32 panic(fmt.Errorf("invalid HDU Type value (%v)", int(htype))) 33 } 34 } 35 36 // HDU is a "Header-Data Unit" block 37 type HDU interface { 38 Close() error 39 Type() HDUType 40 Name() string 41 Version() int 42 Header() *Header 43 } 44 45 // CopyHDU copies the i-th HDU from the src FITS file into the dst one. 46 func CopyHDU(dst, src *File, i int) error { 47 // FIXME(sbinet) 48 // use a more efficient implementation. directly copying raw-bytes 49 // instead of decoding/re-encoding them. 50 hdu := src.HDU(i) 51 return dst.Write(hdu) 52 }