Skip to content

JuliaAstro/FITSIO.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FITSIO.jl

Flexible Image Transport System (FITS) support for Julia

Build Status PkgEval codecov

Stable Dev License

Note: The Libcfitsio submodule has been moved to CFITSIO.jl and will be deprecated in a future release.

Usage

For more in-depth usage and examples, see the documentation

julia> using FITSIO

julia> f = FITS("file.fits")
File: file.fits
Mode: "w" (read-write)
HDUs: Num  Name  Type
      1          Image
      2          Table

julia> f[1]
File: file.fits
HDU: 1
Type: Image
Datatype: Float64
Datasize: (800, 800)

# read an image from disk
julia> data = read(f[1]);

# read just a subset of image
julia> data = read(f[1], :, 790:end);

# Get info about binary table
julia> f[2]
File: file.fits
HDU: 2
Type: Table
Rows: 20
Columns: Name  Size  Type    TFORM
         col2        String  5A
         col1        Int64   1K

# Read a column from the table:
 julia> data = read(f[2], "col1")

# Read the entire header into memory
julia> header = read_header(f[1]);

julia> header["NAXIS1"]  # get value by keyword
800

julia> header[4]  # get value by position
800

# Read single keys into memory
julia> read_key(f[1], 4) # by position
("NAXIS1",800,"length of data axis 1")

julia> read_key(f[1], "NAXIS1") # by keyword
(800,"length of data axis 1")

# write data to file
julia> FITS("new_file.fits", "w") do f
           write(f, data)
       end