Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating empty HDUs #19

Open
jbrinchmann opened this issue Dec 26, 2021 · 1 comment
Open

Creating empty HDUs #19

jbrinchmann opened this issue Dec 26, 2021 · 1 comment

Comments

@jbrinchmann
Copy link

Hi,

I need to create FITS files where the first HDU is empty (only containing a header). Given the structure of fits_create_img I did not find a way to do this (please let me know if I overlooked something!). So I extended the code with the following:

function fits_create_empty_hdu(f::FITSFile)

    status = Ref{Cint}(0)
    naxesr = C_NULL
    N = 0
    bitpix = bitpix_from_type(Int16)

    ccall(
         (:ffcrimll, libcfitsio),
         Cint,
         (Ptr{Cvoid}, Cint, Cint, Ptr{Int64}, Ref{Cint}),
         f.ptr,
         bitpix,
         N,
         naxesr,
         status,
     )

    fits_assert_ok(status[])
end

and a small fits_create_img wrapper

function fits_create_img(f::FITSFile, a::Nothing)
    status = fits_create_empty_hdu(f)
end

This appears to work ok but I am not sure whether this is superfluous. If it is useful, I'm happy to create a PR with this, but I must confess I am a tad uncertain about the logic of the runtests.jl so if you have any hints on how to write a test conforming to the code preferences, I'd be happy to hear them!

@thriveth
Copy link

For compatibility with other FITS libraries such as astropy, this would be a really nice feature to have implemented in FITSIO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants