Image HDU Routines

CFITSIO.fits_create_imgFunction
fits_create_img(f::FITSFile, T::Type, naxes::Vector{<:Integer})

Create a new primary array or IMAGE extension with the specified data type T and size naxes.

source
fits_create_img(f::FITSFile, A::AbstractArray)

Create a new primary array or IMAGE extension with the element type and size of A, that is capable of storing the entire array A.

source
CFITSIO.fits_insert_imgFunction
fits_insert_img(f::FITSFile, T::Type,
                naxes::Union{Vector{<:Integer}, Tuple{Vararg{Integer}}}; prepend_primary::Bool = false)

Insert a new image extension immediately following the current HDU (CHDU), or insert a new primary array at the beginning of the file.

A new primary array may be inserted at the beginning of the FITS file by calling fits_insert_img with prepend_primary set to true. In this case, the existing primary HDU is converted to an image extension, and the new primary array will become the CHDU.

The inserted array has an eltype T and size naxes.

fits_insert_img(f::FITSFile, a::AbstractArray{<:Real}; prepend_primary::Bool = false)

Insert a new image HDU with an element type of eltype(a) and a size of size(a) that is capable of storing the array a. The flag prepend_primary may be specified to insert a new primary array at the beginning of the FITS file.

source
CFITSIO.fits_write_pixFunction
fits_write_pix(f::FITSFile,
               fpixel::Union{Vector{<:Integer}, Tuple{Vararg{Integer}}},
               nelements::Integer, data::StridedArray)

Write nelements pixels from data into the FITS file starting from the pixel fpixel.

Note

The HDU must have been created previously, and its size must match the number of elements being written.

Note

data needs to be stored contiguously in memory.

See also: fits_write_pixnull

source
fits_write_pix(f::FITSFile, data::StridedArray)

Write the entire array data into the FITS file.

Note

The HDU must have been created previously, and its size must match the number of elements being written.

Note

data needs to be stored contiguously in memory.

See also: fits_write_pixnull, fits_write_subset

source
CFITSIO.fits_write_pixnullFunction
fits_write_pixnull(f::FITSFile,
                   fpixel::Union{Vector{<:Integer}, Tuple{Vararg{Integer}}},
                   nelements::Integer, data::StridedArray, nulval)

Write nelements pixels from data into the FITS file starting from the pixel fpixel. The argument nulval specifies the values that are to be considered as "null values", and replaced by appropriate numbers corresponding to the element type of data.

Note

The HDU must have been created previously, and its size must match the number of elements being written.

Note

data needs to be stored contiguously in memory.

See also: fits_write_pix

source
fits_write_pixnull(f::FITSFile, data::StridedArray, nulval)

Write the entire array data into the FITS file. The argument nulval specifies the values that are to be considered as "null values", and replaced by appropriate numbers corresponding to the element type of data.

Note

data needs to be stored contiguously in memory.

See also: fits_write_pix

source
CFITSIO.fits_write_subsetFunction
fits_write_subset(f::FITSFile,
                  fpixel::V, lpixel::V,
                  data::StridedArray) where {V<:Union{Vector{<:Integer}, Tuple{Vararg{Integer}}}}

Write a rectangular section of the FITS image. The number of pixels to be written will be computed from the first and last pixels (specified as the fpixel and lpixel arguments respectively).

Note

The section to be written out must be contiguous in memory, so all the dimensions aside from the last one must span the entire axis range. The arguments fpixel and lpixel must account for this.

See also: fits_write_pix

source
CFITSIO.fits_read_pixFunction
fits_read_pix(f::FITSFile,
              fpixel::NTuple{Vector{<:Integer}, Tuple{Vararg{Integer}}},
              nelements::Integer, [nulval], data::StridedArray)

Read nelements pixels from the FITS file into data starting from the pixel fpixel. If the optional argument nulval is specified and is non-zero, any null value present in the array will be replaced by it.

Note

data needs to be stored contiguously in memory.

See also: fits_read_pixnull, fits_read_subset

source
fits_read_pix(f::FITSFile, data::StridedArray, [nulval])

Read length(data) pixels from the FITS file into data starting from the first pixel. The optional argument nulval, if specified and non-zero, is used to replace any null value present in the array.

Note

data needs to be stored contiguously in memory.

See also: fits_read_pixnull

