DopplerLatticeCovering.c File Reference

Author:
Reinhard Prix Functions for optimal lattice-covering of Doppler-spaces. NOTE: this module always uses *ECLIPTIC* coordinates for interal operations
More...

#include <math.h>
#include <gsl/gsl_sys.h>
#include <lal/LALStdlib.h>
#include <lal/DetectorSite.h>
#include <lal/LALError.h>
#include <lal/LatticeCovering.h>
#include <lal/LogPrintf.h>
#include <lal/FlatPulsarMetric.h>
#include <lal/DopplerFullScan.h>
#include <lal/DopplerLatticeCovering.h>

Include dependency graph for DopplerLatticeCovering.c:

Go to the source code of this file.

Data Structures

struct  vect2Dlist_t
 2D-polygon of points {nX, nY} on a single hemisphere of ecliptic sky-sphere More...
struct  vect3Dlist_t
 List of 3D vectors. More...
struct  dopplerParams_t
 'standard' representation of Doppler-paremeters More...
struct  dopplerBoundary_t
 boundary of (single-hemisphere) search region in Doppler-space More...
struct  tagDopplerLatticeScan

Defines

#define EPS_REAL8   1e-10
 relative error used in REAL8 comparisons
#define TRUE   (1==1)
#define FALSE   (1==0)
#define NUM_SPINS   PULSAR_MAX_SPINS
#define DIM_CANONICAL   (2 + NUM_SPINS)
 dimension of 'canonical' Doppler-space
#define MIN(x, y)   (x < y ? x : y)
#define MAX(x, y)   (x > y ? x : y)
#define SIGN(x)   ( x < 0 ? -1 : ( x > 0 ? 1 : 0 ) )
#define SQUARE(x)   ( (x) * (x) )
#define VECT_NORM(x)   sqrt( SQUARE((x)[0]) + SQUARE((x)[1]) + SQUARE((x)[2]) )
#define VECT_ADD(x, y)   do { (x)[0] += (y)[0]; (x)[1] += (y)[1]; (x)[2] += (y)[2]; } while(0)
#define VECT_MULT(x, k)   do { (x)[0] *= k; (x)[1] *= k; (x)[2] *= k; } while(0)
#define VECT_COPY(dst, src)   do { (dst)[0] = (src)[0]; (dst)[1] = (src)[1]; (dst)[2] = (src)[2]; } while(0)
#define VECT_HEMI(x)   ( (x)[2] < 0 ? HEMI_SOUTH : ( (x)[2] > 0 ? HEMI_NORTH : 0 ) )

Typedefs

typedef REAL8 vect2D_t [2]
 2D vector
typedef REAL8 vect3D_t [3]
 3D vector

Enumerations

enum  hemisphere_t { HEMI_BOTH = 0, HEMI_NORTH = 1, HEMI_SOUTH = 2 }

Functions

 NRCSID (DOPPLERLATTICECOVERING,"$Id: DopplerLatticeCovering.c,v 1.1 2007/10/26 16:03:10 reinhard Exp $")
void skyRegionString2vect3D (LALStatus *status, vect3Dlist_t **skyRegion,const CHAR *skyRegionString)
 Convert a sky-region string into a list of vectors in ecliptic 2D coords {nX, nY}.
void setupSearchRegion (LALStatus *status, DopplerLatticeScan *scan, const DopplerRegion *searchRegion)
 Translate the input 'DopplerRegion' into an internal representation for the scan.
hemisphere_t onWhichHemisphere (const vect3Dlist_t *skypoints)
 Check whether given list of skypoint lie on a single hemisphere.
int skyposToVect3D (vect3D_t *eclVect, const SkyPosition *skypos)
 Convert a 'SkyPosition' {alpha, delta} into a 3D unit vector in ecliptic coordinates Return: 0=OK, -1=ERROR.
int vect2DToSkypos (SkyPosition *skypos, const vect2D_t *vect2D, hemisphere_t hemi)
 Convert (ecliptic) vector pointing to a skypos back into (alpha, delta).
