Closed gulabdewangan closed 5 years ago
Actually it does accept a mode optional argument, but it isn't documented. This should do the trick:
fits_open_file("test.fits", 1)
Besides documenting the behavior, do we want to improve the user interface? The values 0 and 1 aren't really self-explanatory.
I suspect you're using the Libcfitsio
interface instead of the higher-level interface because you want to write a single column to an existing table.
The high-level interface could use a method that writes a column to an existing table extension, such as
write(hdu::TableHDU, colname::String, [range,] data)
Then we could just use the main FITSIO interface for this, which already has easier-to-use names and keyword arguments, like f = FITS("test.fits", mode="r+")
for read-write mode.
Actually it does accept a mode optional argument, but it isn't documented. This should do the trick:
fits_open_file("test.fits", 1)
Besides documenting the behavior, do we want to improve the user interface? The values 0 and 1 aren't really self-explanatory.
Thanks, I can write using the optional argument. I guess, just documenting the behavior is good enough as Libcfitsio functions should have the same parameters as the corresponding cfitsio functions.
As suggested by kbarbary, I am not able to write using the high-level interface.
julia> write(f[2], "test",ccdtemp2) ERROR: MethodError: no method matching write(::TableHDU, ::String, ::Array{Float32,1})
ccdtemp2 is a vector with length exactly the same as the number of rows in the table. Am I missing something?
No, you're not missing anything. I was suggesting that we add that method to FITSIO, as it doesn't currently exist.
It seems writemode is not supported with fits_open_file. I get an error message when closing a fits file after writing a column to an existing file as follows.
The function fits_open_file does not accept 0 or 1 for read/write mode as in cfitsio.