00001 /* 00002 * Copyright (C) 2007 Jolien Creighton 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 /*************************** <lalVerbatim file="ApplyResampleRulesCV"> 00021 Author: Creighton, T. D. 00022 Revision: $Id: ApplyResampleRules.c,v 1.3 2007/06/08 14:41:51 bema Exp $ 00023 **************************************************** </lalVerbatim> */ 00024 00025 /********************************************************** <lalLaTeX> 00026 00027 \subsection{Module \texttt{ApplyResampleRules.c}} 00028 \label{ss:ApplyResampleRules.c} 00029 00030 Resamples a time series according to a set of resampling rules. 00031 00032 \subsubsection*{Prototypes} 00033 \vspace{0.1in} 00034 \input{ApplyResampleRulesCP} 00035 \idx{LALApplyResampleRules()} 00036 00037 \subsubsection*{Description} 00038 00039 This function sets \verb@output->deltaT@ and fills \verb@output->data@ 00040 with data from \verb@*input@, using the resampling rules specified in 00041 \verb@*rules@. If the timespan required to fill \verb@output->data@ 00042 is not a subset of the timespan covered by \verb@*input@ or 00043 \verb@*rules@, the data at the nonintersecting times are set to zero. 00044 00045 \subsubsection*{Algorithm} 00046 00047 At present this routine is just a stub. It does not apply or even 00048 check \verb@*rules@, and instead simply makes \verb@*output@ 00049 equivalent to (a subset of) \verb@*input@. 00050 00051 \subsubsection*{Uses} 00052 00053 \subsubsection*{Notes} 00054 00055 \vfill{\footnotesize\input{ApplyResampleRulesCV}} 00056 00057 ******************************************************* </lalLaTeX> */ 00058 00059 #include <math.h> 00060 #include <lal/LALStdlib.h> 00061 #include <lal/LALConstants.h> 00062 #include <lal/AVFactories.h> 00063 #include <lal/Resample.h> 00064 00065 NRCSID(APPLYRESAMPLERULESC,"$Id: ApplyResampleRules.c,v 1.3 2007/06/08 14:41:51 bema Exp $"); 00066 00067 /* <lalVerbatim file="ApplyResampleRulesCP"> */ 00068 void 00069 LALApplyResampleRules( LALStatus *stat, 00070 REAL4TimeSeries *output, 00071 REAL4TimeSeries *input, 00072 ResampleRules *rules ) 00073 { /* </lalVerbatim> */ 00074 INT4 nStart, nStop; /* output domain for which we can get data */ 00075 00076 INITSTATUS(stat,"LALApplyResampleRules",APPLYRESAMPLERULESC); 00077 00078 /* Check that the inputs all exist. */ 00079 ASSERT(rules,stat,RESAMPLEH_ENUL,RESAMPLEH_MSGENUL); 00080 ASSERT(output,stat,RESAMPLEH_ENUL,RESAMPLEH_MSGENUL); 00081 ASSERT(output->data,stat,RESAMPLEH_ENUL,RESAMPLEH_MSGENUL); 00082 ASSERT(output->data->data,stat,RESAMPLEH_ENUL,RESAMPLEH_MSGENUL); 00083 ASSERT(input,stat,RESAMPLEH_ENUL,RESAMPLEH_MSGENUL); 00084 ASSERT(input->data,stat,RESAMPLEH_ENUL,RESAMPLEH_MSGENUL); 00085 ASSERT(input->data->data,stat,RESAMPLEH_ENUL,RESAMPLEH_MSGENUL); 00086 00087 /* Set the output sampling time. */ 00088 output->deltaT=input->deltaT; 00089 00090 /* Find the difference between the input and output start times, in 00091 samples. */ 00092 nStart=(INT4)((input->epoch.gpsSeconds-output->epoch.gpsSeconds) 00093 /output->deltaT); 00094 nStart+=(INT4)((input->epoch.gpsNanoSeconds 00095 -output->epoch.gpsNanoSeconds) 00096 /(1e9*output->deltaT)); 00097 if(nStart>(INT4)(output->data->length)) 00098 nStart=output->data->length; 00099 00100 /* Ditto for stop times. */ 00101 nStop=nStart+input->data->length; /* since deltaT's are equal */ 00102 if(nStop>(INT4)(output->data->length)) 00103 nStop=output->data->length; 00104 00105 if(nStart>0) 00106 memset(output->data->data,0,nStart*sizeof(REAL4)); 00107 if(nStop>nStart) 00108 memcpy(output->data->data+nStart,input->data->data, 00109 (nStop-nStart)*sizeof(REAL4)); 00110 if((INT4)(output->data->length)>nStop) 00111 memset(output->data->data+nStop,0, 00112 (output->data->length-nStop)*sizeof(REAL4)); 00113 00114 /* That's all for the current stub. */ 00115 RETURN(stat); 00116 }
1.5.2