@Override
    public void setTemperature(int i, int j, double value) {
        if (i >= 0 && i < numLongCells && j >= 0 && j < numLatCells) {
            cellValues[i][j] = value;
        }
        // Allow overrunning the "size" of the grid. We are on
        // a sphere, after all. This is convenient for checking neighbors
        // at boundaries.
        int iIndex = i % numLongCells;
        int jIndex = j % (2 * numLatCells);
        // Translate a negative index to its positive equivalent.
        if (iIndex < 0) { iIndex += numLongCells; }
        if (jIndex < 0) { jIndex += 2 * numLatCells; }
        // If we have not circled past the pole or have circled all the
        // way back, past two poles, the latitude and longitude are simple.
        if (jIndex < numLatCells) {
            cellValues[iIndex][jIndex] = value;
        } else {
            // Otherwise, we have crossed the poles an odd number of times, and
            // the latitude and longitude are more complicated.
            cellValues[Math.abs(iIndex - (numLongCells / 2))][(2 * numLatCells - 1) - jIndex] = value;
        }
    }