def mean(self, idx, jdx):
    'Mean gridding algorithm.\n\n        vgrid implemnets incremental gridding where possible.\n        To do this, the sum of the product of the weights and z values are\n        retained in addition to the sum of the weights. Then method zz()\n        calculates the quotient of the two to obtain the actual weighted\n        mean z values. Note that when all weights are one, (or if w is set to\n        1 for shorthand), a standard mean is calculated.\n\n        Variance is calcualted in a similar way. In this case the sum of\n        w*(z_i - mu)^2 is calculated and stored for each grid node, where\n        z_i is the value to be gridded and mu is the mean of the grid node\n        calculated thus far.  Then this sum is divided by the sum of the\n        weights to get the final estimated variance. As the mean of the grid\n        node approaches the true mean, this value should approach the true\n        variance.\n        '
    self._II = self._I[idx][jdx]
    if (self._w.size == 1):
        self.zw[(idx, jdx)] = np.nansum(np.concatenate((self._z[self._II], [self.zw[(idx, jdx)]])))
        self.ww[(idx, jdx)] = self.nn[(idx, jdx)]
        self.varw[(idx, jdx)] = np.nansum(np.concatenate((np.power((self._z[self._II] - (self.zw[(idx, jdx)] / self.nn[(idx, jdx)])), 2), [self.varw[(idx, jdx)]])))
    else:
        self.zw[(idx, jdx)] = np.nansum(np.append(self.zw[(idx, jdx)], (self._z[self._II] * self._w[self._II])))
        self.ww[(idx, jdx)] = np.nansum(np.append(self.ww[(idx, jdx)], self._w[self._II]))
        self.varw[(idx, jdx)] = np.nansum(np.append(np.power((self._z[self._II] - (self.zw[(idx, jdx)] / self.ww[(idx, jdx)])), 2), self.varw[(idx, jdx)]))
Mean gridding algorithm.

vgrid implemnets incremental gridding where possible.
To do this, the sum of the product of the weights and z values are
retained in addition to the sum of the weights. Then method zz()
calculates the quotient of the two to obtain the actual weighted
mean z values. Note that when all weights are one, (or if w is set to
1 for shorthand), a standard mean is calculated.

Variance is calcualted in a similar way. In this case the sum of
w*(z_i - mu)^2 is calculated and stored for each grid node, where
z_i is the value to be gridded and mu is the mean of the grid node
calculated thus far.  Then this sum is divided by the sum of the
weights to get the final estimated variance. As the mean of the grid
node approaches the true mean, this value should approach the true
variance.
def mean(self, idx, jdx):
    'Mean gridding algorithm.\n\n        vgrid implemnets incremental gridding where possible.\n        To do this, the sum of the product of the weights and z values are\n        retained in addition to the sum of the weights. Then method zz()\n        calculates the quotient of the two to obtain the actual weighted\n        mean z values. Note that when all weights are one, (or if w is set to\n        1 for shorthand), a standard mean is calculated.\n\n        Variance is calcualted in a similar way. In this case the sum of\n        w*(z_i - mu)^2 is calculated and stored for each grid node, where\n        z_i is the value to be gridded and mu is the mean of the grid node\n        calculated thus far.  Then this sum is divided by the sum of the\n        weights to get the final estimated variance. As the mean of the grid\n        node approaches the true mean, this value should approach the true\n        variance.\n        '
    self._II = self._I[idx][jdx]
    if (self._w.size == 1):
        self.zw[(idx, jdx)] = np.nansum(np.concatenate((self._z[self._II], [self.zw[(idx, jdx)]])))
        self.ww[(idx, jdx)] = self.nn[(idx, jdx)]
        self.varw[(idx, jdx)] = np.nansum(np.concatenate((np.power((self._z[self._II] - (self.zw[(idx, jdx)] / self.nn[(idx, jdx)])), 2), [self.varw[(idx, jdx)]])))
    else:
        self.zw[(idx, jdx)] = np.nansum(np.append(self.zw[(idx, jdx)], (self._z[self._II] * self._w[self._II])))
        self.ww[(idx, jdx)] = np.nansum(np.append(self.ww[(idx, jdx)], self._w[self._II]))
        self.varw[(idx, jdx)] = np.nansum(np.append(np.power((self._z[self._II] - (self.zw[(idx, jdx)] / self.ww[(idx, jdx)])), 2), self.varw[(idx, jdx)]))