read parameters; if (sortevlist) { sort the event list; } else { check that the events occur in time order, warn if not; } calculate the dimensions of the variability image; if (withimage) { load fluxImage; } else { make fluxImage; write fluxImage as a FITS file; } # Make the KSS image: ksImage(1:max_i, 1:max_j) = 0.0; counts( 1:max_i, 1:max_j) = 0; for (event from 1 to n_events) { if (the event is within the image bounds) { calculate pixel (i,j) that this event falls into; counts(i, j) = counts(i, j) + 1; d = abs((event - 1) / n_events - counts(i, j) / fluxImage(i, j)); if (ksImage(i, j) < d) { ksImage(i, j) = d; } } } # Weight the KSS image: foreach (i) { foreach (j) { if (counts(i, j) > cutoff) { sqrtNe = sqrt(n_events * counts(i, j) / (n_events + counts(i, j))); ksImage(i, j) = ksImage(i, j) * (sqrtNe + 0.12 + 0.11 / sqrtNe); } else { ksImage(i, j) = 0.827574; # value at which prob of variability is 50% } } } write ksImage as a FITS file;