Skip to content

Instantly share code, notes, and snippets.

@ntakouris
Created July 27, 2021 07:55
Show Gist options
  • Save ntakouris/1ba0aff8374c687baf49d61efff8a9d6 to your computer and use it in GitHub Desktop.
Save ntakouris/1ba0aff8374c687baf49d61efff8a9d6 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 6,
"source": [
"import os\r\n",
"import scipy"
],
"outputs": [],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": 16,
"source": [
"import os\r\n",
"\r\n",
"ROOT = os.getcwd()\r\n",
"\r\n",
"THROTTLE_FILE = os.path.join(ROOT, 'test_file_throttle')\r\n",
"FFT_FILE = os.path.join(ROOT, 'test_file_fft')\r\n",
"\r\n",
"FFT_SIZE = 1024\r\n",
"\r\n",
"THROTTLE_SAMPLE_RATE = 100000\r\n",
"\r\n",
"ROOT, THROTTLE_FILE, FFT_FILE"
],
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"('c:\\\\Users\\\\zarkopafilis\\\\Desktop',\n",
" 'c:\\\\Users\\\\zarkopafilis\\\\Desktop\\\\test_file_throttle',\n",
" 'c:\\\\Users\\\\zarkopafilis\\\\Desktop\\\\test_file_fft')"
]
},
"metadata": {},
"execution_count": 16
}
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": 11,
"source": [
"f = scipy.fromfile(open(THROTTLE_FILE), dtype=scipy.uint8)\r\n",
"f.shape"
],
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"C:\\Users\\zarkopafilis\\AppData\\Roaming\\Python\\Python36\\site-packages\\ipykernel_launcher.py:1: DeprecationWarning: scipy.fromfile is deprecated and will be removed in SciPy 2.0.0, use numpy.fromfile instead\n",
" \"\"\"Entry point for launching an IPython kernel.\n"
]
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"(250793984,)"
]
},
"metadata": {},
"execution_count": 11
}
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": 12,
"source": [
"f = scipy.fromfile(open(FFT_FILE), dtype=scipy.uint8)\r\n",
"f.shape"
],
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"C:\\Users\\zarkopafilis\\AppData\\Roaming\\Python\\Python36\\site-packages\\ipykernel_launcher.py:1: DeprecationWarning: scipy.fromfile is deprecated and will be removed in SciPy 2.0.0, use numpy.fromfile instead\n",
" \"\"\"Entry point for launching an IPython kernel.\n"
]
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"(125427712,)"
]
},
"metadata": {},
"execution_count": 12
}
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": 20,
"source": [
"fft_data = f.reshape((-1, FFT_SIZE))\r\n",
"\r\n",
"fft_data.shape"
],
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"(122488, 1024)"
]
},
"metadata": {},
"execution_count": 20
}
],
"metadata": {}
}
],
"metadata": {
"orig_nbformat": 4,
"language_info": {
"name": "python",
"version": "3.6.8",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3.6.8 64-bit"
},
"interpreter": {
"hash": "f7291e4b392a32fbfa525b87d1bbd0a3d888adf3d0deca0c205c61b9e7284b82"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment