def ndarray2GSLIB(array, data_file, col_name):
    """Convert 1D or 2D numpy ndarray to a GSLIB Geo-EAS file for use with
    GSLIB methods.

    :param array: input array
    :param data_file: file name
    :param col_name: column name
    :return: None
    """
    if array.ndim not in [1, 2]:
        raise ValueError('must use a 2D array')
    with open(data_file, 'w') as f:
        f.write(data_file + '\n')
        f.write('1 \n')
        f.write(col_name + '\n')
        if array.ndim == 2:
            ny, nx = array.shape
            for iy in range(ny):
                for ix in range(nx):
                    f.write(str(array[ny - 1 - iy, ix]) + '\n')
        elif array.ndim == 1:
            nx = len(array)
            for ix in range(0, nx):
                f.write(str(array[ix]) + '\n')
