Skip to content

Commit

Permalink
Subband dedispersion fix for flipped band data.
Browse files Browse the repository at this point in the history
  • Loading branch information
jayanthc committed Dec 18, 2014
1 parent 1336e47 commit ad6e9a8
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/yapp_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2351,7 +2351,7 @@ float YAPP_CalcRMS(float *pfBuf,

for (i = iOffset; i < iLength; i += iStride)
{
fRMS += powf((pfBuf[i] - fMean), 2);
fRMS += powf(pfBuf[i] - fMean, 2);
}
fRMS /= (iLength - 1);
fRMS = sqrtf(fRMS);
Expand Down
109 changes: 83 additions & 26 deletions src/yapp_dedisperse.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ int main(int argc, char *argv[])

if (iBlockSize == iMaxOffset)
{
if (lBytesToProc < (iBlockSize * iNumChans * sizeof(float)))
if (lBytesToProc < (iBlockSize * iNumChans * fSampSize))
{
/* if the block size is equivalent to the maximum delay that is to
be applied, and if the number of bytes to be processed is less
Expand All @@ -530,15 +530,15 @@ int main(int argc, char *argv[])
(void) printf("WARNING: Amount of data to be processed is less "
"than the calculated maximum offset! Will process "
"more data than what was requested.\n");
lBytesToProc = iBlockSize * iNumChans * sizeof(float);
lBytesToProc = iBlockSize * iNumChans * fSampSize;
}
}
else
{
/* here, iBlockSize > iMaxOffset */
assert(iBlockSize > iMaxOffset);

if (lBytesToProc < (iMaxOffset * iNumChans * sizeof(float)))
if (lBytesToProc < (iMaxOffset * iNumChans * fSampSize))
{
/* if the number of bytes to be processed is less than the maximum
offset, de-dispersion will be affected, as we don't have more
Expand All @@ -547,21 +547,21 @@ int main(int argc, char *argv[])
(void) printf("WARNING: Amount of data to be processed is less "
"than the calculated maximum offset! Will process "
"more data than what was requested.\n");
lBytesToProc = iMaxOffset * iNumChans *sizeof(float);
lBytesToProc = iMaxOffset * iNumChans * fSampSize;
(void) printf("WARNING: Amount of data to be processed is less "
"than the block size! Adjusting block size "
"accordingly.\n");
iBlockSize = lBytesToProc / (iNumChans * sizeof(float));
iBlockSize = iMaxOffset;
}
else
{
if (lBytesToProc < (iBlockSize * iNumChans * sizeof(float)))
if (lBytesToProc < (iBlockSize * iNumChans * fSampSize))
{
/* here, iMaxOffset <=(eqv) lBytesToProc <(eqv) iBlockSize */
(void) printf("WARNING: Amount of data to be processed is "
"less than the block size! Adjusting block size "
"accordingly.\n");
iBlockSize = lBytesToProc / (iNumChans * sizeof(float));
iBlockSize = lBytesToProc / (iNumChans * fSampSize);
}
}
}
Expand Down Expand Up @@ -640,16 +640,31 @@ int main(int argc, char *argv[])
/* compute the number of channels per sub-band. iNumChans is a multiple
of iNumSubBands */
iChansPerSubBand = iNumChans / iNumSubBands;
iStartChan = iSubBand * iChansPerSubBand;
iEndChan = (iSubBand + 1) * iChansPerSubBand;
stYUMOut.iNumGoodChans = iChansPerSubBand;
for (i = 0; i < iNumChans; ++i)
if (stYUM.cIsBandFlipped)
{
if (!((i >= iStartChan) && (i < iEndChan)))
iStartChan = (iNumSubBands - iSubBand) * iChansPerSubBand;
iEndChan = (iNumSubBands - (iSubBand + 1)) * iChansPerSubBand;
for (i = 0; i < iNumChans; ++i)
{
stYUM.pcIsChanGood[i] = YAPP_FALSE;
if (!((i >= iEndChan) && (i < iStartChan)))
{
stYUM.pcIsChanGood[i] = YAPP_FALSE;
}
}
}
else
{
iStartChan = iSubBand * iChansPerSubBand;
iEndChan = (iSubBand + 1) * iChansPerSubBand;
for (i = 0; i < iNumChans; ++i)
{
if (!((i >= iStartChan) && (i < iEndChan)))
{
stYUM.pcIsChanGood[i] = YAPP_FALSE;
}
}
}
stYUMOut.iNumGoodChans = iChansPerSubBand;
}

fStatBW = stYUMOut.iNumGoodChans * fChanBW; /* in MHz */
Expand Down Expand Up @@ -981,8 +996,16 @@ int main(int argc, char *argv[])
{
stYUMOut.iNumChans = iChansPerSubBand;
stYUMOut.fBW = stYUMOut.iNumChans * stYUMOut.fChanBW;
stYUMOut.fFMin = stYUM.fFMin
+ (iStartChan * stYUMOut.fChanBW);
if (stYUM.cIsBandFlipped)
{
stYUMOut.fFMin = stYUM.fFMax
- (iStartChan * stYUMOut.fChanBW);
}
else
{
stYUMOut.fFMin = stYUM.fFMin
+ (iStartChan * stYUMOut.fChanBW);
}
stYUMOut.fFMax = stYUMOut.fFMin
+ ((stYUMOut.iNumChans - 1) * stYUMOut.fChanBW);
if (0 == (stYUMOut.iNumChans % 2)) /* even number of channels */
Expand Down Expand Up @@ -1450,26 +1473,60 @@ int main(int argc, char *argv[])
{
if (0 == iDecFac)
{
(void) fwrite(pfPriBuf,
/* kludgy fix to the last block problem */
if (!cIsLastBlock)
{
(void) fwrite(pfPriBuf,
sizeof(float),
iNumChans * iBlockSize,
pFDedispData);
}
else
{
(void) fwrite(pfPriBuf,
sizeof(float),
iNumChans * (iBlockSize - iMaxOffset),
pFDedispData);
}
}
else
{
/* kludgy fix to the last block problem */
if (!cIsLastBlock)
{
(void) fwrite(g_pfDecDedispData,
sizeof(float),
iOutNumChans * iBlockSize,
pFDedispData);
}
else
{
(void) fwrite(g_pfDecDedispData,
sizeof(float),
iOutNumChans * (iBlockSize - iMaxOffset),
pFDedispData);
}

}
}
else
{
/* kludgy fix to the last block problem */
if (!cIsLastBlock)
{
(void) fwrite(g_pfDedispData,
sizeof(float),
iNumChans * iBlockSize,
iBlockSize,
pFDedispData);
}
else
{
(void) fwrite(g_pfDecDedispData,
(void) fwrite(g_pfDedispData,
sizeof(float),
iOutNumChans * iBlockSize,
iBlockSize - iMaxOffset,
pFDedispData);
}
}
else
{
(void) fwrite(g_pfDedispData,
sizeof(float),
iBlockSize,
pFDedispData);
}

if (cHasGraphics)
{
Expand Down
2 changes: 1 addition & 1 deletion src/yapp_makever.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/* TODO: read the path as argument */
#define FILE_VERSRC "src/yapp_version.c"
#define VAR_VER "*g_pcVersion"
#define VER_BUILD_PREFIX "YAPP-REL-3.5.6-beta"
#define VER_BUILD_PREFIX "YAPP-REL-3.5.7-beta"
#define VER_BUILD_DELIM "-"

time_t GetLatestTimestamp(void);
Expand Down

0 comments on commit ad6e9a8

Please sign in to comment.