H3C HEALPix library for PostgreSQL  (version 1.2)
h3c_util.c File Reference

usefull functions in the library heaplix for PostgreSQL More...

#include <math.h>
#include <sys/time.h>
#include <time.h>
#include "common.h"
#include "h3c_util.h"
#include "h3c_math.h"
#include "h3cpp_healpix.h"
#include <postgres.h>
+ Include dependency graph for h3c_util.c:

Go to the source code of this file.

Macros

#define LIMIT_CIRCLE_ORDER_0   2/60.
 get the ipix list of a cone and group them More...
 
#define LIMIT_POLYGONE_ORDER_0   1/60.
 get the ipix list of a polygone and group them More...
 

Functions

void h3c_log (int level, char *fmt,...)
 print statistics More...
 
void h3c_debug_init_clock ()
 initalize the debugger timer
 
h3c_coord_t h3c_theta2dec (h3c_coord_t theta)
 get the declination from the theta value More...
 
h3c_coord_t h3c_dec2theta (h3c_coord_t dec)
 get the theta value from the declination More...
 
h3c_coord_t h3c_phi2ra (h3c_coord_t phi)
 get the right ascension from the phi value More...
 
h3c_coord_t h3c_ra2phi (h3c_coord_t ra)
 get the phi value from the right ascension More...
 
int h3c_order (int nside)
 get the order from the nside number More...
 
h3c_ipix_t h3c_npix (int nside)
 get the number of ipix in the entire sphere More...
 
h3c_coord_t h3c_radius (int nside)
 get the max radius of ipix for a given nside More...
 
h3c_ipix_t * h3c_disk_ipix (h3c_coord_t ra, h3c_coord_t dec, h3c_coord_t radius, int nside, int *count)
 (c++ interface) get the ipix list of a cone More...
 
h3c_coord_t h3c_dist (h3c_coord_t ra1, h3c_coord_t dec1, h3c_coord_t ra2, h3c_coord_t dec2)
 calculate the distance between 2 points More...
 
h3c_coord_t h3c_sindist (h3c_coord_t ra1, h3c_coord_t dec1, h3c_coord_t ra2, h3c_coord_t dec2)
 calculate the sinus distance (to be compatible with Q3C) More...
 
char h3c_in_ellipse (h3c_coord_t alpha, h3c_coord_t delta0, h3c_coord_t alpha1, h3c_coord_t delta01, h3c_coord_t d0, h3c_coord_t e, h3c_coord_t PA0)
 verify if a point is inside an ellipse More...
 

Detailed Description

usefull functions in the library heaplix for PostgreSQL

