Thread: Cfitsio?

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    3

    Cfitsio?

    Hi All,
    I was wondering if anyone had any experience with CFITSIO. I have a FITS file with random grouped data. I would like to extract this data and, among other things, put it into a more accessible format.

    I have been trying to use the command: fits_read_grppar_[flt] (fitsfile *fptr, long group, long firstelem, long nelements, > DTYPE *array, int *status ) without much success. I think I am most confused about the "long group" input. The documentation for this command is fairly scarce, and I do not know if the data is even in a group, or what the default input would be.

    The reference for the above command is here. Thanks,

    Dillon

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Never used it, and the line in the documentation "This routine ... is officially deprecated for future use." worries me.

    Anyway: (1) My hat would like to guess that group gives the number of groups in your data (and that nelements gives the number of elements in each group), and (2) I'm fairly sure that the function call doesn't use the [brackets] (the notation means you need to use one of the list inside the brackets, so your function would be fits_read_grppar_flt). Edit: another possibility is a group identifier number or similar, as well.

    Edit edit: Ooh! It said that the definitions of the parameters are in appendix B, and group is listed there. Looks like I was more right the second time.
    Last edited by tabstop; 06-10-2008 at 07:01 PM.

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    3
    I looked into the "This routine ... is officially deprecated for future use." bit and found that as ominous as that sounds, the routine should be fully functional. The organizations which regulate the FITS standards would like everyone to switch over to storing data in binary tables. Random data groups have been used for some time to store flux data from radio telescope interferometry, and the wording mentioned before actually caused quite a backlash among radio astronomers who worried that the FITSIO would be dropping its random group capabilities.

    Thank you for your input, but I'm afraid that I'm still getting no love. Your suggestions sound very good though, so it might be a mistake on my part, by not understanding what constitutes a "group" in the random data group. Thanks again!

    Edit: Oh! I just saw your edit edit tabstop. That will help immensely!

    Dillon

    Edit Edit: Still no love, even after consulting Appendix B, so any more insights would be greatly appreciated.
    Last edited by dillonr; 06-10-2008 at 08:26 PM. Reason: updates

  4. #4
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by dillonr View Post
    I looked into the "This routine ... is officially deprecated for future use." bit and found that as ominous as that sounds, the routine should be fully functional.
    I would expect it to be functional if it says "future use". The problem will come in a couple of years time, when you try to build this code again with the latest libraries.

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  5. #5
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    I think you'll have to be more specific about your question. Syntax? Semantics? What?

  6. #6
    Registered User
    Join Date
    Jun 2008
    Posts
    3
    Ok, so, I was able to figure it out. Thanks for all your help, tabstop, and thanks for warning me about potential problems QuantumPete. For anyone who is interested, I'll explain what I found out below.

    A FITS file with random group data will have a NAXIS1 parameter of 0, i.e. the primary data unit in the primary Header-Data Unit appears to have no rows. This makes it difficult to view with standard fits viewer software (I never found a program that could, although fv was the best).

    Also in the primary header is the number of groups in the random grouped data. There is a keyword, GROUPS, which tells you how many groups that data is stored in. The "long groups" that I was confused about primarily, is then just the number of any particular group. If you need to extract all of the data contained in the file, you can simply loop through the groups, and read the data into whatever you need. The nelements is then the number of entries in the group, which you can get by multiplying the NAXIS2 and NAXIS3 keywords together. The DTYPE *array is where you are extracting the data into (with DTYPE being a generic keyword which is replaced with whatever data type the group contains). The status variable is an error-check which is set to zero at the beginning of any script utilizing cfitsio. If anything goes wrong with a particular routine, status is then set to a non-zero value, which helps debugging.

    So, using what I found, one simply just supply a pointer to the fits file, and the group number, and the random grouped data will be extracted. Let me know if you want to know anymore, but it kind of resolved to be more of a FITS problem than a problem with C. Thanks again for all of your help though.

    Dillon

Popular pages Recent additions subscribe to a feed