Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "cells": [
- {
- "cell_type": "code",
- "execution_count": 3,
- "metadata": {},
- "outputs": [],
- "source": [
- "import numba\n",
- "import numpy as np\n",
- "\n",
- "def gather_from_detector():\n",
- " return np.random.random((1000, 1000))\n",
- "\n",
- "@numba.jit\n",
- "def smooth(x):\n",
- " out = np.empty_like(x)\n",
- " for i in range(1, x.shape[0] - 1):\n",
- " for j in range(1, x.shape[1] - 1):\n",
- " out[i, j] = (x[i + -1, j + -1] + x[i + -1, j + 0] + x[i + -1, j + 1] +\n",
- " x[i + 0, j + -1] + x[i + 0, j + 0] + x[i + 0, j + 1] +\n",
- " x[i + 1, j + -1] + x[i + 1, j + 0] + x[i + 1, j + 1]) // 9\n",
- "\n",
- " return out\n",
- "\n",
- "def save(x, filename):\n",
- " pass"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 8,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Wall time: 3.17 s\n"
- ]
- }
- ],
- "source": [
- "%%time\n",
- "for i in range(50):\n",
- " img = gather_from_detector()\n",
- " img = smooth(img)\n",
- " img = np.fft.fft2(img)\n",
- " save(img, \"file-\" + str(i) + \"-.dat\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- }
- ],
- "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.7.3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 4
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement