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