Skip to content

Instantly share code, notes, and snippets.

View djhoese's full-sized avatar

David Hoese djhoese

  • Space Science and Engineering Center (@ssec)
  • Madison, WI
  • X @djhoese
View GitHub Profile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2013, 2014, 2015 Martin Raspaud
# Author(s):
# Martin Raspaud <martin.raspaud@smhi.se>
# This program is free software: you can redistribute it and/or modify
@kylemcdonald
kylemcdonald / showarray.py
Created January 3, 2016 08:56
Minimal code for rendering a numpy array as an image in a Jupyter notebook in memory. Borrowed from the Deep Dream notebook.
import PIL.Image
from cStringIO import StringIO
import IPython.display
import numpy as np
def showarray(a, fmt='png'):
a = np.uint8(a)
f = StringIO()
PIL.Image.fromarray(a).save(f, fmt)
IPython.display.display(IPython.display.Image(data=f.getvalue()))
# See https://www.anaconda.com/understanding-and-improving-condas-performance/ for more info.
# help debug channel issues
show_channel_urls: true
# pip will always be installed with python
add_pip_as_python_dependency: true
# strict priority and conda-forge at the top will ensure
# that all of your packages will be from conda-forge unless they only exist on defaults