[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] Problems Using the FITSIO Library with a GSL Vector
From: |
Benjamin Winkel |
Subject: |
Re: [Help-gsl] Problems Using the FITSIO Library with a GSL Vector |
Date: |
Sun, 26 Aug 2007 10:28:51 +0200 |
User-agent: |
Thunderbird 2.0.0.6 (X11/20070802) |
Hi,
changing from void to gsl_vector in the fitsio.h is not a good idea. The
fitsio lib uses the the same function for all datatypes. Therefore you
have to provide the correct datatype when calling the function (using
the ...,int datatype,... field). Your gsl_vector is of type double, so
you have to use the cfitsio typedef 'TDOUBLE' - which is correct in your
example. If the datatype within the fits-file is of different type
cfitsio will do a conversion for you. In order to reach that level of
re-usability fitsio does a type conversion from the input void-array to
the desired double/float/int/...-array.
However, the problem with your example is much simpler. Since you did
input the gslvector as a whole, fitsio just write (after casting to
double) the data to the beginning of the allocated memory which happens
to be misaligned from the data-array within the struct:
typedef struct
{
size_t size;
size_t stride;
double * data;
gsl_block * block;
int owner;
} gsl_vector;
So if you change the function call to
fits_read_subset( data , TDOUBLE , fpixel , lpixel , inc , &nulval ,
image->data , &anynul , &status );
it works! (I tested it.) You should be careful by plugging in gsl-vector
into fitsio-routines. If the gslvector has a stride or is a view to
another vector/matrix you can easily get into trouble.
Hope that helps...
Cheers
Benjamin
--
Dipl.-Phys. Benjamin Winkel
Argelander Institute for Astronomy (AIfA)
University of Bonn
Auf dem Hügel 71, D-53121 Bonn, Germany
tel: +49 (0)228 73-3662
address@hidden
http://www.astro.uni-bonn.de/~bwinkel