47#define ROUND(a) (floor(a+0.5))
50#define MAXALLOC 1048576
59 pid_t mypid = getpid();
62 snprintf(
commandline,
sizeof(
commandline ),
"cat /proc/%d/status | /bin/grep Vm | /usr/bin/fmt -140 -u", (
int )mypid );
74int main(
int argc,
char *argv[] )
86 CHAR outputfile[256] =
"";
100 fprintf( stderr,
"Memory use at start of the code:\n" );
128 fprintf( stderr,
"No pulsar name specified!\n" );
142 fprintf( stderr,
"I've read in the pulsar parameters for %s.\n", psrname );
143 REAL8 rav, decv, pepochv;
156 fprintf( stderr,
"alpha = %lf rads, delta = %lf rads.\n", rav, decv );
166 fprintf( stderr,
"epoch = %.1lf.\n", pepochv );
169 fprintf( stderr,
"I'm looking for gravitational waves at %.2lf times the pulsars spin frequency.\n", inputParams.
freqfactor );
183 fprintf( stderr,
"I've set the detector location for %s.\n", inputParams.
ifo );
197 fprintf( stderr,
"I've read the updated parameters for %s.\n", psrname );
199 REAL8 rav, decv, pepochv;
212 fprintf( stderr,
"alpha = %lf rads, delta = %lf rads.\n", rav, decv );
222 fprintf( stderr,
"epoch = %.1lf.\n", pepochv );
264 fprintf( stderr,
"I've read in the segment list.\n" );
270 fprintf( stderr,
"Error... There's been a problem reading in the frame \
276 fprintf( stderr,
"I've read in the frame list.\n" );
283 fprintf( stderr,
"REMINDER: You aren't giving a filter knee frequency from\
284 the coarse heterodyne stage! You could be reheterodyning data that has\
285 already had the filter response removed, but are you sure this is what you're\
305 fprintf( stderr,
"I've set up the filters.\n" );
310 snprintf( outputfile,
sizeof( outputfile ),
"%s", inputParams.
outputfile );
315 XLALPrintError(
"Error... do not use a \".gz\" file extension for a binary output file\n" );
329 if ( ( fpout = fopen( outputfile,
"w" ) ) == NULL ) {
330 fprintf( stderr,
"Error... can't open output file %s!\n", outputfile );
339 for (
INT4 j = 0;
j < argc;
j++ ) {
343 CHAR dataline[] =
"\n%% GPS time\tReal\tImag\n";
344 if ( strlen( headerinfo ) + strlen( dataline ) >
HEADERSIZE ) {
345 fprintf( stderr,
"Error... HEADERSIZE needs to be increased to accommodate information\n" );
352 memcpy( &headerinfo[
HEADERSIZE - strlen( dataline )], &dataline[0],
sizeof(
CHAR )*strlen( dataline ) );
355 size_t rc = fwrite( &headerinfo[0],
sizeof(
CHAR ),
HEADERSIZE, fpout );
356 if ( ferror( fpout ) || !rc ) {
357 fprintf( stderr,
"Error... problem writing out header data!\n" );
367 fprintf( stderr,
"Memory use before entering main loop:\n" );
397 if ( stops->data[
count] <=
cache->list[0].t0 ) {
423 fprintf( stderr,
"Error... no frame files listed between %d and %d.\n",
426 if (
count < numSegs ) {
446 fprintf( stderr,
"Error... could not open frame files between %d and \
449 if (
count < numSegs ) {
492 fprintf( stderr,
"Reading heterodyned data from %s.\n", inputParams.
datafile );
496 fprintf( stderr,
"Error... Can't open input data file!\n" );
505 fprintf( stderr,
"Error... problem reading in header data!\n" );
526 if ( !isfinite( reVal ) || !isfinite( imVal ) || fabs( reVal ) > 1. || fabs( imVal ) > 1. ) {
535 data->data->data[
i] = reVal + I * imVal;
538 if ( times->
data[
i] > temptime ) {
539 temptime = times->
data[
i];
566 if ( sscanf( linebuf,
"%lf%lf%lf", ×->
data[
i], &reVal, &imVal ) != 3 ) {
572 if ( !isfinite( reVal ) || !isfinite( imVal ) || fabs( reVal ) > 1. || fabs( imVal ) > 1. ) {
581 data->data->data[
i] = reVal + I * imVal;
584 if ( times->
data[
i] > temptime ) {
585 temptime = times->
data[
i];
615 fprintf( stderr,
"I've read in the fine heterodyne data.\n" );
618 fprintf( stderr,
"Error... Heterodyne flag = %d, should be 0, 1, 2, 3 or 4.\n", inputParams.
heterodyneflag );
627 fprintf( stderr,
"I've heterodyned the data.\n" );
635 fprintf( stderr,
"I've low pass filtered the data at %.2lf Hz\n", inputParams.
filterknee );
656 INT4 numOutliers = 0;
660 fprintf( stderr,
"I've removed %lf%% of data above the threshold %.1lf sigma for 1st time.\n",
661 100.*(
double )numOutliers / (
double )resampData->
data->
length,
677 INT4 numOutliers = 0;
681 fprintf( stderr,
"I've removed %lf%% of data above the threshold %.1lf sigma for 2nd time.\n",
682 100.*(
double )numOutliers / (
double )resampData->
data->
length,
689 if ( ( fpout = fopen( outputfile,
"ab" ) ) == NULL ) {
690 fprintf( stderr,
"Error... can't open output file %s!\n", outputfile );
694 if ( ( fpout = fopen( outputfile,
"a" ) ) == NULL ) {
695 fprintf( stderr,
"Error... can't open output file %s!\n", outputfile );
702 if ( setvbuf( fpout, NULL, _IOFBF, 0x100000 ) ) {
703 fprintf( stderr,
"Warning: Unable to set output file buffer!" );
711 REAL8 tempreal, tempimag;
713 tempreal = creal( resampData->
data->
data[
i] );
714 tempimag = cimag( resampData->
data->
data[
i] );
722 rc = fwrite( ×->
data[
i],
sizeof(
REAL8 ), 1, fpout );
723 rc = fwrite( &tempreal,
sizeof(
REAL8 ), 1, fpout );
724 rc = fwrite( &tempimag,
sizeof(
REAL8 ), 1, fpout );
726 if ( ferror( fpout ) || !rc ) {
727 fprintf( stderr,
"Error... problem writing out data to binary file!\n" );
743 fprintf( stderr,
"I've output the data.\n" );
755 fprintf( stderr,
"Error... no data was read in.\n" );
761 fprintf( stderr,
"Outputing %s to gzipped file\n", outputfile );
768 fprintf( stderr,
"Memory usage after completion of main loop:\n" );
772 fprintf( stderr,
"Heterodyning complete.\n" );
790 fprintf( stderr,
"I've destroyed all filters.\n" );
794 if ( filtresp != NULL ) {
804 fprintf( stderr,
"Memory use at the end of the code:\n" );
851 char args[] =
"hi:p:z:f:g:k:s:r:d:D:c:o:e:S:t:l:R:C:F:O:T:m:G:H:M:ABbZLvP";
855 inputParams->
pulsar = NULL;
882 snprintf( inputParams->
channel,
sizeof( inputParams->
channel ),
"DARM_ERR" );
888 int option_index = 0;
898 if ( long_options[option_index].
flag ) {
901 fprintf( stderr,
"Error parsing option %s with argument %s\n",
911 snprintf( inputParams->
ifo,
sizeof( inputParams->
ifo ),
"%s",
LALoptarg );
943 CHAR numerator[10] =
"", *denominator = NULL;
953 inputParams->
filterknee = atof( numerator ) / atof( denominator );
962 CHAR numerator[10] =
"", *denominator = NULL;
971 inputParams->
samplerate = atof( numerator ) / atof( denominator );
980 CHAR numerator[10] =
"", *denominator = NULL;
989 inputParams->
resamplerate = atof( numerator ) / atof( denominator );
1004 snprintf( inputParams->
channel,
sizeof( inputParams->
channel ),
"%s",
1016 snprintf( inputParams->
sunfile,
sizeof( inputParams->
sunfile ),
"%s",
1023 snprintf( inputParams->
segfile,
sizeof( inputParams->
segfile ),
"%s",
1045 CHAR numerator[10] =
"", *denominator = NULL;
1055 inputParams->
freqfactor = atof( numerator ) / atof( denominator );
1077 fprintf( stderr,
"unknown error while parsing options\n" );
1080 fprintf( stderr,
"unknown error while parsing options\n" );
1088 fprintf( stderr,
"Error... sample rate and/or resample rate has not been \
1093 fprintf( stderr,
"Error... sample rate is less than the resample rate.\n" );
1106 fprintf( stderr,
"Error... data chunk length must be greater than zero.\n" );
1111 fprintf( stderr,
"Error... frequency factor must be greater than zero.\n" );
1119 fprintf( stderr,
"Error... binary input should not be set for coarse \
1130 REAL8 phaseCoarse = 0., phaseUpdate = 0., deltaphase = 0.;
1131 REAL8 t = 0.,
t2 = 0., tdt = 0.,
T0 = 0., T0Update = 0.;
1146 REAL8 df = 0., fcoarse = 0., ffine = 0., resp = 0.,
srate = 0.;
1147 REAL8 filtphase = 0.;
1148 UINT4 position = 0, middle = 0;
1152 FILE *fpphase = NULL;
1155 REAL8 pepoch = 0., pepochu = 0., posepoch = 0., posepochu = 0.;
1158 if ( pepoch == 0. && posepoch != 0. ) {
1160 }
else if ( posepoch == 0. && pepoch != 0. ) {
1164 REAL8 waveepoch = 0., waveepochu = 0.;
1173 if ( pepochu == 0. && posepochu != 0. ) {
1174 pepochu = posepochu;
1175 }
else if ( posepochu == 0. && pepochu != 0. ) {
1176 posepochu = pepochu;
1181 waveepochu = pepochu;
1212 baryinput.
dInv = 0.;
1219 baryinput.
dInv = 0.;
1224 REAL8 ra, dec, rau, decu;
1246 REAL8 pmra, pmdec, pmrau, pmdecu;
1262 REAL8 *glep = NULL, *glph = NULL, *glf0 = NULL, *glf1 = NULL, *glf2 = NULL, *glf0d = NULL, *gltd = NULL;
1266 glnum = gleppars->
length;
1271 glep[
i] = gleppars->
data[
i];
1279 glph[
i] = glpars->
data[
i];
1288 glf0[
i] = glpars->
data[
i];
1297 glf1[
i] = glpars->
data[
i];
1306 glf2[
i] = glpars->
data[
i];
1315 glf0d[
i] = glpars->
data[
i];
1324 gltd[
i] = glpars->
data[
i];
1330 fpphase = fopen(
"phase.txt",
"w" );
1333 for (
i = 0;
i < hetParams.
length;
i++ ) {
1336 REAL8 phaseWave = 0.;
1337 REAL8 phaseGlitch = 0.;
1351 baryinput.
delta = dec + dtpos * pmdec;
1352 baryinput.
alpha = ra + dtpos * pmra / cos( baryinput.
delta );
1369 binInput.
earth = earth;
1381 if ( cgw > 0. && cgw < 1. ) {
1396 tWave += wavesin->
data[
k] * sin( om * (
REAL8 )(
k + 1. ) * dtWave ) + wavecos->
data[
k] * cos( om * (
REAL8 )(
k + 1. ) * dtWave );
1398 phaseWave = freqs->
data[0] * freqfactor * tWave;
1404 for (
UINT4 k = 0;
k < glnum;
k++ ) {
1405 if ( tdt >= glep[
k] -
T0 ) {
1406 REAL8 dtg = 0, expd = 1.;
1407 dtg = tdt - ( glep[
k] -
T0 );
1408 if ( gltd[
k] != 0. ) {
1409 expd = exp( -dtg / gltd[
k] );
1412 phaseGlitch += glph[
k] + glf0[
k] * dtg + 0.5 * glf1[
k] * dtg * dtg + ( 1. / 6. ) * glf2[
k] * dtg * dtg * dtg + glf0d[
k] * gltd[
k] * ( 1. - expd );
1415 phaseGlitch *= freqfactor;
1421 REAL8 taylorcoeff = 1.;
1424 taylorcoeff /= (
REAL8 )(
k + 1 );
1425 phaseCoarse += taylorcoeff * freqs->
data[
k] * tdttmp;
1428 phaseCoarse *= freqfactor;
1429 phaseCoarse += phaseWave + phaseGlitch;
1433 fcoarse = freqs->
data[0];
1436 taylorcoeff /= (
REAL8 )
k;
1437 fcoarse += taylorcoeff * freqs->
data[
k] * tdttmp;
1440 fcoarse *= freqfactor;
1442 if ( freqsu != NULL ) {
1444 ffine = freqsu->
data[0];
1447 taylorcoeff /= (
REAL8 )
k;
1448 ffine += taylorcoeff * freqsu->
data[
k] * tdttmp;
1451 ffine *= freqfactor;
1458 REAL8 tWave1 = 0., tWave2 = 0.;
1462 dtpos = hetParams.
timestamp - posepochu;
1464 baryinput.
delta = decu + dtpos * pmdecu;
1465 baryinput.
alpha = rau + dtpos * pmrau / cos( baryinput.
delta );
1470 baryinput2 = baryinput;
1499 tdt = (
t - T0Update ) + emit.
deltaT;
1512 tWave1 += wavesin->
data[
k] * sin( omu * (
REAL8 )(
k + 1. ) * dtWave ) + wavecos->
data[
k] * cos( omu * (
REAL8 )(
k + 1. ) * dtWave );
1513 tWave2 += wavesin->
data[
k] * sin( omu * (
REAL8 )(
k + 1. ) * ( dtWave + ( 1. / 86400. ) ) ) + wavecos->
data[
k] * cos( omu * (
REAL8 )(
k + 1. ) * ( dtWave + ( 1. / 86400. ) ) );
1515 phaseWave = freqsu->
data[0] * freqfactor * tWave1;
1518 if ( filtresp != NULL ) {
1521 if ( cgwu > 0. && cgwu < 1. ) {
1524 df += ( ffine - fcoarse );
1531 position = middle + (
INT4 )floor(
df / filtresp->
deltaf );
1535 if ( cgwu > 0. && cgwu < 1. ) {
1544 taylorcoeff /= (
REAL8 )(
k + 1 );
1545 phaseUpdate += taylorcoeff * freqsu->
data[
k] * tdttmp;
1548 phaseUpdate *= freqfactor;
1553 for (
UINT4 k = 0;
k < glnum;
k++ ) {
1554 if ( tdt >= glep[
k] - T0Update ) {
1555 REAL8 dtg = 0, expd = 1.;
1556 dtg = tdt - ( glep[
k] - T0Update );
1557 if ( gltd[
k] != 0. ) {
1558 expd = exp( -dtg / gltd[
k] );
1561 phaseGlitch += glph[
k] + glf0[
k] * dtg + 0.5 * glf1[
k] * dtg * dtg + ( 1. / 6. ) * glf2[
k] * dtg * dtg * dtg + glf0d[
k] * gltd[
k] * ( 1. - expd );
1564 phaseGlitch *= freqfactor;
1567 phaseUpdate += phaseWave + phaseGlitch;
1571 dataTemp =
data->data->data[
i];
1575 deltaphase = 2.*
LAL_PI * fmod( phaseCoarse, 1. );
1576 dataTemp = creal( dataTemp );
1580 deltaphase = 2.*
LAL_PI * fmod( phaseUpdate - phaseCoarse, 1. );
1584 if ( filtresp != NULL ) {
1589 filtphase = fmod( filtphase - filtresp->
phaseResp->
data[middle],
1597 dataTemp2 = dataTemp;
1599 dataTemp = ( 1. / resp ) * ( creal( dataTemp2 ) * cos( filtphase ) - cimag( dataTemp2 ) * sin( filtphase ) ) +
1600 I * ( 1. / resp ) * ( creal( dataTemp2 ) * sin( filtphase ) + cimag( dataTemp2 ) * cos( filtphase ) );
1604 if ( fpphase != NULL ) {
1605 fprintf( fpphase,
"%.9lf\n", deltaphase );
1608 data->data->data[
i] = ( creal( dataTemp ) * cos( -deltaphase ) - cimag( dataTemp ) * sin( -deltaphase ) ) +
1609 I * ( creal( dataTemp ) * sin( -deltaphase ) + cimag( dataTemp ) * cos( -deltaphase ) );
1620 if ( fpphase != NULL ) {
1631 if ( framefile == NULL ) {
1632 fprintf( stderr,
"Error... Frame filename is not specified!\n" );
1639 for (
j = strlen( framefile ) - 1;
j >= 0;
j-- )
1640 if ( strstr( ( framefile +
j ),
"-" ) != NULL ) {
1645 *
gpstime = atof( framefile +
j - 9 );
1686 for (
i = 0;
i < (
INT4 )length;
i++ ) {
1688 if ( isnan( tseries->
data->
data[
i] ) != 0 ) {
1706 for (
i = 0;
i < (
INT4 )length;
i++ ) {
1708 if ( isnan( dblseries->
data->
data[
i] ) != 0 ) {
1717 fprintf( stderr,
"Error... Channel name %s is not recognised as a proper channel.\n",
channel );
1722 if ( highpass > 0. ) {
1726 highpasspar.
nMax = 8;
1727 highpasspar.
f1 = -1;
1728 highpasspar.
a1 = -1;
1729 highpasspar.
f2 = highpass;
1730 highpasspar.
a2 = 0.9;
1747 wc = tan(
LAL_PI * filterKnee / samplerate );
1749 zpg->
poles->
data[0] = ( wc * sqrt( 3. ) / 2. ) + I * ( wc * 0.5 );
1751 zpg->
poles->
data[2] = -( wc * sqrt( 3. ) / 2. ) + I * ( wc * 0.5 );
1752 zpg->
gain = I * wc * wc * wc;
1781 for (
i = 0;
i < (
INT4 )
data->data->length;
i++ ) {
1791 data->data->data[
i] = creal( tempData ) + I * cimag( tempData );
1802 INT4 i = 0,
j = 0,
k = 0, length;
1809 epoch.gpsSeconds = 0;
1810 epoch.gpsNanoSeconds = 0;
1812 if ( sampleRate != resampleRate ) {
1813 length = (
INT4 )floor(
ROUND( resampleRate *
data->data->length ) / sampleRate );
1815 length =
data->data->length;
1822 XLALPrintError(
"Error creating time series for resampled data.\n" );
1825 if ( hetflag == 0 || hetflag == 3 ) {
1830 for (
j = 0;
j <
size;
j++ ) {
1831 tempData +=
data->data->data[
i +
j];
1840 if ( sampleRate != resampleRate ) {
1842 (
REAL8 )
data->epoch.gpsNanoSeconds / 1.e9 + ( 1. / resampleRate ) / 2. +
1851 }
else if ( hetflag == 1 || hetflag == 2 || hetflag == 4 ) {
1856 INT4 rremainder = 0;
1858 INT4 frombeg = 0, fromend = 0;
1872 starts->
data[
i] = times->
data[
j] - ( ( 1. / sampleRate ) / 2. );
1878 stops->
data[
i] = times->
data[times->
length - 1] + ( ( 1. / sampleRate ) / 2. );
1882 fprintf( stderr,
"Segment %d to %d is outside the times of the data!\n", starts->
data[
i], stops->
data[
i] );
1883 fprintf( stderr,
"End resampling\n" );
1891 starts->
data[
i] = times->
data[
j] - ( ( 1. / sampleRate ) / 2. );
1903 if ( ( times->
data[
j +
k + 1] - times->
data[
j +
k] ) > 1. / sampleRate ) {
1908 starts->
data[
i] = times->
data[
j +
k + 1] - ( ( 1. / sampleRate ) / 2. );
1926 if ( sampleRate != resampleRate ) {
1927 frombeg = floor( rremainder / 2 );
1928 fromend = ceil( rremainder / 2 );
1939 for (
k = 0;
k <
size;
k++ ) {
1940 tempData +=
data->data->data[
j +
k];
1944 if ( sampleRate != resampleRate ) {
1966 series->
deltaT = 1. / resampleRate;
1974 INT4 heterodyneflag )
1984 if ( (
fp = fopen( seglistfile,
"r" ) ) == NULL ) {
1985 fprintf( stderr,
"Error... can't open science segment list file.\n" );
1990 while ( ( ch = fgetc(
fp ) ) != EOF ) {
1997 if ( linecount == 0 ) {
1998 fprintf( stderr,
"Warning... segment list file was empty, so no heterodyne will be performed\n" );
2013 while ( !feof(
fp ) ) {
2014 offset = ftell(
fp );
2016 if (
fscanf(
fp,
"%s", jnkstr ) == EOF ) {
2021 if ( strstr( jnkstr,
"#" ) ) {
2023 if (
fscanf(
fp,
"%*[^\n]" ) == EOF ) {
2028 fseek(
fp, offset, SEEK_SET );
2039 if ( heterodyneflag == 1 || heterodyneflag == 2 ) {
2041 starts->
data[
i] += 60;
2059 INT4 *position,
INT4 maxchunklength )
2062 INT4 tempstart, tempstop;
2065 durlock = *stops - *starts;
2066 tempstart = *starts;
2071 fprintf( stderr,
"Error... could not duplicate frame cache file\n" );
2076 if ( durlock > maxchunklength ) {
2077 tempstop = tempstart + maxchunklength;
2080 if (
XLALCacheSieve( smalllist, tempstart, tempstop, NULL, NULL, NULL ) != 0 ) {
2081 fprintf( stderr,
"Error... could not import frame cache file\n" );
2085 if ( durlock > maxchunklength ) {
2091 if ( smalllist->
length == 0 ) {
2104 FILE *fpcoeff = NULL;
2105 REAL8 Rfunc, Rphase;
2108 INT4 i = 0,
j = 0,
k = 0, ktemp = 0, counter = 0;
2117 fprintf( stderr,
"No calibration coefficient file.\n\
2118Assume calibration coefficients are 1 and use the response function.\n" );
2126 series->
data->
data[
i] = Rfunc * ( creal( tempData ) * cos( Rphase ) - cimag( tempData ) * sin( Rphase ) ) +
2127 I * Rfunc * ( creal( tempData ) * sin( Rphase ) + cimag( tempData ) * cos( Rphase ) );
2132 REAL8 *times = NULL;
2137 fprintf( stderr,
"Error... can't open calibration coefficient file %s.\n\
2138Assume calibration coefficients are 1 and use the response function.\n",
2157 while ( !feof( fpcoeff ) ) {
2158 offset = ftell( fpcoeff );
2160 if (
fscanf( fpcoeff,
"%s", jnkstr ) == EOF ) {
2165 if ( strstr( jnkstr,
"%" ) ) {
2166 rc =
fscanf( fpcoeff,
"%*[^\n]" );
2174 fseek( fpcoeff, offset, SEEK_SET );
2178 if (
i != 0 &&
i % 100 == 0 ) {
2179 if ( ( times =
XLALRealloc( times,
sizeof(
REAL8 ) * (
i + 100 ) ) ) == NULL ) {
2180 fprintf( stderr,
"Error... times memory allocation failed\n" );
2184 fprintf( stderr,
"Error... alpha memory allocation failed\n" );
2187 if ( ( ggamma =
XLALRealloc( ggamma,
sizeof(
REAL8 ) * (
i + 100 ) ) ) == NULL ) {
2188 fprintf( stderr,
"Error... gamma memory allocation failed\n" );
2193 if (
fscanf( fpcoeff,
"%lf%lf%lf", ×[
i], &
alpha[
i], &ggamma[
i] ) != 3 ) {
2194 fprintf( stderr,
"Error... problem reading in values from calibration coefficient file!\n" );
2204 if ( times[0] > datatimes->
data[series->
data->
length - 1] || times[
i - 1] <
2205 datatimes->
data[0] ) {
2206 fprintf( stderr,
"Error... calibration coefficients outside range of data.\n" );
2212 for (
k = ktemp;
k <
i;
k++ ) {
2215 if ( fabs( times[
k] - datatimes->
data[
j] ) <= 30. ) {
2229 if ( strcmp(
channel,
"LSC-DARM_ERR" ) == 0 ) {
2230 Resp = ( ( cos( Cphase ) + ggamma[
k] * G * cos( Gphase - Cphase ) ) / ( ggamma[
k] *
C ) ) +
2231 I * ( ( -sin( Cphase ) + ggamma[
k] * G * sin( Gphase - Cphase ) ) / ( ggamma[
k] *
C ) );
2235 else if ( strcmp(
channel,
"LSC-AS_Q" ) == 0 ) {
2236 Resp = ( ( cos( Cphase ) + ggamma[
k] * G * cos( Gphase - Cphase ) ) / (
alpha[
k] *
C ) ) +
2237 I * ( ( -sin( Cphase ) + ggamma[
k] * G * sin( Gphase - Cphase ) ) / (
alpha[
k] *
C ) );
2239 fprintf( stderr,
"Error... data channel is not set. Give either AS_Q\
2245 series->
data->
data[counter] = tempData * Resp;
2246 datatimes->
data[counter] = datatimes->
data[
j];
2279 if ( calibfilename == NULL ) {
2280 fprintf( stderr,
"Error... calibration filename has a null pointer\n" );
2282 }
else if ( (
fp = fopen( calibfilename,
"r" ) ) == NULL ) {
2283 fprintf( stderr,
"Error... can't open calibration file %s.\n",
2290 offset = ftell(
fp );
2293 if ( strstr( jnkstr,
"%" ) ) {
2301 fseek(
fp, offset, SEEK_SET );
2304 fprintf( stderr,
"Error... problem reading data from calibration \
2317 REAL8 stddevthresh )
2338 for (
i = 0;
i < (
INT4 )
data->data->length;
i++ ) {
2339 stddev += ( creal(
data->data->data[
i] ) - creal( mean ) ) * ( creal(
data->data->data[
i] ) - creal( mean ) ) +
2340 I * ( ( cimag(
data->data->data[
i] ) - cimag( mean ) ) * ( cimag(
data->data->data[
i] ) - cimag( mean ) ) );
2343 stddev = sqrt( creal( stddev ) / (
REAL8 )(
data->data->length ) ) +
2344 I * sqrt( cimag( stddev ) / (
REAL8 )(
data->data->length ) );
2348 for (
i = 0;
i < (
INT4 )
data->data->length;
i++ ) {
2349 if ( fabs( creal(
data->data->data[
i] ) ) < creal( stddev ) * stddevthresh &&
2350 fabs( cimag(
data->data->data[
i] ) ) < cimag( stddev ) * stddevthresh ) {
2365 return startlen -
j;
2379 COMPLEX16FFTPlan *fftplan = NULL;
2385 if ( filterKnee <= 0. ) {
2399 XLALPrintError(
"Error allocating memory for filter response.\n" );
2404 XLALPrintError(
"Error allocating data for filter response.\n" );
2408 for (
i = 0;
i <
srate * ttime;
i++ ) {
2409 REAL8 dataTmpRe = 0., dataTmpIm = 0.;
2424 data->data[
i] = dataTmpRe + I * dataTmpIm;
2444 for (
i = 0;
i <
srate * ttime / 2;
i++ ) {
2447 tempdata = fftdata->
data[
i];
2450 fftdata->
data[
i +
srate * ttime / 2] = tempdata;
2461 for (
i = 0;
i <
srate * ttime;
i++ ) {
2463 cimag( fftdata->
data[
i] ) * cimag( fftdata->
data[
i] ) ) / sqrt( 2. );
2465 phase = atan2( creal( fftdata->
data[
i] ), cimag( fftdata->
data[
i] ) );
2470 }
else if (
phase - tempphase < 0. ) {
2499 static char buf[100];
2500 time_t
x = ( time_t )
t;
2504 strftime( buf,
sizeof( buf ),
"%Y-%m-%d %H:%M:%S", &tm );
int XLALButterworthREAL8TimeSeries(REAL8TimeSeries *series, PassBandParamStruc *params)
void XLALBinaryPulsarDeltaTNew(BinaryPulsarOutput *output, BinaryPulsarInput *input, PulsarParameters *params)
function to calculate the binary system delay using new parameter structure
#define LALDIIRFilter(x, f)
const LALVCSInfoList lalPulsarVCSInfoList
NULL-terminated list of VCS and build information for LALPulsar and its dependencies
int LALgetopt_long(int argc, char *const *argv, const char *options, const struct LALoption *long_options, int *opt_index)
#define required_argument
void PulsarSetParam(PulsarParameters *pars, const CHAR *name, const void *value)
Set the value of a parameter in the PulsarParameters structure.
const REAL8Vector * PulsarGetREAL8VectorParam(const PulsarParameters *pars, const CHAR *name)
Return a REAL8Vector parameter.
REAL8 PulsarGetREAL8ParamOrZero(const PulsarParameters *pars, const CHAR *name)
Return a REAL8 parameter if it exists, otherwise return zero.
int PulsarCheckParam(const PulsarParameters *pars, const CHAR *name)
Check for the existence of the parameter name in the PulsarParameters structure.
PulsarParameters * XLALReadTEMPOParFile(const CHAR *pulsarAndPath)
Read in the parameters from a TEMPO(2) parameter file into a PulsarParameters structure.
REAL8 PulsarGetREAL8Param(const PulsarParameters *pars, const CHAR *name)
Return a REAL8 parameter.
const CHAR * PulsarGetStringParam(const PulsarParameters *pars, const CHAR *name)
Return a string parameter.
void PulsarFreeParams(PulsarParameters *pars)
Function to free memory from pulsar parameters.
REAL8 PulsarGetREAL8VectorParamIndividual(const PulsarParameters *pars, const CHAR *name)
Return an individual REAL8 value from a REAL8Vector parameter.
COMPLEX16FFTPlan * XLALCreateForwardCOMPLEX16FFTPlan(UINT4 size, int measurelvl)
void XLALDestroyCOMPLEX16FFTPlan(COMPLEX16FFTPlan *plan)
int XLALCOMPLEX16VectorFFT(COMPLEX16Vector *_LAL_RESTRICT_ output, const COMPLEX16Vector *_LAL_RESTRICT_ input, const COMPLEX16FFTPlan *plan)
REAL8IIRFilter * XLALCreateREAL8IIRFilter(COMPLEX16ZPGFilter *input)
COMPLEX16ZPGFilter * XLALCreateCOMPLEX16ZPGFilter(INT4 numZeros, INT4 numPoles)
void XLALDestroyREAL8IIRFilter(REAL8IIRFilter *filter)
void XLALDestroyCOMPLEX16ZPGFilter(COMPLEX16ZPGFilter *filter)
int XLALFileClose(LALFILE *file)
int XLALFileEOF(LALFILE *file)
LALFILE * XLALFileOpen(const char *path, const char *mode)
size_t XLALFileRead(void *ptr, size_t size, size_t nobj, LALFILE *file)
int XLALGzipTextFile(const char *path)
char * XLALFileGets(char *s, int size, LALFILE *file)
TimeCorrectionData * XLALInitTimeCorrections(const CHAR *timeCorrectionFile)
An XLAL interface for reading a time correction file containing a table of values for converting betw...
EphemerisData * XLALInitBarycenter(const CHAR *earthEphemerisFile, const CHAR *sunEphemerisFile)
XLAL interface to reading ephemeris files 'earth' and 'sun', and return ephemeris-data in old backwar...
void XLALDestroyTimeCorrectionData(TimeCorrectionData *tcd)
Destructor for TimeCorrectionData struct, NULL robust.
int XLALBarycenter(EmissionTime *emit, const BarycenterInput *baryinput, const EarthState *earth)
Transforms from detector arrival time in GPS (as specified in the LIGOTimeGPS structure) to pulse em...
void XLALDestroyEphemerisData(EphemerisData *edat)
Destructor for EphemerisData struct, NULL robust.
int XLALBarycenterEarthNew(EarthState *earth, const LIGOTimeGPS *tGPS, const EphemerisData *edat, const TimeCorrectionData *tdat, TimeCorrectionType ttype)
Computes the position and orientation of the Earth, at some arrival time, but unlike XLALBarycenterEa...
@ TIMECORRECTION_ORIGINAL
void XLALDestroyCache(LALCache *cache)
LALCache * XLALCacheImport(const char *fname)
LALCache * XLALCacheDuplicate(const LALCache *cache)
int XLALCacheSieve(LALCache *cache, INT4 t0, INT4 t1, const char *srcregex, const char *dscregex, const char *urlregex)
int XLALFrStreamClose(LALFrStream *stream)
LALFrStream * XLALFrStreamCacheOpen(LALCache *cache)
LALTYPECODE XLALFrStreamGetTimeSeriesType(const char *chname, LALFrStream *stream)
REAL8TimeSeries * XLALFrStreamReadREAL8TimeSeries(LALFrStream *stream, const char *chname, const LIGOTimeGPS *start, REAL8 duration, size_t lengthlimit)
REAL4TimeSeries * XLALFrStreamReadREAL4TimeSeries(LALFrStream *stream, const char *chname, const LIGOTimeGPS *start, REAL8 duration, size_t lengthlimit)
void * XLALMalloc(size_t n)
void * XLALCalloc(size_t m, size_t n)
void * XLALRealloc(void *p, size_t n)
char char * XLALStringDuplicate(const char *s)
size_t XLALStringCopy(char *dst, const char *src, size_t size)
int char * XLALStringAppend(char *s, const char *append)
char * XLALStringCaseSubstring(const char *haystack, const char *needle)
char * XLALVCSInfoString(const LALVCSInfoList vcs_list, const int verbose, const char *prefix)
REAL8 XLALGetTimeOfDay(void)
const LALDetector * XLALGetSiteInfo(const CHAR *name)
Find the site geometry-information 'LALDetector' for given a detector name (or prefix).
void XLALDestroyCOMPLEX16TimeSeries(COMPLEX16TimeSeries *series)
COMPLEX16TimeSeries * XLALCreateCOMPLEX16TimeSeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaT, const LALUnit *sampleUnits, size_t length)
void XLALDestroyREAL8TimeSeries(REAL8TimeSeries *series)
void XLALDestroyREAL4TimeSeries(REAL4TimeSeries *series)
REAL8TimeSeries * XLALCreateREAL8TimeSeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaT, const LALUnit *sampleUnits, size_t length)
COMPLEX16TimeSeries * XLALResizeCOMPLEX16TimeSeries(COMPLEX16TimeSeries *series, int first, size_t length)
const LALUnit lalSecondUnit
REAL8Vector * XLALResizeREAL8Vector(REAL8Vector *vector, UINT4 length)
INT4Vector * XLALResizeINT4Vector(INT4Vector *vector, UINT4 length)
INT4Vector * XLALCreateINT4Vector(UINT4 length)
void XLALDestroyINT4Vector(INT4Vector *vector)
REAL8Vector * XLALCreateREAL8Vector(UINT4 length)
COMPLEX16Vector * XLALCreateCOMPLEX16Vector(UINT4 length)
COMPLEX16Vector * XLALResizeCOMPLEX16Vector(COMPLEX16Vector *vector, UINT4 length)
void XLALDestroyREAL8Vector(REAL8Vector *vector)
void XLALDestroyCOMPLEX16Vector(COMPLEX16Vector *vector)
void XLALAbortErrorHandler(const char *func, const char *file, int line, int errnum)
XLALErrorHandlerType * XLALSetErrorHandler(XLALErrorHandlerType *newHandler)
#define XLAL_CHECK(assertion,...)
#define XLAL_CHECK_VOID(assertion,...)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
LIGOTimeGPS * XLALGPSSetREAL8(LIGOTimeGPS *epoch, REAL8 t)
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
int main(int argc, char *argv[])
COMPLEX16TimeSeries * resample_data(COMPLEX16TimeSeries *data, REAL8Vector *times, INT4Vector *starts, INT4Vector *stops, REAL8 sampleRate, REAL8 resampleRate, INT4 hetflag)
void destroy_filter_response(FilterResponse *filtresp)
void set_filters(Filters *iirFilters, REAL8 filterKnee, REAL8 samplerate)
void heterodyne_data(COMPLEX16TimeSeries *data, REAL8Vector *times, HeterodyneParams hetParams, REAL8 freqfactor, FilterResponse *filtresp)
static const char * LogTimeToString(double t)
INT4 remove_outliers(COMPLEX16TimeSeries *data, REAL8Vector *times, REAL8 stddevthresh)
void calibrate(COMPLEX16TimeSeries *series, REAL8Vector *datatimes, CalibrationFiles calfiles, REAL8 frequency, CHAR *channel)
void get_calibration_values(REAL8 *magnitude, REAL8 *phase, CHAR *calibfilename, REAL8 frequency)
LALCache * set_frame_files(INT4 *starts, INT4 *stops, LALCache *cache, INT4 *position, INT4 maxchunklength)
FilterResponse * create_filter_response(REAL8 filterKnee)
INT4 get_segment_list(INT4Vector *starts, INT4Vector *stops, CHAR *seglistfile, INT4 heterodyneflag)
void get_input_args(InputParams *inputParams, int argc, char *argv[])
void get_frame_times(CHAR *framefile, REAL8 *gpstime, INT4 *duration)
REAL8TimeSeries * get_frame_data(LALCache *framecache, CHAR *channel, REAL8 ttime, REAL8 length, INT4 duration, REAL8 samplerate, REAL8 scalefac, REAL8 highpass)
void filter_data(COMPLEX16TimeSeries *data, Filters *iirFilters)
#define localtime_r(timep, result)
def phase(point, coeffs, params, ignoreintcheck=False)
structure containing the output parameters for the binary delay function
REAL8 deltaT
deltaT to add to TDB in order to account for binary
CHAR * calibcoefficientfile
CHAR * sensingfunctionfile
CHAR * responsefunctionfile
Basic output structure of LALBarycenterEarth.c.
Basic output structure produced by LALBarycenter.c.
REAL8 deltaT
(TDB) - (GPS)
LIGOTimeGPS te
pulse emission time (TDB); also sometimes called `‘arrival time (TDB) of same wavefront at SSB’'
This structure contains all information about the center-of-mass positions of the Earth and Sun,...
REAL8IIRFilter * filter2Im
REAL8IIRFilter * filter3Im
REAL8IIRFilter * filter3Re
REAL8IIRFilter * filter1Re
REAL8IIRFilter * filter1Im
REAL8IIRFilter * filter2Re
PulsarParameters * hetUpdate
This structure will contain a vector of time corrections used during conversion from TT to TDB/TCB/Te...