Author
G.Landais (CDS)
Date
19/jul/2011
Note
About the coordinate system, the Healpix library ofeered by the nasa deals with (theta,phi):
  • theta: The polar angle or colatitude on the sphere, ranging from 0 at the North Pole to PI at the South Pole.
  • phi : The azimuthal angle on the sphere, in [0,2PI[.

Definition in file h3c_util.c.

Macro Definition Documentation

◆ LIMIT_CIRCLE_ORDER_0

#define LIMIT_CIRCLE_ORDER_0   2/60.

get the ipix list of a cone and group them

Parameters
raright ascension
decdeclination
radiusradius of the cone
nsidenside level
listthe list of ipix to return (OUT)
listsizesize of list
Returns
number of element of the ipix list
Note
the list returned is sorted and grouped
  ex: list=[1,3,4,4,6,8] => {1-3,4,6-8}
  list[2n]=min of a subset, list[2n+1]=max of a subset

Definition at line 351 of file h3c_util.c.

◆ LIMIT_POLYGONE_ORDER_0

#define LIMIT_POLYGONE_ORDER_0   1/60.

get the ipix list of a polygone and group them

Parameters
in_ra
in_dec
nnumber of points
nsidenside level
listthe ipix list to fill
numberof element of the ipix list
Returns
number of elements filled
Note
enclose the polygon inside a box

Definition at line 533 of file h3c_util.c.

Function Documentation

◆ h3c_dec2theta()

h3c_coord_t h3c_dec2theta ( h3c_coord_t  dec)

get the theta value from the declination

Parameters
decdeclination
Returns
theta

Definition at line 136 of file h3c_util.c.

◆ h3c_disk_ipix()

h3c_ipix_t* h3c_disk_ipix ( h3c_coord_t  ra,
h3c_coord_t  dec,
h3c_coord_t  radius,
int  nside,
int *  count 
)

(c++ interface) get the ipix list of a cone

Parameters
raright ascension
decdeclination
radiusradius of the cone
nsidenside level
Returns
ipix list

Definition at line 225 of file h3c_util.c.

References h3cpp_disk_ipix().

+ Here is the call graph for this function:

◆ h3c_dist()

h3c_coord_t h3c_dist ( h3c_coord_t  ra1,
h3c_coord_t  dec1,
h3c_coord_t  ra2,
h3c_coord_t  dec2 
)

calculate the distance between 2 points

Parameters
ra1right ascention of the first point
dec1declination of the first point
ra2right ascention of the second point
dec2declination of the second point
Returns
the distance
Note
Use the haversine function

Definition at line 460 of file h3c_util.c.

◆ h3c_in_ellipse()

char h3c_in_ellipse ( h3c_coord_t  alpha,
h3c_coord_t  delta0,
h3c_coord_t  alpha1,
h3c_coord_t  delta01,
h3c_coord_t  d0,
h3c_coord_t  e,
h3c_coord_t  PA0 
)

verify if a point is inside an ellipse

Note
: code coming from Q3C

Definition at line 615 of file h3c_util.c.

◆ h3c_log()

void h3c_log ( int  level,
char *  fmt,
  ... 
)

print statistics

Parameters
levelINFO
fmtformat
...optional argument used in format

Definition at line 57 of file h3c_util.c.

◆ h3c_npix()

h3c_ipix_t h3c_npix ( int  nside)

get the number of ipix in the entire sphere

Parameters
nsidenside level
Returns
number of ipix in the entire sphere

Definition at line 194 of file h3c_util.c.

◆ h3c_order()

int h3c_order ( int  nside)

get the order from the nside number

Parameters
nsidenside level
Returns
the order

Definition at line 173 of file h3c_util.c.

References h3c_log().

+ Here is the call graph for this function:

◆ h3c_phi2ra()

h3c_coord_t h3c_phi2ra ( h3c_coord_t  phi)

get the right ascension from the phi value

Parameters
phi
Returns
right ascension

Definition at line 149 of file h3c_util.c.

◆ h3c_ra2phi()

h3c_coord_t h3c_ra2phi ( h3c_coord_t  ra)

get the phi value from the right ascension

Parameters
raright ascension
Returns
phi

Definition at line 161 of file h3c_util.c.

◆ h3c_radius()

h3c_coord_t h3c_radius ( int  nside)

get the max radius of ipix for a given nside

Parameters
nsidenside level
Returns
the radius

Definition at line 204 of file h3c_util.c.

◆ h3c_sindist()

h3c_coord_t h3c_sindist ( h3c_coord_t  ra1,
h3c_coord_t  dec1,
h3c_coord_t  ra2,
h3c_coord_t  dec2 
)

calculate the sinus distance (to be compatible with Q3C)

Parameters
ra1right ascention of the first point
dec1declination of the first point
ra2right ascention of the second point
dec2declination of the second point
Returns
the distance
Note
Use the haversine function

Definition at line 486 of file h3c_util.c.

◆ h3c_theta2dec()

h3c_coord_t h3c_theta2dec ( h3c_coord_t  theta)

get the declination from the theta value

Parameters
theta
Returns
declination

Definition at line 125 of file h3c_util.c.