int findCenterOfMass (vect3D_t *center, const vect3Dlist_t *points)
 Find the "center of mass" of the given list of 3D points Return: 0=OK, -1 on ERROR.
int IndexToCanonical (gsl_vector **canonical, const gsl_vector_int *Index, const DopplerLatticeScan *scan)
 Convert Index-vector {i0, i1, i2, .
int XLALIndexToDoppler (dopplerParams_t *doppler, const gsl_vector_int *Index, const DopplerLatticeScan *scan)
 Convert given Index into doppler-params Return: 0=OK, -1=ERROR.
int isIndexInsideBoundary (const gsl_vector_int *Index, const DopplerLatticeScan *scan)
 Determine whether the given lattice-Index corresponds to a Doppler-point that lies within the search-boundary Return: TRUE, FALSE, -1 = ERROR.
int convertDoppler2Canonical (gsl_vector **canonical, const dopplerParams_t *doppler, const gsl_vector *dopplerUnits)
 Convert Doppler-parameters from {nX, nY, nZ, fkdot} into internal 'canonical' form {w0, kX, kY, w1, w1, .
int convertCanonical2Doppler (dopplerParams_t *doppler, const gsl_vector *canonical, const gsl_vector *dopplerUnits)
 Convert a 'canonical' parameter-space point back into a 'physical' Doppler units: a unit (ecliptic) sky-vector 'vn' and spin-vector 'fkdot'.
int vect2DInPolygon (const vect2D_t *point, const vect2Dlist_t *polygon)
 Function for checking if a given vect2D-point lies inside or outside a given vect2D-polygon.
int isDopplerInsideBoundary (const dopplerParams_t *doppler, const dopplerBoundary_t *boundary)
 Determine whether the given Doppler-point lies within the search-boundary Return: TRUE, FALSE, -1 = ERROR.
int fprintf_vect2D (FILE *fp, const vect2D_t *vect, hemisphere_t hemi)
int fprintf_vect2Dlist (FILE *fp, const vect2Dlist_t *list, hemisphere_t hemi)
DopplerLatticeScanXLALDuplicateDopplerLatticeScan (const DopplerLatticeScan *scan)
 Return a copy a full DopplerLatticeScan state, useful as a backup while counting the lattice.
void InitDopplerLatticeScan (LALStatus *status, DopplerLatticeScan **scan, const DopplerLatticeInit *init)
 Initialize search-grid using optimal lattice-covering.
int XLALFreeDopplerLatticeScan (DopplerLatticeScan **scan)
 Free an allocated DopplerLatticeScan.
int XLALgetCurrentLatticeIndex (gsl_vector_int **Index, const DopplerLatticeScan *scan)
 Return current lattice Index of the scan: allocate Index here if *Index == NULL, otherwise use given vector [has to have right dimension].
int XLALsetCurrentLatticeIndex (DopplerLatticeScan *scan, const gsl_vector_int *Index)
 Set the current index of the scan.
REAL8 XLALCountLatticeTemplates (const DopplerLatticeScan *scan)
 Count number of templates in lattice-grid by stepping through the whole grid.
int XLALadvanceLatticeIndex (DopplerLatticeScan *scan)
 The central "lattice-stepping" function: advance to the 'next' Index-point, taking care not to leave the boundary, and to cover the whole (convex!) search-region eventually!
int XLALgetCurrentDopplerPos (PulsarDopplerParams *pos, const DopplerLatticeScan *scan, CoordinateSystem skyCoords)
 Return the current doppler-position {Freq, Alpha, Delta, f1dot, f2dot, .

Variables

dopplerParams_t empty_dopplerParams
INT4 lalDebugLevel
 DECLARE AND SET GLOBAL DEBUG LEVEL.


Detailed Description

Author:
Reinhard Prix Functions for optimal lattice-covering of Doppler-spaces. NOTE: this module always uses *ECLIPTIC* coordinates for interal operations

Date:
2006

Definition in file DopplerLatticeCovering.c.


Define Documentation

#define EPS_REAL8   1e-10

relative error used in REAL8 comparisons

Definition at line 50 of file DopplerLatticeCovering.c.

#define TRUE   (1==1)

Definition at line 52 of file DopplerLatticeCovering.c.

#define FALSE   (1==0)

Definition at line 53 of file DopplerLatticeCovering.c.

#define NUM_SPINS   PULSAR_MAX_SPINS

Definition at line 55 of file DopplerLatticeCovering.c.

#define DIM_CANONICAL   (2 + NUM_SPINS)

dimension of 'canonical' Doppler-space

Definition at line 56 of file DopplerLatticeCovering.c.

#define MIN ( x,
y   )     (x < y ? x : y)

Definition at line 58 of file DopplerLatticeCovering.c.

#define MAX ( x,
y   )     (x > y ? x : y)

Definition at line 59 of file DopplerLatticeCovering.c.

#define SIGN ( x   )     ( x < 0 ? -1 : ( x > 0 ? 1 : 0 ) )

Definition at line 60 of file DopplerLatticeCovering.c.

#define SQUARE ( x   )     ( (x) * (x) )

Definition at line 62 of file DopplerLatticeCovering.c.

#define VECT_NORM ( x   )     sqrt( SQUARE((x)[0]) + SQUARE((x)[1]) + SQUARE((x)[2]) )

Definition at line 63 of file DopplerLatticeCovering.c.

#define VECT_ADD ( x,
y   )     do { (x)[0] += (y)[0]; (x)[1] += (y)[1]; (x)[2] += (y)[2]; } while(0)

