Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALPulsar 7.1.1.1-b246709
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
TwoDMeshTest.c File Reference

Creates a 2-dimensional template mesh for linearly-changing mismatch ellipses. More...

Detailed Description

Creates a 2-dimensional template mesh for linearly-changing mismatch ellipses.

Author
Creighton, T. D.

Usage

TwoDMeshTest [-o outfile] [-p psfile flags] [-d debug] [-m mismatch nmax cmax]
[-b x1 y1 x2 y2 ] [-e a b c]
[-x dadx dbdx dcdx] [-y dady dbdy dcdy]
#define c
double e
static const INT4 m
static const INT4 a
list y

Description

This test program creates a template mesh for a parameter space with an arbitrary mismatch metric. The following option flags are accepted:

  • -o Writes the output mesh list to the file outfile. If absent, no output is written.
  • -p Plots the output mesh in a PostScript file psfile, using plot flags flags (see below). If absent, no plot is made.
  • -d Sets the debug level to debug. If absent, a debug level of zero is used.
  • -m Sets the maximum mismatch to mismatch, maximum number of mesh points to nmax and the maximum estimated number of columns to cmax. If mismatch is not in the range (0,1], it is taken to be 1. If nmax or cmax is non-positive, it is ignored (no maximum). If this option is not given, -m 1 0 0 is assumed.
  • -b Sets the parameter space boundary to be a parallelogram defined by the vectors (x1,y1) and (x2,y2) from the origin. If absent, the region is taken to be a unit square.
  • -e Sets the parameters of the mismatch ellipse at the origin: its principal axis lengths are a and b units, and the angle from the \( x \) -axis to the first principal axis is c radians. If absent, -e 0.1 0.05 1 is assumed.
  • -x Sets the rates of change in the \( x \) -direction of a, b, and c (above) to dadx, dbdx, and dcdx, respectively. If absent, the rates are taken to be zero.
  • -y Sets the rates of change in the \( y \) -direction of a, b, and c (above) to dady, dbdy, and dcdy, respectively. If absent, the rates are taken to be zero.

Algorithm

The test program reads the input arguments and creates a parameter structure *params to be passed to LALCreateTwoDMesh(). In particular, it computes the domain of the parameter space, and defines functions and parameter lists to compute the range in \( y \) at any \( x \) , and the metric at any point \( (x,y) \) . If PostScript output is requested, it is generated using LALPlotTwoDMesh(), using the value of the command-line number flags to set the plotting parameters. Each of these functions is discussed below.

Parameter ranges:
The parameter space boundary can be specified by input parameters x1 \( =x_1 \) , x2 \( =x_2 \) , y1 \( =y_1 \) , and y2 \( =y_2 \) . The parameter space is then defined to be a parallelogram with one corner on the origin, and two sides defined by vectors \( (x_1,y_1) \) and \( (x_2,y_2) \) . Without loss of generality we assume that \( x_1<x_2 \) . The functions defining the boundaries are denoted \( y_{a,b}(x) \) , and we make no assumption about their signs or relative order. The algorithm used then depends on the signs of \( x_1 \) and \( x_2 \) .

If \( x_1=x_2=0 \) , then the parameter space is singular, and no mesh need be generated.

If \( x_1=0 \) and \( x_2\neq0 \) , then the domain is \( [0,x_2] \) , and the boundary functions are:

\begin{eqnarray} y_a(x) & = & y_2x/x_2\\ y_b(x) & = & y_1 + y_2x/x_2 \end{eqnarray}

If \( x_2=0 \) and \( x_1\neq0 \) , then the domain is \( [x_1,0] \) , and the above equations for \( y_{a,b}(x) \) simply have 1 and 2 reversed.

If \( x_1 \) and \( x_2 \) have the same sign, then the domain is \( [0,x_1+x_2] \) if \( x_1 \) and \( x_2 \) are positive, and \( [x_1+x_2,0] \) otherwise. The boundary functions are:

