-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #9
- Loading branch information
Showing
6 changed files
with
330 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
155 changes: 155 additions & 0 deletions
155
experiments/.ipynb_checkpoints/Experiment 6 - Resampling and chunking-checkpoint.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Experiment 6 - Resampling and chunking" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"during resampling, border issues may arise due to chunking. This experiment is to study those and try to correct them" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import os, sys\n", | ||
"nb_dir = os.path.split(os.getcwd())[0]\n", | ||
"if nb_dir not in sys.path:\n", | ||
" sys.path.append(nb_dir)\n", | ||
" \n", | ||
"%matplotlib inline\n", | ||
"%load_ext autoreload\n", | ||
"%autoreload 2" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 28, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from directdemod import chunker, comm\n", | ||
"import numpy as np" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Let us try to see if a problem arises. Let us try to resample a given array 'a', downsampling by factor of 4" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 29, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[ 0 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96]\n", | ||
"[ 0. 4. 8. 10. 14. 18. 20. 24. 28. 30. 34. 38. 40. 44. 48.\n", | ||
" 50. 54. 58. 60. 64. 68. 70. 74. 78. 80. 84. 88. 90. 94. 98.]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"sigOrig = comm.commSignal(40, range(100))\n", | ||
"sigOrig.bwLim(10)\n", | ||
"print(sigOrig.signal)\n", | ||
"\n", | ||
"sigTest = comm.commSignal(40, range(100))\n", | ||
"chunkerObj = chunker.chunker(sigTest, 10)\n", | ||
"sigTestOut = comm.commSignal(10)\n", | ||
"for i in chunkerObj.getChunks:\n", | ||
" sig = comm.commSignal(40, sigTest.signal[i[0]:i[1]]).bwLim(10)\n", | ||
" sigTestOut.extend(sig)\n", | ||
"print(sigTestOut.signal)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Clearly they are not the same. In order to correct this, we use the chunker obj. Chunker obj will then store some memory that will help in correcting these border issues." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 39, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[ 0 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96]\n", | ||
"[ 0. 4. 8. 12. 16. 20. 24. 28. 32. 36. 40. 44. 48. 52. 56.\n", | ||
" 60. 64. 68. 72. 76. 80. 84. 88. 92. 96.]\n", | ||
"[ True True True True True True True True True True True True\n", | ||
" True True True True True True True True True True True True\n", | ||
" True]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"sigOrig = comm.commSignal(40, range(100))\n", | ||
"sigOrig.bwLim(10)\n", | ||
"print(sigOrig.signal)\n", | ||
"\n", | ||
"sigTest = comm.commSignal(40, range(100))\n", | ||
"chunkerObj = chunker.chunker(sigTest, 10)\n", | ||
"sigTestOut = comm.commSignal(10)\n", | ||
"for i in chunkerObj.getChunks:\n", | ||
" sig = comm.commSignal(40, sigTest.signal[i[0]:i[1]], chunkerObj).bwLim(10)\n", | ||
" sigTestOut.extend(sig)\n", | ||
"print(sigTestOut.signal)\n", | ||
"\n", | ||
"print(np.array(sigOrig.signal) == np.array(sigTestOut.signal))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Conclusion\n", | ||
"\n", | ||
"The problem was solved, by using the chunker object to retain some memory." | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.6.1" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
155 changes: 155 additions & 0 deletions
155
experiments/Experiment 6 - Resampling and chunking.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Experiment 6 - Resampling and chunking" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"during resampling, border issues may arise due to chunking. This experiment is to study those and try to correct them" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import os, sys\n", | ||
"nb_dir = os.path.split(os.getcwd())[0]\n", | ||
"if nb_dir not in sys.path:\n", | ||
" sys.path.append(nb_dir)\n", | ||
" \n", | ||
"%matplotlib inline\n", | ||
"%load_ext autoreload\n", | ||
"%autoreload 2" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 28, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from directdemod import chunker, comm\n", | ||
"import numpy as np" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Let us try to see if a problem arises. Let us try to resample a given array 'a', downsampling by factor of 4" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 29, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[ 0 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96]\n", | ||
"[ 0. 4. 8. 10. 14. 18. 20. 24. 28. 30. 34. 38. 40. 44. 48.\n", | ||
" 50. 54. 58. 60. 64. 68. 70. 74. 78. 80. 84. 88. 90. 94. 98.]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"sigOrig = comm.commSignal(40, range(100))\n", | ||
"sigOrig.bwLim(10)\n", | ||
"print(sigOrig.signal)\n", | ||
"\n", | ||
"sigTest = comm.commSignal(40, range(100))\n", | ||
"chunkerObj = chunker.chunker(sigTest, 10)\n", | ||
"sigTestOut = comm.commSignal(10)\n", | ||
"for i in chunkerObj.getChunks:\n", | ||
" sig = comm.commSignal(40, sigTest.signal[i[0]:i[1]]).bwLim(10)\n", | ||
" sigTestOut.extend(sig)\n", | ||
"print(sigTestOut.signal)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Clearly they are not the same. In order to correct this, we use the chunker obj. Chunker obj will then store some memory that will help in correcting these border issues." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 39, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[ 0 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96]\n", | ||
"[ 0. 4. 8. 12. 16. 20. 24. 28. 32. 36. 40. 44. 48. 52. 56.\n", | ||
" 60. 64. 68. 72. 76. 80. 84. 88. 92. 96.]\n", | ||
"[ True True True True True True True True True True True True\n", | ||
" True True True True True True True True True True True True\n", | ||
" True]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"sigOrig = comm.commSignal(40, range(100))\n", | ||
"sigOrig.bwLim(10)\n", | ||
"print(sigOrig.signal)\n", | ||
"\n", | ||
"sigTest = comm.commSignal(40, range(100))\n", | ||
"chunkerObj = chunker.chunker(sigTest, 10)\n", | ||
"sigTestOut = comm.commSignal(10)\n", | ||
"for i in chunkerObj.getChunks:\n", | ||
" sig = comm.commSignal(40, sigTest.signal[i[0]:i[1]], chunkerObj).bwLim(10)\n", | ||
" sigTestOut.extend(sig)\n", | ||
"print(sigTestOut.signal)\n", | ||
"\n", | ||
"print(np.array(sigOrig.signal) == np.array(sigTestOut.signal))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Conclusion\n", | ||
"\n", | ||
"The problem was solved, by using the chunker object to retain some memory." | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.6.1" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters