{ "cells": [ { "cell_type": "code", "execution_count": 66, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import scipy\n", "from glob import glob" ] }, { "cell_type": "code", "execution_count": 67, "outputs": [], "source": [ "def read_xy(path: str):\n", " df = pd.read_csv(path)\n", " df['N'] = df.index + 1\n", " df['r'] = (df.x ** 2 + df.y ** 2) ** 0.5\n", " df['cr'] = df.r.cummax()\n", " df['fd'] = np.log(df.N) / np.log(df.cr)\n", "\n", " return df" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 68, "outputs": [], "source": [ "def read_all(load_dir: str):\n", " paths = glob(f'{load_dir}/*.csv')\n", " return [read_xy(path) for path in paths]" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 69, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/joshuacoles/Library/Caches/pypoetry/virtualenvs/data-analysis-B4Au_hWl-py3.10/lib/python3.10/site-packages/pandas/core/arraylike.py:402: RuntimeWarning: divide by zero encountered in log\n", " result = getattr(ufunc, method)(*inputs, **kwargs)\n" ] }, { "data": { "text/plain": " x y N r cr fd\n0 0 0 1 0.000000 0.000000 -0.000000\n1 -1 0 2 1.000000 1.000000 inf\n2 -2 0 3 2.000000 2.000000 1.584963\n3 1 0 4 1.000000 2.000000 2.000000\n4 -3 0 5 3.000000 3.000000 1.464974\n.. .. .. ... ... ... ...\n995 -18 -4 996 18.439089 54.120237 1.729739\n996 -47 -19 997 50.695167 54.120237 1.729990\n997 -3 20 998 20.223748 54.120237 1.730241\n998 -40 14 999 42.379240 54.120237 1.730492\n999 35 -3 1000 35.128336 54.120237 1.730743\n\n[1000 rows x 6 columns]", "text/html": "
| \n | x | \ny | \nN | \nr | \ncr | \nfd | \n
|---|---|---|---|---|---|---|
| 0 | \n0 | \n0 | \n1 | \n0.000000 | \n0.000000 | \n-0.000000 | \n
| 1 | \n-1 | \n0 | \n2 | \n1.000000 | \n1.000000 | \ninf | \n
| 2 | \n-2 | \n0 | \n3 | \n2.000000 | \n2.000000 | \n1.584963 | \n
| 3 | \n1 | \n0 | \n4 | \n1.000000 | \n2.000000 | \n2.000000 | \n
| 4 | \n-3 | \n0 | \n5 | \n3.000000 | \n3.000000 | \n1.464974 | \n
| ... | \n... | \n... | \n... | \n... | \n... | \n... | \n
| 995 | \n-18 | \n-4 | \n996 | \n18.439089 | \n54.120237 | \n1.729739 | \n
| 996 | \n-47 | \n-19 | \n997 | \n50.695167 | \n54.120237 | \n1.729990 | \n
| 997 | \n-3 | \n20 | \n998 | \n20.223748 | \n54.120237 | \n1.730241 | \n
| 998 | \n-40 | \n14 | \n999 | \n42.379240 | \n54.120237 | \n1.730492 | \n
| 999 | \n35 | \n-3 | \n1000 | \n35.128336 | \n54.120237 | \n1.730743 | \n
1000 rows × 6 columns
\n