Definition at line 64 of file DopplerLatticeCovering.c.

#define VECT_MULT ( x,
 )     do { (x)[0] *= k; (x)[1] *= k; (x)[2] *= k; } while(0)

Definition at line 65 of file DopplerLatticeCovering.c.

#define VECT_COPY ( dst,
src   )     do { (dst)[0] = (src)[0]; (dst)[1] = (src)[1]; (dst)[2] = (src)[2]; } while(0)

Definition at line 66 of file DopplerLatticeCovering.c.

#define VECT_HEMI ( x   )     ( (x)[2] < 0 ? HEMI_SOUTH : ( (x)[2] > 0 ? HEMI_NORTH : 0 ) )

Definition at line 68 of file DopplerLatticeCovering.c.


Typedef Documentation

typedef REAL8 vect2D_t[2]

2D vector

Definition at line 77 of file DopplerLatticeCovering.c.

typedef REAL8 vect3D_t[3]

3D vector

Definition at line 78 of file DopplerLatticeCovering.c.


Enumeration Type Documentation

enum hemisphere_t

Enumerator:
HEMI_BOTH  points lie on both hemispheres
HEMI_NORTH  all points on northern hemisphere
HEMI_SOUTH  all points on southern hemisphere

Definition at line 71 of file DopplerLatticeCovering.c.


Function Documentation

NRCSID ( DOPPLERLATTICECOVERING  ,
"$Id: DopplerLatticeCovering.  c,
v 1.1 2007/10/26 16:03:10 reinhard Exp $"   
)

void skyRegionString2vect3D ( LALStatus ,
vect3Dlist_t **  skyRegionEcl,
const CHAR skyRegionString 
)

Convert a sky-region string into a list of vectors in ecliptic 2D coords {nX, nY}.

Parameters:
skyRegion  [out] list of skypoints in 3D-ecliptic coordinates {nX, nY, nZ}
skyRegionString  [in] string of equatorial-coord. sky-positions

Definition at line 974 of file DopplerLatticeCovering.c.

void setupSearchRegion ( LALStatus status,
DopplerLatticeScan scan,
const DopplerRegion searchRegion 
)

Translate the input 'DopplerRegion' into an internal representation for the scan.

Note:
DopplerLatticeScan->Tspan must have been set! This is used for conversion Doppler -> canonical

Definition at line 717 of file DopplerLatticeCovering.c.

hemisphere_t onWhichHemisphere ( const vect3Dlist_t skypoints  ) 

Check whether given list of skypoint lie on a single hemisphere.

Definition at line 1045 of file DopplerLatticeCovering.c.

