CFITSIO.jl

GitHubBuild StatusPkgEvalCoverage

This module provides an interface familiar to users of the CFITSIO C library. It can be used with

using CFITSIO

The functions exported by this module operate on FITSFile objects, which is a thin wrapper around a pointer to a CFITSIO fitsfile. For the most part, the functions are thin wrappers around the CFITSIO routines of the same names. Typically, they:

  • Convert from Julia types to C types as necessary.
  • Check the returned status value and raise an appropriate exception if non-zero.

The functionality is described in the various sections.

Note

For a higher-level interface, consider using FITSIO.jl.

Quick start

julia> fname = tempname() * ".fits";
julia> f = fits_create_file(fname);
julia> A = ones(2,2)2×2 Matrix{Float64}: 1.0 1.0 1.0 1.0
julia> fits_create_img(f, A)
julia> fits_get_hdu_type(f):image_hdu
julia> fits_write_pix(f, A)
julia> B = similar(A);
julia> fits_read_pix(f, B);
julia> B2×2 Matrix{Float64}: 1.0 1.0 1.0 1.0
julia> fits_read_key_str(f, "NAXIS")("2", "number of data axes")
julia> fits_create_binary_tbl(f, 0, [("COUNT", "J", "counts"), ("ENERGY", "D", "energy")], "Spectrum")
julia> fits_write_col(f, 1, 1, 1, [2, 10, 5])
julia> fits_write_col(f, 2, 1, 1, [10.0, 15.0, 20.0])
julia> counts, energy = zeros(Int,3), zeros(Float64,3)([0, 0, 0], [0.0, 0.0, 0.0])
julia> fits_read_col(f, 1, 1, 1, counts)3-element Vector{Int64}: 2 10 5
julia> fits_read_col(f, 1, 1, 1, energy)3-element Vector{Float64}: 2.0 10.0 5.0
julia> counts, energy([2, 10, 5], [2.0, 10.0, 5.0])
julia> fits_close_file(f)