File indexing completed on 2024-12-22 04:17:05
0001 /*************************************************************************** 0002 healpix_tools.h - tools for healpix datasource 0003 ------------------- 0004 begin : Wed June 01 2005 0005 copyright : (C) 2005 Ted Kisner 0006 email : tskisner.public@gmail.com 0007 ***************************************************************************/ 0008 0009 /*************************************************************************** 0010 * * 0011 * This program is free software; you can redistribute it and/or modify * 0012 * it under the terms of the GNU General Public License as published by * 0013 * the Free Software Foundation; either version 2 of the License, or * 0014 * (at your option) any later version. * 0015 * * 0016 ***************************************************************************/ 0017 0018 #ifndef HEALPIX_TOOLS_H 0019 #define HEALPIX_TOOLS_H 0020 0021 #include <math.h> 0022 //#include <libcfitsio0/fitsio.h> 0023 #include <fitsio.h> 0024 #include <datasource.h> 0025 0026 # ifdef HEALPIX_PI 0027 # undef HEALPIX_PI 0028 # endif /* define pi... */ 0029 # define HEALPIX_PI M_PI 0030 0031 # ifdef HEALPIX_INVPI 0032 # undef HEALPIX_INVPI 0033 # endif /* define 1/pi... */ 0034 # define HEALPIX_INVPI M_1_PI 0035 0036 # ifdef HEALPIX_PISQ 0037 # undef HEALPIX_PISQ 0038 # endif /* define pi squared... */ 0039 # define HEALPIX_PISQ 9.86960440108936 0040 0041 # ifdef HEALPIX_HALFPI 0042 # undef HEALPIX_HALFPI 0043 # endif /* define half pi... */ 0044 # define HEALPIX_HALFPI M_PI_2 0045 0046 # ifdef HEALPIX_NSIDE_MAX 0047 # undef HEALPIX_NSIDE_MAX 0048 # endif /* max nside value */ 0049 # define HEALPIX_NSIDE_MAX 8192 0050 0051 # ifdef HEALPIX_STRNL 0052 # undef HEALPIX_STRNL 0053 # endif /* max string length */ 0054 # define HEALPIX_STRNL 200 0055 0056 # ifdef HEALPIX_MIN_EXP 0057 # undef HEALPIX_MIN_EXP 0058 # endif /* smallest IEEE double exponent */ 0059 # define HEALPIX_MIN_EXP -1022 0060 0061 # ifdef HEALPIX_MAX_EXP 0062 # undef HEALPIX_MAX_EXP 0063 # endif /* smallest IEEE double exponent */ 0064 # define HEALPIX_MAX_EXP 1023 0065 0066 /* map parameters */ 0067 0068 # ifdef HEALPIX_RING 0069 # undef HEALPIX_RING 0070 # endif /* ordering = ring */ 0071 # define HEALPIX_RING 0 0072 0073 # ifdef HEALPIX_NEST 0074 # undef HEALPIX_NEST 0075 # endif /* ordering = nested */ 0076 # define HEALPIX_NEST 1 0077 0078 # ifdef HEALPIX_COORD_C 0079 # undef HEALPIX_COORD_C 0080 # endif /* coordsys = celestial/equatorial */ 0081 # define HEALPIX_COORD_C 0 0082 0083 # ifdef HEALPIX_COORD_G 0084 # undef HEALPIX_COORD_G 0085 # endif /* coordsys = galactic */ 0086 # define HEALPIX_COORD_G 1 0087 0088 # ifdef HEALPIX_COORD_E 0089 # undef HEALPIX_COORD_E 0090 # endif /* coordsys = ecliptic */ 0091 # define HEALPIX_COORD_E 2 0092 0093 # ifdef HEALPIX_COORD_O 0094 # undef HEALPIX_COORD_O 0095 # endif /* coordsys = other */ 0096 # define HEALPIX_COORD_O 3 0097 0098 /* projection parameters */ 0099 0100 # ifdef HEALPIX_PROJ_CAR 0101 # undef HEALPIX_PROJ_CAR 0102 # endif /* projection = cartesian */ 0103 # define HEALPIX_PROJ_CAR 0 0104 0105 # ifdef HEALPIX_PROJ_SIN 0106 # undef HEALPIX_PROJ_SIN 0107 # endif /* projection = sinusoidal */ 0108 # define HEALPIX_PROJ_SIN 1 0109 0110 /* FITS parameters */ 0111 0112 # ifdef HEALPIX_FITS_FULL 0113 # undef HEALPIX_FITS_FULL 0114 # endif /* file contains full-sphere map(s) */ 0115 # define HEALPIX_FITS_FULL 0 0116 0117 # ifdef HEALPIX_FITS_CUT 0118 # undef HEALPIX_FITS_CUT 0119 # endif /* file contains cut-sphere map(s) */ 0120 # define HEALPIX_FITS_CUT 1 0121 0122 # ifdef HEALPIX_FITS_MAXCOL 0123 # undef HEALPIX_FITS_MAXCOL 0124 # endif /* maximum number of table columns supported */ 0125 # define HEALPIX_FITS_MAXCOL 50 0126 0127 # ifdef HEALPIX_NULL 0128 # undef HEALPIX_NULL 0129 # endif /* null value for float maps */ 0130 # define HEALPIX_NULL (-1.6375e30) 0131 0132 # ifdef HEALPIX_EPSILON 0133 # undef HEALPIX_EPSILON 0134 # endif /* range around HEALPIX_NULL that is considered equal to NULL */ 0135 # define HEALPIX_EPSILON (0.0001e30) 0136 0137 # ifdef HEALPIX_INT_NULL 0138 # undef HEALPIX_INT_NULL 0139 # endif /* null value for int maps */ 0140 # define HEALPIX_INT_NULL (-2147483646) 0141 0142 typedef struct { /* healpix FITS keys */ 0143 size_t nskeys; 0144 size_t nikeys; 0145 size_t nfkeys; 0146 char **skeynames; 0147 char **skeyvals; 0148 char **skeycoms; 0149 char **ikeynames; 0150 int *ikeyvals; 0151 char **ikeycoms; 0152 char **fkeynames; 0153 float *fkeyvals; 0154 char **fkeycoms; 0155 } healpix_keys; 0156 0157 int healpix_is_dnull(double val); 0158 int healpix_is_fnull(float val); 0159 int healpix_is_inull(int val); 0160 char **healpix_strarr_alloc(size_t nstring); 0161 int healpix_strarr_free(char **array, size_t nstring); 0162 int healpix_nsidecheck(size_t nside); 0163 size_t healpix_nside2npix(size_t nside); 0164 size_t healpix_npix2nside(size_t npix); 0165 size_t healpix_nside2factor(size_t nside); 0166 size_t healpix_factor2nside(size_t factor); 0167 0168 int healpix_xy2pix(size_t x, size_t y, size_t *pix); 0169 int healpix_x2pix(size_t x, size_t *pix); 0170 int healpix_y2pix(size_t y, size_t *pix); 0171 int healpix_pix2xy(size_t pix, size_t *x, size_t *y); 0172 0173 int healpix_nest2xyf (size_t nside, size_t pix, size_t *x, 0174 size_t *y, size_t *face_num); 0175 int healpix_xyf2nest (size_t nside, size_t x, size_t y, 0176 size_t face_num, size_t *pix); 0177 int healpix_ring2xyf (size_t nside, size_t pix, size_t *x, 0178 size_t *y, size_t *face_num); 0179 int healpix_xyf2ring (size_t nside, size_t x, size_t y, 0180 size_t face_num, size_t *pix); 0181 0182 int healpix_nest2ring (size_t nside, size_t pnest, size_t *pring); 0183 int healpix_ring2nest(size_t nside, size_t pring, size_t *pnest); 0184 int healpix_ang2pix_ring(size_t nside, double theta, double phi, 0185 size_t *pix); 0186 int healpix_ang2pix_nest(size_t nside, double theta, double phi, 0187 size_t *pix); 0188 int healpix_pix2ang_ring(size_t nside, size_t pix, double *theta, 0189 double *phi); 0190 int healpix_pix2ang_nest(size_t nside, size_t pix, double *theta, 0191 double *phi); 0192 int healpix_degrade_nest(size_t oldnside, size_t oldpix, size_t newnside, 0193 size_t * newpix); 0194 int healpix_degrade_ring(size_t oldnside, size_t oldpix, size_t newnside, 0195 size_t * newpix); 0196 int healpix_neighbors(size_t nside, int ordering, size_t pixel, long *parray); 0197 0198 int healpix_proj_car(double mintheta, double maxtheta, double minphi, 0199 double maxphi, double xmax, double ymax, double theta, 0200 double phi, double *x, double *y); 0201 int healpix_proj_sin(double mintheta, double maxtheta, double minphi, 0202 double maxphi, double xmax, double ymax, double theta, 0203 double phi, double *x, double *y); 0204 int healpix_proj_rev_car(double mintheta, double maxtheta, double minphi, 0205 double maxphi, double xmax, double ymax, double x, 0206 double y, double *theta, double *phi); 0207 int healpix_proj_rev_sin(double mintheta, double maxtheta, double minphi, 0208 double maxphi, double xmax, double ymax, double x, 0209 double y, double *theta, double *phi); 0210 0211 double healpix_loc_dist(size_t nside, int order, size_t pix1, 0212 size_t pix2); 0213 0214 /* FITS keys operations */ 0215 0216 healpix_keys *healpix_keys_alloc(); 0217 int healpix_keys_free(healpix_keys * keys); 0218 int healpix_keys_clear(healpix_keys * keys); 0219 int healpix_keys_sadd(healpix_keys * keys, char *keyname, char *keyval, 0220 char *keycom); 0221 int healpix_keys_iadd(healpix_keys * keys, char *keyname, int keyval, 0222 char *keycom); 0223 int healpix_keys_fadd(healpix_keys * keys, char *keyname, float keyval, 0224 char *keycom); 0225 int healpix_keys_read(healpix_keys * keys, fitsfile * fp, int *ret); 0226 0227 /* file info */ 0228 0229 int healpix_fits_map_test(char *filename, size_t * nside, int *order, 0230 int *coord, int *type, size_t * nmaps); 0231 0232 int healpix_fits_map_info(char *filename, size_t * nside, int *order, 0233 int *coord, int *type, size_t * nmaps, char *creator, char *extname, char **names, char **units, healpix_keys *keys); 0234 0235 0236 #endif 0237 // vim: ts=2 sw=2 et