int skyposToVect3D ( vect3D_t eclVect,
const SkyPosition skypos 
)

Convert a 'SkyPosition' {alpha, delta} into a 3D unit vector in ecliptic coordinates Return: 0=OK, -1=ERROR.

Definition at line 1071 of file DopplerLatticeCovering.c.

int vect2DToSkypos ( SkyPosition skypos,
const vect2D_t vect2D,
hemisphere_t  hemi 
)

Convert (ecliptic) vector pointing to a skypos back into (alpha, delta).

NOTE: The coordinate-system of the result is determined by the 'system'-setting in the output 'skypos'

return: 0=OK, -1=ERROR

Definition at line 1117 of file DopplerLatticeCovering.c.

int findCenterOfMass ( vect3D_t center,
const vect3Dlist_t points 
)

Find the "center of mass" of the given list of 3D points Return: 0=OK, -1 on ERROR.

Definition at line 1182 of file DopplerLatticeCovering.c.

int IndexToCanonical ( gsl_vector **  canonical,
const gsl_vector_int *  Index,
const DopplerLatticeScan scan 
)

Convert Index-vector {i0, i1, i2, .

.} into canonical param-vector {w0, kX, kY, w1, w2, ...}

Note:
the output-vector 'canonical' can be NULL, in which case it will be allocated here, If allocated already, its dimension must be dimCanonical
Return: 0=OK, -1=ERROR

Definition at line 859 of file DopplerLatticeCovering.c.

int XLALIndexToDoppler ( dopplerParams_t doppler,
const gsl_vector_int *  Index,
const DopplerLatticeScan scan 
)

Convert given Index into doppler-params Return: 0=OK, -1=ERROR.

Definition at line 623 of file DopplerLatticeCovering.c.

int isIndexInsideBoundary ( const gsl_vector_int *  Index,
const DopplerLatticeScan scan 
)

Determine whether the given lattice-Index corresponds to a Doppler-point that lies within the search-boundary Return: TRUE, FALSE, -1 = ERROR.

Definition at line 653 of file DopplerLatticeCovering.c.

int convertDoppler2Canonical ( gsl_vector **  canonical,
const dopplerParams_t doppler,
const gsl_vector *  dopplerUnits 
)

Convert Doppler-parameters from {nX, nY, nZ, fkdot} into internal 'canonical' form {w0, kX, kY, w1, w1, .

.. }

Note:
If the return-vector is NULL, it is allocated here, otherwise it has to have dimension DIM_CANONICAL
Return: 0=OK, -1=ERROR

Definition at line 910 of file DopplerLatticeCovering.c.

int convertCanonical2Doppler ( dopplerParams_t doppler,
const gsl_vector *  canonical,
const gsl_vector *  dopplerUnits 
)

Convert a 'canonical' parameter-space point back into a 'physical' Doppler units: a unit (ecliptic) sky-vector 'vn' and spin-vector 'fkdot'.

Return: 0=OK, -1=ERROR

Definition at line 948 of file DopplerLatticeCovering.c.

int vect2DInPolygon ( const vect2D_t point,
const vect2Dlist_t polygon 
)

Function for checking if a given vect2D-point lies inside or outside a given vect2D-polygon.

This is basically indentical to 'pointInPolygon()' only using different data-types.

Note1:
The list of polygon-points must not close on itself, the last point is automatically assumed to be connected to the first
Alorithm:
Count the number of intersections of rays emanating to the right from the point with the lines of the polygon: even=> outside, odd=> inside
Note2:
we try to get this algorith to count all boundary-points as 'inside' we do this by counting intersection to the left _AND_ to the right and consider the point inside if either of those says its inside...
Note3:
correctly handles the case of a 1-point 'polygon', in which the two points must agree within eps=1e-10 relative precision.
Returns:
: TRUE or FALSE, -1=ERROR ----------------------------------------------------------------------

Definition at line 1228 of file DopplerLatticeCovering.c.

int isDopplerInsideBoundary ( const dopplerParams_t doppler,
const dopplerBoundary_t boundary 
)

Determine whether the given Doppler-point lies within the search-boundary Return: TRUE, FALSE, -1 = ERROR.

