LAL  7.5.0.1-08ee4f4
ResampleTimeSeries.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2007 Duncan Brown, Jolien Creighton, Patrick Brady
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with with program; see the file COPYING. If not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301 USA
18 */
19 
20 #include <lal/LALDatatypes.h>
21 #include <lal/BandPassTimeSeries.h>
22 
23 #ifndef _RESAMPLETIMESERIES_H
24 #define _RESAMPLETIMESERIES_H
25 
26 #if defined(__cplusplus)
27 extern "C" {
28 #elif 0
29 } /* so that editors will match preceding brace */
30 #endif
31 
32 /**
33  * \defgroup ResampleTimeSeries_h Header ResampleTimeSeries.h
34  * \ingroup lal_tools
35  * \author Brown, D. A.
36  *
37  * \brief Provides routines to resample a time series.
38  *
39  * At present only integer downsampling of \c REAL4TimeSeries by a power of two is supported.
40  *
41  * ### Synopsis ###
42  *
43  * \code
44  * #include <lal/ResampleTimeSeries.h>
45  * \endcode
46  *
47  * This header covers routines that resample time series by applying
48  * a low pass filter and decimating the resulting time series. Further
49  * documentation is given in the individual routines' modules.
50  *
51  */
52 /** @{ */
53 
54 /**\name Error Codes */
55 /** @{ */
56 #define RESAMPLETIMESERIESH_ENULL 1 /**< Null pointer */
57 #define RESAMPLETIMESERIESH_ENNUL 2 /**< Non-null pointer */
58 #define RESAMPLETIMESERIESH_EZERO 3 /**< Length of input time series is zero */
59 #define RESAMPLETIMESERIESH_ERATE 4 /**< Sample rate is zero */
60 #define RESAMPLETIMESERIESH_EUPSM 5 /**< Cannot upsample */
61 #define RESAMPLETIMESERIESH_EHIGH 6 /**< Input sample rate is greater than 32kHz */
62 #define RESAMPLETIMESERIESH_ELOG2 7 /**< Only power-of-two resampling is avaliable */
63 #define RESAMPLETIMESERIESH_EFILT 8 /**< Unknown filter type */
64 #define RESAMPLETIMESERIESH_EINVD 9 /**< Invalid or non-integer resample factor */
65 #define RESAMPLETIMESERIESH_ELDAS 10 /**< Input resample factor with LDAS FIR */
66 /** @} */
67 
68 /** \cond DONT_DOXYGEN */
69 #define RESAMPLETIMESERIESH_MSGENULL "Null pointer"
70 #define RESAMPLETIMESERIESH_MSGENNUL "Non-null pointer"
71 #define RESAMPLETIMESERIESH_MSGEZERO "Length of input time series is zero"
72 #define RESAMPLETIMESERIESH_MSGERATE "Sample rate is zero"
73 #define RESAMPLETIMESERIESH_MSGEUPSM "Cannot upsample"
74 #define RESAMPLETIMESERIESH_MSGEHIGH "Input sample rate is greater than 32kHz"
75 #define RESAMPLETIMESERIESH_MSGELOG2 "Only power-of-two resampling is avaliable"
76 #define RESAMPLETIMESERIESH_MSGEFILT "Unknown filter type"
77 #define RESAMPLETIMESERIESH_MSGEINVD "Invalid or non-integer resample factor"
78 #define RESAMPLETIMESERIESH_MSGELDAS "Input resample factor with LDAS FIR"
79 /** \endcond */
80 
81 /**
82  * This enum type contains the different low pass filters available to
83  * prevent power above the new Nyquist frequency entering the resampled
84  * time series due to aliasing.
85  */
86 typedef enum
87 tagResampleTSFilter
88 {
89  defaultButterworth, /**< An IIR butterwoth filter of order 20 with attenuation 0.1 at the new Nyquist frequency.
90  * See the package tdfilters for documentation of butterworth filters in LAL.
91  */
92  LDASfirLP /**< For downsampling by a factor of 2, 4 or 8 an
93  * implementation of the FIR filter used by the LDAS datacondAPI resample().
94  * This is provided for testing the result of standalone codes and codes
95  * running under LDAS. The LDAS filter provided here has filter order parameter
96  * 10, so the order of the filter is \f$2 \times 10 \times q\f$ where \f$q\f$ is the
97  * resampling ratio.
98  */
99 }
101 
102 
103 /**
104  * This union is provided so that the code can store the parameters of the
105  * filter in a place accessible by the user for user designed low pass filters.
106  * This is not presently implemented and this structure may be ignored.
107  */
108 typedef union
109 tagResampleTSFilterParams
110 {
111  PassBandParamStruc butterworth; /**< A structure of type \c PassBandParamStruc used to store the parameters
112  * of the butterworth filter used to perform low pass filtering
113  */
114  REAL8IIRFilter iirfilter; /**< A structure of type \c REAL8IIRFilter used to store the parameters of
115  * the IIR or FIR filter used to perform low pass filtering
116  */
117 }
119 
120 /**
121  * This structure controls the behaviour of the resampling function.
122  */
123 typedef struct
124 tagResampleTSParams
125 {
126  REAL8 deltaT; /**< The sample interval desired in the down sampled time series */
127  ResampleTSFilter filterType; /**< The type of filter with which to perform the low pass filtering */
128  ResampleTSFilterParams filterParams; /**< Filter parameters for the low pass filter (Presently ignored) */
129 }
131 
132 /** @} */
133 
134 /* ---------- Function prototypes ---------- */
135 
138 
139 void
141  LALStatus *status,
142  REAL4TimeSeries *ts,
143  ResampleTSParams *params
144  );
145 
146 #if 0
147 { /* so that editors will match succeeding brace */
148 #elif defined(__cplusplus)
149 }
150 #endif
151 
152 #endif /* _RESAMPLETIMESERIES_H */
153 
double REAL8
Double precision real floating-point number (8 bytes).
int XLALResampleREAL4TimeSeries(REAL4TimeSeries *series, REAL8 dt)
int XLALResampleREAL8TimeSeries(REAL8TimeSeries *series, REAL8 dt)
void LALResampleREAL4TimeSeries(LALStatus *status, REAL4TimeSeries *ts, ResampleTSParams *params)
ResampleTSFilter
This enum type contains the different low pass filters available to prevent power above the new Nyqui...
@ LDASfirLP
For downsampling by a factor of 2, 4 or 8 an implementation of the FIR filter used by the LDAS dataco...
@ defaultButterworth
An IIR butterwoth filter of order 20 with attenuation 0.1 at the new Nyquist frequency.
LAL status structure, see The LALStatus structure for more details.
Definition: LALDatatypes.h:947
This structure stores data used for constructing a low- or high-pass filter: either the order and cha...
Time series of REAL4 data, see DATATYPE-TimeSeries types for more details.
Definition: LALDatatypes.h:570
This structure stores the direct and recursive REAL8 filter coefficients, as well as the history of t...
Definition: IIRFilter.h:168
Time series of REAL8 data, see DATATYPE-TimeSeries types for more details.
Definition: LALDatatypes.h:580
This structure controls the behaviour of the resampling function.
ResampleTSFilter filterType
The type of filter with which to perform the low pass filtering.
REAL8 deltaT
The sample interval desired in the down sampled time series.
ResampleTSFilterParams filterParams
Filter parameters for the low pass filter (Presently ignored)
This union is provided so that the code can store the parameters of the filter in a place accessible ...
REAL8IIRFilter iirfilter
A structure of type REAL8IIRFilter used to store the parameters of the IIR or FIR filter used to perf...
PassBandParamStruc butterworth
A structure of type PassBandParamStruc used to store the parameters of the butterworth filter used to...