\begin{eqnarray} y_a(x) & = & \left\{\begin{array}{c@{\qquad}c} y_1x/x_1 & x\mathrm{~between~}0\mathrm{~and~}x_1 \\ y_1 + y_2(x-x_1)/x_2 & x\mathrm{~between~}x_1\mathrm{~and~}x_1+x_2 \end{array}\right.\\ y_b(x) & = & \left\{\begin{array}{c@{\qquad}c} y_2x/x_2 & x\mathrm{~between~}0\mathrm{~and~}x_2 \\ y_2 + y_1(x-x_2)/x_1 & x\mathrm{~between~}x_2\mathrm{~and~}x_1+x_2 \end{array}\right. \end{eqnarray}

If \( x_1 \) and \( x_2 \) have opposite sign, the domain is \( [x_1,x_2] \) if \( x_1<0 \) , and \( [x_2,x_1] \) otherwise. The boundary functions are:

\begin{eqnarray} y_a(x) & = & \left\{\begin{array}{c@{\qquad}c} y_1x/x_1 & x\mathrm{~between~}0\mathrm{~and~}x_1 \\ y_2x/x_2 & x\mathrm{~between~}0\mathrm{~and~}x_2 \end{array}\right.\\ y_b(x) & = & \left\{\begin{array}{c@{\qquad}c} y_1 + y_2(x-x_1)/x_2 & x\mathrm{~between~}x_1\mathrm{~and~}x_1+x_2 \\ y_2 + y1(x-x_2)/x_1 & x\mathrm{~between~}x_2\mathrm{~and~}x_1+x_2 \end{array}\right. \end{eqnarray}

The main program sorts the input parameters so that \( x_1\leq x_2 \) , stores them in a 4-dimensional array, and assigns a void pointer to that array. It also computes the domain. The routine LALTwoDRangeTest() takes a value of \( x \) and the void pointer, computes the values of \( y_a(x) \) and \( y_b(x) \) according to the algorithm above, sorts them, and returns them ordered from lower to higher.

Metric values:
The main program takes the input parameters a, b, c, dadx, dbdx, and dcdx, stores them in a 9-dimensional array, and assigns a void pointer to it. The routine LALTwoDMetricTest() takes a position \( (x,y) \) and the void pointer, and computes the `‘local’' value of the principal axis \( a= \) a \( +x\times \) dadx \( +y\times \) dady, and similarly for \( b \) and \( c \) . If that ellipse corresponds to the \( m_\mathrm{thresh} \) mismatch level contour, then the eigenvalues of the corresponding metric are \( \lambda_1=m_\mathrm{thresh}/a^2 \) and \( \lambda_2=m_\mathrm{thresh}/b^2 \) . The metric components are thus:

\begin{eqnarray} g_{xx} & = & \lambda_1\cos^2(c) + \lambda_2\sin^2(c) \;,\\ g_{yy} & = & \lambda_1\sin^2(c) + \lambda_2\cos^2(c) \;,\\ g_{xy} \quad = \quad g_{yx} & = & (\lambda_1-\lambda_2)\cos(c)\sin(c) \;. \end{eqnarray}

The routine assumes that the values of \( a \) , \( b \) , and \( c \) refer to an \( m_\mathrm{thresh}=1 \) mismatch ellipse. It computes and returns \( g_{xx} \) , \( g_{yy} \) , and \( g_{xy} \) in a 3-dimensional array.
PostScript flags:
The parameter flags is an unsigned integer whose lowest-order bits contain parameters to be passed to LALPlotTwoDMesh(). The bits and their meanings are:
bit 0:
1 if mesh points will be plotted, 0 otherwise.
bit 1:
1 if mesh tiles will be plotted, 0 otherwise.
bit 2:
1 if mismatch ellipses will be plotted, 0 otherwise.
bit 3:
1 if the boundary will be plotted, 0 otherwise.
Thus a value of 15 will plot everything, while a value of 9 will just plot the mesh points and the boundary. A value of zero suppresses the plot.

If mesh points are to be plotted, they will be filled circles \( 1/72'' \) (1~point) in diameter. The parameter space will be rotated so that the longer of the diagonals of the parallelogram will be vertical, and scaled to fit on one \( 8.5''\times11'' \) page. That is, if \( ||(x_1+x_2,y_1+y_2)||\geq||(x_1-x_2,y_1-y_2)|| \) , the rotation angle of the coordinate axes will be \( \theta=\pi/2-\arctan\!2(y_1+y_2,x_1+x_2) \) , or \( \theta=\pi/2-\arctan\!2(y_2-y_1,x_2-x_1) \) otherwise. We note that the function \( \arctan\!2(y,x) \) returns the argument of the complex number \( x+iy \) in the range \( [-\pi,\pi] \) .

Uses

LALPrintError() LALCheckMemoryLeaks()
#define lalDebugLevel
int LALPrintError(const char *fmt,...)
void LALCreateTwoDMesh(LALStatus *stat, TwoDMeshNode **mesh, TwoDMeshParamStruc *params)
Definition: TwoDMesh.c:106
void LALDestroyTwoDMesh(LALStatus *stat, TwoDMeshNode **mesh, UINT4 *nFree)
Definition: TwoDMesh.c:159
void LALPlotTwoDMesh(LALStatus *stat, FILE *stream, TwoDMeshNode *mesh, TwoDMeshPlotStruc *params)
Plots a hierarchical mesh of templates on an 2-dimensional parameter space.
Definition: TwoDMeshPlot.c:97

Notes

Definition in file TwoDMeshTest.c.

Go to the source code of this file.

Macros

Error Codes
#define TWODMESHTESTC_ENORM   0
 
#define TWODMESHTESTC_ESUB   1
 
#define TWODMESHTESTC_EARG   2
 
#define TWODMESHTESTC_EBAD   3
 
#define TWODMESHTESTC_EMEM   4
 
#define TWODMESHTESTC_EFILE   5
 
#define TWODMESHTESTC_EMETRIC   6
 
#define TWODMESHTESTC_MSGENORM   "Normal exit"
 
#define TWODMESHTESTC_MSGESUB   "Subroutine failed"
 
#define TWODMESHTESTC_MSGEARG   "Error parsing arguments"
 
#define TWODMESHTESTC_MSGEBAD   "Bad argument value"
 
#define TWODMESHTESTC_MSGEMEM   "Memory allocation error"
 
#define TWODMESHTESTC_MSGEFILE   "Could not open file"
 
#define TWODMESHTESTC_MSGEMETRIC   "Axis length is zero or negative within specified region"
 

Macro Definition Documentation

◆ TWODMESHTESTC_ENORM

#define TWODMESHTESTC_ENORM   0

Definition at line 202 of file TwoDMeshTest.c.

◆ TWODMESHTESTC_ESUB

#define TWODMESHTESTC_ESUB   1

Definition at line 203 of file TwoDMeshTest.c.

◆ TWODMESHTESTC_EARG

#define TWODMESHTESTC_EARG   2

Definition at line 204 of file TwoDMeshTest.c.

◆ TWODMESHTESTC_EBAD

#define TWODMESHTESTC_EBAD   3

Definition at line 205 of file TwoDMeshTest.c.

◆ TWODMESHTESTC_EMEM

#define TWODMESHTESTC_EMEM   4

Definition at line 206 of file TwoDMeshTest.c.

◆ TWODMESHTESTC_EFILE

#define TWODMESHTESTC_EFILE   5

Definition at line 207 of file TwoDMeshTest.c.

◆ TWODMESHTESTC_EMETRIC

#define TWODMESHTESTC_EMETRIC   6

Definition at line 208 of file TwoDMeshTest.c.

◆ TWODMESHTESTC_MSGENORM

#define TWODMESHTESTC_MSGENORM   "Normal exit"

Definition at line 210 of file TwoDMeshTest.c.

◆ TWODMESHTESTC_MSGESUB

#define TWODMESHTESTC_MSGESUB   "Subroutine failed"

Definition at line 211 of file TwoDMeshTest.c.

◆ TWODMESHTESTC_MSGEARG

#define TWODMESHTESTC_MSGEARG   "Error parsing arguments"

Definition at line 212 of file TwoDMeshTest.c.

◆ TWODMESHTESTC_MSGEBAD

#define TWODMESHTESTC_MSGEBAD   "Bad argument value"

Definition at line 213 of file TwoDMeshTest.c.

◆ TWODMESHTESTC_MSGEMEM

#define TWODMESHTESTC_MSGEMEM   "Memory allocation error"

Definition at line 214 of file TwoDMeshTest.c.

◆ TWODMESHTESTC_MSGEFILE

#define TWODMESHTESTC_MSGEFILE   "Could not open file"

Definition at line 215 of file TwoDMeshTest.c.

◆ TWODMESHTESTC_MSGEMETRIC

#define TWODMESHTESTC_MSGEMETRIC   "Axis length is zero or negative within specified region"

Definition at line 216 of file TwoDMeshTest.c.