Update the pixel mapping equations

Tweaked the equations used to map detectors to their positions in the
output array.  Also added some code to check for invalid array
coordinates.