Commit 92cbb8e3 authored by Cristina Valeria Torres's avatar Cristina Valeria Torres
Browse files

mergeing wandering autotrack branch into main development history

Original: cda01b1250583ffa2ddf58feaa4694577b8b3e60
parents ca772dd0 1f8705d8
define(`SCALE',`0')
define(`SKIP',`0')
ifelse(TYPECODE,`D', `define(`SCALE',`20')')
ifelse(TYPECODE,`D', `define(`SKIP',`1')')
ifelse(TYPECODE,`D', `define(`TYPE',`REAL8')')
ifelse(TYPECODE,`S', `define(`TYPE',`REAL4')')
ifelse(TYPECODE,`I2',`define(`TYPE',`INT2')')
ifelse(TYPECODE,`I4',`define(`TYPE',`INT4')')
ifelse(TYPECODE,`I8',`define(`TYPE',`INT8')')
ifelse(TYPECODE,`', `define(`TYPE',`REAL4')')
define(`XFUNC',`format(`XLALFrGet%sFrameConvertToREAL4TimeSeries',TYPE)')
define(`CREATESERIES',`format(`XLALCreate%sTimeSeries',TYPE)')
define(`GETMETA',`format(`XLALFrGet%sTimeSeriesMetadata',TYPE)')
define(`GETDATA',`format(`XLALFrGet%sTimeSeries',TYPE)')
define(`DESTROYSERIES',`format(`XLALDestroy%sTimeSeries',TYPE)')
define(`VARTYPE',`format(`%sTimeSeries',TYPE)')
int XFUNC (REAL4TimeSeries *inputSeries, FrStream *stream)
{
VARTYPE *tmpData=NULL;
VARTYPE *tmpData2=NULL;
REAL4TimeSeries *tmpData3=NULL;
UINT4 i=0;
INT4 errcode=0;
UINT4 loadPoints=0;
REAL8 factor=1;
tmpData=CREATESERIES (inputSeries->name,
&(inputSeries->epoch),
0,
inputSeries->deltaT,
&(inputSeries->sampleUnits),
inputSeries->data->length);
errcode=GETMETA (tmpData,stream);
if (errcode!=0)
{
fprintf(stderr,"GETMETA : Metadata on %s unavailable in stream.\n",tmpData->name);
fflush(stderr);
return errcode;
}
loadPoints=(1/tmpData->deltaT)*(inputSeries->deltaT*inputSeries->data->length);
tmpData2=CREATESERIES (tmpData->name,
&(tmpData->epoch),
0,
tmpData->deltaT,
&(tmpData->sampleUnits),
loadPoints);
if (tmpData)
DESTROYSERIES (tmpData);
errcode=GETDATA (tmpData2,stream);
if (errcode!=0)
{
fprintf(stderr,"GETDATA : Error getting data from frame stream!\n");
fflush(stderr);
return errcode;
}
errcode=XLALFrSeek(stream,&(tmpData2->epoch));
if (errcode!=0)
{
fprintf(stderr,"XLALFrSeek : Can not seek frame to start epoch?\n");
fflush(stderr);
return errcode;
}
if (SCALE > 0)
tmpData2->sampleUnits.powerOfTen=tmpData2->sampleUnits.powerOfTen-SCALE;
tmpData3=XLALCreateREAL4TimeSeries (tmpData2->name,
&(tmpData2->epoch),
0,
tmpData2->deltaT,
&(tmpData2->sampleUnits),
tmpData2->data->length);
factor=(1/pow(10,SCALE));
for (i=0;i<tmpData3->data->length;i++)
tmpData3->data->data[i]=((REAL4) tmpData2->data->data[i]*factor);
if (tmpData2)
DESTROYSERIES (tmpData2);
errcode=XLALResampleREAL4TimeSeries (tmpData3,inputSeries->deltaT);
if (errcode!=0)
{
fprintf(stderr,"XLALResampleREAL4TimeSeries : Error resampling from %6.2f Hz to %6.2f Hz\n.",(1/tmpData2->deltaT),(1/inputSeries->deltaT));
fflush(stderr);
return errcode;
}
for (i=0;i<inputSeries->data->length;i++)
inputSeries->data->data[i]=tmpData3->data->data[i];
return 0;
}
define(`SCALE',`0')
ifelse(TYPECODE,`D', `define(`SCALE',`20')')
ifelse(TYPECODE,`D', `define(`TYPE',`REAL8')')
ifelse(TYPECODE,`S', `define(`TYPE',`REAL4')')
ifelse(TYPECODE,`I2',`define(`TYPE',`INT2')')
ifelse(TYPECODE,`I4',`define(`TYPE',`INT4')')
ifelse(TYPECODE,`I8',`define(`TYPE',`INT8')')
ifelse(TYPECODE,`U2',`define(`TYPE',`UINT2')')
ifelse(TYPECODE,`U4',`define(`TYPE',`UINT4')')
ifelse(TYPECODE,`U8',`define(`TYPE',`UINT8')')
ifelse(TYPECODE,`', `define(`TYPE',`REAL4')')
define(`XFUNC',`format(`XLALFrGet%sFrameConvertToREAL4TimeSeries',TYPE)')
define(`CREATESERIES',`format(`XLALCreate%sTimeSeries',TYPE)')
define(`GETMETA',`format(`XLALFrGet%sTimeSeriesMetaData',TYPE)')
define(`GETDATA',`format(`XLALFrGet%sTimeSeriesData',TYPE)')
define(`DESTROYSERIES',`format(`XLALDestroy%sTimeSeries',TYPE)')
define(`VARTYPE',`format(`%sTimeSeries',TYPE)')
int XFUNC (REAL4TimeSeries *inputSeries, FrStream *stream);
/*
* Copyright (C) 2004, 2005 Cristina V. Torres
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with with program; see the file COPYING. If not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*/
/*
* Author: Cristina Valeria Torres (LIGO Livingston)
*/
#include "tracksearch.h"
#include "tracksearchToolbox.h"
#include <unistd.h>
NRCSID( TRACKSEARCHC, "tracksearch $Id$");
RCSID( "tracksearch $Id$");
int XLALFrGetREAL8FrameConvertToREAL4TimeSeries (REAL4TimeSeries *inputSeries, FrStream *stream)
{
REAL8TimeSeries *tmpData=NULL;
REAL8TimeSeries *tmpData2=NULL;
REAL4TimeSeries *tmpData3=NULL;
UINT4 i=0;
INT4 errcode=0;
UINT4 loadPoints=0;
REAL8 factor=1;
tmpData=XLALCreateREAL8TimeSeries (inputSeries->name,
&(inputSeries->epoch),
0,
inputSeries->deltaT,
&(inputSeries->sampleUnits),
inputSeries->data->length);
errcode=XLALFrGetREAL8TimeSeriesMetadata (tmpData,stream);
if (errcode!=0)
{
fprintf(stderr,"XLALFrGetREAL8TimeSeriesMetadata : Metadata on %s unavailable in stream.\n",tmpData->name);
fflush(stderr);
return errcode;
}
loadPoints=(1/tmpData->deltaT)*(inputSeries->deltaT*inputSeries->data->length);
tmpData2=XLALCreateREAL8TimeSeries (tmpData->name,
&(tmpData->epoch),
0,
tmpData->deltaT,
&(tmpData->sampleUnits),
loadPoints);
if (tmpData)
XLALDestroyREAL8TimeSeries (tmpData);
errcode=XLALFrGetREAL8TimeSeries (tmpData2,stream);
if (errcode!=0)
{
fprintf(stderr,"XLALFrGetREAL8TimeSeries : Error getting data from frame stream!\n");
fflush(stderr);
return errcode;
}
errcode=XLALFrSeek(stream,&(tmpData2->epoch));
if (errcode!=0)
{
fprintf(stderr,"XLALFrSeek : Can not seek frame to start epoch?\n");
fflush(stderr);
return errcode;
}
if (20 > 0)
tmpData2->sampleUnits.powerOfTen=tmpData2->sampleUnits.powerOfTen-20;
tmpData3=XLALCreateREAL4TimeSeries (tmpData2->name,
&(tmpData2->epoch),
0,
tmpData2->deltaT,
&(tmpData2->sampleUnits),
tmpData2->data->length);
factor=(1/pow(10,20));
for (i=0;i<tmpData3->data->length;i++)
tmpData3->data->data[i]=((REAL4) tmpData2->data->data[i]*factor);
if (tmpData2)
XLALDestroyREAL8TimeSeries (tmpData2);
errcode=XLALResampleREAL4TimeSeries (tmpData3,inputSeries->deltaT);
if (errcode!=0)
{
fprintf(stderr,"XLALResampleREAL4TimeSeries : Error resampling from %6.2f Hz to %6.2f Hz\n.",(1/tmpData2->deltaT),(1/inputSeries->deltaT));
fflush(stderr);
return errcode;
}
for (i=0;i<inputSeries->data->length;i++)
inputSeries->data->data[i]=tmpData3->data->data[i];
return 0;
}
int XLALFrGetREAL4FrameConvertToREAL4TimeSeries (REAL4TimeSeries *inputSeries, FrStream *stream)
{
REAL4TimeSeries *tmpData=NULL;
REAL4TimeSeries *tmpData2=NULL;
REAL4TimeSeries *tmpData3=NULL;
UINT4 i=0;
INT4 errcode=0;
UINT4 loadPoints=0;
REAL8 factor=1;
tmpData=XLALCreateREAL4TimeSeries (inputSeries->name,
&(inputSeries->epoch),
0,
inputSeries->deltaT,
&(inputSeries->sampleUnits),
inputSeries->data->length);
errcode=XLALFrGetREAL4TimeSeriesMetadata (tmpData,stream);
if (errcode!=0)
{
fprintf(stderr,"XLALFrGetREAL4TimeSeriesMetadata : Metadata on %s unavailable in stream.\n",tmpData->name);
fflush(stderr);
return errcode;
}
loadPoints=(1/tmpData->deltaT)*(inputSeries->deltaT*inputSeries->data->length);
tmpData2=XLALCreateREAL4TimeSeries (tmpData->name,
&(tmpData->epoch),
0,
tmpData->deltaT,
&(tmpData->sampleUnits),
loadPoints);
if (tmpData)
XLALDestroyREAL4TimeSeries (tmpData);
errcode=XLALFrGetREAL4TimeSeries (tmpData2,stream);
if (errcode!=0)
{
fprintf(stderr,"XLALFrGetREAL4TimeSeries : Error getting data from frame stream!\n");
fflush(stderr);
return errcode;
}
errcode=XLALFrSeek(stream,&(tmpData2->epoch));
if (errcode!=0)
{
fprintf(stderr,"XLALFrSeek : Can not seek frame to start epoch?\n");
fflush(stderr);
return errcode;
}
if (0 > 0)
tmpData2->sampleUnits.powerOfTen=tmpData2->sampleUnits.powerOfTen-0;
tmpData3=XLALCreateREAL4TimeSeries (tmpData2->name,
&(tmpData2->epoch),
0,
tmpData2->deltaT,
&(tmpData2->sampleUnits),
tmpData2->data->length);
factor=(1/pow(10,0));
for (i=0;i<tmpData3->data->length;i++)
tmpData3->data->data[i]=((REAL4) tmpData2->data->data[i]*factor);
if (tmpData2)
XLALDestroyREAL4TimeSeries (tmpData2);
errcode=XLALResampleREAL4TimeSeries (tmpData3,inputSeries->deltaT);
if (errcode!=0)
{
fprintf(stderr,"XLALResampleREAL4TimeSeries : Error resampling from %6.2f Hz to %6.2f Hz\n.",(1/tmpData2->deltaT),(1/inputSeries->deltaT));
fflush(stderr);
return errcode;
}
for (i=0;i<inputSeries->data->length;i++)
inputSeries->data->data[i]=tmpData3->data->data[i];
return 0;
}
int XLALFrGetINT2FrameConvertToREAL4TimeSeries (REAL4TimeSeries *inputSeries, FrStream *stream)
{
INT2TimeSeries *tmpData=NULL;
INT2TimeSeries *tmpData2=NULL;
REAL4TimeSeries *tmpData3=NULL;
UINT4 i=0;
INT4 errcode=0;
UINT4 loadPoints=0;
REAL8 factor=1;
tmpData=XLALCreateINT2TimeSeries (inputSeries->name,
&(inputSeries->epoch),
0,
inputSeries->deltaT,
&(inputSeries->sampleUnits),
inputSeries->data->length);
errcode=XLALFrGetINT2TimeSeriesMetadata (tmpData,stream);
if (errcode!=0)
{
fprintf(stderr,"XLALFrGetINT2TimeSeriesMetadata : Metadata on %s unavailable in stream.\n",tmpData->name);
fflush(stderr);
return errcode;
}
loadPoints=(1/tmpData->deltaT)*(inputSeries->deltaT*inputSeries->data->length);
tmpData2=XLALCreateINT2TimeSeries (tmpData->name,
&(tmpData->epoch),
0,
tmpData->deltaT,
&(tmpData->sampleUnits),
loadPoints);
if (tmpData)
XLALDestroyINT2TimeSeries (tmpData);
errcode=XLALFrGetINT2TimeSeries (tmpData2,stream);
if (errcode!=0)
{
fprintf(stderr,"XLALFrGetINT2TimeSeries : Error getting data from frame stream!\n");
fflush(stderr);
return errcode;
}
errcode=XLALFrSeek(stream,&(tmpData2->epoch));
if (errcode!=0)
{
fprintf(stderr,"XLALFrSeek : Can not seek frame to start epoch?\n");
fflush(stderr);
return errcode;
}
if (0 > 0)
tmpData2->sampleUnits.powerOfTen=tmpData2->sampleUnits.powerOfTen-0;
tmpData3=XLALCreateREAL4TimeSeries (tmpData2->name,
&(tmpData2->epoch),
0,
tmpData2->deltaT,
&(tmpData2->sampleUnits),
tmpData2->data->length);
factor=(1/pow(10,0));
for (i=0;i<tmpData3->data->length;i++)
tmpData3->data->data[i]=((REAL4) tmpData2->data->data[i]*factor);
if (tmpData2)
XLALDestroyINT2TimeSeries (tmpData2);
errcode=XLALResampleREAL4TimeSeries (tmpData3,inputSeries->deltaT);
if (errcode!=0)
{
fprintf(stderr,"XLALResampleREAL4TimeSeries : Error resampling from %6.2f Hz to %6.2f Hz\n.",(1/tmpData2->deltaT),(1/inputSeries->deltaT));
fflush(stderr);
return errcode;
}
for (i=0;i<inputSeries->data->length;i++)
inputSeries->data->data[i]=tmpData3->data->data[i];
return 0;
}
int XLALFrGetINT4FrameConvertToREAL4TimeSeries (REAL4TimeSeries *inputSeries, FrStream *stream)
{
INT4TimeSeries *tmpData=NULL;
INT4TimeSeries *tmpData2=NULL;
REAL4TimeSeries *tmpData3=NULL;
UINT4 i=0;
INT4 errcode=0;
UINT4 loadPoints=0;
REAL8 factor=1;
tmpData=XLALCreateINT4TimeSeries (inputSeries->name,
&(inputSeries->epoch),
0,
inputSeries->deltaT,
&(inputSeries->sampleUnits),
inputSeries->data->length);
errcode=XLALFrGetINT4TimeSeriesMetadata (tmpData,stream);
if (errcode!=0)
{
fprintf(stderr,"XLALFrGetINT4TimeSeriesMetadata : Metadata on %s unavailable in stream.\n",tmpData->name);
fflush(stderr);
return errcode;
}
loadPoints=(1/tmpData->deltaT)*(inputSeries->deltaT*inputSeries->data->length);
tmpData2=XLALCreateINT4TimeSeries (tmpData->name,
&(tmpData->epoch),
0,
tmpData->deltaT,
&(tmpData->sampleUnits),
loadPoints);
if (tmpData)
XLALDestroyINT4TimeSeries (tmpData);
errcode=XLALFrGetINT4TimeSeries (tmpData2,stream);
if (errcode!=0)
{
fprintf(stderr,"XLALFrGetINT4TimeSeries : Error getting data from frame stream!\n");
fflush(stderr);
return errcode;
}
errcode=XLALFrSeek(stream,&(tmpData2->epoch));
if (errcode!=0)
{
fprintf(stderr,"XLALFrSeek : Can not seek frame to start epoch?\n");
fflush(stderr);
return errcode;
}
if (0 > 0)
tmpData2->sampleUnits.powerOfTen=tmpData2->sampleUnits.powerOfTen-0;
tmpData3=XLALCreateREAL4TimeSeries (tmpData2->name,
&(tmpData2->epoch),
0,
tmpData2->deltaT,
&(tmpData2->sampleUnits),
tmpData2->data->length);
factor=(1/pow(10,0));
for (i=0;i<tmpData3->data->length;i++)
tmpData3->data->data[i]=((REAL4) tmpData2->data->data[i]*factor);
if (tmpData2)
XLALDestroyINT4TimeSeries (tmpData2);
errcode=XLALResampleREAL4TimeSeries (tmpData3,inputSeries->deltaT);
if (errcode!=0)
{
fprintf(stderr,"XLALResampleREAL4TimeSeries : Error resampling from %6.2f Hz to %6.2f Hz\n.",(1/tmpData2->deltaT),(1/inputSeries->deltaT));
fflush(stderr);
return errcode;
}
for (i=0;i<inputSeries->data->length;i++)
inputSeries->data->data[i]=tmpData3->data->data[i];
return 0;
}
int XLALFrGetINT8FrameConvertToREAL4TimeSeries (REAL4TimeSeries *inputSeries, FrStream *stream)
{
INT8TimeSeries *tmpData=NULL;
INT8TimeSeries *tmpData2=NULL;
REAL4TimeSeries *tmpData3=NULL;
UINT4 i=0;
INT4 errcode=0;
UINT4 loadPoints=0;
REAL8 factor=1;
tmpData=XLALCreateINT8TimeSeries (inputSeries->name,
&(inputSeries->epoch),
0,
inputSeries->deltaT,
&(inputSeries->sampleUnits),
inputSeries->data->length);
errcode=XLALFrGetINT8TimeSeriesMetadata (tmpData,stream);
if (errcode!=0)
{
fprintf(stderr,"XLALFrGetINT8TimeSeriesMetadata : Metadata on %s unavailable in stream.\n",tmpData->name);
fflush(stderr);
return errcode;
}
loadPoints=(1/tmpData->deltaT)*(inputSeries->deltaT*inputSeries->data->length);
tmpData2=XLALCreateINT8TimeSeries (tmpData->name,
&(tmpData->epoch),
0,
tmpData->deltaT,
&(tmpData->sampleUnits),
loadPoints);
if (tmpData)
XLALDestroyINT8TimeSeries (tmpData);
errcode=XLALFrGetINT8TimeSeries (tmpData2,stream);
if (errcode!=0)
{
fprintf(stderr,"XLALFrGetINT8TimeSeries : Error getting data from frame stream!\n");
fflush(stderr