Skip to content

Instantly share code, notes, and snippets.

View ChrisBeaumont's full-sized avatar

Chris Beaumont ChrisBeaumont

View GitHub Profile
from glue import core
from glue.core.data_factories import auto_data, tabular_data
from glue.core.link_helpers import Galactic2Equatorial, MultiLink
from glue.qt.glue_application import GlueApplication
from convert_xyz import galactic2xyz
# Load data from files
d = tabular_data('irdcs.fits')
d.label = "IRDC Catalog"
@ChrisBeaumont
ChrisBeaumont / example2.py
Created August 30, 2012 16:18
In-process IPython Qt Widget. Take 2
"""
An attempt to embed an IPython Qt Terminal widget in-process
Current Behavior
----------------
1) Multiple widgets can be instantiated
2) Each widget shares the same namespace (and underlying kernel)
@ChrisBeaumont
ChrisBeaumont / cmap2pixmap.py
Created November 6, 2012 16:30
convert matplotlib colormap to Qt4 pixmap
from matplotlib import cm
import numpy as np
from PyQt4.QtGui import QImage, QPixmap, QColor
def cmap2pixmap(cmap, steps=50):
"""Convert a maplotlib colormap into a QPixmap
:param cmap: The colormap to use
:type cmap: Matplotlib colormap instance (e.g. matplotlib.cm.gray)
@ChrisBeaumont
ChrisBeaumont / convert.pro
Created November 15, 2012 12:59
coordinate conversions
pro writecol, file, c1, c2
openw, lun, file, /get
for i = 0, n_elements(c1) - 1, 1 do begin
printf, lun, c1[i], c2[i], format='(d, ", ", d)'
endfor
free_lun, lun
end
pro generate_j2000_points
seed = 42
@ChrisBeaumont
ChrisBeaumont / mandel.py
Created November 16, 2012 20:37
interactive Mandelbrot numba example
"""From the numba examples
(https://github.com/numba/numba/blob/master/examples/mandel.py),
but tweaked to recalculate on the fly as the viewport changes"""
from numba import autojit
import numpy as np
from pylab import imshow, jet, show, ion
import matplotlib.pyplot as plt
from matplotlib import rcParams
rcParams['image.origin'] = 'lower'
@ChrisBeaumont
ChrisBeaumont / dock.py
Created December 4, 2012 21:13
MPL set_cursor problem under 1.2.0
from PyQt4.QtGui import QApplication, QMainWindow, QDockWidget
from PyQt4.QtCore import Qt
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg
from matplotlib.backends.backend_qt4 import NavigationToolbar2QT
from matplotlib.figure import Figure
a = QApplication([''])
w = QMainWindow()
@ChrisBeaumont
ChrisBeaumont / perseus.ipynb
Last active December 10, 2015 15:29
perseus_bg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ChrisBeaumont
ChrisBeaumont / workaround.py
Created January 10, 2013 02:06
Workaround linker issue when installing scikit-learn on a mac that uses macports
from subprocess import check_call
#remove build directory
check_call('rm -rf build'.split())
#compile and capture stdout
with open('build.log', 'w') as log:
check_call('python setup.py install --user'.split(), stdout=log)
log = open('build.log').read().splitlines()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ChrisBeaumont
ChrisBeaumont / pyside_menu_bug.py
Created February 14, 2013 23:27
The menu bar in this script doesn't display. It *does* display if QMenuBar is created without a reference to its parent. This bug has been reported at https://bugreports.qt-project.org/browse/PYSIDE-21?focusedCommentId=195277&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-195277
from PySide import QtCore, QtGui
app = QtGui.QApplication([''])
mw = QtGui.QMainWindow()
#mbar = QtGui.QMenuBar() # menu visible
mbar = QtGui.QMenuBar(mw) # menu not visible
menu = QtGui.QMenu(mbar)