# -*- coding: utf-8 -*-
# Copyright (C) 2012, Almar Klein
#
# Visvis is distributed under the terms of the (new) BSD License.
# The full license can be found in 'license.txt'.

import numpy as np
import visvis as vv

import sys
import zlib
import base64

# todo: parameterize; allow custum Gaussian blobs at specified positions.

if False:
    # Get data (exported from Matlab)
    from visvis import ssdf
    db = ssdf.load('d:/almar/projects/peaks.ssdf')
    data = db.z.astype(np.float32)

    # Dump
    data = data.tostring()
    data = zlib.compress(data)
    text = base64.encodebytes(data)
    print(text)

def peaks():
    """ peaks()

    Returs a 2D map of z-values that represent an example landscape with
    Gaussian blobs.

    """

    # Decode z data
    base64decode = base64.decodebytes if sys.version_info > (3, ) else base64.decodestring
    data = base64decode(zData.encode('ascii'))
    data = zlib.decompress(data)
    z = np.frombuffer(data, dtype=np.float32 )
    z.shape = 49, 49

    # Done!
    return z


zData = """
[encoded data, 12397 characters]
"""

if __name__ == "__main__":
    m = vv.surf(peaks())
