{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Populating the interactive namespace from numpy and matplotlib\n"
     ]
    }
   ],
   "source": [
    "% pylab inline\n",
    "import urllib2\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "              "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false,
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "def data_array(data):\n",
    "    datas = urllib2.urlopen(data)\n",
    "    lines = datas.readlines()\n",
    "    for k,l in enumerate(lines):\n",
    "        lines[k] = l.strip().split()\n",
    "        for i,j in enumerate(lines[k]):\n",
    "            try: \n",
    "                lines[k][i] = float(j)\n",
    "            except 'VallueError':\n",
    "                print('not a number')\n",
    "    return array(lines)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "beg = 9445\n",
    "end = 23453\n",
    "\n",
    "shots = zeros([shape(arange(beg,end))[0],2])\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\Veverkax\\Anaconda2\\lib\\site-packages\\ipykernel\\__main__.py:9: DeprecationWarning: catching of string exceptions is deprecated\n"
     ]
    }
   ],
   "source": [
    "for i,j in enumerate(arange(beg,end)):\n",
    "    shots[i,0] = int(j)\n",
    "    try:\n",
    "        if data_array('http://golem.fjfi.cvut.cz/utils/data/%i/preionization'%j)[0,0]==2.0:\n",
    "            try:        \n",
    "                shots[i,1] = float(data_array('http://golem.fjfi.cvut.cz/utils/data/%i/breakdown_voltage'%j)[0,0])\n",
    "            except:\n",
    "                shots[i,1] = None                      \n",
    "    except:\n",
    "        shots[i,1] = None\n",
    "        \n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[  9445.,      0.],\n",
       "       [  9446.,      0.],\n",
       "       [  9447.,      0.],\n",
       "       ..., \n",
       "       [ 23450.,      0.],\n",
       "       [ 23451.,      0.],\n",
       "       [ 23452.,      0.]])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "shots"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "np.savetxt('shots2.txt',shots)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [conda root]",
   "language": "python",
   "name": "conda-root-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
