"Fossies" - the Fresh Open Source Software Archive

Member "gnuastro-0.8/lib/gnuastro/fits.h" (15 Aug 2018, 8797 Bytes) of package /linux/privat/gnuastro-0.8.tar.lz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "fits.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 0.7_vs_0.8.

    1 /*********************************************************************
    2 Functions to convert a FITS array to a C array and vice versa.
    3 This is part of GNU Astronomy Utilities (Gnuastro) package.
    4 
    5 Original author:
    6      Mohammad Akhlaghi <mohammad@akhlaghi.org>
    7 Contributing author(s):
    8 Copyright (C) 2015-2018, Free Software Foundation, Inc.
    9 
   10 Gnuastro is free software: you can redistribute it and/or modify it
   11 under the terms of the GNU General Public License as published by the
   12 Free Software Foundation, either version 3 of the License, or (at your
   13 option) any later version.
   14 
   15 Gnuastro is distributed in the hope that it will be useful, but
   16 WITHOUT ANY WARRANTY; without even the implied warranty of
   17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   18 General Public License for more details.
   19 
   20 You should have received a copy of the GNU General Public License
   21 along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
   22 **********************************************************************/
   23 #ifndef __GAL_FITS_H__
   24 #define __GAL_FITS_H__
   25 
   26 /* When we are within Gnuastro's building process, `IN_GNUASTRO_BUILD' is
   27    defined. In the build process, installation information (in particular
   28    `GAL_CONFIG_HAVE_WCSLIB_VERION' that we need in `fits.c') is kept in
   29    `config.h'. When building a user's programs, this information is kept in
   30    `gnuastro/config.h'. Note that all `.c' files must start with the
   31    inclusion of `config.h' and that `gnuastro/config.h' is only created at
   32    installation time (not present during the building of Gnuastro).*/
   33 #ifndef IN_GNUASTRO_BUILD
   34 #include <gnuastro/config.h>
   35 #endif
   36 
   37 /* Include other headers if necessary here. Note that other header files
   38    must be included before the C++ preparations below */
   39 #include <math.h>
   40 #include <float.h>
   41 
   42 #include <fitsio.h>
   43 #include <wcslib/wcs.h>
   44 #include <wcslib/wcshdr.h>
   45 #include <wcslib/wcsfix.h>
   46 
   47 #include <gnuastro/list.h>
   48 #include <gnuastro/data.h>
   49 #include <gnuastro/table.h>
   50 
   51 /* C++ Preparations */
   52 #undef __BEGIN_C_DECLS
   53 #undef __END_C_DECLS
   54 #ifdef __cplusplus
   55 # define __BEGIN_C_DECLS extern "C" {
   56 # define __END_C_DECLS }
   57 #else
   58 # define __BEGIN_C_DECLS                /* empty */
   59 # define __END_C_DECLS                  /* empty */
   60 #endif
   61 /* End of C++ preparations */
   62 
   63 
   64 
   65 /* Actual header contants (the above were for the Pre-processor). */
   66 __BEGIN_C_DECLS  /* From C++ preparations */
   67 
   68 
   69 
   70 /* Macros. */
   71 #define GAL_FITS_MAX_NDIM 999
   72 #define GAL_FITS_KEY_TITLE_START "                      / "
   73 
   74 
   75 
   76 /* To create a linked list of headers. */
   77 typedef struct gal_fits_list_key_t
   78 {
   79   int                        kfree;   /* ==1, free keyword name.   */
   80   int                        vfree;   /* ==1, free keyword value.  */
   81   int                        cfree;   /* ==1, free comment.        */
   82   uint8_t                     type;   /* Keyword value type.       */
   83   char                    *keyname;   /* Keyword Name.             */
   84   void                      *value;   /* Keyword value.            */
   85   char                    *comment;   /* Keyword comment.          */
   86   char                       *unit;   /* Keyword unit.             */
   87   struct gal_fits_list_key_t *next;   /* Pointer next keyword.     */
   88 } gal_fits_list_key_t;
   89 
   90 
   91 
   92 
   93 
   94 /*************************************************************
   95  **************        Reporting errors:       ***************
   96  *************************************************************/
   97 void
   98 gal_fits_io_error(int status, char *message);
   99 
  100 
  101 
  102 
  103 
  104 /*************************************************************
  105  **************           FITS names           ***************
  106  *************************************************************/
  107 int
  108 gal_fits_name_is_fits(char *name);
  109 
  110 int
  111 gal_fits_suffix_is_fits(char *suffix);
  112 
  113 char *
  114 gal_fits_name_save_as_string(char *filename, char *hdu);
  115 
  116 
  117 
  118 /*************************************************************
  119  **************           Type codes           ***************
  120  *************************************************************/
  121 uint8_t
  122 gal_fits_bitpix_to_type(int bitpix);
  123 
  124 int
  125 gal_fits_type_to_bitpix(uint8_t type);
  126 
  127 char
  128 gal_fits_type_to_bin_tform(uint8_t type);
  129 
  130 int
  131 gal_fits_type_to_datatype(uint8_t type);
  132 
  133 uint8_t
  134 gal_fits_datatype_to_type(int datatype, int is_table_column);
  135 
  136 
  137 
  138 
  139 /**************************************************************/
  140 /**********                  HDU                   ************/
  141 /**************************************************************/
  142 fitsfile *
  143 gal_fits_open_to_write(char *filename);
  144 
  145 size_t
  146 gal_fits_hdu_num(char *filename);
  147 
  148 int
  149 gal_fits_hdu_format(char *filename, char *hdu);
  150 
  151 fitsfile *
  152 gal_fits_hdu_open(char *filename, char *hdu, int iomode);
  153 
  154 fitsfile *
  155 gal_fits_hdu_open_format(char *filename, char *hdu, int img0_tab1);
  156 
  157 
  158 
  159 
  160 /**************************************************************/
  161 /**********            Header keywords             ************/
  162 /**************************************************************/
  163 void *
  164 gal_fits_key_img_blank(uint8_t type);
  165 
  166 void
  167 gal_fits_key_clean_str_value(char *string);
  168 
  169 void
  170 gal_fits_key_read_from_ptr(fitsfile *fptr, gal_data_t *keysll,
  171                            int readcomment, int readunit);
  172 
  173 void
  174 gal_fits_key_read(char *filename, char *hdu, gal_data_t *keysll,
  175                   int readcomment, int readunit);
  176 
  177 void
  178 gal_fits_key_list_add(gal_fits_list_key_t **list, uint8_t type,
  179                       char *keyname, int kfree, void *value, int vfree,
  180                       char *comment, int cfree, char *unit);
  181 
  182 void
  183 gal_fits_key_list_add_end(gal_fits_list_key_t **list, uint8_t type,
  184                           char *keyname, int kfree, void *value, int vfree,
  185                           char *comment, int cfree, char *unit);
  186 
  187 void
  188 gal_fits_key_list_reverse(gal_fits_list_key_t **list);
  189 
  190 void
  191 gal_fits_key_write_title_in_ptr(char *title, fitsfile *fptr);
  192 
  193 void
  194 gal_fits_key_write_filename(char *keynamebase, char *filename,
  195                             gal_fits_list_key_t **list, int top1end0);
  196 
  197 void
  198 gal_fits_key_write_wcsstr(fitsfile *fptr, char *wcsstr, int nkeyrec);
  199 
  200 void
  201 gal_fits_key_write(gal_fits_list_key_t **keylist, char *title,
  202                    char *filename, char *hdu);
  203 
  204 void
  205 gal_fits_key_write_in_ptr(gal_fits_list_key_t **keylist, fitsfile *fptr);
  206 
  207 void
  208 gal_fits_key_write_version(gal_fits_list_key_t **keylist, char *title,
  209                            char *filename, char *hdu);
  210 
  211 void
  212 gal_fits_key_write_version_in_ptr(gal_fits_list_key_t **keylist, char *title,
  213                                   fitsfile *fptr);
  214 
  215 void
  216 gal_fits_key_write_config(gal_fits_list_key_t **keylist, char *title,
  217                           char *extname, char *filename, char *hdu);
  218 
  219 
  220 
  221 
  222 
  223 /*************************************************************
  224  ******************     Array functions      *****************
  225  *************************************************************/
  226 void
  227 gal_fits_img_info(fitsfile *fptr, int *type, size_t *ndim, size_t **dsize,
  228                   char **name, char **unit);
  229 
  230 gal_data_t *
  231 gal_fits_img_read(char *filename, char *hdu, size_t minmapsize);
  232 
  233 gal_data_t *
  234 gal_fits_img_read_to_type(char *inputname, char *hdu, uint8_t type,
  235                           size_t minmapsize);
  236 
  237 gal_data_t *
  238 gal_fits_img_read_kernel(char *filename, char *hdu, size_t minmapsize);
  239 
  240 fitsfile *
  241 gal_fits_img_write_to_ptr(gal_data_t *data, char *filename);
  242 
  243 void
  244 gal_fits_img_write(gal_data_t *data, char *filename,
  245                    gal_fits_list_key_t *headers, char *program_string);
  246 
  247 void
  248 gal_fits_img_write_to_type(gal_data_t *data, char *filename,
  249                            gal_fits_list_key_t *headers,
  250                            char *program_string, int type);
  251 
  252 void
  253 gal_fits_img_write_corr_wcs_str(gal_data_t *input, char *filename,
  254                                 char *wcsheader, int nkeyrec, double *crpix,
  255                                 gal_fits_list_key_t *headers,
  256                                 char *program_string);
  257 
  258 
  259 
  260 
  261 
  262 /**************************************************************/
  263 /**********                  Table                 ************/
  264 /**************************************************************/
  265 void
  266 gal_fits_tab_size(fitsfile *fitsptr, size_t *nrows, size_t *ncols);
  267 
  268 int
  269 gal_fits_tab_format(fitsfile *fptr);
  270 
  271 gal_data_t *
  272 gal_fits_tab_info(char *filename, char *hdu, size_t *numcols,
  273                   size_t *numrows, int *tableformat);
  274 
  275 gal_data_t *
  276 gal_fits_tab_read(char *filename, char *hdu, size_t numrows,
  277                   gal_data_t *colinfo, gal_list_sizet_t *indexll,
  278                   size_t minmapsize);
  279 
  280 void
  281 gal_fits_tab_write(gal_data_t *cols, gal_list_str_t *comments,
  282                    int tableformat, char *filename, char *extname);
  283 
  284 
  285 
  286 __END_C_DECLS    /* From C++ preparations */
  287 
  288 #endif           /* __GAL_FITS_H__ */