Faster mtotdev() and htotdev()

The AllanTools functions mtotdev() and htotdev() are now almost 10-times faster, after an update to the code that more efficiently calculates moving averages.

The old code used numpy.mean() for each iteration of a loop:

for j in range(0, 6*m): # summation of the 6m terms.
    xmean1 = np.mean(xstar[j     :   j+m])
    xmean2 = np.mean(xstar[j+m   : j+2*m])
    xmean3 = np.mean(xstar[j+2*m : j+3*m])

However this can be computed much faster by noticing that the new mean differs from the old (already computed!) mean by just two points, one at the start is dropped, and a new one at the end is added:

for j in range(0, 6*m): # summation of the 6m terms.
    if j == 0:
        # intialize the sum
        xmean1 = np.sum( xstar[0:m] )
        xmean2 = np.sum( xstar[m:2*m] )
        xmean3 = np.sum( xstar[2*m:3*m] )
    else:
        # j>=1, subtract old point, add new point
        xmean1 = xmean1 - xstar[j-1] + xstar[j+m-1] #
        xmean2 = xmean2 - xstar[m+j-1] + xstar[j+2*m-1] #
        xmean3 = xmean3 - xstar[2*m+j-1] + xstar[j+3*m-1] #

AD9912 DDS frequency resolution?

See also discussion on the AD forum: https://ez.analog.com/dds/f/q-a/107510/ad9912-ftw-lsb-always-zero

We've tried to measure the frequency resolution of the AD9912 DDS, which when used with a 1 GHz SYSCLK should be 1 GHz / 2**48 = 3.55 uHz.

We tried an ARTIQ Urukul-board and an AD dev-board and got the following results:

In both cases the output frequency corresponds to an even frequency tuning word (FTW) although we step the frequency by one LSB. In other words the LSB appears to be zero in all cases, even when we write an odd FTW with '1' as the LSB. Instead of the expected 3.55 uHz frequency resolution we see double-sized steps of 7.1 uHz.

The Urukul measurement was done with a Microsemi 3120A phase-meter and the dev-board was measured using a PICDIV 1PPS-divider followed by a Keysight 53230A time interval counter. The even FTW frequencies agree with the predicted frequency to much better than 0.1 uHz.