DopplerScan.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2007, 2008 Karl Wette
00003  * Copyright (C) 2004, 2005, 2006 Reinhard Prix
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with with program; see the file COPYING. If not, write to the
00017  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00018  *  MA  02111-1307  USA
00019  */
00020 
00021 /**
00022  * \author Reinhard Prix, Karl Wette
00023  * \date 2004, 2005, 2006, 2007, 2008
00024  * \file
00025  * \brief Header file defining the API for DopplerScan.
00026  *
00027  * $Id: DopplerScan.h,v 1.4 2008/07/30 10:24:10 kwwette Exp $
00028  */
00029 
00030 #ifndef _DOPPLERSCAN_H  /* Double-include protection. */
00031 #define _DOPPLERSCAN_H
00032 
00033 /* C++ protection. */
00034 #ifdef  __cplusplus
00035 extern "C" {
00036 #endif
00037 
00038 /*---------- INCLUDES ----------*/
00039 #include <lal/LALDatatypes.h>
00040 #include <lal/SkyCoordinates.h>
00041 #include <lal/PtoleMetric.h>
00042 #include <lal/StackMetric.h>
00043 #include <lal/LALBarycenter.h>
00044 #include <lal/PulsarDataTypes.h>
00045 #include <lal/ComputeFstat.h>
00046 
00047 NRCSID( DOPPLERSCANH, "$Id: DopplerScan.h,v 1.4 2008/07/30 10:24:10 kwwette Exp $" );
00048 
00049 /*---------- DEFINES ----------*/
00050 
00051 #define DOPPLERSCANH_ENULL              1
00052 #define DOPPLERSCANH_ENOTREADY          2
00053 #define DOPPLERSCANH_ESYS               3
00054 #define DOPPLERSCANH_E2DSKY             4
00055 #define DOPPLERSCANH_E2DSTEP            5
00056 #define DOPPLERSCANH_EGRIDCRPT          6
00057 #define DOPPLERSCANH_ESKYPARAM          7
00058 #define DOPPLERSCANH_EMETRICTYPE        8
00059 #define DOPPLERSCANH_ENONULL            9
00060 #define DOPPLERSCANH_EMEM               10
00061 #define DOPPLERSCANH_ESKYREGION         11
00062 #define DOPPLERSCANH_EINPUT             12
00063 #define DOPPLERSCANH_ENEGMETRIC         13
00064 #define DOPPLERSCANH_EXLAL              14
00065 
00066 
00067 #define DOPPLERSCANH_MSGENULL           "Arguments contained an unexpected null pointer"
00068 #define DOPPLERSCANH_MSGENOTREADY       "Doppler scan is uninitialized or has finished"
00069 #define DOPPLERSCANH_MSGESYS            "System call failed (probably file IO)"
00070 #define DOPPLERSCANH_MSGE2DSKY          "Either need one sky-point or a polygon. (2 sky-points where given)"
00071 #define DOPPLERSCANH_MSGE2DSTEP         "If not using the metric, you need to specify _both_ dDelta and dAlpha"
00072 #define DOPPLERSCANH_MSGEGRIDCRPT       "Unexpected NULL in grid-list. This points to a bug in the code... "
00073 #define DOPPLERSCANH_MSGESKYPARAM       "Invalid sky region! We need 0<= alpha < 2Pi and -Pi/2 <= delta <= PI/2"
00074 #define DOPPLERSCANH_MSGEMETRICTYPE     "Unknown type of metric specified."
00075 #define DOPPLERSCANH_MSGENONULL         "Output pointer is not NULL"
00076 #define DOPPLERSCANH_MSGEMEM            "Out of memory"
00077 #define DOPPLERSCANH_MSGESKYREGION      "Could not parse sky-region correctly"
00078 #define DOPPLERSCANH_MSGEINPUT          "Invald input parameter"
00079 #define DOPPLERSCANH_MSGENEGMETRIC      "Negative metric encountered"
00080 #define DOPPLERSCANH_MSGEXLAL           "XLAL call failed"
00081 
00082 /*---------- external types ----------*/
00083 
00084 /** Different 'states' a Doppler-scan can be in */
00085 typedef enum {
00086   STATE_IDLE = 0,       /**< not initialized yet */
00087   STATE_READY,          /**< initialized and ready */
00088   STATE_FINISHED,       /**< all templates have been read */
00089   STATE_LAST
00090 } scan_state_t;
00091 
00092 /** different types of grids: */
00093 typedef enum
00094 {
00095   /* ----- factored grid-types: sky x f0dot x f1dot x f2dot x f3dot  */
00096   GRID_FLAT             = 0,            /**< "flat" sky-grid: fixed step-size (dAlpha,dDelta) */
00097   GRID_ISOTROPIC        = 1,            /**< approximately isotropic sky-grid */
00098   GRID_METRIC           = 2,            /**< generate grid using a 2D sky-metric */
00099   GRID_FILE_SKYGRID     = 3,            /**< read skygrid from a file */
00100   GRID_METRIC_SKYFILE   = 4,            /**< 'hybrid' grid-construction: use skygrid from file, metric for others */
00101   GRID_SKY_LAST,                        /**< end-marker for factored grid types */
00102   /* ----- full multi-dim grid-types ----- */
00103   GRID_FILE_FULLGRID    = 6,            /**< load the full D-dim grid from a file */
00104   GRID_METRIC_LATTICE   = 7,            /**< 'optimal' covering using An*-lattice and flat metric */
00105   GRID_SPINDOWN_SQUARE  = 8,            /**< spindown tiling for a single sky position and square parameter space */
00106   GRID_SPINDOWN_AGEBRK  = 9,            /**< spindown tiling for a single sky position and non-square parameter space
00107                                            defined by spindown age and braking indices */
00108   /* ----- end-marker ----- */
00109   GRID_LAST
00110 } DopplerGridType;
00111 
00112 /** structure describing a polygon-region in the sky */
00113 typedef struct {
00114   UINT4 numVertices;            /**< number of polygon-vertices */
00115   SkyPosition *vertices;        /**< array of vertices */
00116   SkyPosition lowerLeft;        /**< lower-left point of bounding square */
00117   SkyPosition upperRight;       /**< upper-right point of bounding square */
00118 } SkyRegion;
00119 
00120 typedef struct {
00121   CHAR *skyRegionString;        /**< sky-region string '(a1,d1), (a2,d2), ..' */
00122   LIGOTimeGPS refTime;
00123   PulsarSpins fkdot;            /**< first points of spin-intervals */
00124   PulsarSpins fkdotBand;        /**< spin-intervals */
00125 } DopplerRegion;
00126 
00127 /* ==================== SKYGRID-ONLY types ==================== */
00128 /** sky grid */
00129 typedef struct tagDopplerSkyGrid {
00130   REAL8 Alpha;
00131   REAL8 Delta;
00132   struct tagDopplerSkyGrid *next;
00133 } DopplerSkyGrid;
00134 
00135 /** initialization-structure passed to InitDopplerSkyScan() */
00136 typedef struct {
00137   CHAR *skyRegionString;        /**< sky-region to search: format polygon '(a1,d1), (a2,d2), ..' */
00138   REAL8 Freq;                   /**< Frequency for which to build the skyGrid */
00139   DopplerGridType gridType;     /**< which type of skygrid to generate */
00140   LALPulsarMetricType metricType; /**< which metric to use if GRID_METRIC */
00141   REAL8 dAlpha, dDelta;         /**< sky step-sizes for GRID_FLAT and GRID_ISOTROPIC */
00142   REAL8 metricMismatch;         /**< for GRID_METRIC */
00143   LIGOTimeGPS obsBegin;         /**< GPS start-time of time-series */
00144   REAL8 obsDuration;            /**< length of time-series in seconds */
00145   BOOLEAN projectMetric;        /**< project the metric orthogonal to Freq? */
00146   const LALDetector *Detector;  /**< Current detector */
00147   const EphemerisData *ephemeris;/**< ephemeris-data for "exact" metric */
00148   const CHAR *skyGridFile;              /**< file containing a sky-grid (list of points) if GRID_FILE */
00149   UINT4 numSkyPartitions;       /**< number of (roughly) equal partitions to split sky-grid into */
00150   UINT4 partitionIndex;         /**< index of requested sky-grid partition: in [0, numPartitions - 1] */
00151 } DopplerSkyScanInit;
00152 
00153 /** this structure reflects the current state of a DopplerSkyScan */
00154 typedef struct {
00155   scan_state_t state;                   /**< idle, ready or finished */
00156   SkyRegion skyRegion;          /**< polygon (and bounding square) defining sky-region  */
00157   UINT4 numSkyGridPoints;       /**< how many skygrid-points */
00158   PulsarSpins dfkdot;           /**< fixed-size steps in spins */
00159   DopplerSkyGrid *skyGrid;      /**< head of linked list of skygrid nodes */
00160   DopplerSkyGrid *skyNode;      /**< pointer to current grid-node in skygrid */
00161 } DopplerSkyScanState;
00162 
00163 /** a "sky-ellipse", described by the two major axes and it's angle wrt x-axis */
00164 typedef struct {
00165   REAL8 smajor;
00166   REAL8 sminor;
00167   REAL8 angle;
00168 } MetricEllipse;
00169 
00170 /*---------- Global variables ----------*/
00171 /* some empty structs for initializations */
00172 extern const DopplerSkyGrid empty_DopplerSkyGrid;
00173 extern const DopplerSkyScanState empty_DopplerSkyScanState;
00174 extern const DopplerSkyScanInit empty_DopplerSkyScanInit;
00175 extern const PulsarDopplerParams empty_PulsarDopplerParams;
00176 extern const DopplerRegion empty_DopplerRegion;
00177 extern const SkyRegion empty_SkyRegion;
00178 
00179 /*---------- external prototypes [API] ----------*/
00180 
00181 /* ------ functions to handle factored grids: 'sky x freq x f1dot...' covering ----- */
00182 void InitDopplerSkyScan(LALStatus *, DopplerSkyScanState *skyScan, const DopplerSkyScanInit *init);
00183 int  XLALNextDopplerSkyPos( PulsarDopplerParams *pos, DopplerSkyScanState *skyScan);
00184 void FreeDopplerSkyScan(LALStatus *, DopplerSkyScanState *skyScan);
00185 int XLALFreeDopplerSkyScan (DopplerSkyScanState *skyScan);
00186 
00187 void writeSkyGridFile(LALStatus *, const DopplerSkyGrid *grid, const CHAR *fname );
00188 
00189 /* ----- various utility functions ----- */
00190 void ParseSkyRegionString (LALStatus *, SkyRegion *region, const CHAR *input);
00191 void SkySquare2String (LALStatus *, CHAR **string, REAL8 Alpha, REAL8 Delta, REAL8 AlphaBand, REAL8 DeltaBand);
00192 
00193 void getMCDopplerCube (LALStatus *, DopplerRegion *cube, PulsarDopplerParams signal, UINT4 PointsPerDim, const DopplerSkyScanInit *params);
00194 void getMetricEllipse(LALStatus *, MetricEllipse *ellipse, REAL8 mismatch, const REAL8Vector *metric, UINT4 dim0);
00195 
00196 int fprintfDopplerParams ( FILE *fp, const PulsarDopplerParams *params );
00197 
00198 DopplerSkyGrid *XLALEquiPartitionSkygrid ( const DopplerSkyGrid *skygrid, UINT4 jPart, UINT4 numPartitions );
00199 
00200 #ifdef  __cplusplus
00201 }
00202 #endif
00203 /* C++ protection. */
00204 
00205 #endif  /* Double-include protection. */

Generated on Sat Sep 6 03:06:49 2008 for LAL by  doxygen 1.5.2