Skip to content

Instantly share code, notes, and snippets.

@richstoner
Created December 2, 2013 03:12
Show Gist options
  • Save richstoner/7744414 to your computer and use it in GitHub Desktop.
Save richstoner/7744414 to your computer and use it in GitHub Desktop.
ocp testing nb
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": "ocp-test"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": "import numpy as np\nimport urllib2\nimport zlib\nimport StringIO",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 6
},
{
"cell_type": "code",
"collapsed": false,
"input": "origin = (4000, 4000, 100)\nsize = (256, 256, 256)\n\n## Non-working example\n\ntry:\n f = urllib2.urlopen ( \"http://openconnecto.me/emca/kasthuri11/npz/1/%d,%d/%d,%d/%d,%d/\" % (origin[0], origin[0] + size[0], origin[1], origin[1]+size[1], origin[2], origin[2] + origin[2]))\nexcept urllib2.URLError:\n assert 0\n\nzdata = f.read ()\ndatastr = zlib.decompress ( zdata[:] )\ndatafobj = StringIO.StringIO ( datastr )\ncube = np.load ( datafobj )\nprint cube.shape\nprint cube.dtype\ncube.tofile(open('test-ocp.raw','w'))",
"language": "python",
"metadata": {},
"outputs": [
{
"ename": "AssertionError",
"evalue": "",
"output_type": "pyerr",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-8-b70c4806e609>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0mf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0murllib2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0murlopen\u001b[0m \u001b[0;34m(\u001b[0m \u001b[0;34m\"http://openconnecto.me/emca/kasthuri11/npz/1/%d,%d/%d,%d/%d,%d/\"\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0morigin\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0morigin\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0msize\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0morigin\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0morigin\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0msize\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0morigin\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0morigin\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0morigin\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0murllib2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mURLError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 9\u001b[0;31m \u001b[0;32massert\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 10\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 11\u001b[0m \u001b[0mzdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mAssertionError\u001b[0m: "
]
}
],
"prompt_number": 8
},
{
"cell_type": "code",
"collapsed": false,
"input": "origin = (1000, 1000, 100)\nsize = (256, 256, 256)\n\ntry:\n f = urllib2.urlopen ( \"http://braingraph1dev.cs.jhu.edu/emca/kasthuri11/npz/1/%d,%d/%d,%d/%d,%d/\" % (origin[0], origin[0] + size[0], origin[1], origin[1]+size[1], origin[2], origin[2] + size[2]))\nexcept URLError:\n assert 0\n\nzdata = f.read ()\n\ndatastr = zlib.decompress ( zdata[:] )\ndatafobj = StringIO.StringIO ( datastr )\ncube = np.load ( datafobj )\nprint cube.shape\nprint cube.dtype\ncube.tofile(open('test-ocp.raw','w'))",
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "(100, 256, 256)\nuint8\n"
}
],
"prompt_number": 9
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment