{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import scipy.io as sio\n", "import pandas as pd\n", "import numpy as np\n", "# Load the .mat file\n", "mat_contents = sio.loadmat('mill.mat')" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[1]], dtype=uint8)" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "idx = 0\n", "np.assdata[0][idx][1]" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "(1, 167)\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
caserunVBtimeDOCfeedmaterialsmcACsmcDCvib_tablevib_spindleAE_tableAE_spindle
0110.0021.50.51[-0.01708984375, 0.263671875, 0.20751953125, 0...[0.625, 0.810546875, 0.78125, 0.849609375, 1.0...[0.078125, 0.08544921875, 0.078125, 0.07324218...[0.31494140625, 0.301513671875, 0.303955078125...[0.0872802734375, 0.0982666015625, 0.092163085...[0.103759765625, 0.123291015625, 0.10498046875...
112NaN41.50.51[0.3076171875, 0.3125, 0.1953125, 0.1879882812...[0.6689453125, 0.6787109375, 0.859375, 1.12304...[0.07568359375, 0.08056640625, 0.078125, 0.080...[0.301513671875, 0.308837890625, 0.29907226562...[0.086669921875, 0.0897216796875, 0.0946044921...[0.0994873046875, 0.103759765625, 0.1080322265...
213NaN61.50.51[-0.72509765625, -0.71533203125, -0.5297851562...[0.9130859375, 0.8349609375, 0.908203125, 1.15...[0.0830078125, 0.078125, 0.09033203125, 0.0805...[0.29541015625, 0.296630859375, 0.29296875, 0....[0.0927734375, 0.1007080078125, 0.093383789062...[0.10498046875, 0.1190185546875, 0.10986328125...
3140.1171.50.51[0.1123046875, 0.009765625, -0.1513671875, -0....[0.1318359375, 0.3955078125, 0.7568359375, 0.8...[0.0830078125, 0.07568359375, 0.06591796875, 0...[0.316162109375, 0.311279296875, 0.302734375, ...[0.1129150390625, 0.0994873046875, 0.104980468...[0.1397705078125, 0.1214599609375, 0.124511718...
415NaN111.50.51[-0.1220703125, -0.16357421875, -0.36865234375...[0.44921875, 0.6640625, 0.6689453125, 0.747070...[0.107421875, 0.107421875, 0.1025390625, 0.100...[0.284423828125, 0.289306640625, 0.28442382812...[0.0958251953125, 0.09765625, 0.09765625, 0.09...[0.1104736328125, 0.113525390625, 0.1098632812...
..........................................
162162NaN21.50.52[-0.58349609375, -0.5810546875, -0.51513671875...[1.30859375, 1.318359375, 1.3330078125, 1.3427...[0.0634765625, 0.0732421875, 0.06591796875, 0....[0.330810546875, 0.299072265625, 0.3173828125,...[0.093994140625, 0.0897216796875, 0.0982666015...[0.1092529296875, 0.1025390625, 0.116577148437...
1631630.2431.50.52[-0.2001953125, -0.009765625, 0.0830078125, 0....[1.40625, 1.4013671875, 1.396484375, 1.3867187...[0.06591796875, 0.07080078125, 0.0634765625, 0...[0.279541015625, 0.284423828125, 0.30151367187...[0.11474609375, 0.09521484375, 0.1019287109375...[0.1397705078125, 0.1123046875, 0.120239257812...
164164NaN41.50.52[0.244140625, 0.244140625, 0.205078125, 0.1562...[1.328125, 1.3330078125, 1.3330078125, 1.33300...[0.0634765625, 0.05859375, 0.05859375, 0.06347...[0.29052734375, 0.279541015625, 0.28564453125,...[0.101318359375, 0.1214599609375, 0.1220703125...[0.1177978515625, 0.140380859375, 0.1428222656...
1651650.4061.50.52[-0.205078125, -0.2392578125, -0.15625, 0.1269...[1.3818359375, 1.38671875, 1.38671875, 1.38183...[0.068359375, 0.05859375, 0.07080078125, 0.065...[0.289306640625, 0.30029296875, 0.291748046875...[0.098876953125, 0.096435546875, 0.08972167968...[0.11474609375, 0.1123046875, 0.1068115234375,...
1661660.6291.50.52[-0.380859375, -0.244140625, -0.13671875, -0.0...[1.3818359375, 1.3916015625, 1.396484375, 1.39...[0.04150390625, 0.04150390625, 0.04150390625, ...[0.29296875, 0.30517578125, 0.28564453125, 0.3...[0.07568359375, 0.087890625, 0.0750732421875, ...[0.0830078125, 0.096435546875, 0.0762939453125...
\n", "

167 rows × 13 columns

\n", "
" ], "text/plain": [ " case run VB time DOC feed material \\\n", "0 1 1 0.00 2 1.5 0.5 1 \n", "1 1 2 NaN 4 1.5 0.5 1 \n", "2 1 3 NaN 6 1.5 0.5 1 \n", "3 1 4 0.11 7 1.5 0.5 1 \n", "4 1 5 NaN 11 1.5 0.5 1 \n", ".. ... ... ... ... ... ... ... \n", "162 16 2 NaN 2 1.5 0.5 2 \n", "163 16 3 0.24 3 1.5 0.5 2 \n", "164 16 4 NaN 4 1.5 0.5 2 \n", "165 16 5 0.40 6 1.5 0.5 2 \n", "166 16 6 0.62 9 1.5 0.5 2 \n", "\n", " smcAC \\\n", "0 [-0.01708984375, 0.263671875, 0.20751953125, 0... \n", "1 [0.3076171875, 0.3125, 0.1953125, 0.1879882812... \n", "2 [-0.72509765625, -0.71533203125, -0.5297851562... \n", "3 [0.1123046875, 0.009765625, -0.1513671875, -0.... \n", "4 [-0.1220703125, -0.16357421875, -0.36865234375... \n", ".. ... \n", "162 [-0.58349609375, -0.5810546875, -0.51513671875... \n", "163 [-0.2001953125, -0.009765625, 0.0830078125, 0.... \n", "164 [0.244140625, 0.244140625, 0.205078125, 0.1562... \n", "165 [-0.205078125, -0.2392578125, -0.15625, 0.1269... \n", "166 [-0.380859375, -0.244140625, -0.13671875, -0.0... \n", "\n", " smcDC \\\n", "0 [0.625, 0.810546875, 0.78125, 0.849609375, 1.0... \n", "1 [0.6689453125, 0.6787109375, 0.859375, 1.12304... \n", "2 [0.9130859375, 0.8349609375, 0.908203125, 1.15... \n", "3 [0.1318359375, 0.3955078125, 0.7568359375, 0.8... \n", "4 [0.44921875, 0.6640625, 0.6689453125, 0.747070... \n", ".. ... \n", "162 [1.30859375, 1.318359375, 1.3330078125, 1.3427... \n", "163 [1.40625, 1.4013671875, 1.396484375, 1.3867187... \n", "164 [1.328125, 1.3330078125, 1.3330078125, 1.33300... \n", "165 [1.3818359375, 1.38671875, 1.38671875, 1.38183... \n", "166 [1.3818359375, 1.3916015625, 1.396484375, 1.39... \n", "\n", " vib_table \\\n", "0 [0.078125, 0.08544921875, 0.078125, 0.07324218... \n", "1 [0.07568359375, 0.08056640625, 0.078125, 0.080... \n", "2 [0.0830078125, 0.078125, 0.09033203125, 0.0805... \n", "3 [0.0830078125, 0.07568359375, 0.06591796875, 0... \n", "4 [0.107421875, 0.107421875, 0.1025390625, 0.100... \n", ".. ... \n", "162 [0.0634765625, 0.0732421875, 0.06591796875, 0.... \n", "163 [0.06591796875, 0.07080078125, 0.0634765625, 0... \n", "164 [0.0634765625, 0.05859375, 0.05859375, 0.06347... \n", "165 [0.068359375, 0.05859375, 0.07080078125, 0.065... \n", "166 [0.04150390625, 0.04150390625, 0.04150390625, ... \n", "\n", " vib_spindle \\\n", "0 [0.31494140625, 0.301513671875, 0.303955078125... \n", "1 [0.301513671875, 0.308837890625, 0.29907226562... \n", "2 [0.29541015625, 0.296630859375, 0.29296875, 0.... \n", "3 [0.316162109375, 0.311279296875, 0.302734375, ... \n", "4 [0.284423828125, 0.289306640625, 0.28442382812... \n", ".. ... \n", "162 [0.330810546875, 0.299072265625, 0.3173828125,... \n", "163 [0.279541015625, 0.284423828125, 0.30151367187... \n", "164 [0.29052734375, 0.279541015625, 0.28564453125,... \n", "165 [0.289306640625, 0.30029296875, 0.291748046875... \n", "166 [0.29296875, 0.30517578125, 0.28564453125, 0.3... \n", "\n", " AE_table \\\n", "0 [0.0872802734375, 0.0982666015625, 0.092163085... \n", "1 [0.086669921875, 0.0897216796875, 0.0946044921... \n", "2 [0.0927734375, 0.1007080078125, 0.093383789062... \n", "3 [0.1129150390625, 0.0994873046875, 0.104980468... \n", "4 [0.0958251953125, 0.09765625, 0.09765625, 0.09... \n", ".. ... \n", "162 [0.093994140625, 0.0897216796875, 0.0982666015... \n", "163 [0.11474609375, 0.09521484375, 0.1019287109375... \n", "164 [0.101318359375, 0.1214599609375, 0.1220703125... \n", "165 [0.098876953125, 0.096435546875, 0.08972167968... \n", "166 [0.07568359375, 0.087890625, 0.0750732421875, ... \n", "\n", " AE_spindle \n", "0 [0.103759765625, 0.123291015625, 0.10498046875... \n", "1 [0.0994873046875, 0.103759765625, 0.1080322265... \n", "2 [0.10498046875, 0.1190185546875, 0.10986328125... \n", "3 [0.1397705078125, 0.1214599609375, 0.124511718... \n", "4 [0.1104736328125, 0.113525390625, 0.1098632812... \n", ".. ... \n", "162 [0.1092529296875, 0.1025390625, 0.116577148437... \n", "163 [0.1397705078125, 0.1123046875, 0.120239257812... \n", "164 [0.1177978515625, 0.140380859375, 0.1428222656... \n", "165 [0.11474609375, 0.1123046875, 0.1068115234375,... \n", "166 [0.0830078125, 0.096435546875, 0.0762939453125... \n", "\n", "[167 rows x 13 columns]" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mat_contents.keys()\n", "data=mat_contents['mill']\n", "print(type(data))\n", "print(data.shape)\n", "df= pd.DataFrame(data[0])\n", "\n", "for c in [\"case\",\"run\",\"VB\",\"time\",\"DOC\",\"feed\",\"material\"]:\n", " df[c] = df[c].apply(lambda x: x.item())\n", "\n", "for c in [\"smcAC\",\"smcDC\",\"vib_table\",\"vib_spindle\",\"AE_table\",\"AE_spindle\"]:\n", " df[c] = df[c].apply(lambda x: np.squeeze(x,1))\n", "\n", "df" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0 1\n", "1 1\n", "2 1\n", "3 1\n", "4 1\n", " ..\n", "162 16\n", "163 16\n", "164 16\n", "165 16\n", "166 16\n", "Name: case, Length: 167, dtype: int64" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.to_parquet(\"data.parquet\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Export:\n", "df.to_json('mill/data.jsonl', orient='records', lines=True)" ] }, { "cell_type": "code", "execution_count": 58, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "NpzFile 'mill/data.npz' with keys: arr_0\n" ] } ], "source": [ "# reading data from npz file \n", "data = np.load(\"mill/data.npz\")\n", "with np.load('mill/data.npz') as data:\n", "\tprint(data)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "base", "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.11.0" } }, "nbformat": 4, "nbformat_minor": 2 }