source
CFITSIO.fits_read_pixnullFunction
fits_read_pixnull(f::FITSFile,
                  fpixel::Union{Vector{<:Integer}, Tuple{Vararg{Integer}}},
                  nelements::Integer, data::StridedArray, nullarray::Array{UInt8})

Read nelements pixels from the FITS file into data starting from the pixel fpixel. At output, the indices of nullarray where data has a corresponding null value are set to 1.

Note

data needs to be stored contiguously in memory.

See also: fits_read_pix

source
fits_read_pixnull(f::FITSFile, data::StridedArray, nullarray::Array{UInt8})

Read length(data) pixels from the FITS file into data starting from the first pixel. At output, the indices of nullarray where data has a corresponding null value are set to 1.

Note

data needs to be stored contiguously in memory.

See also: fits_read_pix

source
CFITSIO.fits_read_subsetFunction
fits_read_subset(f::FITSFile,
                 fpixel::V, lpixel::V, inc::V,
                 [nulval],
                 data::StridedArray) where {V<:Union{Vector{<:Integer}, Tuple{Vararg{Integer}}}}

Read a rectangular section of the FITS image. The number of pixels to be read will be computed from the first and last pixels (specified as the fpixel and lpixel arguments respectively). The argument inc specifies the step-size in pixels along each dimension.

If the optional argument nulval is specified and is non-zero, null values in data will be replaced by it.

Note

data needs to be stored contiguously in memory, and will be populated contiguously with the pixels that are read in.

See also: fits_read_pix

source
CFITSIO.fits_read_imghdrFunction
fits_read_imghdr(f::FITSFile, maxdim::Integer = 99)

Read the header of an image HDU, where maxdim represents the maximum number of dimensions to read. By default, maxdim == 99 will read the size along every dimension of the image. The function returns the values of SIMPLE::Bool, BITPIX::Int, NAXIS::Int, NAXES::Vector{Int}, PCOUNT::Int, GCOUNT::Int, and EXTEND::Bool. The length of NAXES is set equal to min(NAXIS, maxdim).

The BITPIX value indicates the data type of the image, and it may be converted to a Julia type using the type_from_bitpix function.

Note

PCOUNT is typically 0 for image HDUs, and GCOUNT is typically 1 for modern files.

source
CFITSIO.fits_copy_image_sectionFunction
fits_copy_image_section(fin::FITSFile, fout::FITSFile, section::String)

Copy a rectangular section of an image from fin and write it to a new FITS primary image or image extension in fout. The section specifier is described on the CFITSIO website.

source
CFITSIO.fits_write_null_imgFunction
fits_write_null_img(f::FITSFile, firstelem::Integer, nelements::Integer)

Set a stretch of elements to the appropriate null value, starting from the pixel number firstelem and extending over nelements pixels.

source
CFITSIO.fits_resize_imgFunction
fits_resize_img(f::FITSFile, T::Type, naxis::Integer,
                sz::Union{Vector{<:Integer}, Tuple{Vararg{Integer}}})

Modify the size, dimensions and optionally the element type of the image in f. The new image will have an element type T, be a naxis-dimensional image with size sz. If the new image is larger than the existing one, it will be zero-padded at the end. If the new image is smaller, existing image data will be truncated.

Note

This method reinterprets the data instead of coercing the elements.

Example

julia> f = fits_clobber_file(tempname());

julia> a = [1 2; 3 4];

julia> fits_create_img(f, a);

julia> fits_write_pix(f, a);

julia> fits_get_img_size(f)
2-element Vector{Int64}:
 2
 2

julia> fits_resize_img(f, [3,3]);

julia> fits_get_img_size(f)
2-element Vector{Int64}:
 3
 3

julia> b = similar(a, (3,3));

julia> fits_read_pix(f, b); b
3×3 Matrix{Int64}:
 1  4  0
 3  0  0
 2  0  0

julia> fits_resize_img(f, [4]);

julia> b = similar(a, (4,));

julia> fits_read_pix(f, b); b
4-element Vector{Int64}:
 1
 3
 2
 4
source
fits_resize_img(f::FITSFile, sz::Union{Vector{<:Integer}, Tuple{Vararg{Integer}}})

Resize the image to the new size sz. The element type is preserved, and the number of dimensions is set equal to length(sz).

source
fits_resize_img(f::FITSFile, T::Type)

Change the element type of the image to T, leaving the size unchanged.

source