Skip to content

Instantly share code, notes, and snippets.

@astrofrog
astrofrog / scipy_2014_entry.py
Created March 21, 2014 12:46
Entry for the SciPy 2014 plotting contest - final animation available here: http://vimeo.com/70466967
import numpy as np
from hyperion.model import ModelOutput
import matplotlib.pyplot as plt
from yt.mods import write_bitmap, ColorTransferFunction
plt.rcParams['font.family'] = 'Arial'
# Read in model from Hyperion
m = ModelOutput('pla704850_lev7_129.rtout')
@astrofrog
astrofrog / hyperion_octree_stats.py
Last active August 29, 2015 13:57
Info on refined as seen by hyperion
from __future__ import print_function
import numpy as np
def hyperion_octree_stats(refined):
if not (len(refined) - 1) % 8 == 0:
raise ValueError("refined should have shape 8 * n + 1")
import numpy as np
from astropy.wcs import WCS
from astropy.io import fits
from astropy import units as u
import matplotlib.pyplot as plt
from wcsaxes import WCSAxes
from sunpy.wcs import *
content = open('logical.safe.txt', 'r').read()
content = content.replace("\n", "").replace('logical', '')
content = content.replace('True', 'T').replace('False', 'F')
prev = content
for iter in range(16):
content = content.replace('TFFFFFFFF', 'F')
import numpy as np
from yt.mods import write_bitmap, ColorTransferFunction
from yt.frontends.stream.api import load_uniform_grid
data = {'density':np.random.random((32, 32, 32))}
shape = data['density'].shape
pf = load_uniform_grid(data, shape, 1.,
bbox=np.array([[-1., 1.], [-1., 1.], [-1., 1.]]),
Traceback (most recent call last):
File "test_yt.py", line 6, in <module>
render_cube_in_yt(cube, 'test.png', spectral_factor=1.0, vmin=0.2, vmax=5., fly_around=None)
File "/Users/tom/Desktop/ALMA Python Workshop/radio_cube/spectral-cube/spectral_cube/yt_wrappers.py", line 109, in render_cube_in_yt
camera.draw_domain(snapshot)
File "/Users/tom/Library/Python/2.7/lib/python/site-packages/yt-2.6.2-py2.7-macosx-10.8-x86_64.egg/yt/visualization/volume_rendering/camera.py", line 470, in draw_domain
color=np.array([1.0,1.0,1.0,alpha]))
File "/Users/tom/Library/Python/2.7/lib/python/site-packages/yt-2.6.2-py2.7-macosx-10.8-x86_64.egg/yt/visualization/volume_rendering/camera.py", line 512, in draw_box
vertices[:,i] = corners[order,i,:].ravel(order='F')
IndexError: too many indices for array
tom$ python setup.py test --remote-data -P utils
running test
running build
running build_py
copying astropy/wcs/include/wcslib/cel.h -> build/lib.macosx-10.8-x86_64-2.7/astropy/wcs/include/wcslib
copying astropy/wcs/include/wcslib/lin.h -> build/lib.macosx-10.8-x86_64-2.7/astropy/wcs/include/wcslib
copying astropy/wcs/include/wcslib/prj.h -> build/lib.macosx-10.8-x86_64-2.7/astropy/wcs/include/wcslib
copying astropy/wcs/include/wcslib/spc.h -> build/lib.macosx-10.8-x86_64-2.7/astropy/wcs/include/wcslib
copying astropy/wcs/include/wcslib/spx.h -> build/lib.macosx-10.8-x86_64-2.7/astropy/wcs/include/wcslib
copying astropy/wcs/include/wcslib/tab.h -> build/lib.macosx-10.8-x86_64-2.7/astropy/wcs/include/wcslib
plugins: xdist
gw0 [5406] / gw1 [5406] / gw2 [5406] / gw3 [0] / gw4 [0] / gw5 [5406] / gw6 [5406] / gw7 [5406]
scheduling tests via LoadScheduling
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "_pytest.main", line 81, in wrap_session
INTERNALERROR> doit(config, session)
INTERNALERROR> File "_pytest.main", line 117, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File "_pytest.core", line 376, in __call__
INTERNALERROR> return self._docall(methods, kwargs)
TARGET api/astropy.coordinates.AltAz py:obj Quantity
TARGET api/astropy.coordinates.BaseCoordinateFrame py:obj AttributeError
TARGET api/astropy.coordinates.BaseCoordinateFrame py:obj attrnm
TARGET api/astropy.coordinates.BaseCoordinateFrame py:obj some_unknown_frame
TARGET api/astropy.coordinates.BaseCoordinateFrame py:obj coord
TARGET api/astropy.coordinates.BaseCoordinateFrame py:obj representation
TARGET api/astropy.coordinates.BaseCoordinateFrame py:obj new_representation
TARGET api/astropy.coordinates.CoordinateTransform py:obj __init__
TARGET api/astropy.coordinates.CoordinateTransform py:obj __init__
TARGET api/astropy.coordinates.CoordinateTransform py:obj fromsys