Definition at line 672 of file DopplerLatticeCovering.c.

int fprintf_vect2D ( FILE *  fp,
const vect2D_t vect,
hemisphere_t  hemi 
)

Definition at line 1291 of file DopplerLatticeCovering.c.

int fprintf_vect2Dlist ( FILE *  fp,
const vect2Dlist_t list,
hemisphere_t  hemi 
)

Definition at line 1308 of file DopplerLatticeCovering.c.

DopplerLatticeScan * XLALDuplicateDopplerLatticeScan ( const DopplerLatticeScan scan  ) 

Return a copy a full DopplerLatticeScan state, useful as a backup while counting the lattice.

Return: NULL=ERROR

Definition at line 533 of file DopplerLatticeCovering.c.

void InitDopplerLatticeScan ( LALStatus status,
DopplerLatticeScan **  scan,
const DopplerLatticeInit init 
)

Initialize search-grid using optimal lattice-covering.

Parameters:
scan  [out] initialized scan-state for lattice-scan
init  [in] scan init parameters

Definition at line 159 of file DopplerLatticeCovering.c.

int XLALFreeDopplerLatticeScan ( DopplerLatticeScan **  scan  ) 

Free an allocated DopplerLatticeScan.

Return: 0=OK, -1=ERROR

Definition at line 273 of file DopplerLatticeCovering.c.

int XLALgetCurrentLatticeIndex ( gsl_vector_int **  Index,
const DopplerLatticeScan scan 
)

Return current lattice Index of the scan: allocate Index here if *Index == NULL, otherwise use given vector [has to have right dimension].

Definition at line 312 of file DopplerLatticeCovering.c.

int XLALsetCurrentLatticeIndex ( DopplerLatticeScan scan,
const gsl_vector_int *  Index 
)

Set the current index of the scan.

Definition at line 339 of file DopplerLatticeCovering.c.

REAL8 XLALCountLatticeTemplates ( const DopplerLatticeScan scan  ) 

Count number of templates in lattice-grid by stepping through the whole grid.

NOTE: original scan-state isn't modified.

Return: > 0: OK, -1=ERROR

Definition at line 358 of file DopplerLatticeCovering.c.

int XLALadvanceLatticeIndex ( DopplerLatticeScan scan  ) 

The central "lattice-stepping" function: advance to the 'next' Index-point, taking care not to leave the boundary, and to cover the whole (convex!) search-region eventually!

Note:
Algorithm: o) start with first Index-dimension aI = 0 1) if Index(aI) >= 0: Index(aI) ++; else Index(aI) --; i.e. increase for pos Index, decrease for negative ones ==> always walk "outwards" from origin, towards boundaries) o) if resulting point lies inside boundary ==> keep & return
o) if boundary was crossed: return aI to origin: Index(aI) = 0; o) step to next dimension: aI ++; o) if no more dimensions left: aI >= dim ==> no further lattice-points! RETURN o) else continue at 1)

Return: 0=OK, -1=ERROR, +1=No more lattice points left

Definition at line 403 of file DopplerLatticeCovering.c.

int XLALgetCurrentDopplerPos ( PulsarDopplerParams pos,
const DopplerLatticeScan scan,
CoordinateSystem  skyCoords 
)

Return the current doppler-position {Freq, Alpha, Delta, f1dot, f2dot, .

.. } of the lattice-scan NOTE: the skyposition coordinate-system is chosen via 'skyCoords' in [EQUATORIAL, ECLIPTIC]

Definition at line 492 of file DopplerLatticeCovering.c.


Variable Documentation

dopplerParams_t empty_dopplerParams

Definition at line 122 of file DopplerLatticeCovering.c.

INT4 lalDebugLevel

DECLARE AND SET GLOBAL DEBUG LEVEL.

see the section (currently 7.4.1) of the LSD on "Status-reporting objects" for a list of predefined debug levels

Definition at line 62 of file BCVSpinTemplates.c.


Generated on Tue Oct 14 02:32:47 2008 for LAL by  doxygen 1.5.2