<div dir="ltr">Hi all,<div><br></div><div>Reading that patch I'm not convinced that randomly adding explicit "(int)" conversions is the proper fix.</div><div>Looking at the difx_datastream.c code the intent of the "toneFreq0" variable is to hold the first integer multiple of the PCal frequency that falls within the actual datastream (subband, channel, observed band, chunk of sky frequency described).</div><div><br></div><div>My suggestion would be something along the lines of:</div><div><br></div><div> toneFreq0 = (int)(( loFreq + dd->phaseCalIntervalMHz ) / dd->phaseCalIntervalMHz ) * dd->phaseCalIntervalMHz;</div><div><br></div><div>Two birds with one stone:</div><div>1) the special case "if(toneFreq0) <= loFreq" can be removed as it will be dealt with automatically</div><div>2) only the first part of the computation needs to be converted to int (i.e. the rounding to an integer number of pcal tones); the multiplication will produce a double again, but the assignment to the integer "toneFreq0" will automatically truncate it again.</div><div><br></div><div>Cheers,</div><div>h</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 13 Feb 2020 at 18:14, Leonid Petrov via Difx-users <<a href="mailto:difx-users@listmgr.nrao.edu">difx-users@listmgr.nrao.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Dear DiFXers,<br>
<br>
pcal_200213 bug in difx2fits was found and fixed:<br>
<br>
Synopsis:<br>
<br>
Phase calibration frequencies in FITS-IDI are not commensurate to the <br>
phase<br>
cal tone spacings and some frequencies are NaN if for the lower <br>
frequency<br>
of a given IF is no commensurate to the phase cal tone spacings. Was <br>
found<br>
in VLBI experiment VT9259 with IF#1 LO Frequency 3448.4 MHz and pcal <br>
tone<br>
spacings 5 MHz.<br>
<br>
Severity:<br>
<br>
Serious<br>
<br>
Reason:<br>
<br>
A trivial coding mistake<br>
<br>
Patch:<br>
<br>
--- libraries/difxio/difxio/difx_datastream.c~ 2019-04-13 <br>
19:05:23.600324077 -0400<br>
+++ libraries/difxio/difxio/difx_datastream.c 2020-02-13 <br>
11:28:46.109375671 -0500<br>
@@ -342,7 +342,7 @@<br>
<br>
if(df->sideband == 'U')<br>
{<br>
- toneFreq0 = (((int)(loFreq)) / dd->phaseCalIntervalMHz) * <br>
dd->phaseCalIntervalMHz;<br>
+ toneFreq0 = ( (int) loFreq / (int) dd->phaseCalIntervalMHz ) * (int) <br>
dd->phaseCalIntervalMHz;<br>
if(toneFreq0 <= loFreq)<br>
{<br>
toneFreq0 += dd->phaseCalIntervalMHz;<br>
@@ -350,7 +350,7 @@<br>
}<br>
else<br>
{<br>
- toneFreq0 = (((int)(loFreq)) / dd->phaseCalIntervalMHz) * <br>
dd->phaseCalIntervalMHz;<br>
+ toneFreq0 = ( (int) loFreq / (int) dd->phaseCalIntervalMHz ) * (int) <br>
dd->phaseCalIntervalMHz;<br>
if(toneFreq0 == loFreq)<br>
{<br>
toneFreq0 -= dd->phaseCalIntervalMHz;<br>
<br>
<br>
Leonid<br>
2020.02.13_12:13:06<br>
<br>
_______________________________________________<br>
Difx-users mailing list<br>
<a href="mailto:Difx-users@listmgr.nrao.edu" target="_blank">Difx-users@listmgr.nrao.edu</a><br>
<a href="https://listmgr.nrao.edu/mailman/listinfo/difx-users" rel="noreferrer" target="_blank">https://listmgr.nrao.edu/mailman/listinfo/difx-users</a><br>
</blockquote></div>