SFTutils.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2005 Reinhard Prix
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with with program; see the file COPYING. If not, write to the 
00016  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
00017  *  MA  02111-1307  USA
00018  */
00019 
00020 /**
00021  * \author Reinhard Prix, Badri Krishnan
00022  * \date 2005
00023  * \file 
00024  * \ingroup SFTfileIO
00025  * \brief Utility functions for handling of SFTtype and SFTVectors
00026  *
00027  * $Id: SFTutils.h,v 1.35 2008/05/29 21:21:24 whelan Exp $
00028  *
00029  *  The helper functions LALCreateSFTtype(), LALDestroySFTtype(), LALCreateSFTVector()
00030  * and LALDestroySFTVector() respectively allocate and free SFT-structs and SFT-vectors. 
00031  * Similarly, LALCreateTimestampVector() and LALDestroyTimestampVector() allocate and free 
00032  * a bunch of GPS-timestamps.
00033  *
00034  */
00035 
00036 #ifndef _SFTUTILS_H  /* Double-include protection. */
00037 #define _SFTUTILS_H
00038 
00039 /* C++ protection. */
00040 #ifdef  __cplusplus
00041 extern "C" {
00042 #endif
00043 
00044 NRCSID( SFTUTILSH, "$Id: SFTutils.h,v 1.35 2008/05/29 21:21:24 whelan Exp $" );
00045 /*---------- INCLUDES ----------*/
00046 #include <stdarg.h>
00047 
00048 #include <lal/LALDatatypes.h>
00049 #include <lal/DetectorSite.h>
00050 #include <lal/Date.h>
00051 #include <lal/SkyCoordinates.h>
00052 #include <lal/RngMedBias.h>
00053 #include <lal/LALRunningMedian.h>
00054 
00055 
00056 
00057 
00058 /*---------- DEFINES ----------*/
00059 
00060 /*----- Error-codes -----*/
00061 
00062 #define SFTUTILS_ENULL          1
00063 #define SFTUTILS_ENONULL        2
00064 #define SFTUTILS_EMEM           3
00065 #define SFTUTILS_EINPUT         4
00066 #define SFTUTILS_EFUNC          6
00067 
00068 #define SFTUTILS_MSGENULL       "Arguments contained an unexpected null pointer"
00069 #define SFTUTILS_MSGENONULL     "Output pointer is not NULL"
00070 #define SFTUTILS_MSGEMEM        "Out of memory"
00071 #define SFTUTILS_MSGEINPUT      "Invald input parameter"
00072 #define SFTUTILS_MSGEFUNC       "Sub-routine failed"
00073 
00074 /*---------- exported types ----------*/
00075 
00076 /** A vector of COMPLEX8FrequencySeries */
00077 typedef struct {
00078   UINT4                         length;         /**< number of SFTs */
00079   COMPLEX8FrequencySeries       *data;          /**< array of SFTs */
00080 } COMPLEX8FrequencySeriesVector;
00081 
00082 /** A vector of REAL8FrequencySeries */
00083 typedef struct {
00084   UINT4                  length;
00085   REAL8FrequencySeries   *data;
00086 } REAL8FrequencySeriesVector;
00087 
00088 
00089 /** A so-called 'SFT' (short-Fourier-transform) will be stored in a COMPLEX8FrequencySeries */
00090 typedef COMPLEX8FrequencySeries         SFTtype;        
00091 
00092 
00093 /** The corresponding vector-type to hold a vector of 'SFTs' */
00094 typedef COMPLEX8FrequencySeriesVector   SFTVector;
00095 
00096 /** Special type for holding a PSD vector (over several SFTs) */
00097 typedef REAL8FrequencySeriesVector PSDVector;
00098 
00099 /** A collection of SFT vectors -- one for each IFO in a multi-IFO search */
00100 typedef struct tagMultiSFTVector {
00101   UINT4      length;    /**< number of ifos */
00102   SFTVector  **data;    /**< sftvector for each ifo */
00103 } MultiSFTVector;
00104 
00105 
00106 /** A collection of PSD vectors -- one for each IFO in a multi-IFO search */
00107 typedef struct {
00108   UINT4      length;    /**< number of ifos */
00109   PSDVector  **data;    /**< sftvector for each ifo */
00110 } MultiPSDVector;
00111 
00112 /** One noise-weight (number) per SFT (therefore indexed over IFOs and SFTs */
00113 typedef struct {
00114   UINT4 length;         /**< number of ifos */
00115   REAL8Vector **data;   /**< weights-vector for each SFTs */
00116   REAL8 Sinv_Tsft;      /**< normalization factor used: \f$\mathcal{S}^{-1}\,T_\mathrm{SFT}\f$ */
00117 } MultiNoiseWeights;
00118 
00119 /** A collection of (multi-IFO) time-series */
00120 typedef struct {
00121   UINT4 length;                 /**< number of ifos */
00122   REAL4TimeSeries **data;       /**< vector of REAL4 timeseries */
00123 } MultiREAL4TimeSeries;
00124 
00125 /** A vector of 'timestamps' of type LIGOTimeGPS */
00126 typedef struct {
00127   UINT4         length;         /**< number of timestamps */
00128   LIGOTimeGPS   *data;          /**< array of timestamps */
00129   REAL8         deltaT;         /**< 'length' of each timestamp (e.g. typically Tsft) */
00130 } LIGOTimeGPSVector;
00131 
00132 /** A vector of 'timestamps' of type LIGOTimeGPS */
00133 typedef struct {
00134   UINT4                 length;    /**< number of timestamps vectors or ifos */
00135   LIGOTimeGPSVector     **data;    /**< timestamps vector for each ifo */
00136 } MultiLIGOTimeGPSVector;
00137 
00138 /*---------- Global variables ----------*/
00139 /* empty init-structs for the types defined in here */
00140 extern const SFTtype empty_SFTtype;
00141 extern const SFTVector empty_SFTVector;
00142 extern const PSDVector empty_PSDVector;
00143 extern const MultiSFTVector empty_MultiSFTVector;
00144 extern const MultiPSDVector empty_MultiPSDVector;
00145 extern const MultiNoiseWeights empty_MultiNoiseWeights;
00146 extern const MultiREAL4TimeSeries empty_MultiREAL4TimeSeries;
00147 extern const LIGOTimeGPSVector empty_LIGOTimeGPSVector;
00148 extern const MultiLIGOTimeGPSVector empty_MultiLIGOTimeGPSVector;
00149 
00150 /*---------- exported prototypes [API] ----------*/
00151 /* ----------------------------------------------------------------------
00152  *  some prototypes for general functions handling these data-types 
00153  *----------------------------------------------------------------------*/
00154 void LALCreateSFTtype (LALStatus *status, SFTtype **sft, UINT4 SFTlen); 
00155 void LALCreateSFTVector (LALStatus *status, SFTVector **sftvect, UINT4 numSFTs, UINT4 SFTlen);
00156 void LALCreateMultiSFTVector ( LALStatus *status, MultiSFTVector **out, UINT4 length, UINT4Vector *numsft );
00157 
00158 SFTVector* XLALCreateSFTVector (UINT4 numSFTs, UINT4 numBins );
00159 
00160 COMPLEX8Vector *XLALrefineCOMPLEX8Vector (const COMPLEX8Vector *in, UINT4 refineby, UINT4 Dterms);
00161 void upsampleMultiSFTVector (LALStatus *, MultiSFTVector *inout, UINT4 upsample, UINT4 Dterms);
00162 void upsampleSFTVector (LALStatus *, SFTVector *inout, UINT4 upsample, UINT4 Dterms);
00163 
00164 void XLALDestroySFTVector (SFTVector *vect);
00165 
00166 void LALDestroySFTtype (LALStatus *status, SFTtype **sft);
00167 void LALDestroySFTVector (LALStatus *status, SFTVector **sftvect);
00168 void LALDestroyPSDVector (LALStatus *status, PSDVector **vect);
00169 
00170 void LALDestroyMultiSFTVector (LALStatus *status, MultiSFTVector **multvect);
00171 void LALDestroyMultiPSDVector (LALStatus *status, MultiPSDVector **multvect);
00172 
00173 SFTVector* XLALExtractBandfromSFTs ( const SFTVector *sfts, REAL8 fMin, REAL8 fMax );
00174 void LALCopySFT (LALStatus *status, SFTtype *dest, const SFTtype *src);
00175 
00176 void LALSubtractSFTVectors (LALStatus *, SFTVector **outVect, const SFTVector *inVect1, const SFTVector *inVect2 );
00177 void LALLinearlyCombineSFTVectors (LALStatus *, SFTVector **outVect, SFTVector **inVects, const COMPLEX16Vector *weights, const CHAR *outName);
00178 void LALAppendSFT2Vector (LALStatus *, SFTVector *vect, const SFTtype *sft );
00179 
00180 LIGOTimeGPSVector *XLALCreateTimestampVector (UINT4 len);
00181 void XLALDestroyTimestampVector (LIGOTimeGPSVector *vect);
00182 
00183 void LALCreateTimestampVector (LALStatus *status, LIGOTimeGPSVector **vect, UINT4 len);
00184 void LALDestroyTimestampVector (LALStatus *status, LIGOTimeGPSVector **vect);
00185 
00186 void LALMakeTimestamps (LALStatus *, LIGOTimeGPSVector **timestamps, const LIGOTimeGPS tStart, REAL8 duration, REAL8 Tsft);
00187 void LALGetSFTtimestamps (LALStatus *, LIGOTimeGPSVector **timestamps, const SFTVector *sfts );
00188 
00189 CHAR *XLALGetChannelPrefix ( const CHAR *name );
00190 LALDetector *XLALGetSiteInfo ( const CHAR *name );
00191 
00192 void LALComputeNoiseWeights  (LALStatus *status, REAL8Vector *weightV, const SFTVector *sftVect, 
00193                               INT4 blkSize, UINT4 excludePercentile);
00194 void LALComputeMultiNoiseWeights  (LALStatus *status, MultiNoiseWeights **weightsV, const MultiPSDVector *multipsd, 
00195                                    UINT4 blocksRngMed, UINT4 excludePercentile);
00196 void LALDestroyMultiNoiseWeights  (LALStatus *status, MultiNoiseWeights **weights);
00197 
00198 #ifdef  __cplusplus
00199 }
00200 #endif  
00201 /* C++ protection. */
00202 
00203 #endif  /* Double-include protection. */

Generated on Sat Aug 30 03:13:11 2008 for LAL by  doxygen 1.5.2