Display NumPy array as continuously updating image with Glumpy

后端 未结 2 1434
北恋
北恋 2021-02-08 23:31

I\'ve got a simulation model running in Python using NumPy and SciPy and it produces a 2D NumPy array as the output each iteration. I\'ve been displaying this output as an image

2条回答
  •  无人及你
    2021-02-09 00:21

    Using pyformulas 0.2.8 you can use pf.screen to create a non-blocking screen:

    import pyformulas as pf
    import numpy as np
    
    canvas = np.floor(np.random.normal(scale=50, size=(480,640,3)) % 256).astype(np.uint8)
    screen = pf.screen(canvas)
    
    while screen.exists():
        canvas = np.floor(np.random.normal(scale=50, size=(480,640,3)) % 256).astype(np.uint8)
        screen.update(canvas)
    
    #screen.close()
    

    Disclaimer: I am the maintainer for pyformulas

提交回复
热议问题