{
"metadata": {
"name": "",
"signature": "sha256:2b27dc30afc5801b549b86c718ac60f04cf5f54a281bec76ad61772eab7fb3e7"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"import h5py\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"file = h5py.File('test_rps.hdf5', 'r') # 'r' means that hdf5 file is open in read-only mode\n",
"dataset = file['RPS01']"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 3
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"print dataset.value[4,2]"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"36.7822\n"
]
}
],
"prompt_number": 4
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"plt.plot( dataset.value[:,0], dataset.value[:,2], color = 'r')\n",
"#plt.xlim([1.45415117E9,1.4541513E9])\n",
"plt.show()"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 5
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"prev_val= dataset.value[0,2]\n",
"n = 0\n",
"angle = np.zeros((dataset.shape[0]))\n",
"for i in range(dataset.value.shape[0]):\n",
" if abs(dataset.value[i,2] - prev_val) > 300:\n",
" n -= 1\n",
" angle[i] = dataset.value[i,2] + n*360\n",
" prev_val = dataset.value[i,2]\n",
"# elif (dataset.value[i,2] - prev_val) < -300:\n",
"# n -= 1\n",
"# angle[i] = dataset.value[i,2] + n*360\n",
"# prev_val = dataset.value[i,2]\n",
" else:\n",
" angle[i] = dataset.value[i,2] + n*360\n",
" prev_val = dataset.value[i,2]"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 55
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"fig, ax1 = plt.subplots()\n",
"\n",
" ax2 = ax1.twinx()\n",
" ax1.plot(x, y1, 'g-')\n",
" ax2.plot(x, y2, 'b-')\n",
"\n",
" ax1.set_xlabel('X data')\n",
" ax1.set_ylabel('Y1 data', color='g')\n",
" ax2.set_ylabel('Y2 data', color='b')\n",
"\n",
" ax1.plot(dataset.value[:,0], angle,'b',dataset.value[:,0], dataset.value[:,2],'r')\n",
" ax2.plot(dataset.value[1:,0], np.diff(angle, n=1, axis=0),'g')\n",
"\n",
"plt.show()"
],
"language": "python",
"metadata": {},
"outputs": [
{
"ename": "IndentationError",
"evalue": "unexpected indent (<ipython-input-68-85470c16d7f6>, line 3)",
"output_type": "pyerr",
"traceback": [
"\u001b[0;36m File \u001b[0;32m\"<ipython-input-68-85470c16d7f6>\"\u001b[0;36m, line \u001b[0;32m3\u001b[0m\n\u001b[0;31m ax2 = ax1.twinx()\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mIndentationError\u001b[0m\u001b[0;31m:\u001b[0m unexpected indent\n"
]
}
],
"prompt_number": 68
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"angle.shape"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 63,
"text": [
"(12120,)"
]
}
],
"prompt_number": 63
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"dataset.value[:,0].shape"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 57,
"text": [
"(12120,)"
]
}
],
"prompt_number": 57
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"dataset.value[:,0].shape"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 60,
"text": [
"(12120,)"
]
}
],
"prompt_number": 60
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"np.diff(angle, n=1, axis=0).shape"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 62,
"text": [
"(12119,)"
]
}
],
"prompt_number": 62
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}