File: chealpix.h

package info (click to toggle)
chealpix 3.30.0-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,436 kB
  • sloc: sh: 11,550; ansic: 1,175; makefile: 28
file content (167 lines) | stat: -rw-r--r-- 7,407 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/* -----------------------------------------------------------------------------
 *
 *  Copyright (C) 1997-2016 Krzysztof M. Gorski, Eric Hivon, Martin Reinecke,
 *                          Benjamin D. Wandelt, Anthony J. Banday,
 *                          Matthias Bartelmann,
 *                          Reza Ansari & Kenneth M. Ganga
 *
 *
 *  This file is part of HEALPix.
 *
 *  HEALPix is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  HEALPix is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with HEALPix; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 *  For more information about HEALPix see http://healpix.sourceforge.net
 *
 *----------------------------------------------------------------------------*/
/*
 * chealpix.h
 */

#ifndef CHEALPIX_H
#define CHEALPIX_H

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/*! \defgroup chealpix HEALPix C interface
    All angles are in radian, all \a theta values are colatitudes, i.e. counted
    downwards from the North Pole. \a Nside can be any positive number for
    pixelisations in RING scheme; in NEST scheme, they must be powers of 2.
    The maximum \a Nside for the traditional interface is 8192; for the
    64bit interface it is 2^29.
 */
/*! \{ */

/* -------------------- */
/* Constant Definitions */
/* -------------------- */

#ifndef HEALPIX_NULLVAL
#define HEALPIX_NULLVAL (-1.6375e30)
#endif /* HEALPIX_NULLVAL */

/* pixel operations */
/* ---------------- */
/*! Sets \a *ipix to the pixel number in NEST scheme at resolution \a nside,
    which contains the position \a theta, \a phi. */
void ang2pix_nest(long nside, double theta, double phi, long *ipix);
/*! Sets \a *ipix to the pixel number in RING scheme at resolution \a nside,
    which contains the position \a theta, \a phi. */
void ang2pix_ring(long nside, double theta, double phi, long *ipix);

/*! Sets \a theta and \a phi to the angular position of the center of pixel
    \a ipix in NEST scheme at resolution \a nside. */
void pix2ang_nest(long nside, long ipix, double *theta, double *phi);
/*! Sets \a theta and \a phi to the angular position of the center of pixel
    \a ipix in NEST scheme at resolution \a nside. */
void pix2ang_ring(long nside, long ipix, double *theta, double *phi);

/*! Computes the RING pixel index of pixel \a ipnest at resolution \a nside
    and returns it in \a *ipring. On error, \a *ipring is set to -1. */
void nest2ring(long nside, long ipnest, long *ipring);
/*! Computes the NEST pixel index of pixel \a ipring at resolution \a nside
    and returns it in \a *ipring. On error, \a *ipnest is set to -1. */
void ring2nest(long nside, long ipring, long *ipnest);

/*! Returns \a 12*nside*nside. */
long nside2npix(long nside);
/*! Returns \a sqrt(npix/12) if this is an integer number, otherwise \a -1. */
long npix2nside(long npix);

/*! Computes a normalized Cartesian vector pointing in the same direction as
    \a theta, \a phi, and stores it in \a vec. \a vec must point to storage
    sufficient for at least three doubles. */
void ang2vec(double theta, double phi, double *vec);
/*! Computes the angles \a *theta and \a *phi describing the same directions
    as the Cartesian vector \a vec. \a vec need not be normalized. */
void vec2ang(const double *vec, double *theta, double *phi);

/*! Sets \a *ipix to the pixel number in NEST scheme at resolution \a nside,
    which contains the direction described the Cartesian vector \a vec. */
void vec2pix_nest(long nside, const double *vec, long *ipix);
/*! Sets \a *ipix to the pixel number in RING scheme at resolution \a nside,
    which contains the direction described the Cartesian vector \a vec. */
void vec2pix_ring(long nside, const double *vec, long *ipix);

/*! Sets \a vec to the Cartesian vector pointing in the direction of the center
    of pixel \a ipix in NEST scheme at resolution \a nside. */
void pix2vec_nest(long nside, long ipix, double *vec);
/*! Sets \a vec to the Cartesian vector pointing in the direction of the center
    of pixel \a ipix in RING scheme at resolution \a nside. */
void pix2vec_ring(long nside, long ipix, double *vec);

/* operations on Nside values up to 2^29 */

/*! Sets \a *ipix to the pixel number in NEST scheme at resolution \a nside,
    which contains the position \a theta, \a phi. */
void ang2pix_nest64(int64_t nside, double theta, double phi, int64_t *ipix);
/*! Sets \a *ipix to the pixel number in RING scheme at resolution \a nside,
    which contains the position \a theta, \a phi. */
void ang2pix_ring64(int64_t nside, double theta, double phi, int64_t *ipix);

/*! Sets \a theta and \a phi to the angular position of the center of pixel
    \a ipix in NEST scheme at resolution \a nside. */
void pix2ang_nest64(int64_t nside, int64_t ipix, double *theta, double *phi);
/*! Sets \a theta and \a phi to the angular position of the center of pixel
    \a ipix in RING scheme at resolution \a nside. */
void pix2ang_ring64(int64_t nside, int64_t ipix, double *theta, double *phi);

/*! Computes the RING pixel index of pixel \a ipnest at resolution \a nside
    and returns it in \a *ipring. On error, \a *ipring is set to -1. */
void nest2ring64(int64_t nside, int64_t ipnest, int64_t *ipring);
/*! Computes the NEST pixel index of pixel \a ipring at resolution \a nside
    and returns it in \a *ipring. On error, \a *ipnest is set to -1. */
void ring2nest64(int64_t nside, int64_t ipring, int64_t *ipnest);

/*! Returns \a 12*nside*nside. */
int64_t nside2npix64(int64_t nside);
/*! Returns \a sqrt(npix/12) if this is an integer number, otherwise \a -1. */
long npix2nside64(int64_t npix);

/*! Sets \a *ipix to the pixel number in NEST scheme at resolution \a nside,
    which contains the direction described the Cartesian vector \a vec. */
void vec2pix_nest64(int64_t nside, const double *vec, int64_t *ipix);
/*! Sets \a *ipix to the pixel number in RING scheme at resolution \a nside,
    which contains the direction described the Cartesian vector \a vec. */
void vec2pix_ring64(int64_t nside, const double *vec, int64_t *ipix);

/*! Sets \a vec to the Cartesian vector pointing in the direction of the center
    of pixel \a ipix in NEST scheme at resolution \a nside. */
void pix2vec_nest64(int64_t nside, int64_t ipix, double *vec);
/*! Sets \a vec to the Cartesian vector pointing in the direction of the center
    of pixel \a ipix in RING scheme at resolution \a nside. */
void pix2vec_ring64(int64_t nside, int64_t ipix, double *vec);

/* FITS operations */
/* --------------- */

float *read_healpix_map (const char *infile, long *nside, char *coordsys,
  char *ordering);

void write_healpix_map (const float *signal, long nside, const char *filename,
  char nest, const char *coordsys);

long get_fits_size(const char *filename, long *nside, char *ordering);

/*! \} */

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* CHEALPIX_H */